trino icon indicating copy to clipboard operation
trino copied to clipboard

Avoid failures when redirecting from incomplete/invalid Delta Lake tables

Open nineinchnick opened this issue 1 year ago • 1 comments

Description

Don't attempt to read Delta Lake table metadata when performing table redirect to a different catalog. This allows redirecting from incomplete or invalid Delta Lake tables.

Without the fix, queries fail with:

io.trino.testing.QueryFailedException: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException: Error: type expected at the position 0 of 'timestamp_ntz' but 'timestamp_ntz' is found.

	at io.trino.testing.AbstractTestingTrinoClient.execute(AbstractTestingTrinoClient.java:134)
	at io.trino.testing.DistributedQueryRunner.executeInternal(DistributedQueryRunner.java:565)
	at io.trino.testing.DistributedQueryRunner.execute(DistributedQueryRunner.java:548)
	at io.trino.testing.AbstractTestQueryFramework.computeActual(AbstractTestQueryFramework.java:313)
	at io.trino.testing.AbstractTestQueryFramework.computeActual(AbstractTestQueryFramework.java:308)
	at io.trino.plugin.deltalake.TestDeltaLakeSharedGlueMetastoreWithTableRedirections.testUnsupportedHiveTypeRedirect(TestDeltaLakeSharedGlueMetastoreWithTableRedirections.java:180)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)
	Suppressed: java.lang.Exception: SQL: SHOW CREATE TABLE hive_with_redirections.test_shared_schema_4jlq4sptnq.unsupported_types
		at io.trino.testing.DistributedQueryRunner.executeInternal(DistributedQueryRunner.java:572)
		... 9 more
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException: Error: type expected at the position 0 of 'timestamp_ntz' but 'timestamp_ntz' is found.
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2085)
	at com.google.common.cache.LocalCache.get(LocalCache.java:4017)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4040)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4989)
	at io.trino.cache.EvictableCache.get(EvictableCache.java:147)
	at com.google.common.cache.AbstractLoadingCache.getUnchecked(AbstractLoadingCache.java:53)
	at io.trino.plugin.hive.metastore.cache.CachingHiveMetastore.getOptional(CachingHiveMetastore.java:285)
	at io.trino.plugin.hive.metastore.cache.CachingHiveMetastore.getTable(CachingHiveMetastore.java:431)
	at io.trino.plugin.hive.metastore.SemiTransactionalHiveMetastore.getTable(SemiTransactionalHiveMetastore.java:276)
	at io.trino.plugin.hive.HiveMetadata.getView(HiveMetadata.java:2899)
	at io.trino.spi.connector.ConnectorMetadata.isView(ConnectorMetadata.java:1005)
	at io.trino.plugin.base.classloader.ClassLoaderSafeConnectorMetadata.isView(ClassLoaderSafeConnectorMetadata.java:721)
	at io.trino.tracing.TracingConnectorMetadata.isView(TracingConnectorMetadata.java:850)
	at io.trino.metadata.MetadataManager.lambda$isView$37(MetadataManager.java:1499)
	at java.base/java.util.Optional.map(Optional.java:260)
	at io.trino.metadata.MetadataManager.isView(MetadataManager.java:1495)
	at io.trino.tracing.TracingMetadata.isView(TracingMetadata.java:886)
	at io.trino.sql.rewrite.ShowQueriesRewrite$Visitor.showCreateTable(ShowQueriesRewrite.java:616)
	at io.trino.sql.rewrite.ShowQueriesRewrite$Visitor.visitShowCreate(ShowQueriesRewrite.java:519)
	at io.trino.sql.rewrite.ShowQueriesRewrite$Visitor.visitShowCreate(ShowQueriesRewrite.java:219)
	at io.trino.sql.tree.ShowCreate.accept(ShowCreate.java:60)
	at io.trino.sql.tree.AstVisitor.process(AstVisitor.java:27)
	at io.trino.sql.rewrite.ShowQueriesRewrite.rewrite(ShowQueriesRewrite.java:216)
	at io.trino.sql.rewrite.StatementRewrite.rewrite(StatementRewrite.java:54)
	at io.trino.sql.analyzer.Analyzer.analyze(Analyzer.java:93)
	at io.trino.sql.analyzer.Analyzer.analyze(Analyzer.java:87)
	at io.trino.execution.SqlQueryExecution.analyze(SqlQueryExecution.java:289)
	at io.trino.execution.SqlQueryExecution.<init>(SqlQueryExecution.java:222)
	at io.trino.execution.SqlQueryExecution$SqlQueryExecutionFactory.createQueryExecution(SqlQueryExecution.java:892)
	at io.trino.dispatcher.LocalDispatchQueryFactory.lambda$createDispatchQuery$0(LocalDispatchQueryFactory.java:153)
	at io.trino.$gen.Trino_testversion____20241010_143532_71.call(Unknown Source)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
	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:1575)
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException: Error: type expected at the position 0 of 'timestamp_ntz' but 'timestamp_ntz' is found.
	at io.trino.cache.EmptyCache.get(EmptyCache.java:100)
	at io.trino.cache.EmptyCache.get(EmptyCache.java:58)
	at com.google.common.cache.AbstractLoadingCache.getUnchecked(AbstractLoadingCache.java:53)
	at io.trino.plugin.hive.metastore.cache.CachingHiveMetastore.getOptional(CachingHiveMetastore.java:285)
	at io.trino.plugin.hive.metastore.cache.CachingHiveMetastore.getTable(CachingHiveMetastore.java:431)
	at io.trino.plugin.hive.metastore.cache.CachingHiveMetastore.loadTable(CachingHiveMetastore.java:436)
	at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:169)
	at io.trino.cache.EvictableCache$TokenCacheLoader.load(EvictableCache.java:471)
	at io.trino.cache.EvictableCache$TokenCacheLoader.load(EvictableCache.java:457)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3574)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2316)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2189)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2079)
	... 36 more
Caused by: java.lang.IllegalArgumentException: Error: type expected at the position 0 of 'timestamp_ntz' but 'timestamp_ntz' is found.
	at io.trino.metastore.type.TypeInfoUtils$TypeInfoParser.expect(TypeInfoUtils.java:193)
	at io.trino.metastore.type.TypeInfoUtils$TypeInfoParser.expect(TypeInfoUtils.java:176)
	at io.trino.metastore.type.TypeInfoUtils$TypeInfoParser.parseType(TypeInfoUtils.java:232)
	at io.trino.metastore.type.TypeInfoUtils$TypeInfoParser.parseTypeInfos(TypeInfoUtils.java:154)
	at io.trino.metastore.type.TypeInfoUtils.getTypeInfosFromTypeString(TypeInfoUtils.java:357)
	at io.trino.metastore.type.TypeInfoUtils.getTypeInfoFromTypeString(TypeInfoUtils.java:362)
	at io.trino.metastore.HiveType.valueOf(HiveType.java:116)
	at io.trino.plugin.hive.metastore.glue.GlueConverter.fromGlueColumn(GlueConverter.java:284)
	at io.trino.plugin.hive.metastore.glue.GlueConverter.lambda$fromGlueColumns$1(GlueConverter.java:272)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1709)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:727)
	at io.trino.plugin.hive.metastore.glue.GlueConverter.fromGlueColumns(GlueConverter.java:273)
	at io.trino.plugin.hive.metastore.glue.GlueConverter.fromGlueTable(GlueConverter.java:188)
	at io.trino.plugin.hive.metastore.glue.GlueHiveMetastore.getTableInternal(GlueHiveMetastore.java:495)
	at io.trino.plugin.hive.metastore.glue.GlueHiveMetastore.lambda$getTable$18(GlueHiveMetastore.java:485)
	at io.trino.plugin.hive.metastore.glue.NoopGlueCache.getTable(NoopGlueCache.java:66)
	at io.trino.plugin.hive.metastore.glue.GlueHiveMetastore.getTable(GlueHiveMetastore.java:485)
	at io.trino.plugin.hive.metastore.cache.CachingHiveMetastore.loadTable(CachingHiveMetastore.java:436)
	at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:169)
	at io.trino.cache.EmptyCache.lambda$get$0(EmptyCache.java:58)
	at io.trino.cache.EmptyCache.get(EmptyCache.java:94)
	... 48 more

Additional context and related issues

Release notes

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

nineinchnick avatar Oct 09 '24 11:10 nineinchnick