Skip to content

Commit 30a9db9

Browse files
alambclaude
authored andcommitted
chore: Update sqlparser to 0.63.0 (apache#25278)
## Which issue does this PR close? - Related to apache/datafusion-sqlparser-rs#2453 ## Rationale for this change `sqlparser` [0.63.0 has been released](https://crates.io/crates/sqlparser/0.63.0) ([changelog](https://github.com/apache/datafusion-sqlparser-rs/blob/main/changelog/0.63.0.md)), so update DataFusion to use it. This PR is based on the testing PR apache#24926 ## What changes are included in this PR? 1. Update `sqlparser` to 0.63.0 2. Update DataFusion for upstream AST changes ## Are these changes tested? Yes, by existing CI (including sqllogictests). ## Are there any user-facing changes? Updated `sqlparser` version. Error messages for a few unsupported syntax cases have changed slightly (see updated test in `datafusion/sql/tests/cases/params.rs`). All existing tests continue to pass --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
1 parent 9c00024 commit 30a9db9

21 files changed

Lines changed: 241 additions & 170 deletions

File tree

‎Cargo.lock‎

Lines changed: 19 additions & 93 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ regex = "1.12"
199199
rstest = "0.27.0"
200200
serde_json = "1"
201201
sha2 = "^0.11.0"
202-
sqlparser = { version = "0.62.0", default-features = false, features = ["std", "visitor"] }
202+
sqlparser = { version = "0.63.0", default-features = false, features = ["std", "visitor"] }
203203
stacker = "0.1.24"
204204
strum = "0.28.0"
205205
strum_macros = "0.28.0"

‎datafusion/common/src/config.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ config_namespace! {
301301
pub collect_spans: bool, default = false
302302

303303
/// Specifies the recursion depth limit when parsing complex SQL Queries
304-
pub recursion_limit: ConfigNonZeroUsize, default = non_zero_usize_default(50)
304+
pub recursion_limit: ConfigNonZeroUsize, default = non_zero_usize_default(51)
305305

306306
/// Specifies the default null ordering for query results. There are 4 options:
307307
/// - `nulls_max`: Nulls appear last in ascending order.

‎datafusion/sql/src/expr/function.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ impl FunctionArgs {
166166
"Calling {name}: LIMIT not supported in function arguments: {limit}"
167167
);
168168
}
169+
FunctionArgumentClause::Where(predicate) => {
170+
return not_impl_err!(
171+
"Calling {name}: WHERE not supported in function arguments: {predicate}"
172+
);
173+
}
169174
FunctionArgumentClause::OnOverflow(overflow) => {
170175
return not_impl_err!(
171176
"Calling {name}: ON OVERFLOW not supported in function arguments: {overflow}"

‎datafusion/sql/src/expr/mod.rs‎

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -450,16 +450,11 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
450450
planner_context,
451451
),
452452

453-
SQLExpr::Cast { array: true, .. } => {
454-
not_impl_err!("`CAST(... AS type ARRAY`) not supported")
455-
}
456-
457453
SQLExpr::Cast {
458454
kind: CastKind::Cast | CastKind::DoubleColon,
459455
expr,
460456
data_type,
461457
format,
462-
array: false,
463458
} => {
464459
self.sql_cast_to_expr(*expr, &data_type, format, schema, planner_context)
465460
}
@@ -469,7 +464,6 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
469464
expr,
470465
data_type,
471466
format,
472-
array: false,
473467
} => {
474468
if let Some(format) = format {
475469
return not_impl_err!("CAST with format is not supported: {format}");
@@ -1068,7 +1062,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
10681062
negated: bool,
10691063
expr: SQLExpr,
10701064
pattern: SQLExpr,
1071-
escape_char: Option<ValueWithSpan>,
1065+
escape_char: Option<Box<SQLExpr>>,
10721066
schema: &DFSchema,
10731067
planner_context: &mut PlannerContext,
10741068
case_insensitive: bool,
@@ -1078,13 +1072,14 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
10781072
return not_impl_err!("ANY in LIKE expression");
10791073
}
10801074
let pattern = self.sql_expr_to_logical_expr(pattern, schema, planner_context)?;
1081-
let escape_char = match escape_char.map(|v| v.value) {
1082-
Some(Value::SingleQuotedString(char)) if char.len() == 1 => {
1083-
Some(char.chars().next().unwrap())
1084-
}
1085-
Some(value) => {
1075+
let escape_char = match escape_char.map(|e| *e) {
1076+
Some(SQLExpr::Value(ValueWithSpan {
1077+
value: Value::SingleQuotedString(char),
1078+
..
1079+
})) if char.len() == 1 => Some(char.chars().next().unwrap()),
1080+
Some(expr) => {
10861081
return plan_err!(
1087-
"Invalid escape character in LIKE expression. Expected a single character wrapped with single quotes, got {value}"
1082+
"Invalid escape character in LIKE expression. Expected a single character wrapped with single quotes, got {expr}"
10881083
);
10891084
}
10901085
None => None,
@@ -1103,18 +1098,19 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
11031098
negated: bool,
11041099
expr: SQLExpr,
11051100
pattern: SQLExpr,
1106-
escape_char: Option<ValueWithSpan>,
1101+
escape_char: Option<Box<SQLExpr>>,
11071102
schema: &DFSchema,
11081103
planner_context: &mut PlannerContext,
11091104
) -> Result<Expr> {
11101105
let pattern = self.sql_expr_to_logical_expr(pattern, schema, planner_context)?;
1111-
let escape_char = match escape_char.map(|v| v.value) {
1112-
Some(Value::SingleQuotedString(char)) if char.len() == 1 => {
1113-
Some(char.chars().next().unwrap())
1114-
}
1115-
Some(value) => {
1106+
let escape_char = match escape_char.map(|e| *e) {
1107+
Some(SQLExpr::Value(ValueWithSpan {
1108+
value: Value::SingleQuotedString(char),
1109+
..
1110+
})) if char.len() == 1 => Some(char.chars().next().unwrap()),
1111+
Some(expr) => {
11161112
return plan_err!(
1117-
"Invalid escape character in SIMILAR TO expression. Expected a single character wrapped with single quotes, got {value}"
1113+
"Invalid escape character in SIMILAR TO expression. Expected a single character wrapped with single quotes, got {expr}"
11181114
);
11191115
}
11201116
None => None,

‎datafusion/sql/src/expr/order_by.rs‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use datafusion_common::{
2222
use datafusion_expr::expr::Sort;
2323
use datafusion_expr::{Expr, SortExpr};
2424
use sqlparser::ast::{
25-
Expr as SQLExpr, OrderByExpr, OrderByOptions, Value, ValueWithSpan,
25+
Expr as SQLExpr, OrderByExpr, OrderByOptions, OrderBySort, Value, ValueWithSpan,
2626
};
2727

2828
impl<S: ContextProvider> SqlToRel<'_, S> {
@@ -75,14 +75,23 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
7575
for order_by_expr in order_by_exprs {
7676
let OrderByExpr {
7777
expr,
78-
options: OrderByOptions { asc, nulls_first },
78+
options: OrderByOptions { sort, nulls_first },
7979
with_fill,
8080
} = order_by_expr;
8181

8282
if let Some(with_fill) = with_fill {
8383
return not_impl_err!("ORDER BY WITH FILL is not supported: {with_fill}");
8484
}
8585

86+
let asc = match sort {
87+
Some(OrderBySort::Asc) => Some(true),
88+
Some(OrderBySort::Desc) => Some(false),
89+
Some(OrderBySort::Using(op)) => {
90+
return not_impl_err!("ORDER BY USING is not supported: {op}");
91+
}
92+
None => None,
93+
};
94+
8695
let expr = match expr {
8796
SQLExpr::Value(ValueWithSpan {
8897
value: Value::Number(v, _),

0 commit comments

Comments
 (0)