From c49f597779842a1ba3c276bc7c1c087c319d9197 Mon Sep 17 00:00:00 2001 From: Emil Sadek Date: Mon, 15 Jun 2026 16:37:13 -0700 Subject: [PATCH] fix: render timestamp with time zone data --- Cargo.lock | 35 +++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- tests/integration_test.rs | 28 ++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 968ae20..1e27226 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,6 +175,7 @@ dependencies = [ "arrow-data", "arrow-schema", "chrono", + "chrono-tz", "half", "hashbrown", "num-complex", @@ -426,6 +427,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "chrono-tz" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6139a8597ed92cf816dfb33f5dd6cf0bb93a6adc938f11039f371bc5bcd26c3" +dependencies = [ + "chrono", + "phf", +] + [[package]] name = "clap" version = "4.6.1" @@ -1080,6 +1091,24 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" +[[package]] +name = "phf" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_shared" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981" +dependencies = [ + "siphasher", +] + [[package]] name = "pkg-config" version = "0.3.32" @@ -1352,6 +1381,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "siphasher" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" + [[package]] name = "smallvec" version = "1.15.1" diff --git a/Cargo.toml b/Cargo.toml index 51b13a3..6dd1bdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ include = ["/src", "/themes", "build.rs", "LICENSE", "README.md"] [dependencies] adbc_core = "0.23.0" adbc_driver_manager = "0.23.0" -arrow = "58.1.0" +arrow = { version = "58.1.0", features = ["chrono-tz"] } arrow-array = "58.1.0" arrow-cast = "58.1.0" arrow-schema = "58.1.0" diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 8cc96a8..808f5ed 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -325,3 +325,31 @@ uri = ":memory:" let stdout = String::from_utf8_lossy(&output.stdout); assert!(stdout.contains("profile_options_test")); } + +#[test] +fn test_timestamp_with_time_zone() { + let output = Command::new("cargo") + .args([ + "run", + "--", + "--driver", + "duckdb", + "--query", + "SET TimeZone = 'America/Los_Angeles'; SELECT TIMESTAMPTZ '1992-09-20 12:30:00.123456789+01:00'", + ]) + .output() + .expect("Failed to execute command"); + + let stderr = String::from_utf8_lossy(&output.stderr); + assert!( + output.status.success(), + "TIMESTAMPTZ query should succeed. stderr: {}", + stderr + ); + let stdout = String::from_utf8_lossy(&output.stdout); + assert!( + stdout.contains("1992-09-20T04:30:00.123456-07:00"), + "expected session-zone-rendered TIMESTAMPTZ in output. stdout: {}", + stdout + ); +}