You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/10/02 08:48:55 UTC

[shardingsphere] branch master updated: Add UnsupportedPipelineJobUniqueKeyDataTypeException (#21318)

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

duanzhengqiang 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 0304f03c4e1 Add UnsupportedPipelineJobUniqueKeyDataTypeException (#21318)
0304f03c4e1 is described below

commit 0304f03c4e16d3a65dd5584ee1f20bb7216455aa
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Oct 2 16:48:47 2022 +0800

    Add UnsupportedPipelineJobUniqueKeyDataTypeException (#21318)
---
 .../user-manual/error-code/sql-error-code.cn.md    |  1 +
 .../user-manual/error-code/sql-error-code.en.md    |  1 +
 ...ortedPipelineJobUniqueKeyDataTypeException.java | 33 ++++++++++++++++++++++
 .../ingest/dumper/AbstractInventoryDumper.java     |  3 +-
 .../sqlbuilder/AbstractPipelineSQLBuilder.java     |  3 +-
 .../core/sqlbuilder/OraclePipelineSQLBuilder.java  |  3 +-
 6 files changed, 41 insertions(+), 3 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 10d3b044653..2dc72e49e4c 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
@@ -96,6 +96,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | HY000     | 18020       | Failed to get DDL for table \`%s\`. |
 | 42S01     | 18030       | Duplicate resource names \`%s\`. |
 | 42S02     | 18031       | Resource names \`%s\` do not exist. |
+| 0A000     | 18032       | Unsupported data type \`%s\` of unique key for pipeline job. |
 | HY000     | 18050       | Before data record is \`%s\`, after data record is \`%s\`. |
 | 08000     | 18051       | Data check table \`%s\` failed. |
 | 0A000     | 18052       | Unsupported pipeline database type \`%s\`. |
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 f55fdc05126..51efcb8ae1b 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
@@ -96,6 +96,7 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
 | HY000     | 18020       | Failed to get DDL for table \`%s\`. |
 | 42S01     | 18030       | Duplicate resource names \`%s\`. |
 | 42S02     | 18031       | Resource names \`%s\` do not exist. |
+| 0A000     | 18032       | Unsupported data type \`%s\` of unique key for pipeline job. |
 | HY000     | 18050       | Before data record is \`%s\`, after data record is \`%s\`. |
 | 08000     | 18051       | Data check table \`%s\` failed. |
 | 0A000     | 18052       | Unsupported pipeline database type \`%s\`. |
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/data/UnsupportedPipelineJobUniqueKeyDataTypeException.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/data/UnsupportedPipelineJobUniqueKeyDataTypeException.java
new file mode 100644
index 00000000000..edc9151c5ae
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/exception/data/UnsupportedPipelineJobUniqueKeyDataTypeException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.data.pipeline.core.exception.data;
+
+import org.apache.shardingsphere.data.pipeline.core.exception.PipelineSQLException;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
+
+/**
+ * Unsupported pipeline job unique key data type exception.
+ */
+public final class UnsupportedPipelineJobUniqueKeyDataTypeException extends PipelineSQLException {
+    
+    private static final long serialVersionUID = -1605633809724671592L;
+    
+    public UnsupportedPipelineJobUniqueKeyDataTypeException(final int uniqueKeyDataType) {
+        super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 32, "Unsupported data type `%s` of unique key for pipeline job.", uniqueKeyDataType);
+    }
+}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java
index 7a5da0d4f0a..d14b3ccfde9 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java
@@ -41,6 +41,7 @@ import org.apache.shardingsphere.data.pipeline.api.job.JobOperationType;
 import org.apache.shardingsphere.data.pipeline.api.metadata.LogicTableName;
 import org.apache.shardingsphere.data.pipeline.api.metadata.loader.PipelineTableMetaDataLoader;
 import org.apache.shardingsphere.data.pipeline.api.metadata.model.PipelineTableMetaData;
+import org.apache.shardingsphere.data.pipeline.core.exception.data.UnsupportedPipelineJobUniqueKeyDataTypeException;
 import org.apache.shardingsphere.data.pipeline.core.ingest.IngestDataChangeType;
 import org.apache.shardingsphere.data.pipeline.core.ingest.exception.IngestException;
 import org.apache.shardingsphere.data.pipeline.core.sqlbuilder.PipelineSQLBuilderFactory;
@@ -161,7 +162,7 @@ public abstract class AbstractInventoryDumper extends AbstractLifecycleExecutor
                 preparedStatement.setObject(1, startUniqueKeyValue);
                 preparedStatement.setInt(2, batchSize);
             } else {
-                throw new IllegalArgumentException("Unsupported uniqueKeyDataType: " + uniqueKeyDataType);
+                throw new UnsupportedPipelineJobUniqueKeyDataTypeException(uniqueKeyDataType);
             }
             try (ResultSet resultSet = preparedStatement.executeQuery()) {
                 ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/AbstractPipelineSQLBuilder.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/AbstractPipelineSQLBuilder.java
index 06ee1f0b349..cf4690c8661 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/AbstractPipelineSQLBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/AbstractPipelineSQLBuilder.java
@@ -22,6 +22,7 @@ import lombok.NonNull;
 import org.apache.shardingsphere.data.pipeline.api.ingest.record.Column;
 import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
 import org.apache.shardingsphere.data.pipeline.api.metadata.LogicTableName;
+import org.apache.shardingsphere.data.pipeline.core.exception.data.UnsupportedPipelineJobUniqueKeyDataTypeException;
 import org.apache.shardingsphere.data.pipeline.core.record.RecordUtil;
 import org.apache.shardingsphere.data.pipeline.core.util.PipelineJdbcUtils;
 import org.apache.shardingsphere.data.pipeline.spi.sqlbuilder.PipelineSQLBuilder;
@@ -70,7 +71,7 @@ public abstract class AbstractPipelineSQLBuilder implements PipelineSQLBuilder {
         if (PipelineJdbcUtils.isStringColumn(uniqueKeyDataType)) {
             return String.format("SELECT * FROM %s WHERE %s%s? ORDER BY %s ASC LIMIT ?", qualifiedTableName, quotedUniqueKey, firstQuery ? ">=" : ">", quotedUniqueKey);
         }
-        throw new IllegalArgumentException("Unknown uniqueKeyDataType: " + uniqueKeyDataType);
+        throw new UnsupportedPipelineJobUniqueKeyDataTypeException(uniqueKeyDataType);
     }
     
     protected final String getQualifiedTableName(final String schemaName, final String tableName) {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
index ac9f89ab7f0..871d81e400e 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.data.pipeline.core.sqlbuilder;
 import lombok.NonNull;
 import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
 import org.apache.shardingsphere.data.pipeline.api.metadata.LogicTableName;
+import org.apache.shardingsphere.data.pipeline.core.exception.data.UnsupportedPipelineJobUniqueKeyDataTypeException;
 import org.apache.shardingsphere.data.pipeline.core.util.PipelineJdbcUtils;
 import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
 
@@ -47,7 +48,7 @@ public final class OraclePipelineSQLBuilder extends AbstractPipelineSQLBuilder {
         if (PipelineJdbcUtils.isStringColumn(uniqueKeyDataType)) {
             return String.format("SELECT * FROM (SELECT * FROM %s WHERE %s%s? ORDER BY %s ASC) WHERE ROWNUM<=?", qualifiedTableName, quotedUniqueKey, firstQuery ? ">=" : ">", quotedUniqueKey);
         }
-        throw new IllegalArgumentException("Unknown uniqueKeyDataType: " + uniqueKeyDataType);
+        throw new UnsupportedPipelineJobUniqueKeyDataTypeException(uniqueKeyDataType);
     }
     
     @Override