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

Failure when reading Iceberg statistics and query involves $path column predicate #17451

Closed
ebyhr opened this issue May 11, 2023 · 2 comments
Closed
Labels
bug Something isn't working iceberg Iceberg connector

Comments

@ebyhr
Copy link
Member

ebyhr commented May 11, 2023

trino:tpch> select * from region where "$path" = '';
 regionkey | name | comment 
-----------+------+---------
(0 rows)

trino:tpch> explain select * from region where "$path" = '';
Query 20230511_011103_00032_8v2jg failed: Constraint on an unexpected column 2147483646:$path:varchar
java.lang.IllegalArgumentException: Constraint on an unexpected column 2147483646:$path:varchar
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:220)
        at io.trino.plugin.iceberg.ExpressionConverter.toIcebergExpression(ExpressionConverter.java:65)
        at io.trino.plugin.iceberg.TableStatisticsReader.makeTableStatistics(TableStatisticsReader.java:142)
        at io.trino.plugin.iceberg.TableStatisticsReader.getTableStatistics(TableStatisticsReader.java:95)
        at io.trino.plugin.iceberg.IcebergMetadata.lambda$getTableStatistics$77(IcebergMetadata.java:2500)
        at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
        at io.trino.plugin.iceberg.IcebergMetadata.getTableStatistics(IcebergMetadata.java:2481)
        at io.trino.plugin.base.classloader.ClassLoaderSafeConnectorMetadata.getTableStatistics(ClassLoaderSafeConnectorMetadata.java:328)
        at io.trino.tracing.TracingConnectorMetadata.getTableStatistics(TracingConnectorMetadata.java:316)
        at io.trino.metadata.MetadataManager.getTableStatistics(MetadataManager.java:473)
        at io.trino.tracing.TracingMetadata.getTableStatistics(TracingMetadata.java:296)
        at io.trino.cost.CachingTableStatsProvider.getTableStatistics(CachingTableStatsProvider.java:45)
        at io.trino.cost.TableScanStatsRule.doCalculate(TableScanStatsRule.java:62)
        at io.trino.cost.TableScanStatsRule.doCalculate(TableScanStatsRule.java:38)
        at io.trino.cost.SimpleStatsRule.calculate(SimpleStatsRule.java:39)
        at io.trino.cost.ComposableStatsCalculator.calculateStats(ComposableStatsCalculator.java:85)
        at io.trino.cost.ComposableStatsCalculator.calculateStats(ComposableStatsCalculator.java:73)
        at io.trino.cost.CachingStatsProvider.getStats(CachingStatsProvider.java:82)
        at io.trino.cost.OutputStatsRule.calculate(OutputStatsRule.java:41)
        at io.trino.cost.OutputStatsRule.calculate(OutputStatsRule.java:27)
        at io.trino.cost.ComposableStatsCalculator.calculateStats(ComposableStatsCalculator.java:85)
        at io.trino.cost.ComposableStatsCalculator.calculateStats(ComposableStatsCalculator.java:73)
        at io.trino.cost.CachingStatsProvider.getStats(CachingStatsProvider.java:82)
        at io.trino.cost.StatsAndCosts.create(StatsAndCosts.java:87)
        at io.trino.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:289)
        at io.trino.sql.analyzer.QueryExplainer.getLogicalPlan(QueryExplainer.java:179)
        at io.trino.sql.analyzer.QueryExplainer.getDistributedPlan(QueryExplainer.java:190)
        at io.trino.sql.analyzer.QueryExplainer.getPlan(QueryExplainer.java:109)
        at io.trino.sql.rewrite.ExplainRewrite$Visitor.getQueryPlan(ExplainRewrite.java:152)
        at io.trino.sql.rewrite.ExplainRewrite$Visitor.visitExplain(ExplainRewrite.java:130)
        at io.trino.sql.rewrite.ExplainRewrite$Visitor.visitExplain(ExplainRewrite.java:75)
        at io.trino.sql.tree.Explain.accept(Explain.java:61)
        at io.trino.sql.tree.AstVisitor.process(AstVisitor.java:27)
        at io.trino.sql.rewrite.ExplainRewrite.rewrite(ExplainRewrite.java:72)
        at io.trino.sql.rewrite.StatementRewrite.rewrite(StatementRewrite.java:55)
        at io.trino.sql.analyzer.Analyzer.analyze(Analyzer.java:92)
        at io.trino.sql.analyzer.Analyzer.analyze(Analyzer.java:86)
        at io.trino.execution.SqlQueryExecution.analyze(SqlQueryExecution.java:271)
        at io.trino.execution.SqlQueryExecution.<init>(SqlQueryExecution.java:206)
        at io.trino.execution.SqlQueryExecution$SqlQueryExecutionFactory.createQueryExecution(SqlQueryExecution.java:845)
        at io.trino.dispatcher.LocalDispatchQueryFactory.lambda$createDispatchQuery$0(LocalDispatchQueryFactory.java:154)
        at io.trino.$gen.Trino_testversion____20230511_010815_75.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:74)
        at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
        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)

@ebyhr ebyhr added bug Something isn't working iceberg Iceberg connector labels May 11, 2023
@chenjian2664
Copy link
Contributor

chenjian2664 commented May 29, 2023

@ebyhr Hi, I did some verifications on this, I found it's not related to the EXPLAIN but the iceberg table statistics computing if involving MetadataColumn, If set session collect_plan_statistics_for_all_queries to true the select query would fail as well.
I tried to fix this on my local ( in TableStatisticsReader.makeTableStatistics method):

  • Remove the meta column predicate in effectivePredicate before pass to ExpressionConverter.toIcebergExpression
  • Skip scan file tasks if the path not match path(using above filtered path predicate), like the IcebergSplitSource do.
    I am not confident about the approach as I have rarely experience about the connector, could you help to check and guide me about this?

@findepi findepi changed the title EXPLAIN with predicates on Iceberg metadata columns fails Failure when reading Iceberg statistics and query involves $path column predicate May 30, 2023
@findepi
Copy link
Member

findepi commented Apr 8, 2024

fixed by #18314

@findepi findepi closed this as completed Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iceberg Iceberg connector
Development

No branches or pull requests

3 participants