Skip to content

EXPLAIN ANALYZE with ALTER TABLE ... EXECUTE optimize on unpartition tables shows exception message #26598

@ebyhr

Description

@ebyhr
trino:tpch> explain analyze alter table region execute optimize;
Query 20250910_031025_00025_xqb6h failed: Unexpected ExplainAnalyzeNode found in plan; probably connector was not able to handle provided WHERE expression
java.lang.IllegalStateException: Unexpected ExplainAnalyzeNode found in plan; probably connector was not able to handle provided WHERE expression
	at io.trino.sql.planner.sanity.TableExecuteStructureValidator.lambda$validate$1(TableExecuteStructureValidator.java:56)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:421)
	at io.trino.sql.planner.sanity.TableExecuteStructureValidator.validate(TableExecuteStructureValidator.java:54)
	at io.trino.sql.planner.sanity.PlanSanityChecker.lambda$validate$0(PlanSanityChecker.java:107)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:421)
	at io.trino.sql.planner.sanity.PlanSanityChecker.validate(PlanSanityChecker.java:107)
	at io.trino.sql.planner.sanity.PlanSanityChecker.validateFinalPlan(PlanSanityChecker.java:78)
	at io.trino.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:274)
	at io.trino.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:238)
	at io.trino.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:233)
	at io.trino.execution.SqlQueryExecution.doPlanQuery(SqlQueryExecution.java:496)
	at io.trino.execution.SqlQueryExecution.planQuery(SqlQueryExecution.java:476)
	at io.trino.execution.SqlQueryExecution.start(SqlQueryExecution.java:414)
	at io.trino.execution.SqlQueryManager.createQuery(SqlQueryManager.java:284)
	at io.trino.dispatcher.LocalDispatchQuery.startExecution(LocalDispatchQuery.java:150)
	at io.trino.dispatcher.LocalDispatchQuery.lambda$waitForMinimumWorkers$1(LocalDispatchQuery.java:134)
	at io.airlift.concurrent.MoreFutures.lambda$addSuccessCallback$12(MoreFutures.java:570)
	at io.airlift.concurrent.MoreFutures$3.onSuccess(MoreFutures.java:545)
	at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1132)
	at io.trino.$gen.Trino_testversion____20250910_030911_1.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1095)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:619)
	at java.base/java.lang.Thread.run(Thread.java:1447)
	Suppressed: java.lang.Exception: Current plan:
                Output[columnNames = [Query Plan]]
                │   Layout: [query_plan:varchar]
                │   Query Plan := query_plan
                └─ ExplainAnalyze[]
                   │   Layout: [query_plan:varchar]
                   └─ LocalExchange[partitioning = SINGLE]
                      │   Layout: [rows:bigint]
                      └─ RemoteExchange[type = GATHER]
                         │   Layout: [rows:bigint]
                         └─ TableCommit[target = iceberg:schemaTableName:tpch.region, procedureId:OPTIMIZE, procedureHandle:{IcebergOptimizeHandle[snapshotId=Optional[4494270946305145416], schemaAsJson={"type":"struct","schema-id":0,"fields":[{"id":1,"name":"regionkey","required":false,"type":"long"},{"id":2,"name":"name","required":false,"type":"string"},{"id":3,"name":"comment","required":false,"type":"string"}]}, partitionSpecAsJson={"spec-id":0,"fields":[]}, tableColumns=[1:regionkey:bigint, 2:name:varchar, 3:comment:varchar], sortOrder=[], fileFormat=PARQUET, tableStorageProperties={write.format.default=PARQUET}, maxScannedFileSize=100MB, retriesEnabled=false]}]
                            │   Layout: [rows:bigint]
                            └─ LocalExchange[partitioning = SINGLE]
                               │   Layout: [partialrows:bigint, fragment:varbinary]
                               └─ RemoteExchange[type = GATHER]
                                  │   Layout: [partialrows:bigint, fragment:varbinary]
                                  └─ TableExecute[]
                                     │   Layout: [partialrows:bigint, fragment:varbinary]
                                     │   regionkey := regionkey
                                     │   name := name
                                     │   comment := comment
                                     └─ RemoteExchange[partitionCount = 100, scaleWriters = true, type = REPARTITION]
                                        │   Layout: [regionkey:bigint, name:varchar, comment:varchar]
                                        └─ TableScan[table = iceberg:tpch.region$data@4494270946305145416]
                                               Layout: [regionkey:bigint, name:varchar, comment:varchar]
                                               regionkey := 1:regionkey:bigint
                                               name := 2:name:varchar
                                               comment := 3:comment:varchar

		at io.trino.sql.planner.sanity.PlanSanityChecker.validate(PlanSanityChecker.java:120)
		... 17 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions