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

Fix: test_generate_general_rule_16 #48

Closed
wants to merge 1 commit into from
Closed

Conversation

HazelYuAhiru
Copy link
Collaborator

@HazelYuAhiru HazelYuAhiru commented Sep 25, 2024

Changes Made

  • Make sure no duplicate names appear in patternTable and rewriteTable in tables method.
  • Add another special case in tables method.

Testing

  • Passed all existing test cases defined under test

@HazelYuAhiru HazelYuAhiru added the bug Something isn't working label Sep 25, 2024
@HazelYuAhiru HazelYuAhiru self-assigned this Sep 25, 2024
@HazelYuAhiru HazelYuAhiru linked an issue Sep 25, 2024 that may be closed by this pull request
@@ -2162,7 +2162,7 @@ def test_generate_general_rule_16():

q0_rule, q1_rule = unify_variable_names(rule['pattern'], rule['rewrite'])
assert q0_rule== "SELECT <x1>, <x2>, <x3>, <x4>, <x5>, <x6> FROM <x7> WHERE <x2> IN (SELECT <x2> FROM <x7> WHERE <x6> = <x8> AND <x3> = <x9>) ORDER BY <x2>, <x3>"
assert q1_rule == "SELECT <x10>.<x1>, <x10>.<x2>, <x10>.<x3>, <x10>.<x4>, <x10>.<x5>, <x10>.<x6> FROM <x10> JOIN <x11> ON <x11>.<x2> = <x10>.<x2> WHERE <x11>.<x6> = <x8> AND <x11>.<x3> = <x9> ORDER BY <x10>.<x2>, <x10>.<x3>"
assert q1_rule == "SELECT <x7>.<x1>, <x7>.<x2>, <x7>.<x3>, <x7>.<x4>, <x7>.<x5>, <x7>.<x6> FROM <x7> JOIN <x10> ON <x10>.<x2> = <x7>.<x2> WHERE <x10>.<x6> = <x8> AND <x10>.<x3> = <x9> ORDER BY <x7>.<x2>, <x7>.<x3>"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we still have <x10>?

Copy link
Collaborator Author

@HazelYuAhiru HazelYuAhiru Sep 25, 2024

Choose a reason for hiding this comment

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

In the example query, we have FROM historicoestatusrequisicion hist1 JOIN historicoestatusrequisicion hist2. In our current logic, hist2 will be represented as <x10> to indicate that a JOIN is being performed on another table (even though hist1 and hist2 are the same table). As we discussed in July, it's still difficult for QueryBooster to determine if two tables with different alias are the same without refactoring the code. This is only a temporary fix before refactoring the code and the user still needs to manually replace <x10> to make the rule meaningful in a pairwise comparison 😢

@baiqiushi
Copy link
Contributor

baiqiushi commented Sep 26, 2024 via email

@HazelYuAhiru
Copy link
Collaborator Author

Close this PR as discussed

@HazelYuAhiru HazelYuAhiru deleted the fix/new_var branch September 30, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] [BE] generate_general_rule failed tests
2 participants