-
Notifications
You must be signed in to change notification settings - Fork 3
[FIX] Infinite Loop in Variablization of Subtrees #77
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1935,9 +1935,14 @@ def test_generate_general_rule_8(): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert StringUtil.strim(RuleGenerator._fingerPrint(rule['pattern'])) == StringUtil.strim(RuleGenerator._fingerPrint(''' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CAST(<x1> AS DATE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ''')) or StringUtil.strim(RuleGenerator._fingerPrint(rule['rewrite'])) == StringUtil.strim(RuleGenerator._fingerPrint(''' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CAST(<<y>> AS DATE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ''')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert StringUtil.strim(RuleGenerator._fingerPrint(rule['rewrite'])) == StringUtil.strim(RuleGenerator._fingerPrint(''' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <x1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ''')) or StringUtil.strim(RuleGenerator._fingerPrint(rule['rewrite'])) == StringUtil.strim(RuleGenerator._fingerPrint(''' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <<y>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ''')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1936
to
1948
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert StringUtil.strim(RuleGenerator._fingerPrint(rule['pattern'])) == StringUtil.strim(RuleGenerator._fingerPrint(''' | |
| CAST(<x1> AS DATE) | |
| ''')) or StringUtil.strim(RuleGenerator._fingerPrint(rule['rewrite'])) == StringUtil.strim(RuleGenerator._fingerPrint(''' | |
| CAST(<<y>> AS DATE) | |
| ''')) | |
| assert StringUtil.strim(RuleGenerator._fingerPrint(rule['rewrite'])) == StringUtil.strim(RuleGenerator._fingerPrint(''' | |
| <x1> | |
| ''')) or StringUtil.strim(RuleGenerator._fingerPrint(rule['rewrite'])) == StringUtil.strim(RuleGenerator._fingerPrint(''' | |
| <<y>> | |
| ''')) | |
| pattern_fp = StringUtil.strim(RuleGenerator._fingerPrint(rule['pattern'])) | |
| rewrite_fp = StringUtil.strim(RuleGenerator._fingerPrint(rule['rewrite'])) | |
| expected_pattern_fps = ( | |
| StringUtil.strim(RuleGenerator._fingerPrint(''' | |
| CAST(<x1> AS DATE) | |
| ''')), | |
| StringUtil.strim(RuleGenerator._fingerPrint(''' | |
| CAST(<<y>> AS DATE) | |
| ''')) | |
| ) | |
| expected_rewrite_fps = ( | |
| StringUtil.strim(RuleGenerator._fingerPrint(''' | |
| <x1> | |
| ''')), | |
| StringUtil.strim(RuleGenerator._fingerPrint(''' | |
| <<y>> | |
| ''')) | |
| ) | |
| assert pattern_fp in expected_pattern_fps | |
| assert rewrite_fp in expected_rewrite_fps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition
len(subtree) == 1assumes a specific structure for variablized subtrees. This magic number should be documented or replaced with a more explicit check that describes what constitutes a variablized subtree structure.