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 fc4e48e20e5 Use DialectKernelSupportedSystemTable to instead of 
KernelSupportedSystemTables (#37071)
fc4e48e20e5 is described below

commit fc4e48e20e59ec44ac79598ba1ed134aa871090e
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Nov 11 23:52:48 2025 +0800

    Use DialectKernelSupportedSystemTable to instead of 
KernelSupportedSystemTables (#37071)
    
    * Refactor KernelSupportedSystemTables
    
    * Use DialectKernelSupportedSystemTable to instead of 
KernelSupportedSystemTables
    
    * Use DialectKernelSupportedSystemTable to instead of 
KernelSupportedSystemTables
    
    * Use DialectKernelSupportedSystemTable to instead of 
KernelSupportedSystemTables
---
 .../system/DialectKernelSupportedSystemTable.java  |  38 +++++++
 .../system/MySQLKernelSupportedSystemTable.java    |  31 +++---
 ...tabase.system.DialectKernelSupportedSystemTable |  18 ++++
 .../OpenGaussKernelSupportedSystemTable.java       |  58 +++++++++++
 ...tabase.system.DialectKernelSupportedSystemTable |  18 ++++
 .../PostgreSQLKernelSupportedSystemTable.java      |  45 +++++++++
 ...tabase.system.DialectKernelSupportedSystemTable |  18 ++++
 .../builder/KernelSupportedSystemTables.java       | 109 ---------------------
 .../schema/builder/SystemSchemaBuilder.java        |  30 ++++--
 9 files changed, 231 insertions(+), 134 deletions(-)

diff --git 
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/system/DialectKernelSupportedSystemTable.java
 
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/system/DialectKernelSupportedSystemTable.java
new file mode 100644
index 00000000000..1ed0d74302f
--- /dev/null
+++ 
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/system/DialectKernelSupportedSystemTable.java
@@ -0,0 +1,38 @@
+/*
+ * 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.database.connector.core.metadata.database.system;
+
+import org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPI;
+import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Dialect kernel supported system table.
+ */
+@SingletonSPI
+public interface DialectKernelSupportedSystemTable extends DatabaseTypedSPI {
+    
+    /**
+     * Get system database schema map.
+     *
+     * @return system database schema map
+     */
+    Map<String, Collection<String>> getSchemaAndTablesMap();
+}
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/KernelSupportedSystemTablesTest.java
 
b/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/system/MySQLKernelSupportedSystemTable.java
similarity index 50%
rename from 
infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/KernelSupportedSystemTablesTest.java
rename to 
database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/system/MySQLKernelSupportedSystemTable.java
index 5edb4b03e74..989d18189c1 100644
--- 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/KernelSupportedSystemTablesTest.java
+++ 
b/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/system/MySQLKernelSupportedSystemTable.java
@@ -15,27 +15,26 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.infra.metadata.database.schema.builder;
+package 
org.apache.shardingsphere.database.connector.mysql.metadata.database.system;
 
-import org.junit.jupiter.api.Test;
+import 
org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable;
 
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
 
-class KernelSupportedSystemTablesTest {
-    
-    @Test
-    void assertIsSupportedSystemTableWithMatchingSchemaAndTable() {
-        assertTrue(KernelSupportedSystemTables.isSupportedSystemTable("sys", 
"sys_config"));
-    }
+/**
+ * Kernel supported system table for MySQL.
+ */
+public final class MySQLKernelSupportedSystemTable implements 
DialectKernelSupportedSystemTable {
     
-    @Test
-    void assertIsNotSupportedSystemTableWithMatchingSchemaButWrongTable() {
-        assertFalse(KernelSupportedSystemTables.isSupportedSystemTable("sys", 
"non_existent_table"));
+    @Override
+    public Map<String, Collection<String>> getSchemaAndTablesMap() {
+        return Collections.singletonMap("sys", 
Collections.singleton("sys_config"));
     }
     
-    @Test
-    void assertIsNotSupportedSystemTableWithUnmatchedSchema() {
-        
assertFalse(KernelSupportedSystemTables.isSupportedSystemTable("non_existent_schema",
 "any_table"));
+    @Override
+    public String getDatabaseType() {
+        return "MySQL";
     }
 }
diff --git 
a/database/connector/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
 
b/database/connector/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
new file mode 100644
index 00000000000..994b2139d13
--- /dev/null
+++ 
b/database/connector/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
@@ -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.database.connector.mysql.metadata.database.system.MySQLKernelSupportedSystemTable
diff --git 
a/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/system/OpenGaussKernelSupportedSystemTable.java
 
b/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/system/OpenGaussKernelSupportedSystemTable.java
new file mode 100644
index 00000000000..3fdad741a69
--- /dev/null
+++ 
b/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/system/OpenGaussKernelSupportedSystemTable.java
@@ -0,0 +1,58 @@
+/*
+ * 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.database.connector.opengauss.metadata.database.system;
+
+import 
org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Kernel supported system table for openGauss.
+ */
+public final class OpenGaussKernelSupportedSystemTable implements 
DialectKernelSupportedSystemTable {
+    
+    @Override
+    public Map<String, Collection<String>> getSchemaAndTablesMap() {
+        Map<String, Collection<String>> result = new HashMap<>(15, 1F);
+        result.put("information_schema", Collections.emptySet());
+        result.put("pg_catalog", Arrays.asList("pg_class", "pg_namespace", 
"pg_database", "pg_roles", "pg_tables", "pg_tablespace"));
+        result.put("blockchain", Collections.emptySet());
+        result.put("cstore", Collections.emptySet());
+        result.put("db4ai", Collections.emptySet());
+        result.put("dbe_perf", Collections.emptySet());
+        result.put("dbe_pldebugger", Collections.emptySet());
+        result.put("gaussdb", Collections.emptySet());
+        result.put("oracle", Collections.emptySet());
+        result.put("pkg_service", Collections.emptySet());
+        result.put("snapshot", Collections.emptySet());
+        result.put("dbe_pldeveloper", Collections.emptySet());
+        result.put("pg_toast", Collections.emptySet());
+        result.put("pkg_util", Collections.emptySet());
+        result.put("sqladvisor", Collections.emptySet());
+        return result;
+    }
+    
+    @Override
+    public String getDatabaseType() {
+        return "openGauss";
+    }
+}
diff --git 
a/database/connector/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
 
b/database/connector/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
new file mode 100644
index 00000000000..1c7a47ea70a
--- /dev/null
+++ 
b/database/connector/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
@@ -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.database.connector.opengauss.metadata.database.system.OpenGaussKernelSupportedSystemTable
diff --git 
a/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/system/PostgreSQLKernelSupportedSystemTable.java
 
b/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/system/PostgreSQLKernelSupportedSystemTable.java
new file mode 100644
index 00000000000..6dcfb328714
--- /dev/null
+++ 
b/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/system/PostgreSQLKernelSupportedSystemTable.java
@@ -0,0 +1,45 @@
+/*
+ * 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.database.connector.postgresql.metadata.database.system;
+
+import 
org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+/**
+ * Kernel supported system table for PostgreSQL.
+ */
+public final class PostgreSQLKernelSupportedSystemTable implements 
DialectKernelSupportedSystemTable {
+    
+    @Override
+    public Map<String, Collection<String>> getSchemaAndTablesMap() {
+        Map<String, Collection<String>> result = new HashMap<>(2, 1F);
+        result.put("information_schema", new 
HashSet<>(Arrays.asList("columns", "tables", "views")));
+        result.put("pg_catalog", Arrays.asList("pg_aggregate", "pg_class", 
"pg_database", "pg_tables", "pg_inherits", "pg_tablespace", "pg_trigger", 
"pg_namespace", "pg_roles"));
+        return result;
+    }
+    
+    @Override
+    public String getDatabaseType() {
+        return "PostgreSQL";
+    }
+}
diff --git 
a/database/connector/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
 
b/database/connector/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
new file mode 100644
index 00000000000..fbffcacfe77
--- /dev/null
+++ 
b/database/connector/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable
@@ -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.database.connector.postgresql.metadata.database.system.PostgreSQLKernelSupportedSystemTable
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/KernelSupportedSystemTables.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/KernelSupportedSystemTables.java
deleted file mode 100644
index 968100ab273..00000000000
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/KernelSupportedSystemTables.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.metadata.database.schema.builder;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-/**
- * Kernel supported system tables.
- */
-@RequiredArgsConstructor
-@Getter
-public enum KernelSupportedSystemTables {
-    
-    MYSQL_SYS("MySQL", "sys", new 
HashSet<>(Collections.singleton("sys_config"))),
-    
-    MYSQL_SHARDING_SPHERE("MySQL", "shardingsphere", new 
HashSet<>(Collections.singletonList("cluster_information"))),
-    
-    POSTGRESQL_INFORMATION_SCHEMA("PostgreSQL", "information_schema", new 
HashSet<>(Arrays.asList("columns", "tables", "views"))),
-    
-    POSTGRESQL_PG_CATALOG("PostgreSQL", "pg_catalog", new 
HashSet<>(Arrays.asList("pg_aggregate", "pg_class", "pg_database", "pg_tables", 
"pg_inherits",
-            "pg_tablespace", "pg_trigger", "pg_namespace", "pg_roles"))),
-    
-    POSTGRESQL_SHARDING_SPHERE("PostgreSQL", "shardingsphere", new 
HashSet<>(Collections.singletonList("cluster_information"))),
-    
-    OPEN_GAUSS_INFORMATION_SCHEMA("openGauss", "information_schema", 
Collections.emptySet()),
-    
-    OPEN_GAUSS_PG_CATALOG("openGauss", "pg_catalog", new 
HashSet<>(Arrays.asList("pg_class", "pg_namespace", "pg_database", "pg_roles", 
"pg_tables", "pg_tablespace"))),
-    
-    OPEN_GAUSS_BLOCKCHAIN("openGauss", "blockchain", Collections.emptySet()),
-    
-    OPEN_GAUSS_CSTORE("openGauss", "cstore", Collections.emptySet()),
-    
-    OPEN_GAUSS_DB4AI("openGauss", "db4ai", Collections.emptySet()),
-    
-    OPEN_GAUSS_DBE_PERF("openGauss", "dbe_perf", Collections.emptySet()),
-    
-    OPEN_GAUSS_DBE_PLDEBUGGER("openGauss", "dbe_pldebugger", 
Collections.emptySet()),
-    
-    OPEN_GAUSS_GAUSSDB("openGauss", "gaussdb", Collections.emptySet()),
-    
-    OPEN_GAUSS_ORACLE("openGauss", "oracle", Collections.emptySet()),
-    
-    OPEN_GAUSS_PKG_SERVICE("openGauss", "pkg_service", Collections.emptySet()),
-    
-    OPEN_GAUSS_SNAPSHOT("openGauss", "snapshot", Collections.emptySet()),
-    
-    OPEN_GAUSS_PLDEVELOPER("openGauss", "dbe_pldeveloper", 
Collections.emptySet()),
-    
-    OPEN_GAUSS_PG_TOAST("openGauss", "pg_toast", Collections.emptySet()),
-    
-    OPEN_GAUSS_PKG_UTIL("openGauss", "pkg_util", Collections.emptySet()),
-    
-    OPEN_GAUSS_SQLADVISOR("openGauss", "sqladvisor", Collections.emptySet()),
-    
-    OPEN_GAUSS_SHARDING_SPHERE("openGauss", "shardingsphere", new 
HashSet<>(Collections.singletonList("cluster_information")));
-    
-    private static final Map<String, KernelSupportedSystemTables> 
SCHEMA_NAME_TO_TABLES = new HashMap<>(values().length, 1F);
-    
-    private final String databaseType;
-    
-    private final String schema;
-    
-    private final Collection<String> tables;
-    
-    static {
-        for (KernelSupportedSystemTables each : values()) {
-            SCHEMA_NAME_TO_TABLES.put(each.getDatabaseType() + "." + 
each.getSchema(), each);
-        }
-    }
-    
-    /**
-     * Judge whether current table is kernel supported system table or not.
-     *
-     * @param schema schema
-     * @param tableName table name
-     * @return whether current table is kernel supported system table or not
-     */
-    public static boolean isSupportedSystemTable(final String schema, final 
String tableName) {
-        for (KernelSupportedSystemTables each : values()) {
-            if (each.getSchema().equals(schema) && 
each.getTables().contains(tableName)) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilder.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilder.java
index 26d5dcd7e0a..812c334a083 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilder.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilder.java
@@ -20,7 +20,9 @@ package 
org.apache.shardingsphere.infra.metadata.database.schema.builder;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.DialectDatabaseMetaData;
+import 
org.apache.shardingsphere.database.connector.core.metadata.database.system.DialectKernelSupportedSystemTable;
 import 
org.apache.shardingsphere.database.connector.core.metadata.database.system.SystemDatabase;
+import 
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
 import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
 import 
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
@@ -38,7 +40,9 @@ import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Properties;
+import java.util.stream.Collectors;
 
 /**
  * System schema builder.
@@ -46,6 +50,8 @@ import java.util.Properties;
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class SystemSchemaBuilder {
     
+    private static final YamlTableSwapper TABLE_SWAPPER = new 
YamlTableSwapper();
+    
     /**
      * Build system schema.
      *
@@ -56,13 +62,11 @@ public final class SystemSchemaBuilder {
      */
     public static Map<String, ShardingSphereSchema> build(final String 
databaseName, final DatabaseType databaseType, final ConfigurationProperties 
props) {
         SystemDatabase systemDatabase = new SystemDatabase(databaseType);
-        Map<String, ShardingSphereSchema> result = new 
LinkedHashMap<>(systemDatabase.getSystemSchemas().size(), 1F);
         boolean isSystemSchemaMetaDataEnabled = 
isSystemSchemaMetaDataEnabled(props.getProps());
-        YamlTableSwapper swapper = new YamlTableSwapper();
-        for (String each : getSystemSchemas(databaseName, databaseType, 
systemDatabase)) {
-            result.put(each.toLowerCase(), createSchema(each, 
SystemSchemaManager.getAllInputStreams(databaseType.getType(), each), swapper, 
isSystemSchemaMetaDataEnabled));
-        }
-        return result;
+        return getSystemSchemas(databaseName, databaseType, 
systemDatabase).stream()
+                .collect(Collectors.toMap(
+                        String::toLowerCase, each -> 
createSchema(databaseType, each, 
SystemSchemaManager.getAllInputStreams(databaseType.getType(), each), 
isSystemSchemaMetaDataEnabled),
+                        (oldValue, currentValue) -> currentValue, 
LinkedHashMap::new));
     }
     
     private static boolean isSystemSchemaMetaDataEnabled(final Properties 
props) {
@@ -76,15 +80,23 @@ public final class SystemSchemaBuilder {
         return 
systemDatabase.getSystemDatabaseSchemaMap().getOrDefault(databaseName, 
Collections.emptyList());
     }
     
-    private static ShardingSphereSchema createSchema(final String schemaName, 
final Collection<InputStream> schemaStreams, final YamlTableSwapper swapper,
+    private static ShardingSphereSchema createSchema(final DatabaseType 
databaseType, final String schemaName, final Collection<InputStream> 
schemaStreams,
                                                      final boolean 
isSystemSchemaMetadataEnabled) {
         Collection<ShardingSphereTable> tables = new LinkedList<>();
         for (InputStream each : schemaStreams) {
             YamlShardingSphereTable metaData = new Yaml().loadAs(each, 
YamlShardingSphereTable.class);
-            if (isSystemSchemaMetadataEnabled || 
KernelSupportedSystemTables.isSupportedSystemTable(schemaName, 
metaData.getName())) {
-                tables.add(swapper.swapToObject(metaData));
+            if (isSystemSchemaMetadataEnabled || 
isSupportedSystemTable(databaseType, schemaName, metaData.getName())) {
+                tables.add(TABLE_SWAPPER.swapToObject(metaData));
             }
         }
         return new ShardingSphereSchema(schemaName, tables, 
Collections.emptyList());
     }
+    
+    private static boolean isSupportedSystemTable(final DatabaseType 
databaseType, final String schemaName, final String tableName) {
+        if ("shardingsphere".equals(schemaName) && 
"cluster_information".equals(tableName)) {
+            return true;
+        }
+        Optional<DialectKernelSupportedSystemTable> kernelSupportedSystemTable 
= DatabaseTypedSPILoader.findService(DialectKernelSupportedSystemTable.class, 
databaseType);
+        return kernelSupportedSystemTable.map(optional -> 
optional.getSchemaAndTablesMap().getOrDefault(schemaName, 
Collections.emptySet()).contains(tableName)).orElse(false);
+    }
 }

Reply via email to