Skip to content

[native] Disable Nested Loop Join in Prestissimo.#23341

Open
kgpai wants to merge 1 commit intoprestodb:masterfrom
kgpai:disable_sorted_aggregations
Open

[native] Disable Nested Loop Join in Prestissimo.#23341
kgpai wants to merge 1 commit intoprestodb:masterfrom
kgpai:disable_sorted_aggregations

Conversation

@kgpai
Copy link
Copy Markdown
Contributor

@kgpai kgpai commented Jul 31, 2024

Description

This PR disables NestedLoopJoins when converting plans to Velox. This is gated by the property : fail_on_nested_loop_join .

Motivation and Context

Currently there is a bug with Streaming aggregations when the source is a Nested loop join. (#22585)

Impact

Test Plan

Adding test cases.

@kgpai kgpai requested a review from a team as a code owner July 31, 2024 16:53
@kgpai kgpai force-pushed the disable_sorted_aggregations branch from ac84520 to 0005412 Compare July 31, 2024 17:20
@aditi-pandit
Copy link
Copy Markdown
Contributor

aditi-pandit commented Jul 31, 2024

@kgpai @amitkdutta : We have encountered this issue already (#22585). This drastic fix is not needed.

You can correct the grouping behavior to avoid streaming aggregation using #22998
The more elaborate fix is to avoid generating such plans in the optimizer #23315

If there is urgency then #22998 is better for you.

@amitkdutta
Copy link
Copy Markdown
Contributor

@kgpai @amitkdutta : We have encountered this issue already (#22585). This drastic fix is not needed.

You can correct the grouping behavior to avoid streaming aggregation using #22998 The more elaborate fix is to avoid generating such plans in the optimizer #23315

If there is urgency then #22998 is better for you.

CC: @pedroerp @mbasmanova

auto streamable = !node->preGroupedVariables.empty()
&& node->groupingSets.groupingSetCount == 1
&& node->groupingSets.globalGroupingSets.empty();
VELOX_CHECK(!streamable,
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.

Is it possible to just use a regular aggregation instead of failing?

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.

@rschlussel : Yes. You are correct.
There is a nuance though, HashAggregation also has preGrouping related optimizations which streamable should disable.

That is the fix in #22998.

@aditi-pandit
Copy link
Copy Markdown
Contributor

aditi-pandit commented Jul 31, 2024

@kgpai @amitkdutta : We have encountered this issue already (#22585). This drastic fix is not needed.
You can correct the grouping behavior to avoid streaming aggregation using #22998 The more elaborate fix is to avoid generating such plans in the optimizer #23315
If there is urgency then #22998 is better for you.

CC: @pedroerp @mbasmanova

@pedroerp @mbasmanova : For context we had tried fixing the NestedLoopJoin in Velox to maintain the grouping property on LHS as well, but there was lot of overhead to maintain RHS to give such behavior. ref facebookincubator/velox#10048

@kgpai kgpai force-pushed the disable_sorted_aggregations branch from 0005412 to fe2f054 Compare August 1, 2024 18:06
@kgpai kgpai changed the title [WIP] [Native] Disable Streaming aggregations in Prestissimo. [WIP] [Native] Disable Nested Loop Join in Prestissimo. Aug 1, 2024
@kgpai kgpai force-pushed the disable_sorted_aggregations branch from fe2f054 to ff877fc Compare August 1, 2024 18:08
@kgpai
Copy link
Copy Markdown
Contributor Author

kgpai commented Aug 1, 2024

@aditi-pandit Based on inputs from @rschlussel its probably safer to turn off NLJ till its fixed.

@aditi-pandit
Copy link
Copy Markdown
Contributor

@aditi-pandit Based on inputs from @rschlussel its probably safer to turn off NLJ till its fixed.

@kgpai @rschlussel : Agree this is a more conservative fix. Please feel free to go ahead with it if you prefer.

@karteekmurthys

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 1, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff 27a3384...aa5761e.

No notifications.

@facebook-github-bot
Copy link
Copy Markdown
Collaborator

@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@kgpai kgpai force-pushed the disable_sorted_aggregations branch from ff877fc to 28a6819 Compare August 1, 2024 19:00
@facebook-github-bot
Copy link
Copy Markdown
Collaborator

@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

rschlussel
rschlussel previously approved these changes Aug 1, 2024
aditi-pandit
aditi-pandit previously approved these changes Aug 1, 2024
Copy link
Copy Markdown
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @kgpai

@kgpai
Copy link
Copy Markdown
Contributor Author

kgpai commented Aug 1, 2024

I am seeing a couple of failures related to docker compose: https://github.com/prestodb/presto/actions/runs/10204170880/job/28232117475?pr=23341

++ docker-compose version
presto-hive-hadoop2/bin/common.sh: line 79: docker-compose: command not found

@amitkdutta amitkdutta changed the title [WIP] [Native] Disable Nested Loop Join in Prestissimo. [native] Disable Nested Loop Join in Prestissimo. Aug 1, 2024
@kgpai kgpai dismissed stale reviews from aditi-pandit and rschlussel via d84549a August 1, 2024 22:02
@kgpai kgpai force-pushed the disable_sorted_aggregations branch from 28a6819 to d84549a Compare August 1, 2024 22:02
@facebook-github-bot
Copy link
Copy Markdown
Collaborator

@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@kgpai kgpai force-pushed the disable_sorted_aggregations branch 2 times, most recently from 1173acf to c6b6eb3 Compare August 1, 2024 23:13
@kgpai
Copy link
Copy Markdown
Contributor Author

kgpai commented Aug 1, 2024

@rschlussel @amitkdutta @aditi-pandit Please have a look again, I have gated this under a configuration.

@kgpai kgpai force-pushed the disable_sorted_aggregations branch from c6b6eb3 to 092dca3 Compare August 1, 2024 23:21
@facebook-github-bot
Copy link
Copy Markdown
Collaborator

@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@karteekmurthys
Copy link
Copy Markdown
Contributor

karteekmurthys commented Aug 1, 2024

@kgpai Would you please also disable streaming agg when nestedloopjoin is enabled?

cc: @aditi-pandit

@kgpai kgpai force-pushed the disable_sorted_aggregations branch from 092dca3 to 2d2f62a Compare August 1, 2024 23:32
@facebook-github-bot
Copy link
Copy Markdown
Collaborator

@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@kgpai kgpai force-pushed the disable_sorted_aggregations branch from 2d2f62a to 67c4a39 Compare August 2, 2024 00:10
@facebook-github-bot
Copy link
Copy Markdown
Collaborator

@kgpai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@aditi-pandit
Copy link
Copy Markdown
Contributor

aditi-pandit commented Aug 2, 2024

@kgpai Would you please also disable streaming agg when nestedloopjoin is enabled?

cc: @aditi-pandit

@karteekmurthys : Let Krishna proceed with this change to keep it minimal. You can add the correction (disable pre-grouping (not disable streaming)) when !disableNestedLoopJoin in a subsequent PR since you are more familiar with those code-paths.

@kgpai , @amitkdutta

@kgpai kgpai force-pushed the disable_sorted_aggregations branch 6 times, most recently from c028258 to 61cdbb8 Compare August 2, 2024 18:12
@kgpai
Copy link
Copy Markdown
Contributor Author

kgpai commented Aug 2, 2024

Unfortunately there are a lot more tests than I anticipated that depend on NLJ.

@kgpai kgpai force-pushed the disable_sorted_aggregations branch from 61cdbb8 to 076b32d Compare August 2, 2024 19:31
@pedroerp
Copy link
Copy Markdown
Contributor

pedroerp commented Aug 2, 2024

This PR should address the NLJ issue in Velox, so hopefully this won't be needed: facebookincubator/velox#10651

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.

7 participants