Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 19 additions & 93 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 @@ -199,7 +199,7 @@ regex = "1.12"
rstest = "0.26.1"
serde_json = "1"
sha2 = "^0.11.0"
sqlparser = { version = "0.62.0", default-features = false, features = ["std", "visitor"] }
sqlparser = { version = "0.63.0", default-features = false, features = ["std", "visitor"] }
stacker = "0.1.24"
strum = "0.28.0"
strum_macros = "0.28.0"
Expand Down
5 changes: 5 additions & 0 deletions datafusion/sql/src/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ impl FunctionArgs {
"Calling {name}: LIMIT not supported in function arguments: {limit}"
);
}
FunctionArgumentClause::Where(predicate) => {
return not_impl_err!(
"Calling {name}: WHERE not supported in function arguments: {predicate}"
);
}
FunctionArgumentClause::OnOverflow(overflow) => {
return not_impl_err!(
"Calling {name}: ON OVERFLOW not supported in function arguments: {overflow}"
Expand Down
36 changes: 16 additions & 20 deletions datafusion/sql/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,16 +450,11 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
planner_context,
),

SQLExpr::Cast { array: true, .. } => {
not_impl_err!("`CAST(... AS type ARRAY`) not supported")
}

SQLExpr::Cast {
kind: CastKind::Cast | CastKind::DoubleColon,
expr,
data_type,
format,
array: false,
} => {
self.sql_cast_to_expr(*expr, &data_type, format, schema, planner_context)
}
Expand All @@ -469,7 +464,6 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
expr,
data_type,
format,
array: false,
} => {
if let Some(format) = format {
return not_impl_err!("CAST with format is not supported: {format}");
Expand Down Expand Up @@ -1068,7 +1062,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
negated: bool,
expr: SQLExpr,
pattern: SQLExpr,
escape_char: Option<ValueWithSpan>,
escape_char: Option<Box<SQLExpr>>,
schema: &DFSchema,
planner_context: &mut PlannerContext,
case_insensitive: bool,
Expand All @@ -1078,13 +1072,14 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
return not_impl_err!("ANY in LIKE expression");
}
let pattern = self.sql_expr_to_logical_expr(pattern, schema, planner_context)?;
let escape_char = match escape_char.map(|v| v.value) {
Some(Value::SingleQuotedString(char)) if char.len() == 1 => {
Some(char.chars().next().unwrap())
}
Some(value) => {
let escape_char = match escape_char.map(|e| *e) {
Some(SQLExpr::Value(ValueWithSpan {
value: Value::SingleQuotedString(char),
..
})) if char.len() == 1 => Some(char.chars().next().unwrap()),
Some(expr) => {
return plan_err!(
"Invalid escape character in LIKE expression. Expected a single character wrapped with single quotes, got {value}"
"Invalid escape character in LIKE expression. Expected a single character wrapped with single quotes, got {expr}"
);
}
None => None,
Expand All @@ -1103,18 +1098,19 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
negated: bool,
expr: SQLExpr,
pattern: SQLExpr,
escape_char: Option<ValueWithSpan>,
escape_char: Option<Box<SQLExpr>>,
schema: &DFSchema,
planner_context: &mut PlannerContext,
) -> Result<Expr> {
let pattern = self.sql_expr_to_logical_expr(pattern, schema, planner_context)?;
let escape_char = match escape_char.map(|v| v.value) {
Some(Value::SingleQuotedString(char)) if char.len() == 1 => {
Some(char.chars().next().unwrap())
}
Some(value) => {
let escape_char = match escape_char.map(|e| *e) {
Some(SQLExpr::Value(ValueWithSpan {
value: Value::SingleQuotedString(char),
..
})) if char.len() == 1 => Some(char.chars().next().unwrap()),
Some(expr) => {
return plan_err!(
"Invalid escape character in SIMILAR TO expression. Expected a single character wrapped with single quotes, got {value}"
"Invalid escape character in SIMILAR TO expression. Expected a single character wrapped with single quotes, got {expr}"
);
}
None => None,
Expand Down
13 changes: 11 additions & 2 deletions datafusion/sql/src/expr/order_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use datafusion_common::{
use datafusion_expr::expr::Sort;
use datafusion_expr::{Expr, SortExpr};
use sqlparser::ast::{
Expr as SQLExpr, OrderByExpr, OrderByOptions, Value, ValueWithSpan,
Expr as SQLExpr, OrderByExpr, OrderByOptions, OrderBySort, Value, ValueWithSpan,
};

impl<S: ContextProvider> SqlToRel<'_, S> {
Expand Down Expand Up @@ -75,14 +75,23 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
for order_by_expr in order_by_exprs {
let OrderByExpr {
expr,
options: OrderByOptions { asc, nulls_first },
options: OrderByOptions { sort, nulls_first },
with_fill,
} = order_by_expr;

if let Some(with_fill) = with_fill {
return not_impl_err!("ORDER BY WITH FILL is not supported: {with_fill}");
}

let asc = match sort {
Some(OrderBySort::Asc) => Some(true),
Some(OrderBySort::Desc) => Some(false),
Some(OrderBySort::Using(op)) => {
return not_impl_err!("ORDER BY USING is not supported: {op}");
}
None => None,
};

let expr = match expr {
SQLExpr::Value(ValueWithSpan {
value: Value::Number(v, _),
Expand Down
Loading