Closed
Description
Copying a mysql TIMEZONE column changes the value.
- DuckDB treats "timestamp" columns as "timestamp with timezone".
- This causes incorrect operation when comparing timestamp columns when not in UTC-0 timezone.
- my timezone: UTC-8
Expected results:
Copying a timestamp column in DuckDB does not change the timestamp value.
Actual Results:
Copying a timestamp column in DuckDB changes the timestamp value.
Execute in mysql:
-- $ mysql -u root -D testdb
create table a(t timestamp(6));
create table b(t timestamp(6));
insert into a values(now(6));
describe a;
-- +-------+--------------+------+-----+---------+-------+
-- | Field | Type | Null | Key | Default | Extra |
-- +-------+--------------+------+-----+---------+-------+
-- | t | timestamp(6) | YES | | NULL | |
-- +-------+--------------+------+-----+---------+-------+
Execute in duckdb:
-- set timezone='UTC'; -- note: my timezone is +8
ATTACH 'host=localhost user=root port=0 database=testdb' AS my(TYPE MYSQL);
select * from my.a;
insert into my.b select * from my.a;
select * from my.b;
describe my.a;
Execution Results:
select * from my.a;
┌───────────────────────────────┐
│ t │
│ timestamp with time zone │
├───────────────────────────────┤
│ 2024-12-16 09:40:40.396764-08 │
└───────────────────────────────┘
select * from my.b;
┌───────────────────────────────┐
│ t │
│ timestamp with time zone │
├───────────────────────────────┤
│ 2024-12-16 17:40:40.396764-08 │ <<<<<<<< value is offset, should be same as above
└───────────────────────────────┘
describe my.a;
┌─────────────┬──────────────────────────┬─────────┬─────────┬─────────┬─────────┐
│ column_name │ column_type │ null │ key │ default │ extra │
│ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │
├─────────────┼──────────────────────────┼─────────┼─────────┼─────────┼─────────┤
│ t │ TIMESTAMP WITH TIME ZONE │ YES │ <<<<<< should be simple TIMESTAMP
└─────────────┴──────────────────────────┴─────────┴─────────┴─────────┴─────────┘
Note that the data error also shows up in MySQL:
mysql> select * from a;
+----------------------------+
| t |
+----------------------------+
| 2024-12-16 09:40:40.396764 |
+----------------------------+
mysql> select * from b;
+----------------------------+
| t |
+----------------------------+
| 2024-12-16 17:40:40.396764 | <<<< should be same as above
+----------------------------+
Metadata
Metadata
Assignees
Labels
No labels