queryverse / Query.jl

Query almost anything in julia
Other
394 stars 50 forks source link

Add gather macro #213

Open TonyLianLong opened 5 years ago

TonyLianLong commented 5 years ago

Add gather macro which uses gather function in QueryOperators.jl.

codecov-io commented 5 years ago

Codecov Report

Merging #213 into master will decrease coverage by 7.15%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #213      +/-   ##
==========================================
- Coverage   90.02%   82.87%   -7.16%     
==========================================
  Files           5        5              
  Lines         441      397      -44     
==========================================
- Hits          397      329      -68     
- Misses         44       68      +24
Impacted Files Coverage Δ
src/standalone_query_macros.jl 100% <ø> (ø) :arrow_up:
src/Query.jl 76.92% <ø> (-1.65%) :arrow_down:
src/query_translation.jl 80.89% <0%> (-8.66%) :arrow_down:
src/table_query_macros.jl 97.05% <0%> (+4.85%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dc5914e...452e48f. Read the comment docs.

TonyLianLong commented 5 years ago

What to do next:

I think the next step would be to add a method to Base.eltype for the EnumerableGather type.

You can look up how that is implemented for some of the other enumerable types

It should return the type of the elements that are being iterated by EnumerableGather (so some sort of NamedTuple).

As soon as we add that method, we will get two things: 1) nice table like printing of the result, and 2) the ability to pipe things into e.g. a DataFrame

Right now we don't have a method for Base.eltype, so it is falling back to the generic method, which will just return Any

That is technically correct (because everything is a subtype of Any)

But downstream consumers of the iterator won't know that this is actually iterating named tuples, and therefor won't interpret the result as a table

By adding a method to eltype, we can change that.

The trick is to have at least one type parameter in EnumerableGather that can hold the eltype, and then make sure you set that accordingly in the gather function

davidanthoff commented 5 years ago

Things still to do: