Skip to content

Commit

Permalink
Support HEAD of sqlparser main
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Aug 15, 2024
1 parent e24a5dd commit 65159e1
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ rand = "0.8"
regex = "1.8"
rstest = "0.22.0"
serde_json = "1"
sqlparser = { version = "0.49", features = ["visitor"] }
sqlparser = { git = "https://github.com/sqlparser-rs/sqlparser-rs.git", rev = "fab834d", features = ["visitor"] }
tempfile = "3"
thiserror = "1.0.44"
tokio = { version = "1.36", features = ["macros", "rt", "sync"] }
Expand Down
6 changes: 2 additions & 4 deletions 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/sql/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
SQLExpr::Value(value) => {
self.parse_value(value, planner_context.prepare_param_data_types())
}
SQLExpr::Extract { field, expr } => {
SQLExpr::Extract { field, expr, .. } => {
let mut extract_args = vec![
Expr::Literal(ScalarValue::from(format!("{field}"))),
self.sql_expr_to_logical_expr(*expr, schema, planner_context)?,
Expand Down
1 change: 1 addition & 0 deletions datafusion/sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
| SQLDataType::Union(_)
| SQLDataType::Nullable(_)
| SQLDataType::LowCardinality(_)
| SQLDataType::Trigger
=> not_impl_err!(
"Unsupported SQL type {sql_type:?}"
),
Expand Down
1 change: 1 addition & 0 deletions datafusion/sql/src/relation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
if let Some(func_args) = args {
let tbl_func_name = name.0.first().unwrap().value.to_string();
let args = func_args
.args
.into_iter()
.flat_map(|arg| {
if let FunctionArg::Unnamed(FunctionArgExpr::Expr(expr)) = arg
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sql/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
match statement {
Statement::ExplainTable {
describe_alias: DescribeAlias::Describe, // only parse 'DESCRIBE table_name' and not 'EXPLAIN table_name'
hive_format: _,
table_name,
..
} => self.describe_table_to_plan(table_name),
Statement::Explain {
verbose,
Expand Down
5 changes: 4 additions & 1 deletion datafusion/sql/src/unparser/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,10 @@ impl TableRelationBuilder {
None => return Err(Into::into(UninitializedFieldError::from("name"))),
},
alias: self.alias.clone(),
args: self.args.clone(),
args: self.args.clone().map(|args| ast::TableFunctionArgs {
args,
settings: None,
}),
with_hints: self.with_hints.clone(),
version: self.version.clone(),
partitions: self.partitions.clone(),
Expand Down
1 change: 1 addition & 0 deletions datafusion/sql/src/unparser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ impl Unparser<'_> {
return Some(ast::Expr::Extract {
field,
expr: Box::new(date_expr),
syntax: ast::ExtractSyntax::From,
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions datafusion/sql/src/unparser/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ impl Unparser<'_> {

let ast_join = ast::Join {
relation,
global: false,
join_operator: self
.join_operator_to_sql(join.join_type, join_constraint),
};
Expand Down Expand Up @@ -435,6 +436,7 @@ impl Unparser<'_> {

let ast_join = ast::Join {
relation,
global: false,
join_operator: self.join_operator_to_sql(
JoinType::Inner,
ast::JoinConstraint::On(ast::Expr::Value(ast::Value::Boolean(
Expand Down
1 change: 1 addition & 0 deletions datafusion/sql/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ pub(crate) fn value_to_string(value: &Value) -> Option<String> {
Value::SingleQuotedString(s) => Some(s.to_string()),
Value::DollarQuotedString(s) => Some(s.to_string()),
Value::Number(_, _) | Value::Boolean(_) => Some(value.to_string()),
Value::UnicodeStringLiteral(s) => Some(s.to_string()),
Value::DoubleQuotedString(_)
| Value::EscapedStringLiteral(_)
| Value::NationalStringLiteral(_)
Expand Down

0 comments on commit 65159e1

Please sign in to comment.