-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
timestampformat option for csv copy ignores configured timezone with timestamptz #11660
Comments
I have a hunch this might be related to #11546 |
I hadn't explicitly set the TimeZone myself, but the following query SELECT value
FROM duckdb_settings()
WHERE name = 'TimeZone'; returns |
I think the cause is this: 658 Timestamp::Convert(input, date, time);
659 idx_t len = GetLength(date, time, 0, nullptr);
660 string_t target = StringVector::EmptyString(result, len);
-> 661 FormatString(date, time, target.GetDataWriteable());
662 target.Finalize();
663 return target;
664 } else { This has a version which takes a timezone, but that is never used here |
It can't use the TZ because it doesn't know how to do the conversion from the instant in the column to the offset value. ICU overrides } else if (!csv_data.options.write_date_format[LogicalTypeId::TIMESTAMP].Empty() &&
(csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP ||
csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP_TZ)) {
// use the timestamp format to cast the chunk
=> csv_data.options.write_date_format[LogicalTypeId::TIMESTAMP].ConvertTimestampVector(
input.data[col_idx], cast_chunk.data[col_idx], input.size());
} else { as this function is not extension-aware. |
If we want to support this: I wonder if we need to make the Though this is part of a bigger problem of interleaving extensions (even though CSV isn't an extension, it still makes use of the Catalog to be discovered) |
Though, thinking more about this, we have Cast functions registered by ICU right? |
Casting doesn't take a format, but ICU also overrides |
This has been fixed 👍 |
What happens?
The
timestampformat
argument described here allows you to customize the formatting of timestamps when converting to CSV but it ignores the configured TimeZone. When converting to CSV without specifying thetimestampformat
, the generated string uses the configured TimeZone. When converting to CSV and specifying thetimestampformat
, however, the generated string ignores the configured TimeZone and writes the timestamp in UTC.To Reproduce
With the TimeZone set to
America/Phoenix
:generates
2024-04-15 08:07:49.561-07
. Note the-07
timezone offset.generates
2024-04-15 15:07:49.561+00
. Note that the timezone offset is now+00
even though the TimeZone is set toAmerica/Phoenix
.OS:
Windows, Linux
DuckDB Version:
0.10.1
DuckDB Client:
JDBC
Full Name:
TJ Brown
Affiliation:
Intel
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
The text was updated successfully, but these errors were encountered: