This is an automated email from the ASF dual-hosted git repository.

chengzhang 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 461f3b04d84 Support show create table, show columns, show index 
statement bind (#34271)
461f3b04d84 is described below

commit 461f3b04d8424371a0c5e2ce8b83143a6a92074c
Author: Zhengqiang Duan <duanzhengqi...@apache.org>
AuthorDate: Mon Jan 6 19:49:58 2025 +0800

    Support show create table, show columns, show index statement bind (#34271)
    
    * Support show create table, show columns, show index statement bind
    
    * update release note
---
 RELEASE-NOTES.md                                   |  1 +
 .../dal/filter/ShowFilterSegmentBinder.java        | 52 +++++++++++++++++++++
 .../statement/dal/ShowColumnsStatementBinder.java  | 54 ++++++++++++++++++++++
 .../dal/ShowCreateTableStatementBinder.java        | 51 ++++++++++++++++++++
 .../statement/dal/ShowIndexStatementBinder.java    | 52 +++++++++++++++++++++
 .../binder/engine/type/DALStatementBindEngine.java | 15 ++++++
 .../src/test/resources/cases/dal/show-columns.xml  | 38 +++++++++++++++
 .../test/resources/cases/dal/show-create-table.xml | 38 +++++++++++++++
 .../src/test/resources/cases/dal/show-index.xml    | 48 +++++++++++++++++++
 .../src/test/resources/sqls/dal/show-columns.xml   | 22 +++++++++
 .../test/resources/sqls/dal/show-create-table.xml  | 22 +++++++++
 .../src/test/resources/sqls/dal/show-index.xml     | 23 +++++++++
 .../dal/impl/ShowCreateTableStatementAssert.java   |  4 ++
 13 files changed, 420 insertions(+)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 01261a82b65..8c96db616a8 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -51,6 +51,7 @@
 1. Mode: Support modifying Hikari-CP configurations via props in standalone 
mode [#34185](https://github.com/apache/shardingsphere/pull/34185)
 1. Encrypt: Support insert statement rewrite use quote 
[#34259](https://github.com/apache/shardingsphere/pull/34259)
 1. SQL Binder: Support optimize table sql bind and add test case - 
[#34242](https://github.com/apache/shardingsphere/pull/34242)
+1. SQL Binder: Support show create table, show columns, show index statement 
bind - [#34271](https://github.com/apache/shardingsphere/pull/34271)
 
 ### Bug Fixes
 
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dal/filter/ShowFilterSegmentBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dal/filter/ShowFilterSegmentBinder.java
new file mode 100644
index 00000000000..6e94a2d167c
--- /dev/null
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/dal/filter/ShowFilterSegmentBinder.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.infra.binder.engine.segment.dal.filter;
+
+import com.cedarsoftware.util.CaseInsensitiveMap.CaseInsensitiveString;
+import com.google.common.collect.Multimap;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.context.TableSegmentBinderContext;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dml.predicate.WhereSegmentBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinderContext;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.ShowFilterSegment;
+
+/**
+ * Show filter segment binder.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ShowFilterSegmentBinder {
+    
+    /**
+     * Bind show filter segment.
+     *
+     * @param segment show filter segment
+     * @param binderContext SQL statement binder context
+     * @param tableBinderContexts table binder contexts
+     * @param outerTableBinderContexts outer table binder contexts
+     * @return bound show filter segment
+     */
+    public static ShowFilterSegment bind(final ShowFilterSegment segment, 
final SQLStatementBinderContext binderContext,
+                                         final Multimap<CaseInsensitiveString, 
TableSegmentBinderContext> tableBinderContexts,
+                                         final Multimap<CaseInsensitiveString, 
TableSegmentBinderContext> outerTableBinderContexts) {
+        ShowFilterSegment result = new 
ShowFilterSegment(segment.getStartIndex(), segment.getStopIndex());
+        segment.getLike().ifPresent(result::setLike);
+        segment.getWhere().ifPresent(optional -> 
result.setWhere(WhereSegmentBinder.bind(optional, binderContext, 
tableBinderContexts, outerTableBinderContexts)));
+        return result;
+    }
+}
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowColumnsStatementBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowColumnsStatementBinder.java
new file mode 100644
index 00000000000..3860e3e10d7
--- /dev/null
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowColumnsStatementBinder.java
@@ -0,0 +1,54 @@
+/*
+ * 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.infra.binder.engine.statement.dal;
+
+import com.cedarsoftware.util.CaseInsensitiveMap.CaseInsensitiveString;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+import lombok.SneakyThrows;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dal.filter.ShowFilterSegmentBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.context.TableSegmentBinderContext;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinderContext;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowColumnsStatement;
+
+/**
+ * Show columns statement binder.
+ */
+public final class ShowColumnsStatementBinder implements 
SQLStatementBinder<ShowColumnsStatement> {
+    
+    @Override
+    public ShowColumnsStatement bind(final ShowColumnsStatement sqlStatement, 
final SQLStatementBinderContext binderContext) {
+        ShowColumnsStatement result = copy(sqlStatement);
+        Multimap<CaseInsensitiveString, TableSegmentBinderContext> 
tableBinderContexts = LinkedHashMultimap.create();
+        result.setTable(SimpleTableSegmentBinder.bind(sqlStatement.getTable(), 
binderContext, tableBinderContexts));
+        sqlStatement.getFromDatabase().ifPresent(result::setFromDatabase);
+        sqlStatement.getFilter().ifPresent(optional -> 
result.setFilter(ShowFilterSegmentBinder.bind(optional, binderContext, 
tableBinderContexts, LinkedHashMultimap.create())));
+        return result;
+    }
+    
+    @SneakyThrows(ReflectiveOperationException.class)
+    private static ShowColumnsStatement copy(final ShowColumnsStatement 
sqlStatement) {
+        ShowColumnsStatement result = 
sqlStatement.getClass().getDeclaredConstructor().newInstance();
+        
result.addParameterMarkerSegments(sqlStatement.getParameterMarkerSegments());
+        result.getCommentSegments().addAll(sqlStatement.getCommentSegments());
+        result.getVariableNames().addAll(sqlStatement.getVariableNames());
+        return result;
+    }
+}
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowCreateTableStatementBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowCreateTableStatementBinder.java
new file mode 100644
index 00000000000..d3fabf6be50
--- /dev/null
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowCreateTableStatementBinder.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.infra.binder.engine.statement.dal;
+
+import com.cedarsoftware.util.CaseInsensitiveMap.CaseInsensitiveString;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+import lombok.SneakyThrows;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.context.TableSegmentBinderContext;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinderContext;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowCreateTableStatement;
+
+/**
+ * Show create table statement binder.
+ */
+public final class ShowCreateTableStatementBinder implements 
SQLStatementBinder<ShowCreateTableStatement> {
+    
+    @Override
+    public ShowCreateTableStatement bind(final ShowCreateTableStatement 
sqlStatement, final SQLStatementBinderContext binderContext) {
+        ShowCreateTableStatement result = copy(sqlStatement);
+        Multimap<CaseInsensitiveString, TableSegmentBinderContext> 
tableBinderContexts = LinkedHashMultimap.create();
+        result.setTable(SimpleTableSegmentBinder.bind(sqlStatement.getTable(), 
binderContext, tableBinderContexts));
+        return result;
+    }
+    
+    @SneakyThrows(ReflectiveOperationException.class)
+    private static ShowCreateTableStatement copy(final 
ShowCreateTableStatement sqlStatement) {
+        ShowCreateTableStatement result = 
sqlStatement.getClass().getDeclaredConstructor().newInstance();
+        
result.addParameterMarkerSegments(sqlStatement.getParameterMarkerSegments());
+        result.getCommentSegments().addAll(sqlStatement.getCommentSegments());
+        result.getVariableNames().addAll(sqlStatement.getVariableNames());
+        return result;
+    }
+}
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowIndexStatementBinder.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowIndexStatementBinder.java
new file mode 100644
index 00000000000..3c165e91529
--- /dev/null
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/ShowIndexStatementBinder.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.infra.binder.engine.statement.dal;
+
+import com.cedarsoftware.util.CaseInsensitiveMap.CaseInsensitiveString;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+import lombok.SneakyThrows;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.context.TableSegmentBinderContext;
+import 
org.apache.shardingsphere.infra.binder.engine.segment.dml.from.type.SimpleTableSegmentBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinderContext;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowIndexStatement;
+
+/**
+ * Show index statement binder.
+ */
+public final class ShowIndexStatementBinder implements 
SQLStatementBinder<ShowIndexStatement> {
+    
+    @Override
+    public ShowIndexStatement bind(final ShowIndexStatement sqlStatement, 
final SQLStatementBinderContext binderContext) {
+        ShowIndexStatement result = copy(sqlStatement);
+        Multimap<CaseInsensitiveString, TableSegmentBinderContext> 
tableBinderContexts = LinkedHashMultimap.create();
+        result.setTable(SimpleTableSegmentBinder.bind(sqlStatement.getTable(), 
binderContext, tableBinderContexts));
+        sqlStatement.getFromDatabase().ifPresent(result::setFromDatabase);
+        return result;
+    }
+    
+    @SneakyThrows(ReflectiveOperationException.class)
+    private static ShowIndexStatement copy(final ShowIndexStatement 
sqlStatement) {
+        ShowIndexStatement result = 
sqlStatement.getClass().getDeclaredConstructor().newInstance();
+        
result.addParameterMarkerSegments(sqlStatement.getParameterMarkerSegments());
+        result.getCommentSegments().addAll(sqlStatement.getCommentSegments());
+        result.getVariableNames().addAll(sqlStatement.getVariableNames());
+        return result;
+    }
+}
diff --git 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/type/DALStatementBindEngine.java
 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/type/DALStatementBindEngine.java
index 2ab63622ff8..e2f2cbc6815 100644
--- 
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/type/DALStatementBindEngine.java
+++ 
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/type/DALStatementBindEngine.java
@@ -20,10 +20,16 @@ package org.apache.shardingsphere.infra.binder.engine.type;
 import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.infra.binder.engine.statement.SQLStatementBinderContext;
 import 
org.apache.shardingsphere.infra.binder.engine.statement.dal.OptimizeTableStatementBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.dal.ShowColumnsStatementBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.dal.ShowCreateTableStatementBinder;
+import 
org.apache.shardingsphere.infra.binder.engine.statement.dal.ShowIndexStatementBinder;
 import org.apache.shardingsphere.infra.hint.HintValueContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.DALStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.OptimizeTableStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowColumnsStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowCreateTableStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowIndexStatement;
 
 /**
  * DAL statement bind engine.
@@ -48,6 +54,15 @@ public final class DALStatementBindEngine {
         if (statement instanceof OptimizeTableStatement) {
             return new 
OptimizeTableStatementBinder().bind((OptimizeTableStatement) statement, 
binderContext);
         }
+        if (statement instanceof ShowCreateTableStatement) {
+            return new 
ShowCreateTableStatementBinder().bind((ShowCreateTableStatement) statement, 
binderContext);
+        }
+        if (statement instanceof ShowColumnsStatement) {
+            return new 
ShowColumnsStatementBinder().bind((ShowColumnsStatement) statement, 
binderContext);
+        }
+        if (statement instanceof ShowIndexStatement) {
+            return new ShowIndexStatementBinder().bind((ShowIndexStatement) 
statement, binderContext);
+        }
         return statement;
     }
 }
diff --git a/test/it/binder/src/test/resources/cases/dal/show-columns.xml 
b/test/it/binder/src/test/resources/cases/dal/show-columns.xml
new file mode 100644
index 00000000000..a76feaf30bd
--- /dev/null
+++ b/test/it/binder/src/test/resources/cases/dal/show-columns.xml
@@ -0,0 +1,38 @@
+<?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.
+  -->
+
+<sql-parser-test-cases>
+    <show-columns sql-case-id="show_columns_from_table">
+        <table name="t_order" start-delimiter="`" end-delimiter="`" 
start-index="18" stop-index="26">
+            <table-bound>
+                <original-database name="foo_db_1" />
+                <original-schema name="foo_db_1" />
+            </table-bound>
+        </table>
+    </show-columns>
+
+    <show-columns sql-case-id="show_columns_from_table_with_owner">
+        <table name="t_product" start-delimiter="`" end-delimiter="`" 
start-index="18" stop-index="39">
+            <owner name="foo_db_2" start-delimiter="`" end-delimiter="`" 
start-index="18" stop-index="27" />
+            <table-bound>
+                <original-database name="foo_db_2" />
+                <original-schema name="foo_db_2" start-delimiter="`" 
end-delimiter="`" />
+            </table-bound>
+        </table>
+    </show-columns>
+</sql-parser-test-cases>
diff --git a/test/it/binder/src/test/resources/cases/dal/show-create-table.xml 
b/test/it/binder/src/test/resources/cases/dal/show-create-table.xml
new file mode 100644
index 00000000000..c7224906a8d
--- /dev/null
+++ b/test/it/binder/src/test/resources/cases/dal/show-create-table.xml
@@ -0,0 +1,38 @@
+<?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.
+  -->
+
+<sql-parser-test-cases>
+    <show-create-table sql-case-id="show_create_table">
+        <table name="t_order" start-delimiter="`" end-delimiter="`" 
start-index="18" stop-index="26">
+            <table-bound>
+                <original-database name="foo_db_1" />
+                <original-schema name="foo_db_1" />
+            </table-bound>
+        </table>
+    </show-create-table>
+
+    <show-create-table sql-case-id="show_create_table_with_owner">
+        <table name="t_product" start-delimiter="`" end-delimiter="`" 
start-index="18" stop-index="39">
+            <owner name="foo_db_2" start-delimiter="`" end-delimiter="`" 
start-index="18" stop-index="27" />
+            <table-bound>
+                <original-database name="foo_db_2" />
+                <original-schema name="foo_db_2" start-delimiter="`" 
end-delimiter="`" />
+            </table-bound>
+        </table>
+    </show-create-table>
+</sql-parser-test-cases>
diff --git a/test/it/binder/src/test/resources/cases/dal/show-index.xml 
b/test/it/binder/src/test/resources/cases/dal/show-index.xml
new file mode 100644
index 00000000000..cf2a6e13ecb
--- /dev/null
+++ b/test/it/binder/src/test/resources/cases/dal/show-index.xml
@@ -0,0 +1,48 @@
+<?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.
+  -->
+
+<sql-parser-test-cases>
+    <show-index sql-case-id="show_index_with_index_with_table">
+        <table name="t_order" start-index="16" stop-index="22">
+            <table-bound>
+                <original-database name="foo_db_1" />
+                <original-schema name="foo_db_1" />
+            </table-bound>
+        </table>
+    </show-index>
+
+    <show-index sql-case-id="show_index_with_indexes_with_table_and_database">
+        <table name="t_order" start-index="18" stop-index="24">
+            <table-bound>
+                <original-database name="foo_db_1" />
+                <original-schema name="foo_db_1" />
+            </table-bound>
+        </table>
+        <database name="foo_db_1" start-index="26" stop-index="38" />
+    </show-index>
+
+    <show-index sql-case-id="show_index_with_keys_with_database_and_table">
+        <table name="t_order" start-index="15" stop-index="30">
+            <owner name="foo_db_1" start-index="15" stop-index="22" />
+            <table-bound>
+                <original-database name="foo_db_1" />
+                <original-schema name="foo_db_1" />
+            </table-bound>
+        </table>
+    </show-index>
+</sql-parser-test-cases>
diff --git a/test/it/binder/src/test/resources/sqls/dal/show-columns.xml 
b/test/it/binder/src/test/resources/sqls/dal/show-columns.xml
new file mode 100644
index 00000000000..5847f2c2646
--- /dev/null
+++ b/test/it/binder/src/test/resources/sqls/dal/show-columns.xml
@@ -0,0 +1,22 @@
+<?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.
+  -->
+
+<sql-cases>
+    <sql-case id="show_columns_from_table" value="SHOW COLUMNS FROM `t_order`" 
db-types="MySQL,Doris" />
+    <sql-case id="show_columns_from_table_with_owner" value="SHOW COLUMNS FROM 
`foo_db_2`.`t_product`" db-types="MySQL,Doris" />
+</sql-cases>
diff --git a/test/it/binder/src/test/resources/sqls/dal/show-create-table.xml 
b/test/it/binder/src/test/resources/sqls/dal/show-create-table.xml
new file mode 100644
index 00000000000..45249ab5337
--- /dev/null
+++ b/test/it/binder/src/test/resources/sqls/dal/show-create-table.xml
@@ -0,0 +1,22 @@
+<?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.
+  -->
+
+<sql-cases>
+    <sql-case id="show_create_table" value="SHOW CREATE TABLE `t_order`" 
db-types="MySQL,Doris" />
+    <sql-case id="show_create_table_with_owner" value="SHOW CREATE TABLE 
`foo_db_2`.`t_product`" db-types="MySQL,Doris" />
+</sql-cases>
diff --git a/test/it/binder/src/test/resources/sqls/dal/show-index.xml 
b/test/it/binder/src/test/resources/sqls/dal/show-index.xml
new file mode 100644
index 00000000000..a0f09bf87c3
--- /dev/null
+++ b/test/it/binder/src/test/resources/sqls/dal/show-index.xml
@@ -0,0 +1,23 @@
+<?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.
+  -->
+
+<sql-cases>
+    <sql-case id="show_index_with_index_with_table" value="SHOW INDEX FROM 
t_order" db-types="MySQL,Doris" />
+    <sql-case id="show_index_with_indexes_with_table_and_database" value="SHOW 
INDEXES FROM t_order FROM foo_db_1" db-types="MySQL,Doris" />
+    <sql-case id="show_index_with_keys_with_database_and_table" value="SHOW 
KEYS FROM foo_db_1.t_order" db-types="MySQL,Doris" />
+</sql-cases>
diff --git 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/impl/ShowCreateTableStatementAssert.java
 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/impl/ShowCreateTableStatementAssert.java
index 901aff44239..bbd9ea0e0e9 100644
--- 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/impl/ShowCreateTableStatementAssert.java
+++ 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/impl/ShowCreateTableStatementAssert.java
@@ -21,6 +21,7 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowCreateTableStatement;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.table.TableAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.ShowCreateTableStatementTestCase;
 
 /**
@@ -37,5 +38,8 @@ public final class ShowCreateTableStatementAssert {
      * @param expected expected show create table statement test case
      */
     public static void assertIs(final SQLCaseAssertContext assertContext, 
final ShowCreateTableStatement actual, final ShowCreateTableStatementTestCase 
expected) {
+        if (null != actual.getTable()) {
+            TableAssert.assertIs(assertContext, actual.getTable(), 
expected.getTable());
+        }
     }
 }

Reply via email to