Skip to content

Commit 593cf50

Browse files
committed
Remove windows in expresion
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 8a53fa3 commit 593cf50

File tree

4 files changed

+0
-113
lines changed

4 files changed

+0
-113
lines changed

src/query/legacy-planners/src/plan_expression.rs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use common_exception::ErrorCode;
2020
use common_exception::Result;
2121
use common_functions::aggregates::AggregateFunctionFactory;
2222
use common_functions::aggregates::AggregateFunctionRef;
23-
use common_functions::window::WindowFrame;
2423
use once_cell::sync::Lazy;
2524

2625
use crate::plan_expression_common::ExpressionDataTypeVisitor;
@@ -75,22 +74,6 @@ pub enum Expression {
7574
args: Vec<Expression>,
7675
},
7776

78-
/// WindowFunction
79-
WindowFunction {
80-
/// operation performed
81-
op: String,
82-
/// params
83-
params: Vec<DataValue>,
84-
/// arguments
85-
args: Vec<Expression>,
86-
/// partition by
87-
partition_by: Vec<Expression>,
88-
/// order by
89-
order_by: Vec<Expression>,
90-
/// window frame
91-
window_frame: Option<WindowFrame>,
92-
},
93-
9477
/// A sort expression, that can be used to sort values.
9578
Sort {
9679
/// The expression to sort on
@@ -348,53 +331,6 @@ impl fmt::Debug for Expression {
348331
Ok(())
349332
}
350333

351-
Expression::WindowFunction {
352-
op,
353-
params,
354-
args,
355-
partition_by,
356-
order_by,
357-
window_frame,
358-
} => {
359-
let args_column_name = args.iter().map(Expression::column_name).collect::<Vec<_>>();
360-
let params_name = params
361-
.iter()
362-
.map(|v| DataValue::custom_display(v, true))
363-
.collect::<Vec<_>>();
364-
365-
if params.is_empty() {
366-
write!(f, "{}", op)?;
367-
} else {
368-
write!(f, "{}({})", op, params_name.join(", "))?;
369-
}
370-
371-
write!(f, "({})", args_column_name.join(","))?;
372-
373-
write!(f, " OVER(")?;
374-
if !partition_by.is_empty() {
375-
write!(f, "PARTITION BY {:?}", partition_by)?;
376-
}
377-
if !order_by.is_empty() {
378-
if !partition_by.is_empty() {
379-
write!(f, " ")?;
380-
}
381-
write!(f, "ORDER BY {:?}", order_by)?;
382-
}
383-
if let Some(window_frame) = window_frame {
384-
if !partition_by.is_empty() || !order_by.is_empty() {
385-
write!(f, " ")?;
386-
}
387-
write!(
388-
f,
389-
"{} BETWEEN {} AND {}",
390-
window_frame.units, window_frame.start_bound, window_frame.end_bound
391-
)?;
392-
}
393-
write!(f, ")")?;
394-
395-
Ok(())
396-
}
397-
398334
Expression::Sort { expr, .. } => write!(f, "{:?}", expr),
399335
Expression::Wildcard => write!(f, "*"),
400336
Expression::Cast {

src/query/legacy-planners/src/plan_expression_chain.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ impl ExpressionChain {
179179
));
180180
}
181181

182-
Expression::WindowFunction { .. } => {}
183-
184182
Expression::Wildcard | Expression::Sort { .. } => {}
185183

186184
Expression::Cast {

src/query/legacy-planners/src/plan_expression_common.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::collections::HashSet;
1717
use common_datavalues::prelude::*;
1818
use common_exception::ErrorCode;
1919
use common_exception::Result;
20-
use common_functions::aggregates::AggregateFunctionFactory;
2120
use common_functions::scalars::FunctionFactory;
2221

2322
use crate::validate_function_arg;
@@ -119,37 +118,7 @@ impl ExpressionVisitor for ExpressionDataTypeVisitor {
119118
self.stack.push(return_type);
120119
Ok(self)
121120
}
122-
Expression::WindowFunction {
123-
op,
124-
params,
125-
args,
126-
partition_by,
127-
order_by,
128-
..
129-
} => {
130-
for _ in 0..partition_by.len() + order_by.len() {
131-
self.stack.remove(0);
132-
}
133-
134-
if !AggregateFunctionFactory::instance().check(op) {
135-
return Err(ErrorCode::LogicalError(
136-
"not yet support non aggr window function",
137-
));
138-
}
139-
140-
let mut fields = Vec::with_capacity(args.len());
141-
for arg in args.iter() {
142-
let arg_type = self.stack.remove(0);
143-
fields.push(DataField::new(&arg.column_name(), arg_type));
144-
}
145121

146-
let aggregate_window_function =
147-
AggregateFunctionFactory::instance().get(op, params.clone(), fields);
148-
let return_type = aggregate_window_function.unwrap().return_type().unwrap();
149-
150-
self.stack.push(return_type);
151-
Ok(self)
152-
}
153122
Expression::Cast { data_type, .. } => {
154123
let inner_type = match self.stack.pop() {
155124
None => Err(ErrorCode::LogicalError(

src/query/legacy-planners/src/plan_expression_visitor.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,6 @@ pub trait ExpressionVisitor: Sized {
6666
stack.push(RecursionProcessing::Call(arg));
6767
}
6868
}
69-
Expression::WindowFunction {
70-
args,
71-
partition_by,
72-
order_by,
73-
..
74-
} => {
75-
for arg_expr in args {
76-
stack.push(RecursionProcessing::Call(arg_expr));
77-
}
78-
for part_by_expr in partition_by {
79-
stack.push(RecursionProcessing::Call(part_by_expr));
80-
}
81-
for order_by_expr in order_by {
82-
stack.push(RecursionProcessing::Call(order_by_expr));
83-
}
84-
}
8569
Expression::Cast { expr, .. } => {
8670
stack.push(RecursionProcessing::Call(expr));
8771
}

0 commit comments

Comments
 (0)