Skip to content

[AURON #2690] Enable native join output column pruning - #2691

Open
lyne7-sc wants to merge 3 commits into
apache:masterfrom
lyne7-sc:perf/native-column-pruning
Open

lyne7-sc wants to merge 3 commits into
apache:masterfrom
lyne7-sc:perf/native-column-pruning

Conversation

@lyne7-sc

@lyne7-sc lyne7-sc commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #2690

Rationale for this change

Native hash joins and sort-merge joins can generate columns that a parent projection immediately discards. This change lets joins output only the requested columns, avoiding unnecessary output work.

What changes are included in this PR?

  • Forward column-pruning requests to the existing native join implementations.
  • Fix the full-projection check and preserve support for reordered and duplicate projections.

Are there any user-facing changes?

This is an internal execution optimization with no new configuration or public APIs.

How was this patch tested?

  • Native column-pruning and join tests passed.
  • Existing related suites: AuronBroadcastHashJoinConditionSuite and AuronSortMergeJoinConditionSuite
  • Validated with Spark SQL on Parquet inputs:
SELECT /*+ BROADCAST(r) */ l.v
FROM prune_l l JOIN prune_r r ON l.k = r.k;

SELECT /*+ MERGE(l,r) */ l.v
FROM prune_l l JOIN prune_r r ON l.k = r.k;

Native logs recorded join output before the parent Project:

Before:

JOIN_OUTPUT node=HashJoin columns=3 rows=8 fields=["#0", "#1", "#2"]
JOIN_OUTPUT node=SortMergeJoin columns=3 rows=2 fields=["#0", "#1", "#2"]
JOIN_OUTPUT node=SortMergeJoin columns=3 rows=6 fields=["#0", "#1", "#2"]

After:

JOIN_OUTPUT node=HashJoin columns=1 rows=8 fields=["#1"]
JOIN_OUTPUT node=SortMergeJoin columns=1 rows=6 fields=["#1"]
JOIN_OUTPUT node=SortMergeJoin columns=1 rows=2 fields=["#1"]

Was this patch authored or co-authored using generative AI tooling?

  • Yes
  • No

If yes, include: Generated-by: OpenAI Codex (GPT-6.1)

ASF guidance: https://www.apache.org/legal/generative-tooling.html

@lyne7-sc lyne7-sc changed the title perf: enable native join output column pruning [AURON #2690] Enable native join output column pruning Nov 5, 2026
@github-actions github-actions Bot added the native label Nov 5, 2026
@slfan1989 slfan1989 self-assigned this Nov 7, 2026
return join.execute_projected(partition, context, projection);
}
if let Some(join) = self.downcast_ref::<SortMergeJoinExec>() {
return join.execute_projected(partition, context, projection);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SortMergeJoinExec caches JoinParams in a OnceCell, so the first projection wins. I verified locally that calling execute_projected with [1] and then [2] on the same instance returns column 1 both times.

A subsequent execute() also returns just one column.

Could we cache only the projection-independent parameters and add a regression test that reuses the same join instance?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! I changed SMJ to create JoinParams per execution and updated the existing test to cover different projections followed by execute() on the same instance.

While checking this path, I also fixed an existing hybrid join layout assumption exposed by column pruning: with a right-only projection, the row-number column used to preserve probe order was placed incorrectly in the output schema. The targeted regression test and Spark SQL reproducer now pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid materializing unused native join output columns

2 participants