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

Feature: support shadow type match regex (#365) #405

Merged
merged 2 commits into from
Sep 12, 2022
Merged

Feature: support shadow type match regex (#365) #405

merged 2 commits into from
Sep 12, 2022

Conversation

csynineyang
Copy link
Contributor

  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)

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?:


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)
@@ -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, " ")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use TrimSpace instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@jjeffcaii jjeffcaii left a comment

Choose a reason for hiding this comment

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

pls add ut

@dongzl dongzl added the shadow Shadow table. label Sep 6, 2022
Copy link
Contributor

@Lvnszn Lvnszn left a 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

@csynineyang
Copy link
Contributor Author

looks like need add create table script

see sharding.sql

add integration test for shadow tables
@csynineyang
Copy link
Contributor Author

pls add ut

add integration test for shadow tables

@jjeffcaii jjeffcaii merged commit b445406 into arana-db:feat/shadow Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shadow Shadow table.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants