Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Support reading date type TIMESTAMP(9) #76

Merged
merged 4 commits into from
May 7, 2021
Merged

Support reading date type TIMESTAMP(9) #76

merged 4 commits into from
May 7, 2021

Conversation

shawnzhu
Copy link
Contributor

@shawnzhu shawnzhu commented May 7, 2021

Supports #75

Progress

  1. Uses support JDBC API to support read date type TIMESTAMP(9). see Failed to read column with data type "TIMESTAMP" #75 (comment)
  2. Supports read/write date type TIMESTAMP with precision up to 6.

Problem

It still can not write date in type TIMESTAMP(9) into any Db2 table b/c of this exception:

2021-05-07T02:32:10.711Z        ERROR   remote-task-callback-10 io.trino.execution.StageStateMachine    Stage 20210507_023206_00010_ruwj2.1 failed
io.trino.spi.TrinoException: [jcc][1091][10824][4.25.13] Invalid data conversion: Parameter instance 2021-05-05T21:49:22.400803 is invalid for the requested conversion. ERRORCODE=-4461, SQLSTATE=42815
        at io.trino.plugin.jdbc.JdbcPageSink.appendPage(JdbcPageSink.java:124)
        at io.trino.operator.TableWriterOperator.addInput(TableWriterOperator.java:257)
        at io.trino.operator.Driver.processInternal(Driver.java:392)
        at io.trino.operator.Driver.lambda$processFor$9(Driver.java:291)
        at io.trino.operator.Driver.tryWithLock(Driver.java:683)
        at io.trino.operator.Driver.processFor(Driver.java:284)
        at io.trino.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:1075)
        at io.trino.execution.executor.PrioritizedSplitRunner.process(PrioritizedSplitRunner.java:163)
        at io.trino.execution.executor.TaskExecutor$TaskRunner.run(TaskExecutor.java:484)
        at io.trino.$gen.Trino_356____20210507_022833_2.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][1091][10824][4.25.13] Invalid data conversion: Parameter instance 2021-05-05T21:49:22.400803 is invalid for the requested conversion. ERRORCODE=-4461, SQLSTATE=42815
        at com.ibm.db2.jcc.am.b6.a(b6.java:810)
        at com.ibm.db2.jcc.am.b6.a(b6.java:66)
        at com.ibm.db2.jcc.am.b6.a(b6.java:116)
        at com.ibm.db2.jcc.am.k4.c(k4.java:2686)
        at com.ibm.db2.jcc.am.k4.setObject(k4.java:2465)
        at io.trino.plugin.jdbc.StandardColumnMappings.lambda$longTimestampWriteFunction$27(StandardColumnMappings.java:535)
        at io.trino.plugin.jdbc.ObjectWriteFunction$1.set(ObjectWriteFunction.java:48)
        at io.trino.plugin.jdbc.JdbcPageSink.appendColumn(JdbcPageSink.java:156)
        at io.trino.plugin.jdbc.JdbcPageSink.appendPage(JdbcPageSink.java:109)
        ... 12 more

@shawnzhu
Copy link
Contributor Author

shawnzhu commented May 7, 2021

Notice that the error message indicated it can not use PreparedStatement#setObject(index, LocalDateTime).

So I will need to try to customize an objectwritefunction to use a supported JDBC API. e.g., PreparedStatement#setTimestamp(index, LocalDateTime).

@shawnzhu
Copy link
Contributor Author

shawnzhu commented May 7, 2021

Fixed the error message when writing TIMESTAMP(9) date type in 58001c8 and tested locally by using a Db2 warehouse.

@shawnzhu shawnzhu marked this pull request as ready for review May 7, 2021 15:22
@shawnzhu shawnzhu linked an issue May 7, 2021 that may be closed by this pull request
Copy link
Member

@apreethi13 apreethi13 left a comment

Choose a reason for hiding this comment

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

lgtm 👍

Copy link

@codyjlin codyjlin left a comment

Choose a reason for hiding this comment

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

Thanks for this! 👍

@shawnzhu shawnzhu merged commit cf07190 into main May 7, 2021
@shawnzhu shawnzhu deleted the issue-75 branch May 7, 2021 16:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to read column with data type "TIMESTAMP"
3 participants