Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIVE-28729: Apply nulls order setting in Reduce Sink operator of join branches #5626

Merged
merged 5 commits into from
Feb 4, 2025

Conversation

kasakrisz
Copy link
Contributor

@kasakrisz kasakrisz commented Jan 30, 2025

What changes were proposed in this pull request?

Use the default null order configured via hive.default.nulls.last in the Calcite rule HiveInsertExchange4JoinRule.java when creating sort keys. This rule is used only when hive.cbo.returnpath.hiveop is enabled.

Why are the changes needed?

The setting hive.default.nulls.last doesn't have affect to the HiveSortExchange operators created by this rule and the RS operators built from them.

Does this PR introduce any user-facing change?

Explain output of query plans has join operation may change.

Is the change a dependency upgrade?

No.

How was this patch tested?

mvn test -Dtest.output.overwrite -Dtest=TestMiniLlapLocalCliDriver -Dqfile=cbo_rp_null_order.q -pl itests/qtest -Pitests

Copy link
Member

@zabetak zabetak left a comment

Choose a reason for hiding this comment

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

I left some minor comments but LGTM so it can go in if we get a green run.

One general question is if this "bug" affects somehow the correctness of some queries. Do we get wrong results without this fix?

@@ -56,20 +57,28 @@
*/
public class HiveInsertExchange4JoinRule extends RelOptRule {

protected static transient final Logger LOG = LoggerFactory
.getLogger(HiveInsertExchange4JoinRule.class);
protected static final Logger LOG = LoggerFactory.getLogger(HiveInsertExchange4JoinRule.class);
Copy link
Member

Choose a reason for hiding this comment

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

The logger does not seem to be used so I guess we can drop it entirely along with the relevant imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

Comment on lines 63 to 75
public static HiveInsertExchange4JoinRule exchangeBelowMultiJoin(
RelFieldCollation.NullDirection defaultAscNullDirection) {
return new HiveInsertExchange4JoinRule(HiveMultiJoin.class, defaultAscNullDirection);
}


/** Rule that creates Exchange operators under a Join operator. */
public static final HiveInsertExchange4JoinRule EXCHANGE_BELOW_JOIN =
new HiveInsertExchange4JoinRule(Join.class);
public static HiveInsertExchange4JoinRule exchangeBelowJoin(
RelFieldCollation.NullDirection defaultAscNullDirection) {
return new HiveInsertExchange4JoinRule(Join.class, defaultAscNullDirection);
}

private final RelFieldCollation.NullDirection defaultAscNullDirection;
Copy link
Member

Choose a reason for hiding this comment

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

I don't see a big advantage in introducing the static factories. Since the constructor is public we could just keep that one. If we want to make the rule creation shorter then we could have a static factory with a shorter name (e.g., of(clazz,nullDirection))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the factory methods. Using constructor in CalcitePlanner

Copy link

sonarqubecloud bot commented Feb 4, 2025

@kasakrisz kasakrisz merged commit 7d46716 into apache:master Feb 4, 2025
6 checks passed
@kasakrisz kasakrisz deleted the HIVE-28729-master-cbo-rp-nulls branch February 4, 2025 14:39
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