Pushdown Rules
With Spark pushdown enabled, each rule computes one kind of subtree natively in Spark, with the same result as the pandas evaluation. A subtree is pushed down only if every use of its channel in the solve is (When a channel is pushed down); otherwise it runs in pandas as before.
| Rule | Subtree | Result | Solve without the UDF |
|---|---|---|---|
resample | channel.resample(sample_rate) | SampleSeries | As a calculated channel |
condition | channel > k, also >=, <, <=, ==, != | Intervals | Yes |
Both apply to continuous channel() and channel_with_alias() selections, and their subtree can
sit anywhere in an expression, e.g. veh_spd.resample(1e6).cumtrapz() or
(rpm > 4000).debounce(1e6).
resample
- Matches
channel.resample(sample_rate)with a positive, finite rate (default1). - Computes the resampled series per continuous block, like
SampleSeries.resample. - Limits:
- If the timestamps are integers (e.g.
longepoch microseconds), the rate must be a whole number too, e.g.resample(1e6); otherwise, e.g.resample(2.5), the resample runs in pandas. - The rule is meant for downsampling: a rate finer than the channel's sample spacing produces more rows than the raw channel.
- If the timestamps are integers (e.g.
- API:
ResamplePushdownRule
condition
- Matches a comparison of a channel with a number, on either side (
500 < rpm). The number is a regular Python or numpy integer or float, e.g.4000or80.5; other number types, e.g.Fraction, are compared in pandas. - Computes the intervals where the comparison holds, merged like
Intervals(..., merge_overlaps=True).- Comparisons follow numpy: NaN and null values satisfy only
!=. - Aliased selections compare the unit-converted values.
- Comparisons follow numpy: NaN and null values satisfy only
- Limits:
- The comparison must be on the channel itself: in
rpm.resample(1e6) > 4000, only the resample is pushed down.
- The comparison must be on the channel itself: in
- Without the UDF: solves whose selections are all comparisons (Solves without the pandas UDF).
- API:
ConditionPushdownRule
Planned rules
- Scalar maps, e.g.
rpm * 60 / 1000. whereon the same channel, e.g.veh_spd.where(veh_spd > 0).- Compositions on one channel, e.g.
rpm.resample(1e6) > 4000. - Interval operations:
debounce,merge_intervals,&,|,~. - Per-series aggregates: statistics and histograms in Spark.