Skip to content
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

mysql extension treats "timestamp" column as "timestamp with timezone", causing data errors #105

Open
marhar opened this issue Dec 16, 2024 · 0 comments

Comments

@marhar
Copy link

marhar commented Dec 16, 2024

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
+----------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant