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

IGNITE-24196 Sql. Merge projection into join node #5398

Merged
merged 7 commits into from
Mar 17, 2025

Conversation

korlov42
Copy link
Contributor

@korlov42 korlov42 commented Mar 12, 2025

https://issues.apache.org/jira/browse/IGNITE-24196

This patch introduces new SqlJoinProjection expression to use instead of RowFactory#concat in join nodes. Besides, in reorganizes schema initialization in ItJoinOrderTest to take an advantage of DDL batching.

Results of SqlJoinBenchmark on my laptop as follow:

Before
Benchmark                        (clusterSize)  (fsync)  Mode  Cnt    Score   Error  Units
SqlJoinBenchmark.leftHashJoin                1    false  avgt   20  122.215 ± 0.768  ms/op
SqlJoinBenchmark.leftMergeJoin               1    false  avgt   20  167.923 ± 1.183  ms/op
SqlJoinBenchmark.leftNestedJoin              1    false  avgt   20  208.322 ± 1.220  ms/op

After Projection Fusion
Benchmark                        (clusterSize)  (fsync)  Mode  Cnt    Score   Error  Units
SqlJoinBenchmark.leftHashJoin                1    false  avgt   20   72.667 ± 0.647  ms/op
SqlJoinBenchmark.leftMergeJoin               1    false  avgt   20  138.896 ± 1.919  ms/op
SqlJoinBenchmark.leftNestedJoin              1    false  avgt   20  173.719 ± 0.852  ms/op

After Projection Fusion + Field getter optimization
Benchmark                        (clusterSize)  (fsync)  Mode  Cnt    Score   Error  Units
SqlJoinBenchmark.leftHashJoin                1    false  avgt   20   54.473 ± 0.099  ms/op
SqlJoinBenchmark.leftMergeJoin               1    false  avgt   20  115.621 ± 0.931  ms/op
SqlJoinBenchmark.leftNestedJoin              1    false  avgt   20  111.341 ± 0.250  ms/op

Also I run query 64 from TPC-DS with sf=1 to make sure there is no degradation:

Before
Benchmark           (fsync)  (queryId)  Mode  Cnt     Score     Error  Units
TpcdsBenchmark.run    false         64  avgt   20  5046.916 ± 150.744  ms/op

After  Projection Fusion + Field getter optimization
Benchmark           (fsync)  (queryId)  Mode  Cnt     Score     Error  Units
TpcdsBenchmark.run    false         64  avgt   20  4799.201 ± 160.410  ms/op

Thank you for submitting the pull request.

To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:

The Review Checklist

  • Formal criteria: TC status, codestyle, mandatory documentation. Also make sure to complete the following:
    - There is a single JIRA ticket related to the pull request.
    - The web-link to the pull request is attached to the JIRA ticket.
    - The JIRA ticket has the Patch Available state.
    - The description of the JIRA ticket explains WHAT was made, WHY and HOW.
    - The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • Design: new code conforms with the design principles of the components it is added to.
  • Patch quality: patch cannot be split into smaller pieces, its size must be reasonable.
  • Code quality: code is clean and readable, necessary developer documentation is added if needed.
  • Tests code quality: test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.

Notes

- replaced `joinNeedsProjection` method with enumSet
- make `joinWithProjectionOnTopReturnsValidaResults` test sensible to changes in `createJoinProjection`
@korlov42 korlov42 requested a review from AMashenkov March 13, 2025 10:51
@ParameterizedTest
@MethodSource("joinTypesWithRulesToDisable")
@SuppressWarnings("ConcatenationWithEmptyString")
void joinWithProjectionOnTopReturnsValidaResults(JoinType joinType, List<String> rulesToDisable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
void joinWithProjectionOnTopReturnsValidaResults(JoinType joinType, List<String> rulesToDisable) {
void joinWithProjectionOnTopReturnsValidResults(JoinType joinType, List<String> rulesToDisable) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks

checker.check();
}

private static Stream<Arguments> joinTypesWithRulesToDisable() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this is second reincarnation of ItAggregatesTest#makePermutations - if so, can we merge them ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we won't get rid of joinTypesWithRulesToDisable because it creates permutation of join algorithms with combinations of rules to disable while ItAggregatesTest#makePermutations only creates combination of rules to disable. We can replace three-line stream

               List<String> rulesToDisable = joinConverterRules.stream()
                        .filter(ruleName -> !joinAlgo.equals(ruleName))
                        .collect(Collectors.toList())

with a single method call, but the amount of changes required to refactor ItAggregatesTest#makePermutations as library function simply makes the effort doesn't worth it.

If you insists, I would propose to do it as follow up ticket though

Copy link
Contributor

Choose a reason for hiding this comment

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

No, i`m not insist, plz proceed

# Conflicts:
#	modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/ExecutionTest.java
@korlov42 korlov42 merged commit 31e86cf into apache:main Mar 17, 2025
1 check passed
@korlov42 korlov42 deleted the ignite-24196 branch March 17, 2025 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants