Skip to content

Commit

Permalink
build: Upgrade sqlparser-rs from version 0.49 to 0.52 (#20110)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie authored Dec 2, 2024
1 parent e805487 commit 4c1c51c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ serde_json = "1"
simd-json = { version = "0.14", features = ["known-key"] }
simdutf8 = "0.1.4"
slotmap = "1"
sqlparser = "0.49"
sqlparser = "0.52"
stacker = "0.1"
streaming-iterator = "0.1.9"
strength_reduce = "0.2"
Expand Down
9 changes: 6 additions & 3 deletions crates/polars-sql/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,17 @@ impl SQLContext {

fn execute_truncate_table(&mut self, stmt: &Statement) -> PolarsResult<LazyFrame> {
if let Statement::Truncate {
table_name,
table_names,
partitions,
..
} = stmt
{
match partitions {
None => {
let tbl = table_name.to_string();
if table_names.len() != 1 {
polars_bail!(SQLInterface: "TRUNCATE expects exactly one table name; found {}", table_names.len())
}
let tbl = table_names[0].to_string();
if let Some(lf) = self.table_map.get_mut(&tbl) {
*lf = DataFrame::empty_with_schema(
lf.schema_with_arenas(&mut self.lp_arena, &mut self.expr_arena)
Expand Down Expand Up @@ -971,7 +974,7 @@ impl SQLContext {
name, alias, args, ..
} => {
if let Some(args) = args {
return self.execute_table_function(name, alias, args);
return self.execute_table_function(name, alias, &args.args);
}
let tbl_name = name.0.first().unwrap().value.as_str();
if let Some(lf) = self.get_table_from_current_scope(tbl_name) {
Expand Down
27 changes: 22 additions & 5 deletions crates/polars-sql/src/sql_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl SQLExprVisitor<'_> {
left,
compare_op,
right,
is_some: _,
} => self.visit_any(left, compare_op, right),
SQLExpr::Array(arr) => self.visit_array_expr(&arr.elem, true, None),
SQLExpr::Between {
Expand All @@ -110,9 +111,11 @@ impl SQLExprVisitor<'_> {
} => self.visit_cast(expr, data_type, format, kind),
SQLExpr::Ceil { expr, .. } => Ok(self.visit_expr(expr)?.ceil()),
SQLExpr::CompoundIdentifier(idents) => self.visit_compound_identifier(idents),
SQLExpr::Extract { field, expr } => {
parse_extract_date_part(self.visit_expr(expr)?, field)
},
SQLExpr::Extract {
field,
syntax: _,
expr,
} => parse_extract_date_part(self.visit_expr(expr)?, field),
SQLExpr::Floor { expr, .. } => Ok(self.visit_expr(expr)?.floor()),
SQLExpr::Function(function) => self.visit_function(function),
SQLExpr::Identifier(ident) => self.visit_identifier(ident),
Expand Down Expand Up @@ -146,16 +149,28 @@ impl SQLExprVisitor<'_> {
SQLExpr::IsTrue(expr) => Ok(self.visit_expr(expr)?.eq(lit(true))),
SQLExpr::Like {
negated,
any,
expr,
pattern,
escape_char,
} => self.visit_like(*negated, expr, pattern, escape_char, false),
} => {
if *any {
polars_bail!(SQLSyntax: "LIKE ANY is not a supported syntax")
}
self.visit_like(*negated, expr, pattern, escape_char, false)
},
SQLExpr::ILike {
negated,
any,
expr,
pattern,
escape_char,
} => self.visit_like(*negated, expr, pattern, escape_char, true),
} => {
if *any {
polars_bail!(SQLSyntax: "ILIKE ANY is not a supported syntax")
}
self.visit_like(*negated, expr, pattern, escape_char, true)
},
SQLExpr::Nested(expr) => self.visit_expr(expr),
SQLExpr::Position { expr, r#in } => Ok(
// note: SQL is 1-indexed
Expand Down Expand Up @@ -537,13 +552,15 @@ impl SQLExprVisitor<'_> {
) {
SQLExpr::Like {
negated: matches!(op, SQLBinaryOperator::PGNotLikeMatch),
any: false,
expr: Box::new(left.clone()),
pattern: Box::new(right.clone()),
escape_char: None,
}
} else {
SQLExpr::ILike {
negated: matches!(op, SQLBinaryOperator::PGNotILikeMatch),
any: false,
expr: Box::new(left.clone()),
pattern: Box::new(right.clone()),
escape_char: None,
Expand Down

0 comments on commit 4c1c51c

Please sign in to comment.