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 b652df5b320 Fix unsigned number column value type inconsistent in 
inventory and incremental (#37280)
b652df5b320 is described below

commit b652df5b32008fa4ca1f38a19b38d424535556a5
Author: Hongsheng Zhong <[email protected]>
AuthorDate: Fri Dec 5 16:45:26 2025 +0800

    Fix unsigned number column value type inconsistent in inventory and 
incremental (#37280)
    
    * Fix unsigned number column value type inconsistent in inventory and 
incremental
    
    * Update RELEASE-NOTES.md
---
 RELEASE-NOTES.md                                                   | 1 +
 .../dumper/inventory/column/InventoryColumnValueReaderEngine.java  | 4 +++-
 .../data/unsigned/impl/MySQLBinlogUnsignedBigintHandler.java       | 2 +-
 .../binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandler.java   | 2 +-
 .../data/unsigned/impl/MySQLBinlogUnsignedSmallintHandler.java     | 2 +-
 .../data/unsigned/impl/MySQLBinlogUnsignedTinyintHandler.java      | 4 ++--
 .../data/unsigned/impl/MySQLBinlogUnsignedBigintHandlerTest.java   | 5 ++++-
 .../data/unsigned/impl/MySQLBinlogUnsignedIntHandlerTest.java      | 3 +++
 .../unsigned/impl/MySQLBinlogUnsignedMediumintHandlerTest.java     | 3 +++
 .../data/unsigned/impl/MySQLBinlogUnsignedSmallintHandlerTest.java | 3 +++
 .../data/unsigned/impl/MySQLBinlogUnsignedTinyintHandlerTest.java  | 7 +++++--
 .../inventory/column/InventoryColumnValueReaderEngineTest.java     | 3 ++-
 12 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 52205305ebc..a767d6f63c1 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -105,6 +105,7 @@
 1. Pipeline: Fix InventoryDumper first time dump SQL without ORDER BY on 
multiple columns unique key table - 
[#34736](https://github.com/apache/shardingsphere/pull/34736)
 1. Pipeline: Fix MySQL JDBC query properties extension when SSL is required on 
server - [#36581](https://github.com/apache/shardingsphere/pull/36581)
 1. Pipeline: Fix migration might skip some records on big table after job 
restarting - [#36878](https://github.com/apache/shardingsphere/pull/36878)
+1. Pipeline: Fix unsigned number column value type inconsistent in inventory 
and incremental - [#37280](https://github.com/apache/shardingsphere/pull/37280)
 
 ### Change Logs
 
diff --git 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/column/InventoryColumnValueReaderEngine.java
 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/column/InventoryColumnValueReaderEngine.java
index 6a8ae2b091a..8e67cb02d52 100644
--- 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/column/InventoryColumnValueReaderEngine.java
+++ 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/column/InventoryColumnValueReaderEngine.java
@@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
 import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
 
+import java.math.BigDecimal;
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.NClob;
@@ -85,7 +86,8 @@ public final class InventoryColumnValueReaderEngine {
                 if (isSigned(metaData, columnIndex)) {
                     return resultSet.getLong(columnIndex);
                 } else {
-                    return resultSet.getBigDecimal(columnIndex);
+                    BigDecimal decimal = resultSet.getBigDecimal(columnIndex);
+                    return null == decimal ? null : decimal.toBigInteger();
                 }
             case Types.NUMERIC:
             case Types.DECIMAL:
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedBigintHandler.java
 
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedBigintHandler.java
index c6eb91bf275..e0305f325b8 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedBigintHandler.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedBigintHandler.java
@@ -30,6 +30,6 @@ public final class MySQLBinlogUnsignedBigintHandler 
implements MySQLBinlogUnsign
     
     @Override
     public Number handle(final Long value) {
-        return value < 0L ? BIGINT_MODULO.add(BigInteger.valueOf(value)) : 
value;
+        return value < 0L ? BIGINT_MODULO.add(BigInteger.valueOf(value)) : 
BigInteger.valueOf(value);
     }
 }
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandler.java
 
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandler.java
index 79c64c9ad07..22d03883100 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandler.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandler.java
@@ -28,6 +28,6 @@ public final class MySQLBinlogUnsignedIntHandler implements 
MySQLBinlogUnsignedN
     
     @Override
     public Number handle(final Integer value) {
-        return value < 0 ? INT_MODULO + value : value;
+        return value < 0 ? INT_MODULO + value : value.longValue();
     }
 }
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedSmallintHandler.java
 
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedSmallintHandler.java
index 64d0e12274a..7be263df382 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedSmallintHandler.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedSmallintHandler.java
@@ -28,6 +28,6 @@ public final class MySQLBinlogUnsignedSmallintHandler 
implements MySQLBinlogUnsi
     
     @Override
     public Number handle(final Short value) {
-        return value < 0 ? SMALLINT_MODULO + value : value;
+        return value < 0 ? SMALLINT_MODULO + value : value.intValue();
     }
 }
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedTinyintHandler.java
 
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedTinyintHandler.java
index a1bdeee467c..4e19ba3e7ae 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedTinyintHandler.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedTinyintHandler.java
@@ -24,10 +24,10 @@ import 
org.apache.shardingsphere.data.pipeline.mysql.ingest.incremental.binlog.d
  */
 public final class MySQLBinlogUnsignedTinyintHandler implements 
MySQLBinlogUnsignedNumberHandler<Byte> {
     
-    private static final int TINYINT_MODULO = 256;
+    private static final short TINYINT_MODULO = 256;
     
     @Override
     public Number handle(final Byte value) {
-        return value < 0 ? TINYINT_MODULO + value : value;
+        return value < 0 ? (short) (TINYINT_MODULO + value) : 
value.shortValue();
     }
 }
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedBigintHandlerTest.java
 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedBigintHandlerTest.java
index 064ca9dfb3e..3bbeb0b7854 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedBigintHandlerTest.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedBigintHandlerTest.java
@@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test;
 import java.io.Serializable;
 import java.math.BigInteger;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
@@ -32,8 +33,10 @@ class MySQLBinlogUnsignedBigintHandlerTest {
     @Test
     void assertHandle() {
         Serializable actual = handler.handle(1L);
-        assertThat(actual, is(1L));
+        assertThat(actual, instanceOf(BigInteger.class));
+        assertThat(actual, is(new BigInteger("1")));
         actual = handler.handle(-1L);
+        assertThat(actual, instanceOf(BigInteger.class));
         assertThat(actual, is(new BigInteger("18446744073709551615")));
     }
 }
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandlerTest.java
 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandlerTest.java
index b4ff3cd42b1..0ef0fb4f7ec 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandlerTest.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedIntHandlerTest.java
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
 
 import java.io.Serializable;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
@@ -31,8 +32,10 @@ class MySQLBinlogUnsignedIntHandlerTest {
     @Test
     void assertHandle() {
         Serializable actual = handler.handle(1);
+        assertThat(actual, instanceOf(Long.class));
         assertThat(actual, is(1L));
         actual = handler.handle(-1);
+        assertThat(actual, instanceOf(Long.class));
         assertThat(actual, is(4294967295L));
     }
 }
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedMediumintHandlerTest.java
 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedMediumintHandlerTest.java
index cebe37edabe..93d2f9ffd67 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedMediumintHandlerTest.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedMediumintHandlerTest.java
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
 
 import java.io.Serializable;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
@@ -31,8 +32,10 @@ class MySQLBinlogUnsignedMediumintHandlerTest {
     @Test
     void assertHandle() {
         Serializable actual = handler.handle(1);
+        assertThat(actual, instanceOf(Integer.class));
         assertThat(actual, is(1));
         actual = handler.handle(-1);
+        assertThat(actual, instanceOf(Integer.class));
         assertThat(actual, is(16777215));
     }
 }
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedSmallintHandlerTest.java
 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedSmallintHandlerTest.java
index 19b4cf4bd6a..28cab367dd5 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedSmallintHandlerTest.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedSmallintHandlerTest.java
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
 
 import java.io.Serializable;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
@@ -31,8 +32,10 @@ class MySQLBinlogUnsignedSmallintHandlerTest {
     @Test
     void assertHandle() {
         Serializable actual = handler.handle((short) 1);
+        assertThat(actual, instanceOf(Integer.class));
         assertThat(actual, is(1));
         actual = handler.handle((short) -1);
+        assertThat(actual, instanceOf(Integer.class));
         assertThat(actual, is(65535));
     }
 }
diff --git 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedTinyintHandlerTest.java
 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedTinyintHandlerTest.java
index 0862bafb76b..3d21d22a8dc 100644
--- 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedTinyintHandlerTest.java
+++ 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/unsigned/impl/MySQLBinlogUnsignedTinyintHandlerTest.java
@@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
 
 import java.io.Serializable;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
@@ -31,8 +32,10 @@ class MySQLBinlogUnsignedTinyintHandlerTest {
     @Test
     void assertHandle() {
         Serializable actual = handler.handle((byte) 1);
-        assertThat(actual, is(1));
+        assertThat(actual, instanceOf(Short.class));
+        assertThat(actual, is((short) 1));
         actual = handler.handle((byte) -1);
-        assertThat(actual, is(255));
+        assertThat(actual, instanceOf(Short.class));
+        assertThat(actual, is((short) 255));
     }
 }
diff --git 
a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/column/InventoryColumnValueReaderEngineTest.java
 
b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/column/InventoryColumnValueReaderEngineTest.java
index c21b2d12bb0..0e6ded9a7bc 100644
--- 
a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/column/InventoryColumnValueReaderEngineTest.java
+++ 
b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/column/InventoryColumnValueReaderEngineTest.java
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.sql.Array;
 import java.sql.Blob;
 import java.sql.Clob;
@@ -132,7 +133,7 @@ class InventoryColumnValueReaderEngineTest {
     void assertReadWithUnSingedBigIntValue() throws SQLException {
         when(metaData.getColumnType(1)).thenReturn(Types.BIGINT);
         when(resultSet.getBigDecimal(1)).thenReturn(new BigDecimal("1"));
-        assertThat(engine.read(resultSet, metaData, 1), is(new 
BigDecimal("1")));
+        assertThat(engine.read(resultSet, metaData, 1), is(new 
BigInteger("1")));
     }
     
     @Test

Reply via email to