# Calling macro with runtime arguments: case of Query.jl

**URL:** https://discourse.julialang.org/t/calling-macro-with-runtime-arguments-case-of-query-jl/21443
**Category:** New to Julia
**Created:** [March 4, 2019, 9:24am UTC](https://discourse.julialang.org/t/calling-macro-with-runtime-arguments-case-of-query-jl/21443 "2019-03-04T09:24:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [March 4, 2019, 9:24am UTC](https://discourse.julialang.org/t/calling-macro-with-runtime-arguments-case-of-query-jl/21443/1 "2019-03-04T09:24:33Z")

</div>

I’m using `Query.jl` a lot, and it is very convenient for dataframe processing. However I cannot understand how to call some of its operations with dynamically generated arguments. E.g. if there is a list of column names like `names = [:a, :b, :c]`, how to group by them? `df |> @groupby(names)` does not work, neither do `df |> @groupby($names)` or similar. I managed to manually craft the expression, and pass the whole line to `@eval` like this:

```julia
group_key_expr = :( {$([:(_.$k) for k in names]...)} )
groups = @eval($(df) |> @groupby($group_key_expr) |> collect)

```

This works, however looks very far from obvious and convenient. Do I miss anything?

---

<div class="post-metadata">

### Author: ![bramtayl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bramtayl/32/3614_2.png) [@bramtayl](https://discourse.julialang.org/u/bramtayl)
#### Post date: [March 4, 2019, 4:21pm UTC](https://discourse.julialang.org/t/calling-macro-with-runtime-arguments-case-of-query-jl/21443/2 "2019-03-04T16:21:43Z")

</div>

Maybe try out LightQuery.jl:

```julia
const names = (:a, :b, :c)
@> df
    Group(By(_, Names(names...))

```

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [March 4, 2019, 5:07pm UTC](https://discourse.julialang.org/t/calling-macro-with-runtime-arguments-case-of-query-jl/21443/3 "2019-03-04T17:07:49Z")

</div>

Would you be amenable to a PR that changed `Names` to `cols`? That’s what DataFramesMeta, StatPlots, and JuliaDBMeta call that escaping operation.

---

<div class="post-metadata">

### Author: ![bramtayl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bramtayl/32/3614_2.png) [@bramtayl](https://discourse.julialang.org/u/bramtayl)
#### Post date: [March 4, 2019, 5:16pm UTC](https://discourse.julialang.org/t/calling-macro-with-runtime-arguments-case-of-query-jl/21443/4 "2019-03-04T17:16:45Z")

</div>

Nope. Sorry, I don’t do abbreviations.

---

<div class="post-metadata">

### Author: ![bramtayl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bramtayl/32/3614_2.png) [@bramtayl](https://discourse.julialang.org/u/bramtayl)
#### Post date: [March 4, 2019, 5:19pm UTC](https://discourse.julialang.org/t/calling-macro-with-runtime-arguments-case-of-query-jl/21443/5 "2019-03-04T17:19:02Z")

</div>

Besides, it’s not an escaping operation, it’s a fully fledged function (there’s nothing to escape).

---

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [March 5, 2019, 8:01pm UTC](https://discourse.julialang.org/t/calling-macro-with-runtime-arguments-case-of-query-jl/21443/6 "2019-03-05T20:01:52Z")

</div>

So, no real solution with Query.jl for now?
