-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove CountWildcardRule in Analyzer and move the functionality in ExprPlanner, add plan_aggregate
and plan_window
to planner
#14689
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
29e77c1
count planner
jayzhan211 64a5694
window
jayzhan211 350ce74
update slt
jayzhan211 9165168
remove rule
jayzhan211 6ae8b44
rm rule
jayzhan211 47bd66c
doc
jayzhan211 ece96ea
fix name
jayzhan211 2740604
fix name
jayzhan211 92362e6
fix test
jayzhan211 7afc362
tpch test
jayzhan211 4d38a31
Merge branch 'main' of github.com:apache/datafusion into rm-count-wil…
jayzhan211 33c6e08
fix avro
jayzhan211 4fd79fd
Merge branch 'main' of github.com:apache/datafusion into rm-count-wil…
jayzhan211 2ea1a32
rename
jayzhan211 8db54fe
switch to count(*)
jayzhan211 8649b11
use count(*)
jayzhan211 1b13f6d
rename
jayzhan211 0e07fe0
doc
jayzhan211 497d201
Merge branch 'main' of github.com:apache/datafusion into rm-count-wil…
jayzhan211 20664e4
rename window funciotn
jayzhan211 5c2acd5
fmt
jayzhan211 7379fad
rm print
jayzhan211 7211656
upd logic
jayzhan211 f31d574
count null
jayzhan211 7f524a4
Merge branch 'main' of github.com:apache/datafusion into rm-count-wil…
jayzhan211 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,12 @@ use datafusion_common::{ | |
config::ConfigOptions, file_options::file_type::FileType, not_impl_err, DFSchema, | ||
Result, TableReference, | ||
}; | ||
use sqlparser::ast; | ||
use sqlparser::ast::{self, NullTreatment}; | ||
|
||
use crate::{AggregateUDF, Expr, GetFieldAccess, ScalarUDF, TableSource, WindowUDF}; | ||
use crate::{ | ||
AggregateUDF, Expr, GetFieldAccess, ScalarUDF, SortExpr, TableSource, WindowFrame, | ||
WindowFunctionDefinition, WindowUDF, | ||
}; | ||
|
||
/// Provides the `SQL` query planner meta-data about tables and | ||
/// functions referenced in SQL statements, without a direct dependency on the | ||
|
@@ -138,7 +141,7 @@ pub trait ExprPlanner: Debug + Send + Sync { | |
|
||
/// Plan an array literal, such as `[1, 2, 3]` | ||
/// | ||
/// Returns origin expression arguments if not possible | ||
/// Returns original expression arguments if not possible | ||
fn plan_array_literal( | ||
&self, | ||
exprs: Vec<Expr>, | ||
|
@@ -149,14 +152,14 @@ pub trait ExprPlanner: Debug + Send + Sync { | |
|
||
/// Plan a `POSITION` expression, such as `POSITION(<expr> in <expr>)` | ||
/// | ||
/// returns origin expression arguments if not possible | ||
/// Returns original expression arguments if not possible | ||
fn plan_position(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> { | ||
Ok(PlannerResult::Original(args)) | ||
} | ||
|
||
/// Plan a dictionary literal, such as `{ key: value, ...}` | ||
/// | ||
/// Returns origin expression arguments if not possible | ||
/// Returns original expression arguments if not possible | ||
fn plan_dictionary_literal( | ||
&self, | ||
expr: RawDictionaryExpr, | ||
|
@@ -167,14 +170,14 @@ pub trait ExprPlanner: Debug + Send + Sync { | |
|
||
/// Plan an extract expression, such as`EXTRACT(month FROM foo)` | ||
/// | ||
/// Returns origin expression arguments if not possible | ||
/// Returns original expression arguments if not possible | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good change. nit Could go in separate PR to keep PR size lower. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can keep this |
||
fn plan_extract(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> { | ||
Ok(PlannerResult::Original(args)) | ||
} | ||
|
||
/// Plan an substring expression, such as `SUBSTRING(<expr> [FROM <expr>] [FOR <expr>])` | ||
/// | ||
/// Returns origin expression arguments if not possible | ||
/// Returns original expression arguments if not possible | ||
fn plan_substring(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> { | ||
Ok(PlannerResult::Original(args)) | ||
} | ||
|
@@ -195,14 +198,14 @@ pub trait ExprPlanner: Debug + Send + Sync { | |
|
||
/// Plans an overlay expression, such as `overlay(str PLACING substr FROM pos [FOR count])` | ||
/// | ||
/// Returns origin expression arguments if not possible | ||
/// Returns original expression arguments if not possible | ||
fn plan_overlay(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> { | ||
Ok(PlannerResult::Original(args)) | ||
} | ||
|
||
/// Plans a `make_map` expression, such as `make_map(key1, value1, key2, value2, ...)` | ||
/// | ||
/// Returns origin expression arguments if not possible | ||
/// Returns original expression arguments if not possible | ||
fn plan_make_map(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> { | ||
Ok(PlannerResult::Original(args)) | ||
} | ||
|
@@ -230,6 +233,23 @@ pub trait ExprPlanner: Debug + Send + Sync { | |
fn plan_any(&self, expr: RawBinaryExpr) -> Result<PlannerResult<RawBinaryExpr>> { | ||
Ok(PlannerResult::Original(expr)) | ||
} | ||
|
||
/// Plans aggregate functions, such as `COUNT(<expr>)` | ||
/// | ||
/// Returns original expression arguments if not possible | ||
fn plan_aggregate( | ||
&self, | ||
expr: RawAggregateExpr, | ||
) -> Result<PlannerResult<RawAggregateExpr>> { | ||
Ok(PlannerResult::Original(expr)) | ||
} | ||
|
||
/// Plans window functions, such as `COUNT(<expr>)` | ||
/// | ||
/// Returns original expression arguments if not possible | ||
fn plan_window(&self, expr: RawWindowExpr) -> Result<PlannerResult<RawWindowExpr>> { | ||
Ok(PlannerResult::Original(expr)) | ||
} | ||
} | ||
|
||
/// An operator with two arguments to plan | ||
|
@@ -266,6 +286,30 @@ pub struct RawDictionaryExpr { | |
pub values: Vec<Expr>, | ||
} | ||
|
||
/// This structure is used by `AggregateFunctionPlanner` to plan operators with | ||
/// custom expressions. | ||
#[derive(Debug, Clone)] | ||
pub struct RawAggregateExpr { | ||
pub func: Arc<AggregateUDF>, | ||
pub args: Vec<Expr>, | ||
pub distinct: bool, | ||
pub filter: Option<Box<Expr>>, | ||
pub order_by: Option<Vec<SortExpr>>, | ||
pub null_treatment: Option<NullTreatment>, | ||
} | ||
|
||
/// This structure is used by `WindowFunctionPlanner` to plan operators with | ||
/// custom expressions. | ||
#[derive(Debug, Clone)] | ||
pub struct RawWindowExpr { | ||
pub func_def: WindowFunctionDefinition, | ||
pub args: Vec<Expr>, | ||
pub partition_by: Vec<Expr>, | ||
pub order_by: Vec<SortExpr>, | ||
pub window_frame: WindowFrame, | ||
pub null_treatment: Option<NullTreatment>, | ||
} | ||
|
||
/// Result of planning a raw expr with [`ExprPlanner`] | ||
#[derive(Debug, Clone)] | ||
pub enum PlannerResult<T> { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also deprecate
wildcard()
and Expr::Wildcard (in a follow on PR?)https://docs.rs/datafusion/latest/datafusion/logical_expr/fn.wildcard.html
https://docs.rs/datafusion/latest/datafusion/prelude/enum.Expr.html#variant.Wildcard
🤔