Skip to content

Commit e257063

Browse files
andygroveayushdg
authored andcommitted
Upgrade sqlparser (apache#3200)
* Changes to planning for SHOW TABLES due to changes in sqlparser (apache#3193) * Update planning for LIKE due to changes in sqlparser (apache#3194) * rename array function to make_array (apache#3199) * [sqlparser-0.21] Update trimExpr members during planning (apache#3181) * Update sqlparser version to use main from git * Update SqlExpr::Trim struct to match latest sqlparser changes * use sqlparser 0.21 (apache#3202) Co-authored-by: Ayush Dattagupta <[email protected]>
1 parent 3c4ed45 commit e257063

File tree

6 files changed

+44
-9
lines changed

6 files changed

+44
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-cli/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion/common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ cranelift-module = { version = "0.82.0", optional = true }
4444
ordered-float = "2.10"
4545
parquet = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "51f62a72c625cad48c8bd705e89834c3209744b3", features = ["arrow"], optional = true }
4646
pyo3 = { version = "0.16", optional = true }
47-
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "883cc6a3cf8483ecdcba22ebf9ba8215c9abcb11" }
47+
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "10782e5d11fc0e2900c9359dddee0fbefbffd359" }

datafusion/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pin-project-lite= "^0.2.7"
7979
pyo3 = { version = "0.16", optional = true }
8080
rand = "0.8"
8181
smallvec = { version = "1.6", features = ["union"] }
82-
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "883cc6a3cf8483ecdcba22ebf9ba8215c9abcb11" }
82+
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "10782e5d11fc0e2900c9359dddee0fbefbffd359" }
8383
tempfile = "3"
8484
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] }
8585
tokio-stream = "0.1"

datafusion/core/src/sql/planner.rs

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,10 +1606,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
16061606
BinaryOperator::Modulo => Ok(Operator::Modulo),
16071607
BinaryOperator::And => Ok(Operator::And),
16081608
BinaryOperator::Or => Ok(Operator::Or),
1609-
BinaryOperator::Like => Ok(Operator::Like),
1610-
BinaryOperator::NotLike => Ok(Operator::NotLike),
1611-
BinaryOperator::ILike => Ok(Operator::ILike),
1612-
BinaryOperator::NotILike => Ok(Operator::NotILike),
16131609
BinaryOperator::PGRegexMatch => Ok(Operator::RegexMatch),
16141610
BinaryOperator::PGRegexIMatch => Ok(Operator::RegexIMatch),
16151611
BinaryOperator::PGRegexNotMatch => Ok(Operator::RegexNotMatch),
@@ -2005,6 +2001,45 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
20052001
})
20062002
}
20072003

2004+
SQLExpr::Like { negated, expr, pattern, escape_char } => {
2005+
match escape_char {
2006+
Some(_) => {
2007+
// to support this we will need to introduce `Expr::Like` instead
2008+
// of treating it like a binary expression
2009+
Err(DataFusionError::NotImplemented("LIKE with ESCAPE is not yet supported".to_string()))
2010+
},
2011+
_ => {
2012+
Ok(Expr::BinaryExpr {
2013+
left: Box::new(self.sql_expr_to_logical_expr(*expr, schema,)?),
2014+
op: if negated { Operator::NotLike } else { Operator::Like },
2015+
right: Box::new(self.sql_expr_to_logical_expr(*pattern, schema)?),
2016+
})
2017+
}
2018+
}
2019+
}
2020+
2021+
SQLExpr::ILike { negated, expr, pattern, escape_char } => {
2022+
match escape_char {
2023+
Some(_) => {
2024+
// to support this we will need to introduce `Expr::ILike` instead
2025+
// of treating it like a binary expression
2026+
Err(DataFusionError::NotImplemented("ILIKE with ESCAPE is not yet supported".to_string()))
2027+
},
2028+
_ => {
2029+
Ok(Expr::BinaryExpr {
2030+
left: Box::new(self.sql_expr_to_logical_expr(*expr, schema,)?),
2031+
op: if negated { Operator::NotILike } else { Operator::ILike },
2032+
right: Box::new(self.sql_expr_to_logical_expr(*pattern, schema)?),
2033+
})
2034+
}
2035+
}
2036+
}
2037+
2038+
SQLExpr::SimilarTo { .. } => {
2039+
// https://github.com/apache/arrow-datafusion/issues/3099
2040+
Err(DataFusionError::NotImplemented("SIMILAR TO is not yet supported".to_string()))
2041+
}
2042+
20082043
SQLExpr::BinaryOp {
20092044
left,
20102045
op,

datafusion/expr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ path = "src/lib.rs"
3838
ahash = { version = "0.7", default-features = false }
3939
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "51f62a72c625cad48c8bd705e89834c3209744b3", features = ["prettyprint"] }
4040
datafusion-common = { path = "../common", version = "7.0.0" }
41-
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "883cc6a3cf8483ecdcba22ebf9ba8215c9abcb11" }
41+
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "10782e5d11fc0e2900c9359dddee0fbefbffd359" }

0 commit comments

Comments
 (0)