# Queryverse @map question

**URL:** <https://discourse.julialang.org/t/queryverse-map-question/12484>\
**Category:** Data\
**Tags:** queryverse\
**Created:** [July 19, 2018, 8:20am UTC](https://discourse.julialang.org/t/queryverse-map-question/12484 "2018-07-19T08:20:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johann.spies](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johann.spies/32/8805_2.png) [@johann.spies](https://discourse.julialang.org/u/johann.spies)\
**Post date:** [July 19, 2018, 8:20am UTC](https://discourse.julialang.org/t/queryverse-map-question/12484/1 "2018-07-19T08:20:55Z")

</div>

I have

```julia
describe(gewig)

Summary Stats:
Mean: 2979.413793
Minimum: 1613.000000
1st Quartile: 2226.500000
Median: 2822.500000
3rd Quartile: 3618.250000
Maximum: 5140.000000
Length: 406
Type: Int64

```

According to a Queryverse tutorial I can do

```julia
 gewig |> @map({foo=_, bar=_^2}) 

```

which works as expected.

But when I do this:

```julia
m = 2979.413793
sa = std(gewig, mean = m)
gewig |> @map({foo=_, bar=(_-m)/sa})

```

I get an error which I do not understand:

type UnionAll has no field parameters

What is the correct way to do this?

---

<div class="post-metadata">

**Author:** ![swt30](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swt30/32/4667_2.png) [@swt30](https://discourse.julialang.org/u/swt30)\
**Post date:** [July 19, 2018, 11:27am UTC](https://discourse.julialang.org/t/queryverse-map-question/12484/2 "2018-07-19T11:27:07Z")

</div>

Are you running this in the REPL? It looks like Query cannot be certain of the types of the values `m` and `sa` because they are non-constant globals, and I think Query relies on type inference to know what the final column types should be. The first example is okay because the 2 in `^2` is hardcoded and the compiler knows its type can’t change.

I understand there are [plans](https://discourse.julialang.org/t/using-a-string-variable-in-a-query-jl-query/7372/9) to remove this reliance on type inference in the future. But for now, if you wrap all the code in a function or declare the variables as constant beforehand (e.g. `const m = 2979.413793`) then it should work.

---

<div class="post-metadata">

**Author:** ![johann.spies](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johann.spies/32/8805_2.png) [@johann.spies](https://discourse.julialang.org/u/johann.spies)\
**Post date:** [July 19, 2018, 2:01pm UTC](https://discourse.julialang.org/t/queryverse-map-question/12484/3 "2018-07-19T14:01:29Z")

</div>

Thanks for the clarification.  
Defining constants helped in this case (using REPL).

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [July 20, 2018, 12:17am UTC](https://discourse.julialang.org/t/queryverse-map-question/12484/4 "2018-07-20T00:17:04Z")

</div>

Yep, that is correct. The version that runs on 0.7 will drop the reliance on type inference, I’m almost done with it.
