Skip to content

HIVE-29734: Cleanup Bug.java after Calcite upgrade 1.42.0 - #6720

Open
rubenada wants to merge 12 commits into
apache:masterfrom
rubenada:HIVE-29734
Open

HIVE-29734: Cleanup Bug.java after Calcite upgrade 1.42.0#6720
rubenada wants to merge 12 commits into
apache:masterfrom
rubenada:HIVE-29734

Conversation

@rubenada

@rubenada rubenada commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Cleanup Bug.java after Calcite upgrade 1.42.0, i.e. remove ad-hoc pieces of code with fixes on Hive side that are no longer required, since these fixes are now on Calcite side.

Items removed:

Why are the changes needed?

Remove unnecessary code.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

No real change is expected with this adjustment, so existing tests should pass with no regressions.

… seem identical to Calcite's version, the latter causes issues with certain tests:

- Testing / split-14 / PostProcess / testCliDriver[lvj_mapjoin] – org.apache.hadoop.hive.cli.split13.TestMiniLlapLocalCliDriver
- Testing / split-05 / PostProcess / testCliDriver[lateral_view_cbo] – org.apache.hadoop.hive.cli.split12.TestMiniLlapLocalCliDriver
- Testing / split-05 / PostProcess / testCliDriver[lateral_view_ppd] – org.apache.hadoop.hive.cli.split12.TestMiniLlapLocalCliDriver
- Testing / split-10 / PostProcess / testCliDriver[tez_union_udtf] – org.apache.hadoop.hive.cli.TestMiniTezCliDriver
- Testing / split-19 / PostProcess / testCliDriver[union26] – org.apache.hadoop.hive.cli.split27.TestMiniLlapLocalCliDriver
- Testing / split-04 / PostProcess / testCliDriver[nonmr_fetch] – org.apache.hadoop.hive.cli.split7.TestCliDriver
@rubenada rubenada changed the title [WIP] HIVE-29734: Cleanup Bug.java after Calcite upgrade 1.42.0 HIVE-29734: Cleanup Bug.java after Calcite upgrade 1.42.0 Aug 27, 2026

@zabetak zabetak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left some suggestions for further cleanup but overall looks good.

Comment on lines 137 to 139
private static final class JoinLeftEmptyRuleConfig extends HiveRuleConfig
implements PruneEmptyRules.JoinLeftEmptyRuleConfig {
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we do a bit better in terms of cleanup and drop this kind of trivial extension class? Maybe we can instantiate the rules directly using the configs available in Calcite. For example:

  public static final RelOptRule JOIN_LEFT_INSTANCE = PruneEmptyRules.JoinLeftEmptyRuleConfig.DEFAULT
      .withRelBuilderFactory(HiveRelFactories.HIVE_BUILDER).toRule();
  public static final RelOptRule JOIN_RIGHT_INSTANCE = PruneEmptyRules.JoinRightEmptyRuleConfig.DEFAULT
      .withRelBuilderFactory(HiveRelFactories.HIVE_BUILDER).toRule();

Maybe this allow us to drop also some SEMI/ANTI rule instances. Can you check if its feasible?

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.

I think it can be done, on it....
BTW, I noticed there's getJoinRightInstance for HiveJoin, HiveSemiJoin and HiveAntiJoin; but for getJoinLeftInstance there's only HiveJoin, HiveSemiJoin.
Is there a specific reason why HiveAntiJoin is not considered for JoinLeftEmptyRule?
Was it intentional or just a slip?
If we refactor to use the above suggestion, we will also get JoinLeftEmptyRule for Anti...

Comment on lines +145 to +147
private static final class CorrelateLeftEmptyRuleConfig extends HiveRuleConfig
implements PruneEmptyRules.CorrelateLeftEmptyRuleConfig {
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Likewise let's re-evaluate how much we need the trivial extension classes.

Comment on lines 31 to 32

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not blocking for the PR but if we can test and get rid of the entire class as part of this cleanup it would be great.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about setting calcite.default.charset property in saffron and get rid of the entire class?


# Change logger level to DEBUG, to see all application of CBO rules and the operators they produce
logger.CBORuleLogger.name = org.apache.hadoop.hive.ql.optimizer.calcite.RuleEventLogger
logger.CBORuleLogger.name = org.apache.calcite.plan.RuleEventLogger

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you verify that the logs are displayed as expected after the change?

@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants