-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Respect hive.timestamp-precision in Hive views
#16258
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -482,30 +482,22 @@ public void testTimestampHiveView() | |
| unsetSessionProperty("hive_timestamp_nanos.timestamp_precision"); | ||
|
|
||
| assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM timestamp_hive_view")).containsOnly(row("1990-01-02 12:13:14.123")); | ||
| assertThatThrownBy( | ||
| // TODO(https://github.com/trinodb/trino/issues/6295) it is not possible to query Hive view with timestamps if hive.timestamp-precision=NANOSECONDS | ||
| () -> assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM hive_timestamp_nanos.default.timestamp_hive_view")).containsOnly(row("1990-01-02 12:13:14.123456789")) | ||
| ).hasMessageContaining("timestamp(9) projected from query view at position 0 cannot be coerced to column [ts] of type timestamp(3) stored in view definition"); | ||
| assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM hive_timestamp_nanos.default.timestamp_hive_view")) | ||
| .containsOnly(row("1990-01-02 12:13:14.123456789")); | ||
|
|
||
| setSessionProperty("hive.timestamp_precision", "'MILLISECONDS'"); | ||
| setSessionProperty("hive_timestamp_nanos.timestamp_precision", "'MILLISECONDS'"); | ||
|
|
||
| assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM timestamp_hive_view")).containsOnly(row("1990-01-02 12:13:14.123")); | ||
| assertThatThrownBy( | ||
| // TODO(https://github.com/trinodb/trino/issues/6295) it is not possible to query Hive view with timestamps if hive.timestamp-precision=NANOSECONDS | ||
| () -> assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM hive_timestamp_nanos.default.timestamp_hive_view")).containsOnly(row("1990-01-02 12:13:14.123")) | ||
| ).hasMessageContaining("timestamp(9) projected from query view at position 0 cannot be coerced to column [ts] of type timestamp(3) stored in view definition"); | ||
| assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM hive_timestamp_nanos.default.timestamp_hive_view")) | ||
| .containsOnly(row("1990-01-02 12:13:14.123456789")); | ||
|
|
||
| setSessionProperty("hive.timestamp_precision", "'NANOSECONDS'"); | ||
| setSessionProperty("hive_timestamp_nanos.timestamp_precision", "'NANOSECONDS'"); | ||
|
|
||
| // TODO(https://github.com/trinodb/trino/issues/6295) timestamp_precision has no effect on Hive views | ||
| // should be: assertThat(query("SELECT CAST(ts AS varchar) FROM timestamp_hive_view")).containsOnly(row("1990-01-02 12:13:14.123456789")) | ||
| assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM timestamp_hive_view")).containsOnly(row("1990-01-02 12:13:14.123")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was the TODO here incorrect?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that |
||
| assertThatThrownBy( | ||
| // TODO(https://github.com/trinodb/trino/issues/6295) it is not possible to query Hive view with timestamps if hive.timestamp-precision=NANOSECONDS | ||
| () -> assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM hive_timestamp_nanos.default.timestamp_hive_view")).containsOnly(row("1990-01-02 12:13:14.123456789")) | ||
| ).hasMessageContaining("timestamp(9) projected from query view at position 0 cannot be coerced to column [ts] of type timestamp(3) stored in view definition"); | ||
| assertThat(onTrino().executeQuery("SELECT CAST(ts AS varchar) FROM hive_timestamp_nanos.default.timestamp_hive_view")) | ||
| .containsOnly(row("1990-01-02 12:13:14.123456789")); | ||
| } | ||
|
|
||
| @Test(groups = HIVE_VIEWS) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment indicated the hive_timestamp_nanos.tpch.xxx view should return ts in nano precision (
....14.123456789). Why isn't it the case after the change?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The definition of the Trino view is encoded internally in the JSON saved in the metastore.
I think in this case the assumption from the comment was false.