Selection

Selection

Experimentally, there is a new macro to simplify the creation of selector objects:

JuliaDBMeta.@=>Macro.

@=>(expr...)

Create a selector based on expressions expr. Symbols are used to select columns and infer an appropriate anonymous function. In this context, _ refers to the whole row. To use actual symbols, escape them with ^, as in ^(:a). Use cols(c) to refer to field c where c is a variable that evaluates to a symbol. c must be available in the scope where the macro is called.

Examples

julia> t = table((a = [1,2,3], b = [4,5,6]));

julia> select(t, @=>(:a, :a + :b))
Table with 3 rows, 2 columns:
a  a + b
────────
1  5
2  7
3  9
source

@select(d, x)

Short-hand for select(d, @=>(x))

Examples

julia> t = table((a = [1,2,3], b = [4,5,6]));

julia> @select(t, (:a, :a + :b))
Table with 3 rows, 2 columns:
a  a + b
────────
1  5
2  7
3  9
source