Support SHOW TABLES LIKE pattern and Where expr #1518
Conversation
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
|
Hello @mapleFU, 🎉 Thank you for opening the pull request! 🎉 |
|
@mapleFU LGTM, better to add a stateless test in |
Codecov Report
@@ Coverage Diff @@
## master #1518 +/- ##
=======================================
Coverage 72% 73%
=======================================
Files 521 528 +7
Lines 31533 32229 +696
=======================================
+ Hits 22997 23746 +749
+ Misses 8536 8483 -53
Continue to review full report at Codecov.
|
| Ok(DfStatement::ShowTables(DfShowTables)) | ||
| let tok = self.parser.next_token(); | ||
| match &tok { | ||
| Token::EOF => Ok(DfStatement::ShowTables(DfShowTables::All)), |
There was a problem hiding this comment.
What happens to the following SQL?
SHOW TABLES ;
SHOW TABLES -- commentThere was a problem hiding this comment.
I will add some tests and check if it's ok tonight.
| self.ctx.get_current_database(), i, | ||
| ) | ||
| } | ||
| DfShowTables::Where(e) => { |
There was a problem hiding this comment.
What happens to the following SQL?
SHOW TABLES WHERE 1 = 1 OR 1 = 1
There was a problem hiding this comment.
What happens to the following SQL?
SHOW TABLES WHERE 1 = 1 OR 1 = 1
It's ok, we don't care about it, just let it be any complex expr. The optimize / select executor will handle that.
There was a problem hiding this comment.
According to MySQL standard,parse_expr can handle all of them: https://dev.mysql.com/doc/refman/5.7/en/expressions.html
Buf I didn't check the code in sqlparse-rs, so I cannot guarantee it works well.
There was a problem hiding this comment.
May this change the behavior of the query?
After format:
SELECT name FROM system.tables where database = '{}' AND 1 = 1 OR 1 = 1 ORDER BY database, name
There was a problem hiding this comment.
May this change the behavior of the query?
After format:
SELECT name FROM system.tables where database = '{}' AND 1 = 1 OR 1 = 1 ORDER BY database, name
Got It. Sorry for misunderstanding this case! I will adding tests about it in stateless test.
There was a problem hiding this comment.
evaluation proceeds left to right, with the exception that assignments evaluate right to left
According to https://dev.mysql.com/doc/refman/8.0/en/operator-precedence.html , it will not return all tables. But I think maybe it's proper to build sql like:
SELECT name FROM system.tables where database = '{}' AND (1 = 1 OR 1 = 1) ORDER BY database, name
@zhang2014 do you think it's ok?
|
@zhang2014 @sundy-li Sorry for fixing the problem so late! I add some tests in There are some cases:
|
|
CI Passed |
I hereby agree to the terms of the CLA available at: https://datafuse.rs/policies/cla/
Summary
Summary about this PR
This pr supports
like 'pattern'andwhere exprinshow tables. I use some interface of sqlparse, and I don't know does I really catch it.Changelog
Related Issues
Fixes #1388 #1389
Test Plan
Unit Tests