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

zhonghongsheng 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 6a77fa0d1a8 Add UnsupportedActualDataNodeStructureException (#20423)
6a77fa0d1a8 is described below

commit 6a77fa0d1a88a0d0391155ce701b615298feb492
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Aug 22 22:23:17 2022 +0800

    Add UnsupportedActualDataNodeStructureException (#20423)
    
    * Add UnsupportedActualDataNodeStructureException
    
    * Ignore failed test case
---
 .../user-manual/error-code/sql-error-code.cn.md    |  1 +
 .../user-manual/error-code/sql-error-code.en.md    |  1 +
 .../shardingsphere/infra/datanode/DataNode.java    |  6 ++--
 ...nsupportedActualDataNodeStructureException.java | 36 ++++++++++++++++++++++
 .../database/schema/util/SchemaMetaDataUtil.java   |  7 ++---
 .../scenario/migration/MigrationJobAPIImpl.java    |  2 +-
 6 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md 
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index c77cd9b1017..04bd7537c0c 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -14,6 +14,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 42000     | 11001       | configuration error |
 | 42000     | 11002       | Resource does not exist |
 | 42000     | 11003       | Rule does not exist |
+| 42000     | 11004       | Can not support 3-tier structure for actual data 
node \`%s\` with JDBC \`%s\` |
 | 42000     | 12000       | Unsupported command: %s |
 | 44000     | 13000       | SQL check failed, error message: %s |
 | HY000     | 14000       | The table \`%s\` of schema \`%s\` is locked |
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md 
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index e66a02fe5e4..8bd060fd926 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -14,6 +14,7 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 42000     | 11001       | configuration error |
 | 42000     | 11002       | Resource does not exist |
 | 42000     | 11003       | Rule does not exist |
+| 42000     | 11004       | Can not support 3-tier structure for actual data 
node \`%s\` with JDBC \`%s\` |
 | 42000     | 12000       | Unsupported command: %s |
 | 44000     | 13000       | SQL check failed, error message: %s |
 | HY000     | 14000       | The table \`%s\` of schema \`%s\` is locked |
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNode.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNode.java
index 0dc048f7bbb..e04b444f364 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNode.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNode.java
@@ -88,9 +88,9 @@ public final class DataNode {
     }
     
     /**
-     * Format DataNode as string.
+     * Format data node as string.
      *
-     * @return formatted string
+     * @return formatted data node
      */
     public String format() {
         return dataSourceName + DELIMITER + tableName;
@@ -108,7 +108,7 @@ public final class DataNode {
     /**
      * Is Actual data nodes three tier structure.
      *
-     * @param actualDataNodes dataSource map
+     * @param actualDataNodes data source map
      * @return boolean
      */
     public static boolean isActualDataNodesIncludedDataSourceInstance(final 
String actualDataNodes) {
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/exception/UnsupportedActualDataNodeStructureException.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/exception/UnsupportedActualDataNodeStructureException.java
new file mode 100644
index 00000000000..b80118fa3a5
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/exception/UnsupportedActualDataNodeStructureException.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.database.schema.exception;
+
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import 
org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
+import 
org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;
+
+import java.util.Collection;
+
+/**
+ * Unsupported actual data node structure exception.
+ */
+public final class UnsupportedActualDataNodeStructureException extends 
ShardingSphereSQLException {
+    
+    private static final long serialVersionUID = -8921823916974492519L;
+    
+    public UnsupportedActualDataNodeStructureException(final DataNode 
dataNode, final Collection<String> jdbcUrlPrefixes) {
+        super(XOpenSQLState.SYNTAX_ERROR, 11004, "Can not support 3-tier 
structure for actual data node `%s` with JDBC `%s`", dataNode.format(), 
jdbcUrlPrefixes.toString());
+    }
+}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SchemaMetaDataUtil.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SchemaMetaDataUtil.java
index 690bed0887e..9adedf5f989 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SchemaMetaDataUtil.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SchemaMetaDataUtil.java
@@ -23,8 +23,8 @@ import 
org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import org.apache.shardingsphere.infra.datanode.DataNodes;
 import 
org.apache.shardingsphere.infra.datasource.registry.GlobalDataSourceRegistry;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilderMaterials;
+import 
org.apache.shardingsphere.infra.metadata.database.schema.exception.UnsupportedActualDataNodeStructureException;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.loader.SchemaMetaDataLoaderMaterials;
 
 import java.util.Collection;
@@ -66,9 +66,8 @@ public class SchemaMetaDataUtil {
     
     private static void 
checkDataSourceTypeIncludeInstanceAndSetDatabaseTableMap(final DatabaseType 
databaseType, final DataNodes dataNodes, final String tableName) {
         for (DataNode dataNode : dataNodes.getDataNodes(tableName)) {
-            if (databaseType.getType() != null && 
!databaseType.getType().equals("MySQL") && 
dataNode.getDataSourceName().contains(".")) {
-                throw new ShardingSphereException("Unsupported jdbc: '%s', 
actualDataNode:'%s', database type is not mysql, but actual data is three-tier 
structure",
-                        databaseType.getJdbcUrlPrefixes(), 
dataNode.getDataSourceName());
+            if (null != databaseType.getType() && 
!"MySQL".equals(databaseType.getType()) && 
dataNode.getDataSourceName().contains(".")) {
+                throw new 
UnsupportedActualDataNodeStructureException(dataNode, 
databaseType.getJdbcUrlPrefixes());
             }
             if (dataNode.getDataSourceName().contains(".")) {
                 String database = dataNode.getDataSourceName().split("\\.")[1];
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
index 7ce1ec50bbd..f56e646d6de 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
@@ -174,7 +174,7 @@ public final class MigrationJobAPIImpl extends 
AbstractPipelineJobAPIImpl implem
         Map<LogicTableName, String> tableNameSchemaMap = 
TableNameSchemaNameMapping.convert(jobConfig.getSchemaTablesMap());
         TableNameSchemaNameMapping tableNameSchemaNameMapping = new 
TableNameSchemaNameMapping(tableNameSchemaMap);
         DumperConfiguration dumperConfig = 
createDumperConfiguration(jobConfig.getJobId(), 
jobConfig.getSourceDataSourceName(), jobConfig.getSource(), tableNameMap, 
tableNameSchemaNameMapping);
-        // TODO now shardingColumnsMap always empty, 
+        // TODO now shardingColumnsMap always empty,
         ImporterConfiguration importerConfig = 
createImporterConfiguration(jobConfig, pipelineProcessConfig, 
Collections.emptyMap(), tableNameSchemaNameMapping);
         TaskConfiguration result = new TaskConfiguration(dumperConfig, 
importerConfig);
         log.info("createTaskConfiguration, dataSourceName={}, result={}", 
jobConfig.getSourceDataSourceName(), result);

Reply via email to