-
Notifications
You must be signed in to change notification settings - Fork 92
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
Feature: support shadow type match regex (#365) #405
Conversation
1. create shadow tables in init.sql & sharding.sql 2. hide shadow tables for "show tables" command 3. impl shadow match hint rule (only select) 4. support shadow type match regex (only select)
pkg/runtime/ast/expression_atom.go
Outdated
@@ -132,7 +132,7 @@ func (u *UnaryExpressionAtom) Accept(visitor Visitor) (interface{}, error) { | |||
} | |||
|
|||
func (u *UnaryExpressionAtom) IsOperatorNot() bool { | |||
switch u.Operator { | |||
switch strings.ToUpper(strings.Trim(u.Operator, " ")) { |
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.
Use TrimSpace
instead.
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.
done
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.
pls add ut
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.
looks like need add create table script
see sharding.sql |
add integration test for shadow tables
add integration test for shadow tables |
Test Cases:
SELECT name FROM student WHERE uid = 1; //sharding
SELECT name FROM student WHERE name = 'lilei'; //fullscan
SELECT name FROM student WHERE uid = 1 and name = 'lilei'; //sharding
SELECT name FROM student WHERE uid = 1 or name = 'lilei'; //fullscan
/*A! shadow(shadow) */ SELECT name FROM student WHERE uid = 1; //sharding shadow tables
/*A! shadow(shadow) */ SELECT name FROM student WHERE name = 'lilei'; //fullscan shadow tables
/*A! shadow(shadow) */ SELECT name FROM student WHERE uid = 1 and name = 'lilei'; //sharding shadow tables
/*A! shadow(shadow) */ SELECT name FROM student WHERE uid = 1 or name = 'lilei'; //fullscan shadow tables
regex:only support eq & ne
SELECT name FROM student WHERE name = 'hanmeimei'; //fullscan shadow tables
SELECT name FROM student WHERE uid = 1 and name = 'hanmeimei'; //sharding shadow tables
SELECT name FROM student WHERE uid = 1 or name = 'hanmeimei'; //fullscan shadow tables
SELECT name FROM student WHERE NOT name = 'hanmeimei'; //fullscan
What this PR does:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: