This is an automated email from the ASF dual-hosted git repository.
jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new e27f4ad2a1f Add DistSQL syntax to `mask rule` (#23154)
e27f4ad2a1f is described below
commit e27f4ad2a1f63554664b9e56def095605db7a8fa
Author: Zichao <[email protected]>
AuthorDate: Thu Dec 29 20:44:46 2022 +1300
Add DistSQL syntax to `mask rule` (#23154)
* Add DistSQL syntax to `mask rule`
* Add DistSQL syntax to `mask rule`
---
features/mask/{ => distsql/handler}/pom.xml | 31 +++++--
...here.distsql.handler.resultset.DistSQLResultSet | 19 ++++
...re.distsql.handler.update.RuleDefinitionUpdater | 20 +++++
features/mask/distsql/parser/pom.xml | 69 ++++++++++++++
.../src/main/antlr4/imports/mask/Alphabet.g4 | 48 ++++++++++
.../src/main/antlr4/imports/mask/BaseRule.g4 | 52 +++++++++++
.../parser/src/main/antlr4/imports/mask/Keyword.g4 | 100 +++++++++++++++++++++
.../src/main/antlr4/imports/mask/Literals.g4 | 50 +++++++++++
.../src/main/antlr4/imports/mask/RDLStatement.g4 | 52 +++++++++++
.../src/main/antlr4/imports/mask/RQLStatement.g4 | 32 +++++++
.../parser/src/main/antlr4/imports/mask/Symbol.g4 | 61 +++++++++++++
.../distsql/parser/autogen/MaskDistSQLStatement.g4 | 29 ++++++
.../mask/distsql/parser/core/MaskDistSQLLexer.java | 32 +++++++
.../distsql/parser/core/MaskDistSQLParser.java | 40 +++++++++
.../parser/core/MaskDistSQLStatementVisitor.java | 29 ++++++
.../facade/MaskDistSQLStatementParserFacade.java | 52 +++++++++++
...engine.spi.FeaturedDistSQLStatementParserFacade | 18 ++++
features/mask/{ => distsql}/pom.xml | 9 +-
features/mask/{ => distsql/statement}/pom.xml | 16 ++--
features/mask/pom.xml | 1 +
20 files changed, 742 insertions(+), 18 deletions(-)
diff --git a/features/mask/pom.xml b/features/mask/distsql/handler/pom.xml
similarity index 55%
copy from features/mask/pom.xml
copy to features/mask/distsql/handler/pom.xml
index 3f67bb70b3e..5029c87f132 100644
--- a/features/mask/pom.xml
+++ b/features/mask/distsql/handler/pom.xml
@@ -21,15 +21,32 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-features</artifactId>
+ <artifactId>shardingsphere-mask-distsql</artifactId>
<version>5.3.1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-mask</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-mask-distsql-handler</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>api</module>
- <module>core</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-distsql-handler</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mask-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mask-distsql-statement</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mask-distsql-parser</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.resultset.DistSQLResultSet
b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.resultset.DistSQLResultSet
new file mode 100644
index 00000000000..847d8dbb05d
--- /dev/null
+++
b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.resultset.DistSQLResultSet
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.mask.distsql.handler.query.MaskRuleResultSet
+org.apache.shardingsphere.mask.distsql.handler.query.CountMaskRuleResultSet
diff --git
a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.update.RuleDefinitionUpdater
b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.update.RuleDefinitionUpdater
new file mode 100644
index 00000000000..d736f522cef
--- /dev/null
+++
b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.update.RuleDefinitionUpdater
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.mask.distsql.handler.update.CreateMaskRuleStatementUpdater
+org.apache.shardingsphere.mask.distsql.handler.update.AlterMaskRuleStatementUpdater
+org.apache.shardingsphere.mask.distsql.handler.update.DropMaskRuleStatementUpdater
diff --git a/features/mask/distsql/parser/pom.xml
b/features/mask/distsql/parser/pom.xml
new file mode 100644
index 00000000000..ac46397931f
--- /dev/null
+++ b/features/mask/distsql/parser/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mask-distsql</artifactId>
+ <version>5.3.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>shardingsphere-mask-distsql-parser</artifactId>
+ <name>${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-sql-parser-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-distsql-parser</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-mask-distsql-statement</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>antlr</id>
+ <goals>
+ <goal>antlr4</goal>
+ </goals>
+ <configuration>
+
<libDirectory>src/main/antlr4/imports/mask/</libDirectory>
+ <listener>false</listener>
+ <visitor>true</visitor>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/features/mask/distsql/parser/src/main/antlr4/imports/mask/Alphabet.g4
b/features/mask/distsql/parser/src/main/antlr4/imports/mask/Alphabet.g4
new file mode 100644
index 00000000000..f7603cc7e63
--- /dev/null
+++ b/features/mask/distsql/parser/src/main/antlr4/imports/mask/Alphabet.g4
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Alphabet;
+
+FOR_GENERATOR: 'DO NOT MATCH ANY THING, JUST FOR GENERATOR';
+
+fragment A: [Aa];
+fragment B: [Bb];
+fragment C: [Cc];
+fragment D: [Dd];
+fragment E: [Ee];
+fragment F: [Ff];
+fragment G: [Gg];
+fragment H: [Hh];
+fragment I: [Ii];
+fragment J: [Jj];
+fragment K: [Kk];
+fragment L: [Ll];
+fragment M: [Mm];
+fragment N: [Nn];
+fragment O: [Oo];
+fragment P: [Pp];
+fragment Q: [Qq];
+fragment R: [Rr];
+fragment S: [Ss];
+fragment T: [Tt];
+fragment U: [Uu];
+fragment V: [Vv];
+fragment W: [Ww];
+fragment X: [Xx];
+fragment Y: [Yy];
+fragment Z: [Zz];
+fragment UL_: '_';
diff --git
a/features/mask/distsql/parser/src/main/antlr4/imports/mask/BaseRule.g4
b/features/mask/distsql/parser/src/main/antlr4/imports/mask/BaseRule.g4
new file mode 100644
index 00000000000..413275f30db
--- /dev/null
+++ b/features/mask/distsql/parser/src/main/antlr4/imports/mask/BaseRule.g4
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+grammar BaseRule;
+
+import Symbol, Keyword, Literals;
+
+literal
+ : STRING_ | (MINUS_)? INT_
+ ;
+
+algorithmDefinition
+ : TYPE LP_ NAME EQ_ algorithmTypeName (COMMA_ propertiesDefinition)? RP_
+ ;
+
+algorithmTypeName
+ : buildinAlgorithmTypeName | STRING_
+ ;
+
+buildinAlgorithmTypeName
+ : MD5
+ ;
+
+propertiesDefinition
+ : PROPERTIES LP_ properties? RP_
+ ;
+
+properties
+ : property (COMMA_ property)*
+ ;
+
+property
+ : key=STRING_ EQ_ value=literal
+ ;
+
+ruleName
+ : IDENTIFIER_
+ ;
diff --git
a/features/mask/distsql/parser/src/main/antlr4/imports/mask/Keyword.g4
b/features/mask/distsql/parser/src/main/antlr4/imports/mask/Keyword.g4
new file mode 100644
index 00000000000..ec9a9763da7
--- /dev/null
+++ b/features/mask/distsql/parser/src/main/antlr4/imports/mask/Keyword.g4
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Keyword;
+
+import Alphabet;
+
+WS
+ : [ \t\r\n] + ->skip
+ ;
+
+CREATE
+ : C R E A T E
+ ;
+
+ALTER
+ : A L T E R
+ ;
+
+DROP
+ : D R O P
+ ;
+
+SHOW
+ : S H O W
+ ;
+
+RULE
+ : R U L E
+ ;
+
+FROM
+ : F R O M
+ ;
+
+MASK
+ : M A S K
+ ;
+
+TYPE
+ : T Y P E
+ ;
+
+NAME
+ : N A M E
+ ;
+
+PROPERTIES
+ : P R O P E R T I E S
+ ;
+
+COLUMN
+ : C O L U M N
+ ;
+
+RULES
+ : R U L E S
+ ;
+
+TABLE
+ : T A B L E
+ ;
+
+COLUMNS
+ : C O L U M N S
+ ;
+
+IF
+ : I F
+ ;
+
+EXISTS
+ : E X I S T S
+ ;
+
+COUNT
+ : C O U N T
+ ;
+
+NOT
+ : N O T
+ ;
+
+MD5
+ : M D [5]
+ ;
diff --git
a/features/mask/distsql/parser/src/main/antlr4/imports/mask/Literals.g4
b/features/mask/distsql/parser/src/main/antlr4/imports/mask/Literals.g4
new file mode 100644
index 00000000000..c6557635906
--- /dev/null
+++ b/features/mask/distsql/parser/src/main/antlr4/imports/mask/Literals.g4
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Literals;
+
+import Alphabet, Symbol;
+
+IDENTIFIER_
+ : [A-Za-z_$0-9]*?[A-Za-z_$]+?[A-Za-z_$0-9]*
+ | BQ_ ~'`'+ BQ_
+ ;
+
+STRING_
+ : (DQ_ ('\\'. | '""' | ~('"' | '\\'))* DQ_)
+ | (SQ_ ('\\'. | '\'\'' | ~('\'' | '\\'))* SQ_)
+ ;
+
+INT_
+ : [0-9]+
+ ;
+
+HEX_
+ : [0-9a-fA-F]
+ ;
+
+NUMBER_
+ : INT_? DOT_? INT_ (E (PLUS_ | MINUS_)? INT_)?
+ ;
+
+HEXDIGIT_
+ : '0x' HEX_+ | 'X' SQ_ HEX_+ SQ_
+ ;
+
+BITNUM_
+ : '0b' ('0' | '1')+ | B SQ_ ('0' | '1')+ SQ_
+ ;
diff --git
a/features/mask/distsql/parser/src/main/antlr4/imports/mask/RDLStatement.g4
b/features/mask/distsql/parser/src/main/antlr4/imports/mask/RDLStatement.g4
new file mode 100644
index 00000000000..59d61cdc900
--- /dev/null
+++ b/features/mask/distsql/parser/src/main/antlr4/imports/mask/RDLStatement.g4
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+grammar RDLStatement;
+
+import BaseRule;
+
+createMaskRule
+ : CREATE MASK TABLE? RULE ifNotExists? maskRuleDefinition (COMMA_
maskRuleDefinition)*
+ ;
+
+alterMaskRule
+ : ALTER MASK TABLE? RULE maskRuleDefinition (COMMA_ maskRuleDefinition)*
+ ;
+
+dropMaskRule
+ : DROP MASK TABLE? RULE ifExists? ruleName (COMMA_ ruleName)*
+ ;
+
+maskRuleDefinition
+ : ruleName LP_ COLUMNS LP_ columnDefinition (COMMA_ columnDefinition)* RP_
RP_
+ ;
+
+columnDefinition
+ : NAME EQ_ columnName COMMA_ algorithmDefinition
+ ;
+
+columnName
+ : IDENTIFIER_
+ ;
+
+ifExists
+ : IF EXISTS
+ ;
+
+ifNotExists
+ : IF NOT EXISTS
+ ;
diff --git
a/features/mask/distsql/parser/src/main/antlr4/imports/mask/RQLStatement.g4
b/features/mask/distsql/parser/src/main/antlr4/imports/mask/RQLStatement.g4
new file mode 100644
index 00000000000..228b0377e02
--- /dev/null
+++ b/features/mask/distsql/parser/src/main/antlr4/imports/mask/RQLStatement.g4
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+grammar RQLStatement;
+
+import BaseRule;
+
+showMaskRules
+ : SHOW MASK TABLE? (RULE ruleName | RULES) (FROM databaseName)?
+ ;
+
+countMaskRule
+ : COUNT MASK RULE (FROM databaseName)?
+ ;
+
+databaseName
+ : IDENTIFIER_
+ ;
diff --git
a/features/mask/distsql/parser/src/main/antlr4/imports/mask/Symbol.g4
b/features/mask/distsql/parser/src/main/antlr4/imports/mask/Symbol.g4
new file mode 100644
index 00000000000..90dba68ccfc
--- /dev/null
+++ b/features/mask/distsql/parser/src/main/antlr4/imports/mask/Symbol.g4
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+lexer grammar Symbol;
+
+AND_: '&&';
+OR_: '||';
+NOT_: '!';
+TILDE_: '~';
+VERTICALBAR_: '|';
+AMPERSAND_: '&';
+SIGNEDLEFTSHIFT_: '<<';
+SIGNEDRIGHTSHIFT_: '>>';
+CARET_: '^';
+MOD_: '%';
+COLON_: ':';
+PLUS_: '+';
+MINUS_: '-';
+ASTERISK_: '*';
+SLASH_: '/';
+BACKSLASH_: '\\';
+DOT_: '.';
+DOTASTERISK_: '.*';
+SAFEEQ_: '<=>';
+DEQ_: '==';
+EQ_: '=';
+NEQ_: '<>' | '!=';
+GT_: '>';
+GTE_: '>=';
+LT_: '<';
+LTE_: '<=';
+POUND_: '#';
+LP_: '(';
+RP_: ')';
+LBE_: '{';
+RBE_: '}';
+LBT_: '[';
+RBT_: ']';
+COMMA_: ',';
+DQ_: '"';
+SQ_: '\'';
+BQ_: '`';
+QUESTION_: '?';
+AT_: '@';
+SEMI_: ';';
+JSONSEPARATOR_: '->>';
+UL_: '_';
diff --git
a/features/mask/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/MaskDistSQLStatement.g4
b/features/mask/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/MaskDistSQLStatement.g4
new file mode 100644
index 00000000000..3a135a884b4
--- /dev/null
+++
b/features/mask/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/MaskDistSQLStatement.g4
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+grammar MaskDistSQLStatement;
+
+import Symbol, RDLStatement, RQLStatement;
+
+execute
+ : (createMaskRule
+ | alterMaskRule
+ | dropMaskRule
+ | showMaskRules
+ | countMaskRule
+ ) SEMI?
+ ;
diff --git
a/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLLexer.java
b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLLexer.java
new file mode 100644
index 00000000000..db42d76dd5b
--- /dev/null
+++
b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLLexer.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.distsql.parser.core;
+
+import org.antlr.v4.runtime.CharStream;
+import
org.apache.shardingsphere.distsql.parser.autogen.MaskDistSQLStatementLexer;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLLexer;
+
+/**
+ * SQL lexer for mask DistSQL.
+ */
+public final class MaskDistSQLLexer extends MaskDistSQLStatementLexer
implements SQLLexer {
+
+ public MaskDistSQLLexer(final CharStream input) {
+ super(input);
+ }
+}
diff --git
a/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLParser.java
b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLParser.java
new file mode 100644
index 00000000000..43589551c65
--- /dev/null
+++
b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLParser.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.distsql.parser.core;
+
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.TokenStream;
+import
org.apache.shardingsphere.distsql.parser.autogen.MaskDistSQLStatementParser;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
+import org.apache.shardingsphere.sql.parser.core.ParseASTNode;
+
+/**
+ * SQL parser for mask DistSQL.
+ */
+public final class MaskDistSQLParser extends MaskDistSQLStatementParser
implements SQLParser {
+
+ public MaskDistSQLParser(final TokenStream input) {
+ super(input);
+ }
+
+ @Override
+ public ASTNode parse() {
+ return new ParseASTNode(execute(), (CommonTokenStream)
getTokenStream());
+ }
+}
diff --git
a/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java
b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java
new file mode 100644
index 00000000000..771eaa6c83e
--- /dev/null
+++
b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/core/MaskDistSQLStatementVisitor.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.distsql.parser.core;
+
+import
org.apache.shardingsphere.distsql.parser.autogen.MaskDistSQLStatementBaseVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
+
+/**
+ * SQL statement visitor for mask DistSQL.
+ */
+public final class MaskDistSQLStatementVisitor extends
MaskDistSQLStatementBaseVisitor<ASTNode> implements SQLVisitor {
+
+}
diff --git
a/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/facade/MaskDistSQLStatementParserFacade.java
b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/facade/MaskDistSQLStatementParserFacade.java
new file mode 100644
index 00000000000..b697d264e70
--- /dev/null
+++
b/features/mask/distsql/parser/src/main/java/org/apache/shardingsphere/mask/distsql/parser/facade/MaskDistSQLStatementParserFacade.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.distsql.parser.facade;
+
+import
org.apache.shardingsphere.distsql.parser.engine.spi.FeaturedDistSQLStatementParserFacade;
+import org.apache.shardingsphere.mask.distsql.parser.core.MaskDistSQLLexer;
+import org.apache.shardingsphere.mask.distsql.parser.core.MaskDistSQLParser;
+import
org.apache.shardingsphere.mask.distsql.parser.core.MaskDistSQLStatementVisitor;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLLexer;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
+
+/**
+ * SQL parser facade for mask DistSQL statement.
+ */
+public final class MaskDistSQLStatementParserFacade implements
FeaturedDistSQLStatementParserFacade {
+
+ @Override
+ public Class<? extends SQLLexer> getLexerClass() {
+ return MaskDistSQLLexer.class;
+ }
+
+ @Override
+ public Class<? extends SQLParser> getParserClass() {
+ return MaskDistSQLParser.class;
+ }
+
+ @Override
+ public Class<? extends SQLVisitor> getVisitorClass() {
+ return MaskDistSQLStatementVisitor.class;
+ }
+
+ @Override
+ public String getType() {
+ return "mask";
+ }
+}
diff --git
a/features/mask/distsql/parser/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.parser.engine.spi.FeaturedDistSQLStatementParserFacade
b/features/mask/distsql/parser/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.parser.engine.spi.FeaturedDistSQLStatementParserFacade
new file mode 100644
index 00000000000..ed5fe776af1
--- /dev/null
+++
b/features/mask/distsql/parser/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.parser.engine.spi.FeaturedDistSQLStatementParserFacade
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.mask.distsql.parser.facade.MaskDistSQLStatementParserFacade
diff --git a/features/mask/pom.xml b/features/mask/distsql/pom.xml
similarity index 86%
copy from features/mask/pom.xml
copy to features/mask/distsql/pom.xml
index 3f67bb70b3e..c4c1dcf1d22 100644
--- a/features/mask/pom.xml
+++ b/features/mask/distsql/pom.xml
@@ -21,15 +21,16 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-features</artifactId>
+ <artifactId>shardingsphere-mask</artifactId>
<version>5.3.1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-mask</artifactId>
+ <artifactId>shardingsphere-mask-distsql</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>api</module>
- <module>core</module>
+ <module>statement</module>
+ <module>parser</module>
+ <module>handler</module>
</modules>
</project>
diff --git a/features/mask/pom.xml b/features/mask/distsql/statement/pom.xml
similarity index 76%
copy from features/mask/pom.xml
copy to features/mask/distsql/statement/pom.xml
index 3f67bb70b3e..1920fdacefe 100644
--- a/features/mask/pom.xml
+++ b/features/mask/distsql/statement/pom.xml
@@ -21,15 +21,17 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-features</artifactId>
+ <artifactId>shardingsphere-mask-distsql</artifactId>
<version>5.3.1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-mask</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-mask-distsql-statement</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>api</module>
- <module>core</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-distsql-statement</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/features/mask/pom.xml b/features/mask/pom.xml
index 3f67bb70b3e..c7d73dd5c85 100644
--- a/features/mask/pom.xml
+++ b/features/mask/pom.xml
@@ -31,5 +31,6 @@
<modules>
<module>api</module>
<module>core</module>
+ <module>distsql</module>
</modules>
</project>