Skip to content

Add support for TIMESTAMP and TIMESTAMP WITH TIME ZONE types in Exasol connector #26259

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

skyglass
Copy link

Description

Added Exasol Trino connector support for Timestamp and Timestamp With Local Time Zone JDBC data types

Additional context and related issues

  • added correspondent tests for timestamp with precision data type
  • added correspondent tests for timestamp with local time zone with precision data type
  • implemented special addRoundTrip method with additional column expression parameter for the predicate to fix the test predicate assumption
  • all timestamp with timezone tests use input literal timestamp string, which is interpreted as a JVM timestamp string ("America/Bahia_Banderas") but expected literal strings are interpreted as UTC strings. Therefore the difference between these timestamps is 6 hours (with DST) or 5 (without DST); for some historical values, like 1970 for example, the difference can be 7, which is expected behaviour for timestamp with local time zone

Release notes

## Exasol Connect
* Add support for `timestamp` and `timestamp with time zone` types. 

Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions bot added the exasol Exasol connector label Jul 22, 2025
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@skyglass skyglass force-pushed the feature/724_timestamp_data_types branch from 37a2fe5 to 78d1495 Compare July 22, 2025 10:03
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@skyglass skyglass changed the title Add support for TIMESTAMP and TIMESTAMP WITH TIME ZONE types in Exasol connector [Closed Duplicate] Add support for TIMESTAMP and TIMESTAMP WITH TIME ZONE types in Exasol connector Jul 22, 2025
@skyglass skyglass changed the title [Closed Duplicate] Add support for TIMESTAMP and TIMESTAMP WITH TIME ZONE types in Exasol connector Add support for TIMESTAMP and TIMESTAMP WITH TIME ZONE types in Exasol connector Jul 22, 2025
@dekimir dekimir mentioned this pull request Jul 22, 2025
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@skyglass skyglass force-pushed the feature/724_timestamp_data_types branch from c950205 to d7ff56f Compare July 23, 2025 08:59
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

1 similar comment
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions bot added the docs label Jul 23, 2025
skyglass added 5 commits July 23, 2025 16:12
- implemented additional timestamp with precision data type for ExasolClient
- added correspondent tests for timestamp with precision data type
- implemented additional timestamp with local time zone data type for ExasolClient
- implemented special addRoundTrip method with additional column expression parameter for the predicate to fix the test predicate assumption
- all timestamp with timezone tests use input literal timestamp string, which is interpreted as a JVM timestamp string ("America/Bahia_Banderas") but expected literal strings are interpreted as UTC strings. Therefore the difference between these timestamps is 6 hours (with DST) or 5 (without DST); for some historical values, like 1970 for example, the difference can be 7, which is expected behaviour for timestamp with local time zone
- removed mapper classes and moved the logic to ExasolClient, based on the PR suggesions
- removed unnecessary javadocs
- improved javadocs and comments for testing timestamp with time zone by explaining why only jvm time zone is currently used for testing timestamp with time zone
- removed using * import in ExasolClient based on the PR suggestions
- removed TestExasolTimestampMapping and moved testing timestamp and timestamp with timezone to TestExasolTypeMapping, based on the PR suggestions
- defined test methods as package-private, based on the PR suggestions
@skyglass skyglass force-pushed the feature/724_timestamp_data_types branch from ef6b95a to 07a421f Compare July 23, 2025 14:12
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@@ -28,6 +28,8 @@
import io.trino.plugin.jdbc.JdbcTypeHandle;
import io.trino.plugin.jdbc.LongReadFunction;
import io.trino.plugin.jdbc.LongWriteFunction;
import io.trino.plugin.jdbc.ObjectReadFunction;
Copy link
Member

Choose a reason for hiding this comment

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

The 1st commit contains redundant commit body. Please remove it.

@@ -17,6 +17,7 @@
import org.testng.annotations.Test;

import java.math.BigDecimal;
import java.sql.Timestamp;
Copy link
Member

Choose a reason for hiding this comment

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

  • implemented testing of timestamp columns in the product test

I would drop this commit.

Product tests are useful for catching class loader issues. TestExasolTypeMapping is sufficient in this case.

https://trino.io/docs/current/develop/tests.html#avoid-product-tests

@@ -101,6 +101,13 @@ Trino data type mapping:
* - ``DATE``
- ``DATE``
-
* - ``TIMESTAMP(n)``
Copy link
Member

Choose a reason for hiding this comment

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

Updated documentation with new TIMESTAMP type mappings

Please squash this commit into the 1st commit. We don't separate a commit for documentation.

Exasol `TIMESTAMP(n)` columns are mapped to Trino's `TIMESTAMP(n)` type and vice versa, with the following exceptions:

- **No precision specified**:
If the precision is omitted (i.e., the column is defined as `TIMESTAMP` without `(n)`), Exasol defaults to a precision of 3. This maps to Trino's `TIMESTAMP(3)`.
Copy link
Member

Choose a reason for hiding this comment

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

Please wrap at 80 characters. Same for other places.

Comment on lines +432 to +433
long nanosUtc = millisUtc * 1_000_000L + timestamp.getNanos() % 1_000_000;
int picosOfMilli = (int) ((nanosUtc - millisUtc * 1_000_000) * 1_000);
Copy link
Member

Choose a reason for hiding this comment

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

There are some constants in Timestamps.

test.execute(getQueryRunner(), session, exasolCreateAndInsert(TEST_SCHEMA + "." + "test_timestamp"));
}

private void testTimestamp(ZoneId sessionZone)
Copy link
Member

Choose a reason for hiding this comment

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

Move this method under testTimestamp().

* This difference is intentional and verifies correct conversion between zones.
* <p>
*/
private void testTimestampWithTimeZone(ZoneId sessionZone)
Copy link
Member

Choose a reason for hiding this comment

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

Move this method under testTimestampWithTimeZone().

}

@Test
void testUnsupportedTimestampValues()
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a similar test with timestamp with time zone type?

Comment on lines +314 to +316
assertExasolQueryFails(
"INSERT INTO " + table.getName() + " VALUES (TIMESTAMP '2024-01-01 12:34:56.1234567890')",
"data exception - invalid character value for cast");
Copy link
Member

Choose a reason for hiding this comment

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

This should round values instead of failures in my opinion.

void testTimestampWithTimeZone()
{
//Only JVM Time Zone is currently used for testing timestamp with time zone
//Adding test cases for other time zones would require improving the test to forcibly apply session changes for timestamp with timezone
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this comment. Can you elaborate on that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs exasol Exasol connector
Development

Successfully merging this pull request may close these issues.

2 participants