This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 b3b34a405a1 [DistSQL] support 'show sharding audit algorithms' (#18842)
b3b34a405a1 is described below
commit b3b34a405a14e8b8ad619f190530ae88269f306f
Author: natehuang <[email protected]>
AuthorDate: Tue Jul 5 11:42:46 2022 +0800
[DistSQL] support 'show sharding audit algorithms' (#18842)
---
.../distsql/syntax/rql/rule-query/sharding.cn.md | 24 ++++++-
.../distsql/syntax/rql/rule-query/sharding.en.md | 22 ++++++
.../ShardingAuditAlgorithmsQueryResultSet.java | 83 ++++++++++++++++++++++
...dingsphere.infra.distsql.query.DistSQLResultSet | 1 +
.../src/main/antlr4/imports/sharding/Keyword.g4 | 4 ++
.../main/antlr4/imports/sharding/RQLStatement.g4 | 4 ++
.../parser/autogen/ShardingDistSQLStatement.g4 | 1 +
.../core/ShardingDistSQLStatementVisitor.java | 7 ++
.../ShowShardingAuditAlgorithmsStatement.java | 31 ++++++++
...ShowShardingAuditAlgorithmsStatementAssert.java | 51 +++++++++++++
.../jaxb/cases/domain/SQLParserTestCases.java | 5 ++
...owShardingAuditAlgorithmsStatementTestCase.java | 36 ++++++++++
.../src/main/resources/case/rql/show.xml | 5 ++
.../src/main/resources/sql/supported/rql/show.xml | 1 +
14 files changed, 274 insertions(+), 1 deletion(-)
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
index 9071c544c90..3c35e6401f5 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.cn.md
@@ -13,6 +13,8 @@ SHOW SHARDING TABLE tableRule | RULES [FROM databaseName]
SHOW SHARDING ALGORITHMS [FROM databaseName]
SHOW UNUSED SHARDING ALGORITHMS [FROM databaseName]
+
+SHOW SHARDING AUDIT ALGORITHMS [FROM databaseName]
SHOW SHARDING TABLE RULES USED ALGORITHM algorithmName [FROM databaseName]
@@ -30,7 +32,8 @@ tableRule:
RULE tableName
```
- 支持查询所有数据分片规则和指定表查询;
-- 支持查询所有分片算法。
+- 支持查询所有分片算法;
+- 支持查询所有分片审计算法。
### Sharding Binding Table Rule
@@ -86,6 +89,14 @@ SHOW SHARDING SCALING RULES [FROM databaseName]
| type | 分片算法类型 |
| props | 分片算法参数 |
+### Sharding Audit Algorithms
+
+| 列 | 说明 |
+| ------|-------------------|
+| name | 分片审计算法名称 |
+| type | 分片审计算法类型 |
+| props | 分片审计算法参数 |
+
### Sharding Key Generators
| 列 | 说明 |
@@ -194,6 +205,17 @@ mysql> SHOW UNUSED SHARDING ALGORITHMS;
1 row in set (0.01 sec)
```
+*SHOW SHARDING AUDIT ALGORITHMS*
+```sql
+mysql> SHOW SHARDING AUDIT ALGORITHMS;
++------------+-------------------------+-------+
+| name | type | props |
++------------+-------------------------+-------+
+| dml_audit | DML_SHARDING_CONDITIONS | |
++------------+-------------------------+-------+
+2 row in set (0.01 sec)
+```
+
*SHOW SHARDING TABLE RULES USED ALGORITHM algorithmName*
```sql
mysql> SHOW SHARDING TABLE RULES USED ALGORITHM t_order_inline;
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
index e66ff2a1985..64ea142a7ff 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding.en.md
@@ -13,6 +13,8 @@ SHOW SHARDING TABLE tableRule | RULES [FROM databaseName]
SHOW SHARDING ALGORITHMS [FROM databaseName]
SHOW UNUSED SHARDING ALGORITHMS [FROM databaseName]
+
+SHOW SHARDING AUDIT ALGORITHMS [FROM databaseName]
SHOW SHARDING TABLE RULES USED ALGORITHM algorithmName [FROM databaseName]
@@ -31,6 +33,7 @@ tableRule:
```
- Support query all data fragmentation rules and specified table query
- Support query all sharding algorithms
+- Support query all sharding audit algorithms
### Sharding Binding Table Rule
@@ -86,6 +89,14 @@ SHOW SHARDING SCALING RULES [FROM databaseName]
| type | Sharding algorithm type |
| props | Sharding algorithm properties |
+### Sharding audit Algorithms
+
+| Column | Description |
+| ------ |-------------------------------------|
+| name | Sharding audit algorithm name |
+| type | Sharding audit algorithm type |
+| props | Sharding audit algorithm properties |
+
### Sharding key generators
| Column | Description |
@@ -194,6 +205,17 @@ mysql> SHOW UNUSED SHARDING ALGORITHMS;
1 row in set (0.01 sec)
```
+*SHOW SHARDING AUDIT ALGORITHMS*
+```sql
+mysql> SHOW SHARDING AUDIT ALGORITHMS;
++------------+-------------------------+-------+
+| name | type | props |
++------------+-------------------------+-------+
+| dml_audit | DML_SHARDING_CONDITIONS | |
++------------+-------------------------+-------+
+2 row in set (0.01 sec)
+```
+
*SHOW SHARDING TABLE RULES USED ALGORITHM algorithmName*
```sql
mysql> SHOW SHARDING TABLE RULES USED ALGORITHM t_order_inline;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingAuditAlgorithmsQueryResultSet.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingAuditAlgorithmsQueryResultSet.java
new file mode 100644
index 00000000000..da813775510
--- /dev/null
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingAuditAlgorithmsQueryResultSet.java
@@ -0,0 +1,83 @@
+/*
+ * 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.sharding.distsql.handler.query;
+
+import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.properties.PropertiesConverter;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingAuditAlgorithmsStatement;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Properties;
+
+/**
+ * Query result set for show sharding audit algorithms.
+ */
+public final class ShardingAuditAlgorithmsQueryResultSet implements
DistSQLResultSet {
+
+ private Iterator<Entry<String, ShardingSphereAlgorithmConfiguration>> data;
+
+ @Override
+ public void init(final ShardingSphereDatabase database, final SQLStatement
sqlStatement) {
+ Optional<ShardingRule> rule =
database.getRuleMetaData().findSingleRule(ShardingRule.class);
+ data = rule.map(optional -> ((ShardingRuleConfiguration)
optional.getConfiguration()).getAuditAlgorithms().entrySet().iterator()).orElse(Collections.emptyIterator());
+ }
+
+ @Override
+ public Collection<String> getColumnNames() {
+ return Arrays.asList("name", "type", "props");
+ }
+
+ @Override
+ public boolean next() {
+ return data.hasNext();
+ }
+
+ @Override
+ public Collection<Object> getRowData() {
+ return buildTableRowData(data.next());
+ }
+
+ private Collection<Object> buildTableRowData(final Entry<String,
ShardingSphereAlgorithmConfiguration> data) {
+ Collection<Object> result = new LinkedList<>();
+ result.add(data.getKey());
+ result.add(data.getValue().getType());
+ result.add(buildProps(data.getValue().getProps()));
+ return result;
+ }
+
+ private Object buildProps(final Properties props) {
+ return Objects.nonNull(props) ? PropertiesConverter.convert(props) :
"";
+ }
+
+ @Override
+ public String getType() {
+ return ShowShardingAuditAlgorithmsStatement.class.getName();
+ }
+}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet
index 733e99d2fb6..8f037316ed2 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet
@@ -19,6 +19,7 @@
org.apache.shardingsphere.sharding.distsql.handler.query.ShardingTableRuleQueryR
org.apache.shardingsphere.sharding.distsql.handler.query.ShardingBindingTableRuleQueryResultSet
org.apache.shardingsphere.sharding.distsql.handler.query.ShardingBroadcastTableRuleQueryResultSet
org.apache.shardingsphere.sharding.distsql.handler.query.ShardingAlgorithmsQueryResultSet
+org.apache.shardingsphere.sharding.distsql.handler.query.ShardingAuditAlgorithmsQueryResultSet
org.apache.shardingsphere.sharding.distsql.handler.query.ShardingTableNodesQueryResultSet
org.apache.shardingsphere.sharding.distsql.handler.query.ShardingKeyGeneratorsQueryResultSet
org.apache.shardingsphere.sharding.distsql.handler.query.DefaultShardingStrategyQueryResultSet
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/Keyword.g4
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/Keyword.g4
index d672af7648c..8633cf22ac1 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/Keyword.g4
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/Keyword.g4
@@ -210,3 +210,7 @@ EXISTS
WITH
: W I T H
;
+
+AUDIT
+ : A U D I T
+ ;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RQLStatement.g4
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RQLStatement.g4
index ab673b3174e..e378d155684 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RQLStatement.g4
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RQLStatement.g4
@@ -35,6 +35,10 @@ showShardingAlgorithms
: SHOW SHARDING ALGORITHMS (FROM databaseName)?
;
+showShardingAuditAlgorithms
+ : SHOW SHARDING AUDIT ALGORITHMS (FROM databaseName)?
+ ;
+
showShardingTableNodes
: SHOW SHARDING TABLE NODES tableName? (FROM databaseName)?
;
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4
index 4b0eb180a67..6e04256f341 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/sharding/org/apache/shardingsphere/distsql/parser/autogen/ShardingDistSQLStatement.g4
@@ -37,6 +37,7 @@ execute
| showShardingBindingTableRules
| showShardingBroadcastTableRules
| showShardingAlgorithms
+ | showShardingAuditAlgorithms
| setShardingHintDatabaseValue
| addShardingHintDatabaseValue
| addShardingHintTableValue
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
index e1c634438e6..c2d8ab02693 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
@@ -58,6 +58,7 @@ import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatement
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShardingTableRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShardingTableRuleDefinitionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingAlgorithmsContext;
+import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingAuditAlgorithmsContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingBindingTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingBroadcastTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.ShardingDistSQLStatementParser.ShowShardingDefaultShardingStrategyContext;
@@ -100,6 +101,7 @@ import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingK
import
org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingTableRuleStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowDefaultShardingStrategyStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingAlgorithmsStatement;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingAuditAlgorithmsStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingBindingTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingBroadcastTableRulesStatement;
import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingKeyGeneratorsStatement;
@@ -290,6 +292,11 @@ public final class ShardingDistSQLStatementVisitor extends
ShardingDistSQLStatem
return new
ShowShardingAlgorithmsStatement(Objects.nonNull(ctx.databaseName()) ?
(DatabaseSegment) visit(ctx.databaseName()) : null);
}
+ @Override
+ public ASTNode visitShowShardingAuditAlgorithms(final
ShowShardingAuditAlgorithmsContext ctx) {
+ return new
ShowShardingAuditAlgorithmsStatement(Objects.nonNull(ctx.databaseName()) ?
(DatabaseSegment) visit(ctx.databaseName()) : null);
+ }
+
@Override
public ASTNode visitShardingTableRuleDefinition(final
ShardingTableRuleDefinitionContext ctx) {
if (null != ctx.shardingTableRule()) {
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/ShowShardingAuditAlgorithmsStatement.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/ShowShardingAuditAlgorithmsStatement.java
new file mode 100644
index 00000000000..203ac9f6d1a
--- /dev/null
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/statement/ShowShardingAuditAlgorithmsStatement.java
@@ -0,0 +1,31 @@
+/*
+ * 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.sharding.distsql.parser.statement;
+
+import
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowRulesStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DatabaseSegment;
+
+/**
+ * Show sharding audit algorithms statement.
+ */
+public final class ShowShardingAuditAlgorithmsStatement extends
ShowRulesStatement {
+
+ public ShowShardingAuditAlgorithmsStatement(final DatabaseSegment
database) {
+ super(database);
+ }
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/rule/ShowShardingAuditAlgorithmsStatementAssert.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/rule/ShowShardingAuditAlgorithmsStatementAssert.java
new file mode 100644
index 00000000000..d916fd79793
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/rql/impl/rule/ShowShardingAuditAlgorithmsStatementAssert.java
@@ -0,0 +1,51 @@
+/*
+ * 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.test.sql.parser.parameterized.asserts.statement.distsql.rql.impl.rule;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import
org.apache.shardingsphere.sharding.distsql.parser.statement.ShowShardingAuditAlgorithmsStatement;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.segment.database.DatabaseAssert;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShardingAuditAlgorithmsStatementTestCase;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Show sharding audit algorithms statement assert.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ShowShardingAuditAlgorithmsStatementAssert {
+
+ /**
+ * Assert show sharding audit algorithms statement is correct with
expected parser result.
+ *
+ * @param assertContext assert context
+ * @param actual actual show sharding audit algorithms statement
+ * @param expected expected show sharding audit algorithms statement test
case
+ */
+ public static void assertIs(final SQLCaseAssertContext assertContext,
final ShowShardingAuditAlgorithmsStatement actual, final
ShowShardingAuditAlgorithmsStatementTestCase expected) {
+ if (null != expected.getDatabase()) {
+ assertTrue(assertContext.getText("Actual database should exist."),
actual.getDatabase().isPresent());
+ DatabaseAssert.assertIs(assertContext, actual.getDatabase().get(),
expected.getDatabase());
+ } else {
+ assertFalse(assertContext.getText("Actual database should not
exist."), actual.getDatabase().isPresent());
+ }
+ }
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index eec0b2454d3..285665618f4 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -353,6 +353,7 @@ import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShadowRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShadowTableRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShardingAlgorithmsStatementTestCase;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShardingAuditAlgorithmsStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShardingBindingTableRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShardingBroadcastTableRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql.ShowShardingKeyGeneratorsStatementTestCase;
@@ -934,6 +935,9 @@ public final class SQLParserTestCases {
@XmlElement(name = "show-sharding-algorithms")
private final List<ShowShardingAlgorithmsStatementTestCase>
showShardingAlgorithmsTestCases = new LinkedList<>();
+ @XmlElement(name = "show-sharding-audit-algorithms")
+ private final List<ShowShardingAuditAlgorithmsStatementTestCase>
showShardingAuditAlgorithmsTestCases = new LinkedList<>();
+
@XmlElement(name = "show-sharding-table-rules")
private final List<ShowShardingTableRulesStatementTestCase>
showShardingTableRulesTestCases = new LinkedList<>();
@@ -1673,6 +1677,7 @@ public final class SQLParserTestCases {
putAll(showShardingBindingTableRulesTestCases, result);
putAll(showShardingBroadcastTableRulesTestCases, result);
putAll(showShardingAlgorithmsTestCases, result);
+ putAll(showShardingAuditAlgorithmsTestCases, result);
putAll(showShardingTableRulesTestCases, result);
putAll(showShardingTableRuleTestCases, result);
putAll(showScalingListTestCases, result);
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowShardingAuditAlgorithmsStatementTestCase.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowShardingAuditAlgorithmsStatementTestCase.java
new file mode 100644
index 00000000000..632e28daafe
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/rql/ShowShardingAuditAlgorithmsStatementTestCase.java
@@ -0,0 +1,36 @@
+/*
+ * 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.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rql;
+
+import lombok.Getter;
+import lombok.Setter;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.segment.impl.schema.ExpectedDatabase;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * Show sharding audit algorithms statement test case.
+ */
+@Getter
+@Setter
+public final class ShowShardingAuditAlgorithmsStatementTestCase extends
SQLParserTestCase {
+
+ @XmlElement
+ private ExpectedDatabase database;
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml
index 0bc8152646e..54790984f85 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/rql/show.xml
@@ -41,6 +41,10 @@
<show-sharding-algorithms sql-case-id="show-sharding-algorithms-from">
<database name="databaseName" start-index="30" stop-index="41"/>
</show-sharding-algorithms>
+
+ <show-sharding-audit-algorithms
sql-case-id="show-sharding-audit-algorithms-from">
+ <database name="databaseName" start-index="36" stop-index="47"/>
+ </show-sharding-audit-algorithms>
<show-readwrite-splitting-rules
sql-case-id="show-readwrite-splitting-rules">
<database name="readwrite_splitting_db" start-index="36"
stop-index="57"/>
@@ -126,4 +130,5 @@
<show-sharding-table-rules-used-algorithm
sql-case-id="show-sharding-table-rules-used-algorithm"
algorithmName="t_order_inline">
<database name="sharding_db" start-index="61" stop-index="71"/>
</show-sharding-table-rules-used-algorithm>
+
</sql-parser-test-cases>
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rql/show.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rql/show.xml
index b60a3015529..7d63c024944 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rql/show.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/rql/show.xml
@@ -23,6 +23,7 @@
<distsql-case id="show-sharding-table-rule" value="SHOW SHARDING TABLE
RULE t_order" />
<distsql-case id="show-sharding-table-rule-from" value="SHOW SHARDING
TABLE RULE t_order FROM databaseName" />
<distsql-case id="show-sharding-algorithms-from" value="SHOW SHARDING
ALGORITHMS FROM databaseName" />
+ <distsql-case id="show-sharding-audit-algorithms-from" value = "SHOW
SHARDING AUDIT ALGORITHMS FROM databaseName" />
<distsql-case id="show-readwrite-splitting-rules" value="SHOW
READWRITE_SPLITTING RULES FROM readwrite_splitting_db" />
<distsql-case id="show-db-discovery-rules" value="SHOW DB_DISCOVERY RULES
FROM db_discovery_db" />
<distsql-case id="show-db-discovery-types" value="SHOW DB_DISCOVERY TYPES
FROM db_discovery_db" />