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

Failed to read column with data type "TIMESTAMP" #75

Closed
shawnzhu opened this issue May 5, 2021 · 1 comment · Fixed by #76
Closed

Failed to read column with data type "TIMESTAMP" #75

shawnzhu opened this issue May 5, 2021 · 1 comment · Fixed by #76
Assignees
Labels
bug Something isn't working

Comments

@shawnzhu
Copy link
Contributor

shawnzhu commented May 5, 2021

Given trino 356 and trino-db 356:

When query table table contains columns with data type TIMESTAMP(3), TIMESTAMP(6) and TIMESTAMP(9), when running select statement, it will report exception like:

May 5 11:43:20 trino-coordinator-cf87bd8bb-pz77v trino-coordinator ERROR remote-task-callback-32	io.trino.execution.StageStateMachine	Stage 20210505_154318_00007_zhr9s.1 failed
io.trino.spi.TrinoException: [jcc][t4][1092][13956][4.25.13] Invalid data conversion: Wrong result column type for requested conversion. ERRORCODE=-4461, SQLSTATE=42815
	at io.trino.plugin.jdbc.JdbcRecordCursor.handleSqlException(JdbcRecordCursor.java:299)
	at io.trino.plugin.jdbc.JdbcRecordCursor.getObject(JdbcRecordCursor.java:238)
	at io.trino.spi.connector.RecordPageSource.getNextPage(RecordPageSource.java:116)
	at io.trino.operator.TableScanOperator.getOutput(TableScanOperator.java:301)
	at io.trino.operator.Driver.processInternal(Driver.java:387)
	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____20210505_151828_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][t4][1092][13956][4.25.13] Invalid data conversion: Wrong result column type for 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:133)
	at com.ibm.db2.jcc.am.ResultSet.getObject(ResultSet.java:1961)
	at io.trino.plugin.jdbc.StandardColumnMappings.lambda$longTimestampReadFunction$24(StandardColumnMappings.java:508)
	at io.trino.plugin.jdbc.ObjectReadFunction$1.readObject(ObjectReadFunction.java:46)
	at io.trino.plugin.jdbc.JdbcRecordCursor.getObject(JdbcRecordCursor.java:235)
	... 13 more

It will work if the value of the row is NULL.

So I suspect it's a driver specific implementation that it can not use ResultSet.getObject() on data type like Timestamp. see https://github.com/trinodb/trino/blob/3219bc9c810c897dcfeb97ea1b0c5dc21ae5dd79/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/StandardColumnMappings.java#L496-L509

@shawnzhu shawnzhu added the bug Something isn't working label May 5, 2021
@shawnzhu shawnzhu self-assigned this May 5, 2021
@shawnzhu
Copy link
Contributor Author

shawnzhu commented May 6, 2021

This is the very problem that Db2 JDBC driver doesn't support:

https://github.com/trinodb/trino/blob/6c46f68fbe422990164a19148fdf0a284d75b9ac/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/StandardColumnMappings.java#L499

It will support resultSet.getTimestamp(int columnIndex), resultSet.getObject(int columnIndex), but NOT resultSet.getObject(int columnIndex, Class<T> type).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant