Skip to content

Commit

Permalink
chore: Update sqlparser requirement from 0.38.0 to 0.39.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener committed Oct 30, 2023
1 parent 806a963 commit f14c42c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ arrow-buffer = { version = "48.0.0", default-features = false }
arrow-flight = { version = "48.0.0", features = ["flight-sql-experimental"] }
arrow-schema = { version = "48.0.0", default-features = false }
parquet = { version = "48.0.0", features = ["arrow", "async", "object_store"] }
sqlparser = { version = "0.38.0", features = ["visitor"] }
sqlparser = { version = "0.39.0", features = ["visitor"] }
chrono = { version = "0.4.31", default-features = false }

[profile.release]
Expand Down
9 changes: 7 additions & 2 deletions datafusion/sql/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
planner_context,
),

SQLExpr::Cast { expr, data_type } => Ok(Expr::Cast(Cast::new(
SQLExpr::Cast {
expr, data_type, ..
} => Ok(Expr::Cast(Cast::new(
Box::new(self.sql_expr_to_logical_expr(
*expr,
schema,
Expand All @@ -231,7 +233,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
self.convert_data_type(&data_type)?,
))),

SQLExpr::TryCast { expr, data_type } => Ok(Expr::TryCast(TryCast::new(
SQLExpr::TryCast {
expr, data_type, ..
} => Ok(Expr::TryCast(TryCast::new(
Box::new(self.sql_expr_to_logical_expr(
*expr,
schema,
Expand Down Expand Up @@ -412,6 +416,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
expr,
trim_where,
trim_what,
..
} => self.sql_trim_to_expr(
*expr,
trim_where,
Expand Down
16 changes: 11 additions & 5 deletions datafusion/sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use arrow_schema::*;
use datafusion_common::field_not_found;
use datafusion_common::internal_err;
use datafusion_expr::WindowUDF;
use sqlparser::ast::ExactNumberInfo;
use sqlparser::ast::TimezoneInfo;
use sqlparser::ast::{ArrayElemTypeDef, ExactNumberInfo};
use sqlparser::ast::{ColumnDef as SQLColumnDef, ColumnOption};
use sqlparser::ast::{DataType as SQLDataType, Ident, ObjectName, TableAlias};

Expand Down Expand Up @@ -297,14 +297,15 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {

pub(crate) fn convert_data_type(&self, sql_type: &SQLDataType) -> Result<DataType> {
match sql_type {
SQLDataType::Array(Some(inner_sql_type)) => {
SQLDataType::Array(ArrayElemTypeDef::AngleBracket(inner_sql_type))
| SQLDataType::Array(ArrayElemTypeDef::SquareBracket(inner_sql_type)) => {
let data_type = self.convert_simple_data_type(inner_sql_type)?;

Ok(DataType::List(Arc::new(Field::new(
"field", data_type, true,
))))
}
SQLDataType::Array(None) => {
SQLDataType::Array(ArrayElemTypeDef::None) => {
not_impl_err!("Arrays with unspecified type is not supported")
}
other => self.convert_simple_data_type(other),
Expand All @@ -330,7 +331,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
SQLDataType::Char(_)
| SQLDataType::Varchar(_)
| SQLDataType::Text
| SQLDataType::String => Ok(DataType::Utf8),
| SQLDataType::String(_) => Ok(DataType::Utf8),
SQLDataType::Timestamp(None, tz_info) => {
let tz = if matches!(tz_info, TimezoneInfo::Tz)
|| matches!(tz_info, TimezoneInfo::WithTimeZone)
Expand Down Expand Up @@ -400,7 +401,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
| SQLDataType::Dec(_)
| SQLDataType::BigNumeric(_)
| SQLDataType::BigDecimal(_)
| SQLDataType::Clob(_) => not_impl_err!(
| SQLDataType::Clob(_)
| SQLDataType::Bytes(_)
| SQLDataType::Int64
| SQLDataType::Float64
| SQLDataType::Struct(_)
=> not_impl_err!(
"Unsupported SQL type {sql_type:?}"
),
}
Expand Down
3 changes: 3 additions & 0 deletions datafusion/sql/src/set_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
SetQuantifier::AllByName => {
return not_impl_err!("UNION ALL BY NAME not implemented")
}
SetQuantifier::DistinctByName => {
return not_impl_err!("UNION DISTINCT BY NAME not implemented")
}
};

let left_plan = self.set_expr_to_plan(*left, planner_context)?;
Expand Down
15 changes: 15 additions & 0 deletions datafusion/sql/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
table,
on,
returning,
ignore,
} => {
if or.is_some() {
plan_err!("Inserts with or clauses not supported")?;
Expand All @@ -449,6 +450,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
if returning.is_some() {
plan_err!("Insert-returning clause not supported")?;
}
if ignore {
plan_err!("Insert-ignore clause not supported")?;
}
let _ = into; // optional keyword doesn't change behavior
self.insert_to_plan(table_name, columns, source, overwrite)
}
Expand All @@ -471,6 +475,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
selection,
returning,
from,
order_by,
limit,
} => {
if !tables.is_empty() {
plan_err!("DELETE <TABLE> not supported")?;
Expand All @@ -483,6 +489,15 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
if returning.is_some() {
plan_err!("Delete-returning clause not yet supported")?;
}

if !order_by.is_empty() {
plan_err!("Delete-order-by clause not yet supported")?;
}

if limit.is_some() {
plan_err!("Delete-limit clause not yet supported")?;
}

let table_name = self.get_delete_target(from)?;
self.delete_to_plan(table_name, selection)
}
Expand Down

0 comments on commit f14c42c

Please sign in to comment.