-
Notifications
You must be signed in to change notification settings - Fork 1.9k
chore(deps): Update sqlparser to 0.60 #19672
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
base: main
Are you sure you want to change the base?
Conversation
|
Could we address the CI failures? Looks like some tests are failing |
Signed-off-by: StandingMan <jmtangcs@gmail.com>
0ea9df1 to
c2dd55b
Compare
Signed-off-by: StandingMan <jmtangcs@gmail.com>
Signed-off-by: StandingMan <jmtangcs@gmail.com>
|
@Jefffrey ready to review. |
|
I was literally about to sit down and have codex try to do this -- thank you @Standing-Man -- taking a look now |
alamb
left a comment
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.
Looks good to me @Standing-Man -- thank you. THe only question I have is about the change of API to use Boxed results
datafusion/expr/src/expr.rs
Outdated
| write!(f, " ({})", display_comma_separated(&self.items))?; | ||
| for item in &self.items { | ||
| write!(f, " ({item})")?; | ||
| } |
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.
I'm a bit curious on this change, it doesn't look right at first glance 🤔
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.
If you take a second look, you’ll see that the display_comma_separated method is a private helper used to format ReplaceSelectItem. 😄
https://github.com/apache/datafusion-sqlparser-rs/blob/main/src/ast/query.rs#L960-L966
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.
If we put two replace items in this test:
datafusion/datafusion/expr/src/expr.rs
Lines 3861 to 3868 in 102caeb
| Some(PlannedReplaceSelectItem { | |
| items: vec![ReplaceSelectElement { | |
| expr: ast::Expr::Identifier(Ident::from("c1")), | |
| column_name: Ident::from("a1"), | |
| as_keyword: false | |
| }], | |
| planned_expressions: vec![] | |
| }), |
This new code will format the display like so:
* REPLACE (c1 a1) (c1 a1)Which doesn't seem quite right?
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.
Yes, you're right. the correct format display like:
* REPLACE (c1 a1, c1 a1)
i will update on next commit.
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.
We should just reuse this function by removing its cfg guard:
datafusion/datafusion/expr/src/expr.rs
Lines 1271 to 1278 in a55b77e
| #[cfg(not(feature = "sql"))] | |
| pub fn display_comma_separated<T>(slice: &[T]) -> String | |
| where | |
| T: Display, | |
| { | |
| use itertools::Itertools; | |
| slice.iter().map(|v| format!("{v}")).join(", ") | |
| } |
Signed-off-by: StandingMan <jmtangcs@gmail.com>
Signed-off-by: StandingMan <jmtangcs@gmail.com>
alamb
left a comment
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.
Thanks @Standing-Man and @Jefffrey
Signed-off-by: StandingMan <jmtangcs@gmail.com>
Jefffrey
left a comment
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.
It is very tempting to not destructure the nested fields/enums because it makes the code less verbose. However, by doing so we miss fields that might be introduced in newer versions. These fields usually correspond to supporting more syntax. If we are unaware of this syntax, it means the SQL dialect we have will start accepting more and more syntax even if we don't do anything with the syntax.
I admit it might be painful and verbose to do it that way but I find its a very good way to use Rust's characteristics to help us catch this issues at compile time, instead of at runtime.
datafusion/expr/src/expr.rs
Outdated
| write!(f, " ({})", display_comma_separated(&self.items))?; | ||
| for item in &self.items { | ||
| write!(f, " ({item})")?; | ||
| } |
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.
We should just reuse this function by removing its cfg guard:
datafusion/datafusion/expr/src/expr.rs
Lines 1271 to 1278 in a55b77e
| #[cfg(not(feature = "sql"))] | |
| pub fn display_comma_separated<T>(slice: &[T]) -> String | |
| where | |
| T: Display, | |
| { | |
| use itertools::Itertools; | |
| slice.iter().map(|v| format!("{v}")).join(", ") | |
| } |
datafusion/sql/src/statement.rs
Outdated
| })), | ||
| ast::ColumnOption::PrimaryKey(PrimaryKeyConstraint { | ||
| characteristics, | ||
| .. |
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.
We're still ignoring fields here with the usage of ..
datafusion/sql/src/statement.rs
Outdated
| func_desc, | ||
| .. | ||
| } => { | ||
| Statement::DropFunction(func) => { |
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.
We should be destructuring this like so
Statement::DropFunction(DropFunction {
if_exists,
func_desc,
drop_behaviour,
})
datafusion/sql/src/statement.rs
Outdated
| characteristics, | ||
| } => constraints.push(TableConstraint::Unique { | ||
| ast::ColumnOption::Unique(UniqueConstraint { | ||
| characteristics, .. |
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.
We should be destructuring this not ignoring the fields with ..
datafusion/sql/src/statement.rs
Outdated
| }), | ||
| ast::ColumnOption::Check(expr) => { | ||
| constraints.push(TableConstraint::Check { | ||
| .. |
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.
We should be destructuring this not ignoring the fields with ..
datafusion/sql/src/statement.rs
Outdated
| characteristics: *characteristics, | ||
| })) | ||
| } | ||
| ast::ColumnOption::Check(CheckConstraint { name, expr, .. }) => { |
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.
We should be destructuring this not ignoring the fields with ..
| or, | ||
| limit, | ||
| } => { | ||
| .. |
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.
We should be destructuring this not ignoring the fields with ..
| from, | ||
| order_by, | ||
| limit, | ||
| .. |
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.
We should be destructuring this not ignoring the fields with ..
|
@Standing-Man could you please refrain from marking the comments as resolved? I see quite of few of my recent comments were marked as resolved even though no action was taken. Can you leave it to us to determine if a conversation is resolved, it makes it easier for us to review. |
Signed-off-by: StandingMan <jmtangcs@gmail.com>
1f5ceb7 to
e00823c
Compare
Which issue does this PR close?
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?