Skip to content

Conversation

@Max-Cheng
Copy link
Contributor

@Max-Cheng Max-Cheng commented Aug 6, 2025

Description

Close #21506

Minimising Reproduction:

SELECT *
FROM (
        SELECT n.n_name AS "col1",
            n.n_nationkey AS "col2",
            CAST(null AS varchar) AS "col3"
        FROM tpch.sf1.nation n
        WHERE n.n_nationkey <= 3
        UNION ALL
        SELECT r.r_name AS "col1",
            CAST(r.r_regionkey AS bigint) AS "col2",
            r.r_comment AS "col3"
        FROM tpch.sf1.region r
    ) subquery
WHERE "col3" IN (
        SELECT r.r_comment
        FROM tpch.sf1.region r
    );
-- ERROR Trigger!
Query 20250806_041012_00085_hbymq failed: No catalog handle for partitioning handle: SINGLE
java.lang.IllegalStateException: No catalog handle for partitioning handle: SINGLE
        at io.trino.sql.planner.NodePartitioningManager.lambda$requiredCatalogHandle$0(NodePartitioningManager.java:299)
        at java.base/java.util.Optional.orElseThrow(Optional.java:403)
        at io.trino.sql.planner.NodePartitioningManager.requiredCatalogHandle(NodePartitioningManager.java:298)
        at io.trino.sql.planner.NodePartitioningManager.getConnectorBucketNodeMap(NodePartitioningManager.java:258)
        at io.trino.sql.planner.NodePartitioningManager.getBucketNodeMap(NodePartitioningManager.java:192)
        at io.trino.execution.scheduler.PipelinedQueryScheduler$DistributedStagesScheduler.createStageScheduler(PipelinedQueryScheduler.java:1170)
        at io.trino.execution.scheduler.PipelinedQueryScheduler$DistributedStagesScheduler.create(PipelinedQueryScheduler.java:949)
        at io.trino.execution.scheduler.PipelinedQueryScheduler.createDistributedStagesScheduler(PipelinedQueryScheduler.java:328)
        at io.trino.execution.scheduler.PipelinedQueryScheduler.start(PipelinedQueryScheduler.java:311)
        at io.trino.execution.SqlQueryExecution.start(SqlQueryExecution.java:440)
        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_dev____20250806_031006_2.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)

Additional context and related issues

Should call RemoveEmptyUnionBranches after RemoveTrivialFilters
Prune empty union branches.

Release notes

( ) 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.
( x ) Release notes are required, with the following suggested text:

## Section
* Enhance after `RemoveTrivialFilters` call `RemoveEmptyUnionBranches` to prune empty union branches. ({issue}`21506`)

@cla-bot cla-bot bot added the cla-signed label Aug 6, 2025
@Max-Cheng
Copy link
Contributor Author

@sopel39 PTAL

@Max-Cheng Max-Cheng requested a review from sopel39 August 6, 2025 05:04
@Max-Cheng Max-Cheng force-pushed the fix/partitioning_handle branch from 1b71de0 to 435cb6c Compare August 6, 2025 05:53
@wendigo wendigo requested a review from kasiafi August 6, 2025 12:54
@Max-Cheng Max-Cheng force-pushed the fix/partitioning_handle branch from 435cb6c to fd3cdf5 Compare August 7, 2025 02:12
@raunaqmorarka raunaqmorarka requested a review from martint August 14, 2025 05:42
@github-actions
Copy link

github-actions bot commented Sep 4, 2025

This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack.

@github-actions github-actions bot added the stale label Sep 4, 2025
@wendigo
Copy link
Contributor

wendigo commented Sep 4, 2025

@kasiafi ptal

@github-actions github-actions bot removed the stale label Sep 5, 2025
@Max-Cheng Max-Cheng force-pushed the fix/partitioning_handle branch from fd3cdf5 to 7a149e0 Compare September 7, 2025 13:19
@github-actions
Copy link

This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack.

@github-actions github-actions bot added the stale label Sep 29, 2025
@github-actions
Copy link

Closing this pull request, as it has been stale for six weeks. Feel free to re-open at any time.

@github-actions github-actions bot closed this Oct 21, 2025
@martint martint reopened this Oct 21, 2025
@github-actions github-actions bot removed the stale label Oct 22, 2025
@Max-Cheng Max-Cheng changed the title fix:using simplifyOptimizerRules wasn't RemoveEmptyUnionBranches feat:after RemoveTrivialFilters call RemoveEmptyUnionBranches to prune empty union branches. Nov 6, 2025
@Max-Cheng Max-Cheng force-pushed the fix/partitioning_handle branch from 7a149e0 to db6a5e5 Compare November 6, 2025 04:40
@Max-Cheng
Copy link
Contributor Author

@kasiafi @chenjian2664 PTAL

@kasiafi kasiafi merged commit 26c2ee6 into trinodb:master Nov 6, 2025
196 of 198 checks passed
@kasiafi
Copy link
Member

kasiafi commented Nov 6, 2025

Merged. Thank you @Max-Cheng!

@github-actions github-actions bot added this to the 479 milestone Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Trino v428: java.lang.IllegalArgumentException: No catalog handle for partitioning handle: SINGLE

5 participants