trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.48k stars 3.02k forks source link

Listing `system.jdbc.columns` with table_name throws `View data missing prefix` in Hive and Iceberg catalogs having MV #13761

Open ebyhr opened 2 years ago

ebyhr commented 2 years ago

Steps to reproduce

  1. Add Hive and Iceberg catalogs with same metastore
  2. Execute below query
CREATE TABLE iceberg.default.test (c1 int);
CREATE MATERIALIZED VIEW iceberg.default.test_mv AS SELECT * FROM iceberg.default.test;
SELECT * FROM system.jdbc.columns; -- success
SELECT * FROM system.jdbc.columns WHERE table_name LIKE '%test_mv%';

View data missing prefix: /* Presto Materialized View: eyJvcmlnaW5hbFNxbCI6IlNFTEVDVCAqXG5GUk9NXG4gIGljZWJlcmcuZGVmYXVsdC50ZXN0XG4iLCJjb2x1bW5zIjpbeyJuYW1lIjoiYzEiLCJ0eXBlIjoiaW50ZWdlciJ9XX0= */
io.trino.spi.TrinoException: View data missing prefix: /* Presto Materialized View: eyJvcmlnaW5hbFNxbCI6IlNFTEVDVCAqXG5GUk9NXG4gIGljZWJlcmcuZGVmYXVsdC50ZXN0XG4iLCJjb2x1bW5zIjpbeyJuYW1lIjoiYzEiLCJ0eXBlIjoiaW50ZWdlciJ9XX0= */
    at io.trino.plugin.hive.util.HiveUtil.checkCondition(HiveUtil.java:920)
    at io.trino.plugin.hive.ViewReaderUtil$PrestoViewReader.decodeViewData(ViewReaderUtil.java:183)
    at io.trino.plugin.hive.ViewReaderUtil$PrestoViewReader.decodeViewData(ViewReaderUtil.java:178)
    at io.trino.plugin.hive.HiveMetadata.lambda$toConnectorViewDefinition$69(HiveMetadata.java:2504)
    at java.base/java.util.Optional.map(Optional.java:260)
    at io.trino.plugin.hive.HiveMetadata.toConnectorViewDefinition(HiveMetadata.java:2498)
    at io.trino.plugin.hive.HiveMetadata.getView(HiveMetadata.java:2491)
    at io.trino.plugin.base.classloader.ClassLoaderSafeConnectorMetadata.getView(ClassLoaderSafeConnectorMetadata.java:612)
    at io.trino.metadata.MetadataManager.getViews(MetadataManager.java:1077)
    at io.trino.metadata.MetadataManager.listTableColumns(MetadataManager.java:553)
    at io.trino.metadata.MetadataListing.listTableColumns(MetadataListing.java:164)
    at io.trino.connector.system.jdbc.ColumnJdbcTable.cursor(ColumnJdbcTable.java:263)
    at io.trino.connector.system.SystemPageSourceProvider$1.cursor(SystemPageSourceProvider.java:129)
    at io.trino.split.MappedRecordSet.cursor(MappedRecordSet.java:53)
    at io.trino.spi.connector.RecordPageSource.<init>(RecordPageSource.java:37)
    at io.trino.connector.system.SystemPageSourceProvider.createPageSource(SystemPageSourceProvider.java:108)
    at io.trino.split.PageSourceManager.createPageSource(PageSourceManager.java:62)
    at io.trino.operator.ScanFilterAndProjectOperator$SplitToPages.process(ScanFilterAndProjectOperator.java:268)
    at io.trino.operator.ScanFilterAndProjectOperator$SplitToPages.process(ScanFilterAndProjectOperator.java:196)
    at io.trino.operator.WorkProcessorUtils$3.process(WorkProcessorUtils.java:338)
    at io.trino.operator.WorkProcessorUtils$ProcessWorkProcessor.process(WorkProcessorUtils.java:391)
    at io.trino.operator.WorkProcessorUtils$3.process(WorkProcessorUtils.java:325)
    at io.trino.operator.WorkProcessorUtils$ProcessWorkProcessor.process(WorkProcessorUtils.java:391)
    at io.trino.operator.WorkProcessorUtils$3.process(WorkProcessorUtils.java:325)
    at io.trino.operator.WorkProcessorUtils$ProcessWorkProcessor.process(WorkProcessorUtils.java:391)
    at io.trino.operator.WorkProcessorUtils.getNextState(WorkProcessorUtils.java:240)
    at io.trino.operator.WorkProcessorUtils.lambda$processStateMonitor$3(WorkProcessorUtils.java:219)
    at io.trino.operator.WorkProcessorUtils$ProcessWorkProcessor.process(WorkProcessorUtils.java:391)
    at io.trino.operator.WorkProcessorUtils.getNextState(WorkProcessorUtils.java:240)
    at io.trino.operator.WorkProcessorUtils.lambda$finishWhen$4(WorkProcessorUtils.java:234)
    at io.trino.operator.WorkProcessorUtils$ProcessWorkProcessor.process(WorkProcessorUtils.java:391)
    at io.trino.operator.WorkProcessorSourceOperatorAdapter.getOutput(WorkProcessorSourceOperatorAdapter.java:150)
    at io.trino.operator.Driver.processInternal(Driver.java:410)
    at io.trino.operator.Driver.lambda$process$10(Driver.java:313)
    at io.trino.operator.Driver.tryWithLock(Driver.java:698)
    at io.trino.operator.Driver.process(Driver.java:305)
    at io.trino.operator.Driver.processForDuration(Driver.java:276)
    at io.trino.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:740)
    at io.trino.execution.executor.PrioritizedSplitRunner.process(PrioritizedSplitRunner.java:164)
    at io.trino.execution.executor.TaskExecutor$TaskRunner.run(TaskExecutor.java:490)
    at io.trino.$gen.Trino_392____20220819_235554_2.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
findepi commented 2 years ago

Relates to https://github.com/trinodb/trino/issues/6551