After thinking through the approaches I discussed in #370, I developed an alternative approach that doesn't require giving the planner access to the input data to manually expand the facet into a list of group marks. The approach this PR takes is to handle the special (common) case of facet marks that define a transform pipeline where the first transform is aggregate. This single transform can be lifted out of the facet with the modification that the groupby fields are augmented with the facet's groupby fields. Any remaining transforms after aggregate are left inside the facet to be evaluated in the client with Vega.js.
Additionally, this PR handles the case where the facet defines custom aggregate fields. This is most commonly used when sorting facets by aggregate values in Vega-Lite. In this case a joinaggregate transform is inserted prior to the lifted aggregate transform.
In the uncommon case of a facet dataset being used by multiple child datasets, aggregate lifting is not performed.
Overview
This PR adds support for extracting aggregate transforms from facet charts so that they can be evaluated using the regular VegaFusion machinery.
Closes https://github.com/hex-inc/vegafusion/issues/370
Approach
After thinking through the approaches I discussed in #370, I developed an alternative approach that doesn't require giving the planner access to the input data to manually expand the facet into a list of group marks. The approach this PR takes is to handle the special (common) case of facet marks that define a transform pipeline where the first transform is
aggregate
. This single transform can be lifted out of the facet with the modification that thegroupby
fields are augmented with the facet'sgroupby
fields. Any remaining transforms after aggregate are left inside the facet to be evaluated in the client with Vega.js.Additionally, this PR handles the case where the facet defines custom
aggregate
fields. This is most commonly used when sorting facets by aggregate values in Vega-Lite. In this case ajoinaggregate
transform is inserted prior to the liftedaggregate
transform.In the uncommon case of a facet dataset being used by multiple child datasets, aggregate lifting is not performed.