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

Various precision for Oracle timestamp #17934

Merged

Conversation

vlad-lyutenko
Copy link
Contributor

@vlad-lyutenko vlad-lyutenko commented Jun 16, 2023

Description

Additional context and related issues

Release notes

( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text:

Now we can use any presicion for oracle timestamp(p),
p could be in range from 0 to 9.

# Oracle
* Add support for Oracle timestamp with non-milliseconds precision

@cla-bot cla-bot bot added the cla-signed label Jun 16, 2023
@vlad-lyutenko vlad-lyutenko marked this pull request as draft June 16, 2023 13:40
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from a0ea050 to af691c3 Compare June 19, 2023 14:40
@vlad-lyutenko vlad-lyutenko marked this pull request as ready for review June 19, 2023 14:42
@vlad-lyutenko vlad-lyutenko requested a review from ebyhr June 20, 2023 08:16
@@ -482,6 +491,14 @@ else if (precision > Decimals.MAX_PRECISION || actualPrecision <= 0) {
DISABLE_PUSHDOWN));

case OracleTypes.TIMESTAMP:
// nano precision
if (typeHandle.getDecimalDigits().isPresent() && typeHandle.getDecimalDigits().get() == 9) {
Copy link
Member

Choose a reason for hiding this comment

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

Does oracle supports only nano precision or can it be between 0 and 6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oracle supports as far as I see any precision from 0 to 9.

In trino for oracle as default we have milis (3).
But we could add also micros in separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

Can we file an issue and leave TODO comment? Special handling only for nano precision is weird to me.

Copy link
Member

Choose a reason for hiding this comment

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

Why is it not possible to do what we do in SQLServer for example where we map a timestamp(p) from SQL Server to matching timestamp(p) in Trino.

This change means Oracle connector would either use NANOS or MILLIS, no other precisions even though they seem technically possible to implement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will try to generify

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ebyhr @hashhar Can you please take a look again, I refactored to any precision

@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from af691c3 to 3f65da2 Compare June 21, 2023 08:16
@github-actions github-actions bot added the docs label Jun 21, 2023
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from 3f65da2 to b3b6919 Compare June 21, 2023 09:01
}

@Test
public void testTimestampNanosBeyondPrecision()
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 another test method verifying failure when writing min - 1 & max + 1?

@@ -482,6 +491,14 @@ else if (precision > Decimals.MAX_PRECISION || actualPrecision <= 0) {
DISABLE_PUSHDOWN));

case OracleTypes.TIMESTAMP:
// nano precision
if (typeHandle.getDecimalDigits().isPresent() && typeHandle.getDecimalDigits().get() == 9) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we file an issue and leave TODO comment? Special handling only for nano precision is weird to me.

@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from b3b6919 to e7d1d00 Compare June 21, 2023 13:27
@vlad-lyutenko vlad-lyutenko changed the title Nano precision for Oracle timestamp Various precision for Oracle timestamp Jun 21, 2023
@vlad-lyutenko
Copy link
Contributor Author

Refactored to any precision support

@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch 3 times, most recently from 5898964 to 844e5f3 Compare June 21, 2023 20:50
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch 2 times, most recently from 8a96cd0 to 5c998d4 Compare June 28, 2023 11:55
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from 5c998d4 to 1ac5783 Compare June 28, 2023 21:45
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from 1ac5783 to 36ffbb2 Compare July 4, 2023 12:40
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch 3 times, most recently from 6049aa7 to 2e8575d Compare July 8, 2023 10:43
Copy link
Member

@Praveen2112 Praveen2112 left a comment

Choose a reason for hiding this comment

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

Minor changes.

@vlad-lyutenko vlad-lyutenko requested a review from ebyhr July 12, 2023 12:38
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from 2e8575d to 29f33fb Compare July 12, 2023 13:44
Copy link
Contributor

@krvikash krvikash left a comment

Choose a reason for hiding this comment

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

LGTM. few nit comments.

if (timestampType.isShort()) {
return WriteMapping.longMapping(dataType, oracleTimestampWriteFunction(timestampType));
}
return WriteMapping.objectMapping(dataType, oracleLongTimestampWriteFunction(createTimestampType(precision)));
Copy link
Member

Choose a reason for hiding this comment

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

Calling createTimestampType looks redundant to me. oracleLongTimestampWriteFunction uses only precision. Same for oracleTimestampWriteFunction

Copy link
Contributor Author

@vlad-lyutenko vlad-lyutenko Jul 15, 2023

Choose a reason for hiding this comment

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

want to be consistent with oracleLongTimestampReadFunction which requires timestampType or need to refactor toTrinoTimestamp from base-jdbc

docs/src/main/sphinx/connector/oracle.rst Show resolved Hide resolved
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from 29f33fb to bc2305e Compare July 15, 2023 13:37
@vlad-lyutenko vlad-lyutenko requested a review from ebyhr July 18, 2023 13:09
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch 3 times, most recently from 6e9a7f3 to 3bfc4bf Compare July 18, 2023 22:16
We can use any presicion for oracle timestamp(p),
p could be in range from 0 to 9.
@vlad-lyutenko vlad-lyutenko force-pushed the vlad-lyutenko/oracle-nano-timestemp branch from 3bfc4bf to 845b488 Compare July 18, 2023 22:18
@Praveen2112
Copy link
Member

@vlad-lyutenko Can you update the release notes description

@Praveen2112 Praveen2112 merged commit 80df4e2 into trinodb:master Jul 19, 2023
@Praveen2112
Copy link
Member

Thanks for working on this.

@github-actions github-actions bot added this to the 423 milestone Jul 19, 2023
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.

5 participants