-
Notifications
You must be signed in to change notification settings - Fork 25.7k
SQL: Fix RLIKE bug and improve testing for RLIKE statement #40354
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
x-pack/plugin/sql/qa/src/main/resources/filter.csv-spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| // | ||
| // Filter | ||
| // | ||
|
|
||
| whereFieldWithRLikeMatch | ||
| SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 AND last_name RLIKE 'S.*'; | ||
|
|
||
| l:s | ||
| --------------- | ||
| Simmel | ||
| ; | ||
|
|
||
| whereFieldWithNotRLikeMatch | ||
| SELECT last_name, first_name FROM "test_emp" WHERE emp_no < 10020 AND first_name NOT RLIKE 'Ma.*' ORDER BY first_name LIMIT 5; | ||
|
|
||
| last_name:s | first_name:s | ||
| ---------------+--------------- | ||
| Preusig |Anneke | ||
| Genin |Berni | ||
| Simmel |Bezalel | ||
| Koblick |Chirstian | ||
| Bouloucos |Cristinel | ||
| ; | ||
|
|
||
| whereFieldWithRLikeMatchNot | ||
| SELECT last_name AS L, emp_no FROM "test_emp" WHERE NOT (emp_no < 10003 AND L NOT RLIKE 'K.*') ORDER BY emp_no LIMIT 5; | ||
|
|
||
| L:s | emp_no:i | ||
| ---------------+--------------- | ||
| Bamford |10003 | ||
| Koblick |10004 | ||
| Maliniak |10005 | ||
| Preusig |10006 | ||
| Zielinski |10007 | ||
| ; | ||
|
|
||
| whereFieldOnMatchWithAndAndOr | ||
| SELECT last_name l, gender g FROM "test_emp" WHERE (last_name RLIKE 'K.*' OR gender = 'F') AND emp_no < 10050 ORDER BY last_name; | ||
|
|
||
| l:s | g:s | ||
| ---------------+--------------- | ||
| Casley |F | ||
| Kalloufi |M | ||
| Koblick |M | ||
| Lenart |F | ||
| Meriste |F | ||
| Montemayor |F | ||
| Peac |F | ||
| Pettey |F | ||
| Preusig |F | ||
| Reistad |F | ||
| Reistad |F | ||
| Simmel |F | ||
| Stamatiou |F | ||
| Tramer |F | ||
| Zielinski |F | ||
| ; | ||
|
|
||
| whereFieldWithRLikeAndGroupByOrderBy | ||
| SELECT last_name l, gender g, COUNT(*) c, MAX(salary) AS sal FROM "test_emp" WHERE emp_no < 10050 AND (last_name RLIKE 'B.*' OR gender = 'F') GROUP BY g, l ORDER BY sal; | ||
|
|
||
| l:s | g:s | c:l | sal:i | ||
| ---------------+---------------+---------------+--------------- | ||
| Berztiss |M |1 |28336 | ||
| Stamatiou |F |1 |30404 | ||
| Brender |M |1 |36051 | ||
| Meriste |F |1 |37112 | ||
| Tramer |F |1 |37853 | ||
| Casley |F |1 |39728 | ||
| Montemayor |F |1 |47896 | ||
| Bridgland |null |1 |48942 | ||
| Simmel |F |1 |56371 | ||
| Lenart |F |1 |56415 | ||
| Bouloucos |null |1 |58715 | ||
| Preusig |F |1 |60335 | ||
| Bamford |M |1 |61805 | ||
| Pettey |F |1 |64675 | ||
| Peac |F |1 |66174 | ||
| Reistad |F |2 |73851 | ||
| Zielinski |F |1 |74572 | ||
| ; | ||
|
|
||
| whereFieldWithRLikeAndNotRLike | ||
| SELECT COUNT(*), last_name AS f FROM test_emp WHERE last_name RLIKE '.*o.*' AND last_name NOT RLIKE '.*f.*' GROUP BY f HAVING COUNT(*) > 1; | ||
|
|
||
| COUNT(*):l | f:s | ||
| ---------------+--------------- | ||
| 2 |Lortz | ||
| ; | ||
|
|
||
| whereInlineRLike | ||
| SELECT emp_no FROM test_emp WHERE 'aaabbb' RLIKE 'aa+b+' AND 'aaabbb' NOT RLIKE 'a++c+' AND emp_no < 10080 ORDER BY emp_no DESC LIMIT 5; | ||
|
|
||
| emp_no:i | ||
| --------------- | ||
| 10079 | ||
| 10078 | ||
| 10077 | ||
| 10076 | ||
| 10075 | ||
| ; | ||
|
|
||
| whereInlineRLikeAndCount_1 | ||
| SELECT COUNT(*), TRUNCATE(emp_no, -2) t FROM test_emp WHERE 'aaabbb' RLIKE '.....?.?' AND 'aaabbb' NOT RLIKE 'aa?bb?' GROUP BY TRUNCATE(emp_no, -2) ORDER BY t ASC; | ||
|
|
||
| COUNT(*):l | t:i | ||
| ---------------+--------------- | ||
| 99 |10000 | ||
| 1 |10100 | ||
| ; | ||
|
|
||
| whereInlineRLikeAndCount_2 | ||
| SELECT COUNT(*), TRUNCATE(emp_no, -2) t FROM test_emp WHERE 'aaabbb' RLIKE 'a{2,}b{2,}' AND 'aaabbb' NOT RLIKE 'a{4,6}b{4,6}' GROUP BY TRUNCATE(emp_no, -2) ORDER BY t ASC; | ||
|
|
||
| COUNT(*):l | t:i | ||
| ---------------+--------------- | ||
| 99 |10000 | ||
| 1 |10100 | ||
| ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
unnecessary whitespace