Skip to content

Conversation

zabetak
Copy link
Member

@zabetak zabetak commented Oct 7, 2025

What changes were proposed in this pull request?

  1. Use introduceDerivedTable(RelNode) instead of introduceDerivedTable(RelNode,RelNode) to avoid the exception when the (left) input is already modified by the shuttle.
  2. Manually link the derived table with the join in SelfJoinHandler.
  3. Create new join (copy) only if one of the input(s) is modified.

Why are the changes needed?

The problem occurs when we need to introduce a derived table over the left input of the join but the input is already modified (newL) by the shuttle. Looking for the modified input in the join's children fails and raises an exception. Since we know which input needs to be replaced we can avoid the lookup mechanism in introduceDerivedTable(RelNode, RelNode) and build directly the new join operator via copy.

To avoid unnecessary object creation bubling further up via the HiveRelShuttle mechansim we perform the copy only when one of the inputs is modified.

Does this PR introduce any user-facing change?

No

How was this patch tested?

mvn test -Dtest=TestMiniLlapLocalCliDriver -Dqfile_regex=.*cte.* -Dtest.output.overwrite
mvn test -Dtest=TestMiniLlapLocalCliDriver -Dqfile_regex=.*view.* -Dtest.output.overwrite

…edTable for queries with self joins

The problem occurs when we need to introduce a derived table over the left input of the join but the input is already modified (newL) by the shuttle.
Looking for the modified input in the join's children fails and raises an exception. Since we know which input needs to be replaced we can avoid the lookup mechanism in
`introduceDerivedTable(RelNode, RelNode)` and build directly the new join operator via copy.

To avoid unnecessary object creation bubling further up via the HiveRelShuttle mechansim we perform the copy *only* when one of the inputs is modified.
Copy link

sonarqubecloud bot commented Oct 7, 2025

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants