Skip to content

Commit

Permalink
fix: tz now
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinlanhenke authored and jeffreyssmith2nd committed Jun 18, 2024
1 parent e495f1f commit ab7469d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion datafusion/core/tests/expr_api/simplification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ fn multiple_now() -> Result<()> {
// expect the same timestamp appears in both exprs
let actual = get_optimized_plan_formatted(plan, &time);
let expected = format!(
"Projection: TimestampNanosecond({}, Some(\"+00:00\")) AS now(), TimestampNanosecond({}, Some(\"+00:00\")) AS t2\
"Projection: TimestampNanosecond({}, Some(\"UTC\")) AS now(), TimestampNanosecond({}, Some(\"UTC\")) AS t2\
\n TableScan: test",
time.timestamp_nanos_opt().unwrap(),
time.timestamp_nanos_opt().unwrap()
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/tests/optimizer_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn timestamp_nano_ts_utc_predicates() {
// constant and compared to the column without a cast so it can be
// pushed down / pruned
let expected =
"Projection: test.col_int32\n Filter: test.col_ts_nano_utc < TimestampNanosecond(1666612093000000000, Some(\"+00:00\"))\
"Projection: test.col_int32\n Filter: test.col_ts_nano_utc < TimestampNanosecond(1666612093000000000, Some(\"UTC\"))\
\n TableScan: test projection=[col_int32, col_ts_nano_utc]";
assert_eq!(expected, format!("{plan:?}"));
}
Expand Down Expand Up @@ -180,7 +180,7 @@ impl ContextProvider for MyContextProvider {
// timestamp with UTC timezone
Field::new(
"col_ts_nano_utc",
DataType::Timestamp(TimeUnit::Nanosecond, Some("+00:00".into())),
DataType::Timestamp(TimeUnit::Nanosecond, Some("UTC".into())),
true,
),
],
Expand Down
4 changes: 2 additions & 2 deletions datafusion/functions/src/datetime/now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl ScalarUDFImpl for NowFunc {
}

fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
Ok(Timestamp(Nanosecond, Some("+00:00".into())))
Ok(Timestamp(Nanosecond, Some("UTC".into())))
}

fn invoke(&self, _args: &[ColumnarValue]) -> Result<ColumnarValue> {
Expand All @@ -81,7 +81,7 @@ impl ScalarUDFImpl for NowFunc {
.query_execution_start_time
.timestamp_nanos_opt();
Ok(ExprSimplifyResult::Simplified(Expr::Literal(
ScalarValue::TimestampNanosecond(now_ts, Some("+00:00".into())),
ScalarValue::TimestampNanosecond(now_ts, Some("UTC".into())),
)))
}
}
4 changes: 2 additions & 2 deletions datafusion/sqllogictest/test_files/arrow_typeof.slt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Timestamp(Nanosecond, None)
query T
SELECT arrow_typeof(now())
----
Timestamp(Nanosecond, Some("+00:00"))
Timestamp(Nanosecond, Some("UTC"))

# arrow_typeof_timestamp_date32(
query T
Expand Down Expand Up @@ -322,7 +322,7 @@ select arrow_cast('30 minutes', 'Duration(Second)');
## Timestamptz

query P
select arrow_cast(timestamp '2000-01-01T00:00:00', 'Timestamp(Nanosecond, Some( "+00:00" ))');
select arrow_cast(timestamp '2000-01-01T00:00:00', 'Timestamp(Nanosecond, Some( "UTC" ))');
----
2000-01-01T00:00:00Z

Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/dates.slt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ g
h

## Plan error when compare Utf8 and timestamp in where clause
statement error DataFusion error: type_coercion\ncaused by\nError during planning: Cannot coerce arithmetic expression Timestamp\(Nanosecond, Some\("\+00:00"\)\) \+ Utf8 to valid types
statement error DataFusion error: type_coercion\ncaused by\nError during planning: Cannot coerce arithmetic expression Timestamp\(Nanosecond, Some\("UTC"\)\) \+ Utf8 to valid types
select i_item_desc from test
where d3_date > now() + '5 days';

Expand Down

0 comments on commit ab7469d

Please sign in to comment.