Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Feb 6, 2024
1 parent 840499f commit 699b831
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datafusion/sql/src/expr/arrow_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions datafusion/sql/src/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions datafusion/sql/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
17 changes: 17 additions & 0 deletions datafusion/sqllogictest/test_files/order.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 699b831

Please sign in to comment.