diff --git a/datafusion/sql/src/expr/arrow_cast.rs b/datafusion/sql/src/expr/arrow_cast.rs index 9a0d61f41c01..e12b6338502e 100644 --- a/datafusion/sql/src/expr/arrow_cast.rs +++ b/datafusion/sql/src/expr/arrow_cast.rs @@ -45,7 +45,7 @@ pub const ARROW_CAST_NAME: &str = "arrow_cast"; /// select cast(column_x as int) ... /// ``` /// -/// Use the `arrow_cast` functiont to cast to a specfic arrow type +/// Use the `arrow_cast` function to cast to a specific arrow type /// /// For example /// ```sql diff --git a/datafusion/sql/src/expr/function.rs b/datafusion/sql/src/expr/function.rs index 3187f26dcc5d..d22ebcb425f0 100644 --- a/datafusion/sql/src/expr/function.rs +++ b/datafusion/sql/src/expr/function.rs @@ -233,6 +233,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { // Special case arrow_cast (as its type is dependent on its argument value) if name == ARROW_CAST_NAME { + println!("arrow_cast: {}", schema); let args = self.function_args_to_expr(args, schema, planner_context)?; return super::arrow_cast::create_arrow_cast(args, schema); } diff --git a/datafusion/sql/src/expr/mod.rs b/datafusion/sql/src/expr/mod.rs index ecf510da7bce..58ea7fe490c8 100644 --- a/datafusion/sql/src/expr/mod.rs +++ b/datafusion/sql/src/expr/mod.rs @@ -447,6 +447,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { } SQLExpr::Function(function) => { + println!("function: {}", schema); self.sql_function_to_expr(function, schema, planner_context) } diff --git a/datafusion/sqllogictest/test_files/order.slt b/datafusion/sqllogictest/test_files/order.slt index 61888eb8006d..af8fb6550c44 100644 --- a/datafusion/sqllogictest/test_files/order.slt +++ b/datafusion/sqllogictest/test_files/order.slt @@ -784,3 +784,20 @@ SortPreservingMergeExec: [m@0 ASC NULLS LAST,t@1 ASC NULLS LAST] ----------------AggregateExec: mode=Partial, gby=[1 as Int64(1), t@0 as t], aggr=[] ------------------ProjectionExec: expr=[column1@0 as t] --------------------ValuesExec + +statement ok +create table ts (a int); + +statement ok +insert into ts values (915148800); + +query error DataFusion error: Schema error: No field named a\. Valid fields are minute\. +EXPLAIN ANALYZE SELECT + DATE_TRUNC('minute', arrow_cast(a, 'Timestamp(Second, None)')) AS minute +FROM + ts +ORDER BY + DATE_TRUNC('minute', arrow_cast(a, 'Timestamp(Second, None)')); + +statement ok +drop table ts;