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

Failed to write timestamp values with NANOSECONDS hive.timestamp_precision on Avro files in Hive connector #20342

Open
ebyhr opened this issue Jan 11, 2024 · 2 comments · May be fixed by #24785
Assignees
Labels
bug Something isn't working hive Hive connector

Comments

@ebyhr
Copy link
Member

ebyhr commented Jan 11, 2024

set session hive.timestamp_precision = 'NANOSECONDS';
create table test (a timestamp(9)) with (format = 'avro');
insert into test values (timestamp '1970-01-01 00:00:00');

Query 20240111_080943_00059_278c5 failed: Failed to write data page to Avro file
io.trino.spi.TrinoException: Failed to write data page to Avro file
	at io.trino.plugin.hive.avro.AvroHiveFileWriter.appendRows(AvroHiveFileWriter.java:127)
	at io.trino.plugin.hive.HiveWriter.append(HiveWriter.java:85)
	at io.trino.plugin.hive.HivePageSink.writePage(HivePageSink.java:325)
	at io.trino.plugin.hive.HivePageSink.appendPage(HivePageSink.java:274)
	at io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSink.appendPage(ClassLoaderSafeConnectorPageSink.java:68)
	at io.trino.operator.TableWriterOperator.addInput(TableWriterOperator.java:278)
	at io.trino.operator.Driver.processInternal(Driver.java:403)
	at io.trino.operator.Driver.lambda$process$8(Driver.java:301)
	at io.trino.operator.Driver.tryWithLock(Driver.java:704)
	at io.trino.operator.Driver.process(Driver.java:293)
	at io.trino.operator.Driver.processForDuration(Driver.java:264)
	at io.trino.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:887)
	at io.trino.execution.executor.timesharing.PrioritizedSplitRunner.process(PrioritizedSplitRunner.java:187)
	at io.trino.execution.executor.timesharing.TimeSharingTaskExecutor$TaskRunner.run(TimeSharingTaskExecutor.java:565)
	at io.trino.$gen.Trino_testversion____20240111_073142_75.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.io.IOException: Error writing to avro file
	at io.trino.hive.formats.avro.AvroFileWriter.write(AvroFileWriter.java:80)
	at io.trino.plugin.hive.avro.AvroHiveFileWriter.appendRows(AvroHiveFileWriter.java:124)
	... 17 more
Caused by: org.apache.avro.file.DataFileWriter.AppendWriteException: java.lang.ClassCastException: class io.trino.spi.type.LongTimestamp cannot be cast to class io.trino.spi.type.SqlTimestamp (io.trino.spi.type.LongTimestamp and io.trino.spi.type.SqlTimestamp are in unnamed module of loader 'app')
	at org.apache.avro.file.DataFileWriter.append(DataFileWriter.java:317)
	at io.trino.hive.formats.avro.AvroFileWriter.write(AvroFileWriter.java:77)
	... 18 more
Caused by: java.lang.ClassCastException: class io.trino.spi.type.LongTimestamp cannot be cast to class io.trino.spi.type.SqlTimestamp (io.trino.spi.type.LongTimestamp and io.trino.spi.type.SqlTimestamp are in unnamed module of loader 'app')
	at io.trino.plugin.hive.avro.HiveAvroTypeManager.lambda$overrideBlockToAvroObject$6(HiveAvroTypeManager.java:222)
	at io.trino.hive.formats.avro.AvroPagePositionDataWriter$UserDefinedBlockPositionEncoder.encodeFromBlock(AvroPagePositionDataWriter.java:585)
	at io.trino.hive.formats.avro.AvroPagePositionDataWriter$BlockPositionEncoder.encode(AvroPagePositionDataWriter.java:142)
	at io.trino.hive.formats.avro.AvroPagePositionDataWriter$RecordBlockPositionEncoder.encodeInternal(AvroPagePositionDataWriter.java:563)
	at io.trino.hive.formats.avro.AvroPagePositionDataWriter$RecordBlockPositionEncoder.encodePositionInEachChannel(AvroPagePositionDataWriter.java:555)
	at io.trino.hive.formats.avro.AvroPagePositionDataWriter.write(AvroPagePositionDataWriter.java:106)
	at io.trino.hive.formats.avro.AvroPagePositionDataWriter.write(AvroPagePositionDataWriter.java:61)
	at org.apache.avro.file.DataFileWriter.append(DataFileWriter.java:314)
	... 19 more

The above INSERT statement succeeds once change to other precisions.

set session hive.timestamp_precision = 'MICROSECONDS';
insert into test values (timestamp '1970-01-01 00:00:00');
INSERT: 1 row
@ebyhr ebyhr added bug Something isn't working hive Hive connector labels Jan 11, 2024
@sug-ghosh
Copy link
Contributor

Hello @ebyhr can I take this up?

@ebyhr
Copy link
Member Author

ebyhr commented Jan 20, 2025

@sug-ghosh Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hive Hive connector
Development

Successfully merging a pull request may close this issue.

2 participants