Skip to content

Add support for reading DateTime(timezone) from ClickHouse#14110

Merged
hashhar merged 2 commits intotrinodb:masterfrom
tangjiangling:add-support-for-datetime-in-clickhouse
Nov 4, 2022
Merged

Add support for reading DateTime(timezone) from ClickHouse#14110
hashhar merged 2 commits intotrinodb:masterfrom
tangjiangling:add-support-for-datetime-in-clickhouse

Conversation

@tangjiangling
Copy link
Copy Markdown
Member

@tangjiangling tangjiangling commented Sep 13, 2022

Description

Previously Trino only supported reading DateTime from ClickHouse (no
timezone specified) and for DateTime(timezone) users had to configure
the parameter unsupported-type-handling or
jdbc-types-mapped-to-varchar to support reading of this type.

This commit supports reading DateTime(timezone) from ClickHouse and
maps it to Trino's TIMESTAMP(0) WITH TIME ZONE.

NOTE: writing data from Trino to ClickHouse DateTime(timezone) is not
supported.

Fixes #13541
Related #11148 (review)

Release notes

(x) Release notes are required, with the following suggested text:

# ClickHouse
* Map ClickHouse `DateTime(timezone)` data type to Trino `TIMESTAMP(0) WITH TIME ZONE`. ({issue}`13541`)

Reading DateTime from ClickHouse should be mapped to Trino TIMESTAMP(0).
@tangjiangling
Copy link
Copy Markdown
Member Author

(Change 2nd commit title)

@tangjiangling tangjiangling force-pushed the add-support-for-datetime-in-clickhouse branch from e35e101 to fed6722 Compare September 18, 2022 10:05
@tangjiangling
Copy link
Copy Markdown
Member Author

(squashed commit)

Copy link
Copy Markdown
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take one more look at tests.

Some comments meanwhile.

Copy link
Copy Markdown
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments about tests

It'd be useful to take inspiration from probably PostgreSQL type mapping tests for some useful values to test.

Comment on lines 800 to 791
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only clickhouseCreateAndInsert? trinoCreateAsSelect is also useful since CTAS and INSERT follow different code paths.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Trino's TIMESTAMP(p) WITH TIME ZONE does not know the timezone, we cannot create ClickHouse's DateTime(timezone) through Trino.

@tangjiangling
Copy link
Copy Markdown
Member Author

Thanks for the review, I'll address these comments this weekend.

@tangjiangling
Copy link
Copy Markdown
Member Author

It'd be useful to take inspiration from probably PostgreSQL type mapping tests for some useful values to test.

I'll take a look and make them both as consistent as possible.

@hashhar hashhar self-requested a review October 28, 2022 08:46
Copy link
Copy Markdown
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % using literal strings in test

Previously Trino only supported reading `DateTime` from ClickHouse (no
timezone specified) and for `DateTime(timezone)` users had to configure
the parameter `unsupported-type-handling` or
`jdbc-types-mapped-to-varchar` to support reading of this type.

This commit supports reading `DateTime(timezone)` from ClickHouse and
maps it to Trino's `TIMESTAMP(0) WITH TIME ZONE`.

NOTE: writing data from Trino to ClickHouse `DateTime(timezone)` is not
supported.
@tangjiangling tangjiangling force-pushed the add-support-for-datetime-in-clickhouse branch from 494dfd6 to 9a8cd80 Compare November 4, 2022 09:08
@hashhar hashhar merged commit 55656b7 into trinodb:master Nov 4, 2022
@hashhar hashhar mentioned this pull request Nov 4, 2022
@tangjiangling tangjiangling deleted the add-support-for-datetime-in-clickhouse branch November 4, 2022 19:17
@github-actions github-actions bot added this to the 403 milestone Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Support ClickHouse DateTime(<timezone>) data type

3 participants