Apache DataFusion SQL Query Engine
update stale documentations related to window functions (#598)
Jiayu Liu20f6f21ec551
diff --git a/README.md b/README.mdindex 195d1a7b3c..d3160608bd 100644--- a/README.md+++ b/README.md@@ -225,10 +225,11 @@ DataFusion also includes a simple command-line interactive SQL utility. See the- [x] FULL JOIN- [x] CROSS JOIN- [ ] Window- - [x] [Empty window](https://github.com/apache/arrow-datafusion/issues/298)+ - [x] Empty window- [x] Common window functions- - [ ] [Window with ORDER BY clause](https://github.com/apache/arrow-datafusion/issues/360)- - [ ] [Window with PARTITION BY clause](https://github.com/apache/arrow-datafusion/issues/299)+ - [x] Window with PARTITION BY clause+ - [x] Window with ORDER BY clause+ - [ ] Window with FILTER clause- [ ] [Window with custom WINDOW FRAME](https://github.com/apache/arrow-datafusion/issues/361)- [ ] UDF and UDAF for window functionsdiff --git a/ballista/rust/core/src/serde/logical_plan/from_proto.rs b/ballista/rust/core/src/serde/logical_plan/from_proto.rsindex 1b7deb7b71..418d60de3e 100644--- a/ballista/rust/core/src/serde/logical_plan/from_proto.rs+++ b/ballista/rust/core/src/serde/logical_plan/from_proto.rs@@ -1178,10 +1178,12 @@ impl TryFrom<protobuf::WindowFrameBound> for WindowFrameBound {}protobuf::WindowFrameBoundType::Preceding => {// FIXME implement bound value parsing+ // https://github.com/apache/arrow-datafusion/issues/361Ok(WindowFrameBound::Preceding(Some(1)))}protobuf::WindowFrameBoundType::Following => {// FIXME implement bound value parsing+ // https://github.com/apache/arrow-datafusion/issues/361Ok(WindowFrameBound::Following(Some(1)))}}diff --git a/ballista/rust/core/src/serde/logical_plan/to_proto.rs b/ballista/rust/core/src/serde/logical_plan/to_proto.rsindex 24e2b56bad..4049622b83 100644--- a/ballista/rust/core/src/serde/logical_plan/to_proto.rs+++ b/ballista/rust/core/src/serde/logical_plan/to_proto.rs@@ -1002,7 +1002,6 @@ impl TryInto<protobuf::LogicalExprNode> for &Expr {ref partition_by,ref order_by,ref window_frame,- ..} => {let window_function = match fun {WindowFunction::AggregateFunction(fun) => {diff --git a/datafusion/src/logical_plan/builder.rs b/datafusion/src/logical_plan/builder.rsindex 4b4ed0fb9d..147f8322df 100644--- a/datafusion/src/logical_plan/builder.rs+++ b/datafusion/src/logical_plan/builder.rs@@ -351,23 +351,14 @@ impl LogicalPlanBuilder {}))}- /// Apply a window- ///- /// NOTE: this feature is under development and this API will be changing- ///- /// - https://github.com/apache/arrow-datafusion/issues/359 basic structure- /// - https://github.com/apache/arrow-datafusion/issues/298 empty over clause- /// - https://github.com/apache/arrow-datafusion/issues/299 with partition clause- /// - https://github.com/apache/arrow-datafusion/issues/360 with order by- /// - https://github.com/apache/arrow-datafusion/issues/361 with window frame- pub fn window(&self, window_expr: Vec<Expr>) -> Result<Self> {+ /// Apply a window functions to extend the schema+ pub fn window(&self, window_expr: impl IntoIterator<Item = Expr>) -> Result<Self> {+ let window_expr = window_expr.into_iter().collect::<Vec<Expr>>();let all_expr = window_expr.iter();validate_unique_names("Windows", all_expr.clone(), self.plan.schema())?;-let mut window_fields: Vec<DFField> =exprlist_to_fields(all_expr, self.plan.schema())?;window_fields.extend_from_slice(self.plan.schema().fields());-Ok(Self::from(&LogicalPlan::Window {input: Arc::new(self.plan.clone()),window_expr,diff --git a/datafusion/src/logical_plan/plan.rs b/datafusion/src/logical_plan/plan.rsindex 2562472282..99f0fa14a2 100644--- a/datafusion/src/logical_plan/plan.rs+++ b/datafusion/src/logical_plan/plan.rs@@ -95,12 +95,6 @@ pub enum LogicalPlan {input: Arc<LogicalPlan>,/// The window function expressionwindow_expr: Vec<Expr>,- /// Filter by expressions- // filter_by_expr: Vec<Expr>,- /// Partition by expressions- // partition_by_expr: Vec<Expr>,- /// Window Frame- // window_frame: Option<WindowFrame>,/// The schema description of the window outputschema: DFSchemaRef,},diff --git a/datafusion/src/physical_plan/windows.rs b/datafusion/src/physical_plan/windows.rsindex bb25551137..2f539057c8 100644--- a/datafusion/src/physical_plan/windows.rs+++ b/datafusion/src/physical_plan/windows.rs@@ -171,9 +171,6 @@ impl WindowExpr for BuiltInWindowExpr {}fn evaluate(&self, batch: &RecordBatch) -> Result<ArrayRef> {- // FIXME, for now we assume all the rows belong to the same partition, which will not be the- // case when partition_by is supported, in which case we'll parallelize the calls.- // See https://github.com/apache/arrow-datafusion/issues/299let values = self.evaluate_args(batch)?;let partition_points = self.evaluate_partition_points(batch.num_rows(),@@ -309,9 +306,6 @@ impl WindowExpr for AggregateWindowExpr {/// evaluate the window function values against the batchfn evaluate(&self, batch: &RecordBatch) -> Result<ArrayRef> {- // FIXME, for now we assume all the rows belong to the same partition, which will not be the- // case when partition_by is supported, in which case we'll parallelize the calls.- // See https://github.com/apache/arrow-datafusion/issues/299match self.evaluation_mode() {WindowFrameUnits::Range => self.peer_based_evaluate(batch),WindowFrameUnits::Rows => self.row_based_evaluate(batch),@@ -477,9 +471,6 @@ fn compute_window_aggregates(window_expr: Vec<Arc<dyn WindowExpr>>,batch: &RecordBatch,) -> Result<Vec<ArrayRef>> {- // FIXME, for now we assume all the rows belong to the same partition, which will not be the- // case when partition_by is supported, in which case we'll parallelize the calls.- // See https://github.com/apache/arrow-datafusion/issues/299window_expr.iter().map(|window_expr| window_expr.evaluate(batch))