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 e30f69490e8 Merge CopyStatementContext and 
TableAvailableSQLStatementContext (#35705)
e30f69490e8 is described below

commit e30f69490e8b41c27356722c77deb53ab8f5cd00
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Sat Jun 14 13:17:51 2025 +0800

    Merge CopyStatementContext and TableAvailableSQLStatementContext (#35705)
    
    * Merge CopyStatementContext and TableAvailableSQLStatementContext
    
    * Merge CopyStatementContext and TableAvailableSQLStatementContext
---
 .../ShardingCreateProcedureSupportedChecker.java   |  3 +-
 .../sql/dml/ShardingCopySupportedChecker.java      | 11 +++---
 .../sql/dml/ShardingCopySupportedCheckerTest.java  | 13 ++++---
 .../statement/SQLStatementContextFactory.java      |  8 +---
 .../type/ddl/DropIndexStatementContext.java        |  4 +-
 infra/binder/dialect/opengauss/pom.xml             |  5 +++
 .../OpenGaussProjectionIdentifierExtractor.java    | 16 ++++----
 .../opengauss/OpenGaussSQLStatementExtractor.java  | 43 ++++++++++++++++++++++
 ....context.extractor.DialectSQLStatementExtractor | 18 +++++++++
 .../PostgreSQLSQLStatementExtractor.java}          | 30 +++++++--------
 ....context.extractor.DialectSQLStatementExtractor | 18 +++++++++
 11 files changed, 121 insertions(+), 48 deletions(-)

diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedChecker.java
index d07ce6c6d8b..1bfc8a3222d 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateProcedureSupportedChecker.java
@@ -55,7 +55,6 @@ public final class ShardingCreateProcedureSupportedChecker 
implements SupportedS
         ShardingSphereSchema schema = 
createProcedureStatement.getProcedureName().flatMap(optional -> 
optional.getOwner()
                 .map(owner -> 
database.getSchema(owner.getIdentifier().getValue()))).orElse(currentSchema);
         ShardingSupportedCommonChecker.checkTableExist(schema, existTables);
-        Collection<SimpleTableSegment> notExistTables = 
extractor.extractNotExistTableFromRoutineBody(routineBodySegment.get());
-        ShardingSupportedCommonChecker.checkTableNotExist(schema, 
notExistTables);
+        ShardingSupportedCommonChecker.checkTableNotExist(schema, 
extractor.extractNotExistTableFromRoutineBody(routineBodySegment.get()));
     }
 }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedChecker.java
index 110344ecb90..6a9be23d2a4 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedChecker.java
@@ -19,28 +19,29 @@ package org.apache.shardingsphere.sharding.checker.sql.dml;
 
 import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.dml.CopyStatementContext;
+import 
org.apache.shardingsphere.infra.binder.context.statement.TableAvailableSQLStatementContext;
 import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.sharding.exception.syntax.UnsupportedShardingOperationException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.CopyStatement;
 
 /**
  * Copy supported checker for sharding.
  */
 @HighFrequencyInvocation
-public final class ShardingCopySupportedChecker implements 
SupportedSQLChecker<CopyStatementContext, ShardingRule> {
+public final class ShardingCopySupportedChecker implements 
SupportedSQLChecker<TableAvailableSQLStatementContext, ShardingRule> {
     
     @Override
     public boolean isCheck(final SQLStatementContext sqlStatementContext) {
-        return sqlStatementContext instanceof CopyStatementContext && 
((CopyStatementContext) 
sqlStatementContext).getSqlStatement().getTable().isPresent();
+        return sqlStatementContext.getSqlStatement() instanceof CopyStatement 
&& ((CopyStatement) 
sqlStatementContext.getSqlStatement()).getTable().isPresent();
     }
     
     @Override
-    public void check(final ShardingRule rule, final ShardingSphereDatabase 
database, final ShardingSphereSchema currentSchema, final CopyStatementContext 
sqlStatementContext) {
-        String tableName = 
sqlStatementContext.getSqlStatement().getTable().map(optional -> 
optional.getTableName().getIdentifier().getValue()).orElse("");
+    public void check(final ShardingRule rule, final ShardingSphereDatabase 
database, final ShardingSphereSchema currentSchema, final 
TableAvailableSQLStatementContext sqlStatementContext) {
+        String tableName = ((CopyStatement) 
sqlStatementContext.getSqlStatement()).getTable().map(optional -> 
optional.getTableName().getIdentifier().getValue()).orElse("");
         
ShardingSpherePreconditions.checkState(!rule.isShardingTable(tableName), () -> 
new UnsupportedShardingOperationException("COPY", tableName));
     }
 }
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
index 5fbafef2481..ec7dcda90ff 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.sharding.checker.sql.dml;
 
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.dml.CopyStatementContext;
+import 
org.apache.shardingsphere.infra.binder.context.statement.TableAvailableSQLStatementContext;
 import 
org.apache.shardingsphere.sharding.exception.syntax.UnsupportedShardingOperationException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
@@ -44,18 +44,19 @@ class ShardingCopySupportedCheckerTest {
     
     @Test
     void assertCheckWithNotShardingTable() {
-        assertDoesNotThrow(() -> new 
ShardingCopySupportedChecker().check(rule, mock(), mock(), 
createCopyStatementContext()));
+        assertDoesNotThrow(() -> new 
ShardingCopySupportedChecker().check(rule, mock(), mock(), 
createSQLStatementContext()));
     }
     
     @Test
     void assertCheckWitShardingTable() {
         when(rule.isShardingTable("foo_tbl")).thenReturn(true);
-        assertThrows(UnsupportedShardingOperationException.class, () -> new 
ShardingCopySupportedChecker().check(rule, mock(), mock(), 
createCopyStatementContext()));
+        assertThrows(UnsupportedShardingOperationException.class, () -> new 
ShardingCopySupportedChecker().check(rule, mock(), mock(), 
createSQLStatementContext()));
     }
     
-    private CopyStatementContext createCopyStatementContext() {
+    private TableAvailableSQLStatementContext createSQLStatementContext() {
         CopyStatement sqlStatement = mock(CopyStatement.class);
-        when(sqlStatement.getTable()).thenReturn(Optional.of(new 
SimpleTableSegment(new TableNameSegment(0, 0, new 
IdentifierValue("foo_tbl")))));
-        return new CopyStatementContext(mock(), sqlStatement);
+        SimpleTableSegment table = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
+        when(sqlStatement.getTable()).thenReturn(Optional.of(table));
+        return new TableAvailableSQLStatementContext(mock(), sqlStatement, 
table);
     }
 }
diff --git 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
 
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
index 8ba016d86c3..a9196cf323d 100644
--- 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
+++ 
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
@@ -37,7 +37,6 @@ import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CursorS
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropIndexStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.FetchStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.MoveStatementContext;
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.dml.CopyStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.dml.DeleteStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.dml.InsertStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.dml.LoadDataStatementContext;
@@ -82,7 +81,6 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.Prepare
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.RenameTableStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.TruncateStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.CallStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.CopyStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DMLStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DeleteStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DoStatement;
@@ -120,7 +118,8 @@ public final class SQLStatementContextFactory {
         if (dialectSQLStatementExtractor.isPresent()) {
             Collection<SimpleTableSegment> tableSegments = 
dialectSQLStatementExtractor.get().extractTables(sqlStatement);
             if (!tableSegments.isEmpty()) {
-                return new TableAvailableSQLStatementContext(databaseType, 
sqlStatement, tableSegments);
+                return new TableAvailableSQLStatementContext(databaseType, 
sqlStatement,
+                        (1 == tableSegments.size() && null == 
tableSegments.iterator().next()) ? Collections.emptyList() : tableSegments);
             }
         }
         if (sqlStatement instanceof DMLStatement) {
@@ -152,9 +151,6 @@ public final class SQLStatementContextFactory {
         if (sqlStatement instanceof InsertStatement) {
             return new InsertStatementContext(databaseType, (InsertStatement) 
sqlStatement, params, metaData, currentDatabaseName);
         }
-        if (sqlStatement instanceof CopyStatement) {
-            return new CopyStatementContext(databaseType, (CopyStatement) 
sqlStatement);
-        }
         if (sqlStatement instanceof LoadDataStatement) {
             return new LoadDataStatementContext(databaseType, 
(LoadDataStatement) sqlStatement);
         }
diff --git 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropIndexStatementContext.java
 
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropIndexStatementContext.java
index 9c545580007..e599af7f03a 100644
--- 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropIndexStatementContext.java
+++ 
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropIndexStatementContext.java
@@ -25,7 +25,6 @@ import 
org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
-import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropIndexStatement;
 
 import java.util.Collection;
@@ -41,8 +40,7 @@ public final class DropIndexStatementContext extends 
CommonSQLStatementContext i
     
     public DropIndexStatementContext(final DatabaseType databaseType, final 
DropIndexStatement sqlStatement) {
         super(databaseType, sqlStatement);
-        SimpleTableSegment simpleTableSegment = 
sqlStatement.getSimpleTable().orElse(null);
-        tablesContext = new TablesContext(simpleTableSegment);
+        tablesContext = new 
TablesContext(sqlStatement.getSimpleTable().orElse(null));
     }
     
     @Override
diff --git a/infra/binder/dialect/opengauss/pom.xml 
b/infra/binder/dialect/opengauss/pom.xml
index 00145475ca5..ff89acfdc36 100644
--- a/infra/binder/dialect/opengauss/pom.xml
+++ b/infra/binder/dialect/opengauss/pom.xml
@@ -38,5 +38,10 @@
             
<artifactId>shardingsphere-parser-sql-statement-opengauss</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-infra-binder-postgresql</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 </project>
diff --git 
a/infra/binder/dialect/opengauss/src/main/java/org/apache/shardingsphere/infra/binder/opengauss/OpenGaussProjectionIdentifierExtractor.java
 
b/infra/binder/dialect/opengauss/src/main/java/org/apache/shardingsphere/infra/binder/opengauss/OpenGaussProjectionIdentifierExtractor.java
index 58eab321343..24bc023be4b 100644
--- 
a/infra/binder/dialect/opengauss/src/main/java/org/apache/shardingsphere/infra/binder/opengauss/OpenGaussProjectionIdentifierExtractor.java
+++ 
b/infra/binder/dialect/opengauss/src/main/java/org/apache/shardingsphere/infra/binder/opengauss/OpenGaussProjectionIdentifierExtractor.java
@@ -18,9 +18,8 @@
 package org.apache.shardingsphere.infra.binder.opengauss;
 
 import 
org.apache.shardingsphere.infra.binder.context.segment.select.projection.extractor.DialectProjectionIdentifierExtractor;
+import 
org.apache.shardingsphere.infra.binder.postgresql.PostgreSQLProjectionIdentifierExtractor;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.ExpressionSegment;
-import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.FunctionSegment;
-import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.item.ExpressionProjectionSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dml.item.SubqueryProjectionSegment;
 import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
 
@@ -29,27 +28,26 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.Iden
  */
 public final class OpenGaussProjectionIdentifierExtractor implements 
DialectProjectionIdentifierExtractor {
     
+    private final PostgreSQLProjectionIdentifierExtractor delegate = new 
PostgreSQLProjectionIdentifierExtractor();
+    
     @Override
     public String getIdentifierValue(final IdentifierValue identifierValue) {
-        return identifierValue.getValue().toLowerCase();
+        return delegate.getIdentifierValue(identifierValue);
     }
     
     @Override
     public String getColumnNameFromFunction(final String functionName, final 
String functionExpression) {
-        return functionName.toLowerCase();
+        return delegate.getColumnNameFromFunction(functionName, 
functionExpression);
     }
     
     @Override
     public String getColumnNameFromExpression(final ExpressionSegment 
expressionSegment) {
-        return expressionSegment instanceof ExpressionProjectionSegment && 
((ExpressionProjectionSegment) expressionSegment).getExpr() instanceof 
FunctionSegment
-                ? ((FunctionSegment) ((ExpressionProjectionSegment) 
expressionSegment).getExpr()).getFunctionName()
-                : "?column?";
+        return delegate.getColumnNameFromExpression(expressionSegment);
     }
     
     @Override
     public String getColumnNameFromSubquery(final SubqueryProjectionSegment 
subquerySegment) {
-        // TODO support subquery projection
-        return subquerySegment.getText();
+        return delegate.getColumnNameFromSubquery(subquerySegment);
     }
     
     @Override
diff --git 
a/infra/binder/dialect/opengauss/src/main/java/org/apache/shardingsphere/infra/binder/opengauss/OpenGaussSQLStatementExtractor.java
 
b/infra/binder/dialect/opengauss/src/main/java/org/apache/shardingsphere/infra/binder/opengauss/OpenGaussSQLStatementExtractor.java
new file mode 100644
index 00000000000..c82cf46c370
--- /dev/null
+++ 
b/infra/binder/dialect/opengauss/src/main/java/org/apache/shardingsphere/infra/binder/opengauss/OpenGaussSQLStatementExtractor.java
@@ -0,0 +1,43 @@
+/*
+ * 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.opengauss;
+
+import 
org.apache.shardingsphere.infra.binder.context.extractor.DialectSQLStatementExtractor;
+import 
org.apache.shardingsphere.infra.binder.postgresql.PostgreSQLSQLStatementExtractor;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
+
+import java.util.Collection;
+
+/**
+ * SQL statement extractor for openGauss.
+ */
+public final class OpenGaussSQLStatementExtractor implements 
DialectSQLStatementExtractor {
+    
+    private final PostgreSQLSQLStatementExtractor delegate = new 
PostgreSQLSQLStatementExtractor();
+    
+    @Override
+    public Collection<SimpleTableSegment> extractTables(final SQLStatement 
sqlStatement) {
+        return delegate.extractTables(sqlStatement);
+    }
+    
+    @Override
+    public String getDatabaseType() {
+        return "openGauss";
+    }
+}
diff --git 
a/infra/binder/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.binder.context.extractor.DialectSQLStatementExtractor
 
b/infra/binder/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.binder.context.extractor.DialectSQLStatementExtractor
new file mode 100644
index 00000000000..f5252e5019e
--- /dev/null
+++ 
b/infra/binder/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.binder.context.extractor.DialectSQLStatementExtractor
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.infra.binder.opengauss.OpenGaussSQLStatementExtractor
diff --git 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/CopyStatementContext.java
 
b/infra/binder/dialect/postgresql/src/main/java/org/apache/shardingsphere/infra/binder/postgresql/PostgreSQLSQLStatementExtractor.java
similarity index 50%
rename from 
infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/CopyStatementContext.java
rename to 
infra/binder/dialect/postgresql/src/main/java/org/apache/shardingsphere/infra/binder/postgresql/PostgreSQLSQLStatementExtractor.java
index 21fece61eb4..b11322bda61 100644
--- 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/CopyStatementContext.java
+++ 
b/infra/binder/dialect/postgresql/src/main/java/org/apache/shardingsphere/infra/binder/postgresql/PostgreSQLSQLStatementExtractor.java
@@ -15,35 +15,31 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.infra.binder.context.statement.type.dml;
+package org.apache.shardingsphere.infra.binder.postgresql;
 
-import lombok.Getter;
-import 
org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
-import 
org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
-import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.binder.context.extractor.DialectSQLStatementExtractor;
 import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.dml.CopyStatement;
 
 import java.util.Collection;
 import java.util.Collections;
 
 /**
- * Copy statement context.
+ * SQL statement extractor for PostgreSQL.
  */
-@Getter
-public final class CopyStatementContext extends CommonSQLStatementContext 
implements TableAvailable {
+public final class PostgreSQLSQLStatementExtractor implements 
DialectSQLStatementExtractor {
     
-    private final TablesContext tablesContext;
-    
-    public CopyStatementContext(final DatabaseType databaseType, final 
CopyStatement sqlStatement) {
-        super(databaseType, sqlStatement);
-        Collection<SimpleTableSegment> tables = 
sqlStatement.getTable().isPresent() ? 
Collections.singleton(sqlStatement.getTable().get()) : Collections.emptyList();
-        tablesContext = new TablesContext(tables);
+    @Override
+    public Collection<SimpleTableSegment> extractTables(final SQLStatement 
sqlStatement) {
+        if (sqlStatement instanceof CopyStatement) {
+            return Collections.singleton(((CopyStatement) 
sqlStatement).getTable().isPresent() ? ((CopyStatement) 
sqlStatement).getTable().get() : null);
+        }
+        return Collections.emptyList();
     }
     
     @Override
-    public CopyStatement getSqlStatement() {
-        return (CopyStatement) super.getSqlStatement();
+    public String getDatabaseType() {
+        return "PostgreSQL";
     }
 }
diff --git 
a/infra/binder/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.binder.context.extractor.DialectSQLStatementExtractor
 
b/infra/binder/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.binder.context.extractor.DialectSQLStatementExtractor
new file mode 100644
index 00000000000..aacf7f28a2e
--- /dev/null
+++ 
b/infra/binder/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.binder.context.extractor.DialectSQLStatementExtractor
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.infra.binder.postgresql.PostgreSQLSQLStatementExtractor

Reply via email to