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 b4fa59e6f5b Add new DistSQL syntax SHOW SQL_TRANSLATOR RULE. (#19494)
b4fa59e6f5b is described below
commit b4fa59e6f5ba1bd3555e8a4afc32bb6c38d6e928
Author: yx9o <[email protected]>
AuthorDate: Sun Jul 24 12:13:33 2022 +0800
Add new DistSQL syntax SHOW SQL_TRANSLATOR RULE. (#19494)
---
.../src/main/antlr4/imports/Keyword.g4 | 4 ++
.../src/main/antlr4/imports/RALStatement.g4 | 4 ++
.../parser/autogen/KernelDistSQLStatement.g4 | 1 +
.../core/kernel/KernelDistSQLStatementVisitor.java | 11 +++-
.../queryable/ShowSQLTranslatorRuleStatement.java | 26 +++++++++
.../text/distsql/ral/RALBackendHandlerFactory.java | 7 ++-
.../queryable/ShowSQLTranslatorRuleHandler.java | 50 ++++++++++++++++++
.../ShowSQLTranslatorRuleHandlerTest.java | 61 ++++++++++++++++++++++
.../ral/impl/QueryableRALStatementAssert.java | 5 ++
.../ShowSQLTranslatorRuleStatementAssert.java | 46 ++++++++++++++++
.../jaxb/cases/domain/SQLParserTestCases.java | 4 ++
.../ShowSQLTranslatorRuleStatementTestCase.java | 30 +++++++++++
.../src/main/resources/case/ral/common.xml | 1 +
.../main/resources/sql/supported/ral/common.xml | 1 +
14 files changed, 247 insertions(+), 4 deletions(-)
diff --git
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
index 929aa4e13d2..f0cb72355fc 100644
---
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
+++
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/Keyword.g4
@@ -326,3 +326,7 @@ DISCARD
SINGLE_TABLE
: S I N G L E UL_ T A B L E
;
+
+SQL_TRANSLATOR
+ : S Q L UL_ T R A N S L A T O R
+ ;
diff --git
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
index cb9dd5e0a21..b3f3bfd3988 100644
---
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
+++
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
@@ -143,6 +143,10 @@ convertYamlConfiguration
: CONVERT YAML (CONFIGURATION | CONFIG) FILE EQ filePath
;
+showSQLTranslatorRule
+ : SHOW SQL_TRANSLATOR RULE
+ ;
+
filePath
: STRING
;
diff --git
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/KernelDistSQLStatement.g4
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/KernelDistSQLStatement.g4
index 78fba169281..657f2fdef18 100644
---
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/KernelDistSQLStatement.g4
+++
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/KernelDistSQLStatement.g4
@@ -61,5 +61,6 @@ execute
| showRulesUsedResource
| importDatabaseConfiguration
| convertYamlConfiguration
+ | showSQLTranslatorRule
) SEMI?
;
diff --git
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java
index 0ab38d09d81..e1745233e80 100644
---
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java
+++
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementVisitor.java
@@ -32,6 +32,7 @@ import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementPa
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ApplyDistSQLContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.CacheOptionContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ClearHintContext;
+import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ConvertYamlConfigurationContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.CountDatabaseRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.CountSingleTableRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.CreateDefaultSingleTableRuleContext;
@@ -45,7 +46,6 @@ import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementPa
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.DropTrafficRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.EnableInstanceContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ExportDatabaseConfigurationContext;
-import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ConvertYamlConfigurationContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.FromSegmentContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ImportDatabaseConfigurationContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.InstanceIdContext;
@@ -66,6 +66,7 @@ import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementPa
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowResourcesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowRulesUsedResourceContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowSQLParserRuleContext;
+import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowSQLTranslatorRuleContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowSingleTableContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowSingleTableRulesContext;
import
org.apache.shardingsphere.distsql.parser.autogen.KernelDistSQLStatementParser.ShowTableMetadataContext;
@@ -85,13 +86,14 @@ import
org.apache.shardingsphere.distsql.parser.segment.TrafficRuleSegment;
import
org.apache.shardingsphere.distsql.parser.segment.TransactionProviderSegment;
import
org.apache.shardingsphere.distsql.parser.segment.URLBasedDataSourceSegment;
import
org.apache.shardingsphere.distsql.parser.statement.ral.hint.ClearHintStatement;
-import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ExportDatabaseConfigurationStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ConvertYamlConfigurationStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ExportDatabaseConfigurationStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowAllVariableStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowAuthorityRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowInstanceModeStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowInstanceStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLParserRuleStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLTranslatorRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTableMetadataStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTrafficRulesStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTransactionRuleStatement;
@@ -472,6 +474,11 @@ public final class KernelDistSQLStatementVisitor extends
KernelDistSQLStatementB
return new
ImportDatabaseConfigurationStatement(getIdentifierValue(ctx.filePath()));
}
+ @Override
+ public ASTNode visitShowSQLTranslatorRule(final
ShowSQLTranslatorRuleContext ctx) {
+ return new ShowSQLTranslatorRuleStatement();
+ }
+
private String getIdentifierValue(final ParseTree context) {
return null == context ? null : new
IdentifierValue(context.getText()).getValue();
}
diff --git
a/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/queryable/ShowSQLTranslatorRuleStatement.java
b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/queryable/ShowSQLTranslatorRuleStatement.java
new file mode 100644
index 00000000000..ff0816c905e
--- /dev/null
+++
b/shardingsphere-distsql/shardingsphere-distsql-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/queryable/ShowSQLTranslatorRuleStatement.java
@@ -0,0 +1,26 @@
+/*
+ * 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.distsql.parser.statement.ral.queryable;
+
+import
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
+
+/**
+ * Show SQL translator rule statement.
+ */
+public final class ShowSQLTranslatorRuleStatement extends
QueryableRALStatement {
+}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
index 312428ad4ff..7e12850f340 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
@@ -24,13 +24,14 @@ import
org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.advanced.FormatStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.advanced.ParseStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.advanced.PreviewStatement;
-import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ExportDatabaseConfigurationStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ConvertYamlConfigurationStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ExportDatabaseConfigurationStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowAllVariableStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowAuthorityRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowInstanceModeStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowInstanceStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLParserRuleStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLTranslatorRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTableMetadataStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTrafficRulesStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTransactionRuleStatement;
@@ -57,14 +58,15 @@ import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.advanced.FormatS
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.advanced.ParseDistSQLHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.advanced.PreviewHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.hint.HintRALBackendHandler;
-import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ExportDatabaseConfigurationHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ConvertYamlConfigurationHandler;
+import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ExportDatabaseConfigurationHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowAllVariableHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowAuthorityRuleHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowInstanceHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowInstanceModeHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowReadwriteSplittingReadResourcesHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowSQLParserRuleHandler;
+import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowSQLTranslatorRuleHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowTableMetadataHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowTrafficRulesHandler;
import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable.ShowTransactionRuleHandler;
@@ -133,6 +135,7 @@ public final class RALBackendHandlerFactory {
HANDLERS.put(ParseStatement.class, ParseDistSQLHandler.class);
HANDLERS.put(PreviewStatement.class, PreviewHandler.class);
HANDLERS.put(FormatStatement.class, FormatSQLHandler.class);
+ HANDLERS.put(ShowSQLTranslatorRuleStatement.class,
ShowSQLTranslatorRuleHandler.class);
}
/**
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/queryable/ShowSQLTranslatorRuleHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/queryable/ShowSQLTranslatorRuleHandler.java
new file mode 100644
index 00000000000..b8b342f0f9a
--- /dev/null
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/queryable/ShowSQLTranslatorRuleHandler.java
@@ -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.
+ */
+
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable;
+
+import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLTranslatorRuleStatement;
+import
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import
org.apache.shardingsphere.proxy.backend.text.distsql.ral.QueryableRALBackendHandler;
+import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Show SQL translator rule handler.
+ */
+public final class ShowSQLTranslatorRuleHandler extends
QueryableRALBackendHandler<ShowSQLTranslatorRuleStatement> {
+
+ private static final String TYPE = "type";
+
+ private static final String USE_ORIGINAL_SQL_WHEN_TRANSLATING_FAILED =
"useOriginalSQLWhenTranslatingFailed";
+
+ @Override
+ protected Collection<String> getColumnNames() {
+ return Arrays.asList(TYPE, USE_ORIGINAL_SQL_WHEN_TRANSLATING_FAILED);
+ }
+
+ @Override
+ protected Collection<LocalDataQueryResultRow> getRows(final ContextManager
contextManager) {
+ SQLTranslatorRule sqlTranslatorRule =
contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(SQLTranslatorRule.class);
+ return Collections.singleton(new LocalDataQueryResultRow(null ==
sqlTranslatorRule.getConfiguration().getType() ? "" :
sqlTranslatorRule.getConfiguration().getType(),
+
String.valueOf(sqlTranslatorRule.getConfiguration().isUseOriginalSQLWhenTranslatingFailed())));
+ }
+}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/queryable/ShowSQLTranslatorRuleHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/queryable/ShowSQLTranslatorRuleHandlerTest.java
new file mode 100644
index 00000000000..9576c668484
--- /dev/null
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/queryable/ShowSQLTranslatorRuleHandlerTest.java
@@ -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.
+ */
+
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.queryable;
+
+import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLTranslatorRuleStatement;
+import
org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.util.ProxyContextRestorer;
+import
org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration;
+import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class ShowSQLTranslatorRuleHandlerTest extends
ProxyContextRestorer {
+
+ @Test
+ public void assertExecutor() throws SQLException {
+ ShowSQLTranslatorRuleHandler handler = new
ShowSQLTranslatorRuleHandler();
+ handler.init(new ShowSQLTranslatorRuleStatement(), null);
+ ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
+ ShardingSphereRuleMetaData metaData =
createGlobalRuleMetaData("MYSQL", true);
+
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(metaData);
+ ProxyContext.init(contextManager);
+ handler.execute();
+ handler.next();
+ List<Object> data = handler.getRowData().getData();
+ assertThat(data.size(), is(2));
+ assertThat(data.get(0), is("MYSQL"));
+ assertThat(data.get(1), is("true"));
+ }
+
+ private ShardingSphereRuleMetaData createGlobalRuleMetaData(final String
type, final boolean useOriginalSQLWhenTranslatingFailed) {
+ SQLTranslatorRule rule = new SQLTranslatorRule(new
SQLTranslatorRuleConfiguration(type, useOriginalSQLWhenTranslatingFailed));
+ return new ShardingSphereRuleMetaData(Collections.singleton(rule));
+ }
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/QueryableRALStatementAssert.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/QueryableRALStatementAssert.java
index 06efb8f328d..e10d8a9f01b 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/QueryableRALStatementAssert.java
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/QueryableRALStatementAssert.java
@@ -27,6 +27,7 @@ import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowAllV
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowAuthorityRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowInstanceStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLParserRuleStatement;
+import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLTranslatorRuleStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTableMetadataStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTrafficRulesStatement;
import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTransactionRuleStatement;
@@ -41,6 +42,7 @@ import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.queryable.ShowInstanceStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.queryable.ShowReadwriteSplittingReadResourcesStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.queryable.ShowSQLParserRuleStatementAssert;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.queryable.ShowSQLTranslatorRuleStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.queryable.ShowTableMetadataStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.queryable.ShowTrafficRulesStatementAssert;
import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.queryable.ShowTransactionRuleStatementAssert;
@@ -54,6 +56,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.ral.ShowInstanceStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowReadwriteSplittingReadResourcesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowSQLParserRuleStatementTestCase;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowSQLTranslatorRuleStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowTableMetadataStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowTrafficRulesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowTransactionRuleStatementTestCase;
@@ -98,6 +101,8 @@ public final class QueryableRALStatementAssert {
PreviewStatementAssert.assertIs(assertContext, (PreviewStatement)
actual, (PreviewStatementTestCase) expected);
} else if (actual instanceof ParseStatement) {
ParseStatementAssert.assertIs(assertContext, (ParseStatement)
actual, (ParseStatementTestCase) expected);
+ } else if (actual instanceof ShowSQLTranslatorRuleStatement) {
+ ShowSQLTranslatorRuleStatementAssert.assertIs(assertContext,
(ShowSQLTranslatorRuleStatement) actual,
(ShowSQLTranslatorRuleStatementTestCase) expected);
}
}
}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/queryable/ShowSQLTranslatorRuleStatementAssert.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/queryable/ShowSQLTranslatorRuleStatementAssert.java
new file mode 100644
index 00000000000..cae4a17b29f
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/queryable/ShowSQLTranslatorRuleStatementAssert.java
@@ -0,0 +1,46 @@
+/*
+ * 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.ral.impl.queryable;
+
+import
org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowSQLTranslatorRuleStatement;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowSQLTranslatorRuleStatementTestCase;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Show SQL translator rule statement assert.
+ */
+public final class ShowSQLTranslatorRuleStatementAssert {
+
+ /**
+ * Assert show SQL translator rule statement is correct with expected
parser result.
+ *
+ * @param assertContext assert context
+ * @param actual actual show SQL translator rule statement
+ * @param expected expected show SQL translator rule statement test case
+ */
+ public static void assertIs(final SQLCaseAssertContext assertContext,
final ShowSQLTranslatorRuleStatement actual, final
ShowSQLTranslatorRuleStatementTestCase expected) {
+ if (null == expected) {
+ assertNull(assertContext.getText("Actual statement should not
exist."), actual);
+ } else {
+ assertNotNull(assertContext.getText("Actual statement should
exist."), actual);
+ }
+ }
+}
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 81d7d9c1a9d..90310ac6c58 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
@@ -288,6 +288,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.ral.ShowReadwriteSplittingHintStatusStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowReadwriteSplittingReadResourcesStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowSQLParserRuleStatementTestCase;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowSQLTranslatorRuleStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowScalingListStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowShardingHintStatusStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowTableMetadataStatementTestCase;
@@ -1603,6 +1604,9 @@ public final class SQLParserTestCases {
@XmlElement(name = "create-foreign-data-wrapper")
private final List<CreateForeignDataWrapperStatementTestCase>
createForeignDataWrapperStatementTestCases = new LinkedList<>();
+ @XmlElement(name = "show-sql-translator-rule")
+ private final List<ShowSQLTranslatorRuleStatementTestCase>
showSQLTranslatorRuleStatementTestCases = new LinkedList<>();
+
/**
* Get all SQL parser test cases.
*
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/ShowSQLTranslatorRuleStatementTestCase.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/ShowSQLTranslatorRuleStatementTestCase.java
new file mode 100644
index 00000000000..14f1eda2c95
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/ShowSQLTranslatorRuleStatementTestCase.java
@@ -0,0 +1,30 @@
+/*
+ * 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.ral;
+
+import lombok.Getter;
+import lombok.Setter;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+/**
+ * Show SQL translator rule statement test case.
+ */
+@Setter
+@Getter
+public final class ShowSQLTranslatorRuleStatementTestCase extends
SQLParserTestCase {
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/common.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/common.xml
index 0558e13f92f..a216097094c 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/common.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/common.xml
@@ -109,4 +109,5 @@
<import-database-config sql-case-id="import-database-config">
<filePath>/yaml/config-sharding.yaml</filePath>
</import-database-config>
+ <show-sql-translator-rule sql-case-id="show-sql-translator-rule" />
</sql-parser-test-cases>
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/common.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/common.xml
index b21a79e33a4..8b4ece1a281 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/common.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/common.xml
@@ -58,4 +58,5 @@
<distsql-case id="alter-instance-xa-recovery-nodes" value="ALTER INSTANCE
instance_xa_recovery SET XA_RECOVERY_NODES=instance_1" />
<distsql-case id="alter-instance-xa-recovery-nodes-with-multiple-values"
value="ALTER INSTANCE instance_xa_recovery_multiple SET
XA_RECOVERY_NODES=instance_1,instance_2 " />
<distsql-case id="import-database-config" value="IMPORT DATABASE CONFIG
FILE='/yaml/config-sharding.yaml'" />
+ <distsql-case id="show-sql-translator-rule" value="SHOW SQL_TRANSLATOR
RULE" />
</sql-cases>