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

Add join table reference check in JOIN ON clause #17460

Conversation

rmarduga
Copy link
Contributor

Often times, while specifying the joining condition in JOIN ON clause,
users make mistakes and not referencing the joining table along side
with other table in join condition that result in performance issue due
to conditional join resulting in CROSS JOIN.

This change will extend the number of cases when user is shown the
PERFORMANCE_WARNING when JOIN ON clause misses the comparison expression
with joining table and other table. Specifically, it covers the cases
when user does not explicitly refer to the relation through table name
or alias in JOIN ON clause.

Resolves:#17382
See also: #17333

== NO RELEASE NOTE ==

Copy link
Contributor

@kaikalur kaikalur left a comment

Choose a reason for hiding this comment

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

Nice!

Comment on lines 1775 to 1776
String warningMessage = tableName.isPresent()
?
Copy link
Contributor

Choose a reason for hiding this comment

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

put ? to the end of last line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 1782 to 1783
tableName.get()))
:
Copy link
Contributor

Choose a reason for hiding this comment

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

put : to the end of the last line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@highker highker self-assigned this Mar 11, 2022
rightTableName = ((Table) rightRelation).getName().toString();
else if (relation instanceof AliasedRelation) {
AliasedRelation aliasedRelation = (AliasedRelation) relation;
if (aliasedRelation.getRelation() instanceof Table) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can call tryGetTable here on the aliasedRelation.getRelation()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not see tryGetTable() method anywhere, only tryGetTableName(). And you are pointing to the body of tryGetTableName().

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah tryGetTableName, it could have kept the code cleaner. Anyways @highker merged the PR.

Often times, while specifying the joining condition in JOIN ON clause,
users make mistakes and not referencing the joining table along side
with other table in join condition that result in performance issue due
to conditional join resulting in CROSS JOIN.

This change will extend the number of cases when user is shown the
PERFORMANCE_WARNING when JOIN ON clause misses the comparison expression
with joining table and other table. Specifically, it covers the cases
when  user does not explicitly refer to the relation through table name
or alias in JOIN ON clause.

Resolves:prestodb#17382
See also: prestodb#17333
@rmarduga rmarduga force-pushed the Add_join_table_reference_check_in_JOIN_ON_clause branch from b08b8dc to 97db2f2 Compare March 11, 2022 14:23
@highker highker merged commit 5790022 into prestodb:master Mar 11, 2022
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.

None yet

4 participants