Skip to content

Commit

Permalink
Upgrade sqlparser (apache#3200)
Browse files Browse the repository at this point in the history
* 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 <ayushdg95@gmail.com>
  • Loading branch information
2 people authored and MazterQyou committed Dec 1, 2022
1 parent 3c4ed45 commit e257063
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 9 deletions.
2 changes: 1 addition & 1 deletion 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 datafusion-cli/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 datafusion/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ cranelift-module = { version = "0.82.0", optional = true }
ordered-float = "2.10"
parquet = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "51f62a72c625cad48c8bd705e89834c3209744b3", features = ["arrow"], optional = true }
pyo3 = { version = "0.16", optional = true }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "883cc6a3cf8483ecdcba22ebf9ba8215c9abcb11" }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "10782e5d11fc0e2900c9359dddee0fbefbffd359" }
2 changes: 1 addition & 1 deletion datafusion/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pin-project-lite= "^0.2.7"
pyo3 = { version = "0.16", optional = true }
rand = "0.8"
smallvec = { version = "1.6", features = ["union"] }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "883cc6a3cf8483ecdcba22ebf9ba8215c9abcb11" }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "10782e5d11fc0e2900c9359dddee0fbefbffd359" }
tempfile = "3"
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] }
tokio-stream = "0.1"
Expand Down
43 changes: 39 additions & 4 deletions datafusion/core/src/sql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,10 +1606,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
BinaryOperator::Modulo => Ok(Operator::Modulo),
BinaryOperator::And => Ok(Operator::And),
BinaryOperator::Or => Ok(Operator::Or),
BinaryOperator::Like => Ok(Operator::Like),
BinaryOperator::NotLike => Ok(Operator::NotLike),
BinaryOperator::ILike => Ok(Operator::ILike),
BinaryOperator::NotILike => Ok(Operator::NotILike),
BinaryOperator::PGRegexMatch => Ok(Operator::RegexMatch),
BinaryOperator::PGRegexIMatch => Ok(Operator::RegexIMatch),
BinaryOperator::PGRegexNotMatch => Ok(Operator::RegexNotMatch),
Expand Down Expand Up @@ -2005,6 +2001,45 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
})
}

SQLExpr::Like { negated, expr, pattern, escape_char } => {
match escape_char {
Some(_) => {
// to support this we will need to introduce `Expr::Like` instead
// of treating it like a binary expression
Err(DataFusionError::NotImplemented("LIKE with ESCAPE is not yet supported".to_string()))
},
_ => {
Ok(Expr::BinaryExpr {
left: Box::new(self.sql_expr_to_logical_expr(*expr, schema,)?),
op: if negated { Operator::NotLike } else { Operator::Like },
right: Box::new(self.sql_expr_to_logical_expr(*pattern, schema)?),
})
}
}
}

SQLExpr::ILike { negated, expr, pattern, escape_char } => {
match escape_char {
Some(_) => {
// to support this we will need to introduce `Expr::ILike` instead
// of treating it like a binary expression
Err(DataFusionError::NotImplemented("ILIKE with ESCAPE is not yet supported".to_string()))
},
_ => {
Ok(Expr::BinaryExpr {
left: Box::new(self.sql_expr_to_logical_expr(*expr, schema,)?),
op: if negated { Operator::NotILike } else { Operator::ILike },
right: Box::new(self.sql_expr_to_logical_expr(*pattern, schema)?),
})
}
}
}

SQLExpr::SimilarTo { .. } => {
// https://github.com/apache/arrow-datafusion/issues/3099
Err(DataFusionError::NotImplemented("SIMILAR TO is not yet supported".to_string()))
}

SQLExpr::BinaryOp {
left,
op,
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ path = "src/lib.rs"
ahash = { version = "0.7", default-features = false }
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "51f62a72c625cad48c8bd705e89834c3209744b3", features = ["prettyprint"] }
datafusion-common = { path = "../common", version = "7.0.0" }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "883cc6a3cf8483ecdcba22ebf9ba8215c9abcb11" }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "10782e5d11fc0e2900c9359dddee0fbefbffd359" }

0 comments on commit e257063

Please sign in to comment.