perf(promql): run a compiled native tree over fused raw series

Add a `FusedSeries` node that runs a bound native tree over the raw series
its input produces, instead of materialising a row batch through the
existing per-operator path. The node binds the time column, the fields and
the tags once, checks the input against that binding at construction, and
converts the chunks the tree settles back into the statement's output
columns.

The binding is a caller commitment this node cannot verify: a wrong
constant metric name, or a timestamp column that is the right type but the
wrong column, reads as a legal input. What it can verify it does — an input
column that takes no part in the series' identity is refused, because such
a column would silently drop a label that keeps two series apart.

An error releases the input and the evaluator rather than holding them
until the consumer drops the terminated stream.

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>
This commit is contained in:
discord9
2026-10-20 01:02:59 +08:00
parent 9e5595ca3e
commit 32c76d35ea
4 changed files with 2142 additions and 2 deletions
+2
View File
@@ -14,6 +14,7 @@
mod absent;
mod empty_metric;
mod fused_series;
mod histogram_fold;
mod instant_manipulate;
mod normalize;
@@ -37,6 +38,7 @@ use datafusion::error::{DataFusionError, Result as DataFusionResult};
use datafusion::logical_expr::{Expr, Extension, LogicalPlan};
use datatypes::data_type::DataType as _;
pub use empty_metric::{EmptyMetric, EmptyMetricExec, EmptyMetricStream, build_special_time_expr};
pub use fused_series::{FusedSeries, FusedSeriesBinding, FusedSeriesExec, FusedSeriesStream};
pub use histogram_fold::{
HistogramFold, HistogramFoldExec, HistogramFoldOperation, HistogramFoldStream,
};
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -23,8 +23,8 @@ use datafusion::physical_plan::ExecutionPlan;
use datafusion::physical_planner::{ExtensionPlanner, PhysicalPlanner};
use crate::extension_plan::{
Absent, EmptyMetric, HistogramFold, InstantManipulate, RangeManipulate, ScalarCalculate,
SeriesDivide, SeriesNormalize, UnionDistinctOn,
Absent, EmptyMetric, FusedSeries, HistogramFold, InstantManipulate, RangeManipulate,
ScalarCalculate, SeriesDivide, SeriesNormalize, UnionDistinctOn,
};
pub struct PromExtensionPlanner;
@@ -65,6 +65,8 @@ impl ExtensionPlanner for PromExtensionPlanner {
)))
} else if let Some(node) = node.as_any().downcast_ref::<Absent>() {
Ok(Some(node.to_execution_plan(physical_inputs[0].clone())))
} else if let Some(node) = node.as_any().downcast_ref::<FusedSeries>() {
Ok(Some(node.to_execution_plan(physical_inputs[0].clone())?))
} else {
Ok(None)
}