Skip to content
Merged
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
11 changes: 8 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ async-recursion = { git = "https://github.com/datafuse-extras/async-recursion.gi
backtrace = { git = "https://github.com/rust-lang/backtrace-rs.git", rev = "72265be" }
color-eyre = { git = "https://github.com/eyre-rs/eyre.git", rev = "e5d92c3" }
deltalake = { git = "https://github.com/delta-io/delta-rs", rev = "9954bff" }
jsonb = { git = "https://github.com/databendlabs/jsonb", rev = "1868abf" }
map-api = { git = "https://github.com/databendlabs/map-api", tag = "v0.4.2" }
openraft = { git = "https://github.com/databendlabs/openraft", tag = "v0.10.0-alpha.13" }
orc-rust = { git = "https://github.com/datafuse-extras/orc-rust", rev = "fc812ad7010" }
Expand Down
2 changes: 1 addition & 1 deletion src/query/expression/src/types/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ pub fn cast_scalar_to_variant(
ScalarRef::Timestamp(ts) => jsonb::Value::Timestamp(jsonb::Timestamp { value: ts }),
ScalarRef::TimestampTz(ts_tz) => jsonb::Value::TimestampTz(jsonb::TimestampTz {
value: ts_tz.timestamp(),
offset: ts_tz.hours_offset(),
offset: ts_tz.seconds_offset(),
}),
ScalarRef::Date(d) => jsonb::Value::Date(jsonb::Date { value: d }),
ScalarRef::Interval(i) => {
Expand Down
8 changes: 2 additions & 6 deletions src/query/functions/src/scalars/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,7 @@ pub fn register(registry: &mut FunctionRegistry) {
}
match RawJsonb::new(v).as_timestamp_tz() {
Ok(Some(res)) => {
let offset_seconds = i32::from(res.offset) * 3_600;
output.push(timestamp_tz::new(res.value, offset_seconds));
output.push(timestamp_tz::new(res.value, res.offset));
}
Ok(None) => output.push_null(),
Err(err) => {
Expand Down Expand Up @@ -3474,10 +3473,7 @@ fn cast_to_timestamp_tz(val: &[u8], tz: &TimeZone) -> Result<Option<timestamp_tz
let value = jsonb::from_slice(val)?;
match value {
JsonbValue::Null => Ok(None),
JsonbValue::TimestampTz(ts) => {
let offset_seconds = i32::from(ts.offset) * 3_600;
Ok(Some(timestamp_tz::new(ts.value, offset_seconds)))
}
JsonbValue::TimestampTz(ts) => Ok(Some(timestamp_tz::new(ts.value, ts.offset))),
JsonbValue::Timestamp(ts) => {
let mut value = ts.value;
clamp_timestamp(&mut value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,23 @@ select to_timestamp('2025-01-01 10:00:00')::variant, to_timestamp(to_timestamp('
query TTTT
select to_timestamp_tz('2025-01-01 10:00:00 +0800')::variant, to_timestamp_tz(to_timestamp_tz('2025-01-01 10:00:00 +0800')::variant), to_timestamp_tz(parse_json('"2025-01-01 10:00:00 +0800"')), as_timestamp_tz(to_timestamp_tz('2025-01-01 10:00:00 +0800')::variant)
----
"2025-01-01 10:00:00.000000" 2025-01-01 10:00:00.000000 +0800 2025-01-01 10:00:00.000000 +0800 2025-01-01 10:00:00.000000 +0800
"2025-01-01 10:00:00.000000 +0800" 2025-01-01 10:00:00.000000 +0800 2025-01-01 10:00:00.000000 +0800 2025-01-01 10:00:00.000000 +0800

query TTTT
select to_timestamp_tz('2025-01-01 10:00:00 +0830')::variant, to_timestamp_tz(to_timestamp_tz('2025-01-01 10:00:00 +0830')::variant), to_timestamp_tz(parse_json('"2025-01-01 10:00:00 +0830"')), as_timestamp_tz(to_timestamp_tz('2025-01-01 10:00:00 +0830')::variant)
----
"2025-01-01 10:00:00.000000 +0830" 2025-01-01 10:00:00.000000 +0830 2025-01-01 10:00:00.000000 +0830 2025-01-01 10:00:00.000000 +0830

query TTTT
select to_interval('10 months 2 days')::variant, to_interval(to_interval('10 months 2 days')::variant), to_interval(parse_json('"10 months 2 days"')), as_interval(to_interval('10 months 2 days')::variant)
----
"10 months 2 days" 10 months 2 days 10 months 2 days 10 months 2 days

query TTTT
select to_interval('-10 months -2 days')::variant, to_interval(to_interval('-10 months -2 days')::variant), to_interval(parse_json('"-10 months -2 days"')), as_interval(to_interval('-10 months -2 days')::variant)
----
"-10 months -2 days" -10 months -2 days -10 months -2 days -10 months -2 days

query TTTT
select to_decimal(10, 2)(parse_json('3.14')), as_decimal(parse_json('3.14')), as_decimal(10, 2)(parse_json('3.14')), as_decimal(parse_json('3.14'), 10, 2)
----
Expand Down
Loading