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 53151eddfe7 Remove nullable annotations for sharding columns and 
handle empty lists in SQL builder methods (#35611)
53151eddfe7 is described below

commit 53151eddfe7ee3285d23110b571cceb394b73482
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jun 6 23:57:59 2025 +0800

    Remove nullable annotations for sharding columns and handle empty lists in 
SQL builder methods (#35611)
    
    * Remove nullable annotations for sharding columns and handle empty lists 
in SQL builder methods
    
    * Remove nullable annotations for sharding columns and handle empty lists 
in SQL builder methods
    
    * Remove nullable annotations for sharding columns and handle empty lists 
in SQL builder methods
    
    * Remove nullable annotations for sharding columns and handle empty lists 
in SQL builder methods
    
    * Remove nullable annotations for sharding columns and handle empty lists 
in SQL builder methods
---
 distribution/proxy/src/main/release-docs/LICENSE             |  6 +++---
 .../core/consistencycheck/DataConsistencyCheckUtils.java     |  5 +----
 .../calculator/RecordSingleTableInventoryCalculator.java     |  4 +---
 .../calculator/SingleTableInventoryCalculateParameter.java   | 11 ++++++-----
 .../sql/PipelineDataConsistencyCalculateSQLBuilder.java      | 12 +++++-------
 .../sql/PipelineDataConsistencyCalculateSQLBuilderTest.java  |  2 +-
 kernel/sql-federation/compiler/pom.xml                       |  6 ------
 pom.xml                                                      | 12 +++++++++++-
 8 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/distribution/proxy/src/main/release-docs/LICENSE 
b/distribution/proxy/src/main/release-docs/LICENSE
index fa6f2f18a26..0c69969089f 100644
--- a/distribution/proxy/src/main/release-docs/LICENSE
+++ b/distribution/proxy/src/main/release-docs/LICENSE
@@ -272,8 +272,8 @@ The text of each license is the standard Apache 2.0 license.
     json-path 2.9.0: https://github.com/jayway/JsonPath, Apache 2.0
     json-smart 2.4.10: https://www.minidev.net/, Apache 2.0
     json-simple 1.1.1: https://code.google.com/archive/p/json-simple/, Apache 
2.0
-    jsr305 3.0.2: http://findbugs.sourceforge.net/, Apache 2.0
-    memory 0.9.0, Apache 2.0
+    jspecify 1.0.0: https://jspecify.dev/, Apache 2.0
+    memory 0.9.0: https://datasketches.github.io/, Apache 2.0
     netty-buffer 4.1.121.Final: https://github.com/netty, Apache 2.0
     netty-codec 4.1.121.Final: https://github.com/netty, Apache 2.0
     netty-codec-http 4.1.121.Final: https://github.com/netty, Apache 2.0
@@ -299,7 +299,7 @@ The text of each license is the standard Apache 2.0 license.
     proto-google-common-protos 2.29.0: 
https://github.com/googleapis/common-protos-java, Apache 2.0
     proj4j 1.2.2: https://github.com/locationtech/proj4j, Apache 2.0
     quartz 2.3.2: https://github.com/quartz-scheduler/quartz, Apache 2.0
-    sketches-core 0.9.0, Apache 2.0
+    sketches-core 0.9.0: https://datasketches.github.io/, Apache 2.0
     snakeyaml 2.2: https://bitbucket.org/snakeyaml/snakeyaml, Apache 2.0
     transmittable-thread-local 2.14.2: 
https://github.com/alibaba/transmittable-thread-local, Apache 2.0
     uzaygezen-core 0.2: https://code.google.com/p/uzaygezen, Apache 2.0
diff --git 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtils.java
 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtils.java
index eb9d345d1ce..89154fcd90f 100644
--- 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtils.java
+++ 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/DataConsistencyCheckUtils.java
@@ -194,9 +194,6 @@ public final class DataConsistencyCheckUtils {
      * @return first unique key value
      */
     public static Object getFirstUniqueKeyValue(final Map<String, Object> 
rawRecord, final @Nullable String uniqueKey) {
-        if (rawRecord.isEmpty() || null == uniqueKey) {
-            return null;
-        }
-        return rawRecord.get(uniqueKey);
+        return rawRecord.isEmpty() || null == uniqueKey ? null : 
rawRecord.get(uniqueKey);
     }
 }
diff --git 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/RecordSingleTableInventoryCalculator.java
 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/RecordSingleTableInventoryCalculator.java
index ebf59bb3c7c..5862e9b5c8f 100644
--- 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/RecordSingleTableInventoryCalculator.java
+++ 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/RecordSingleTableInventoryCalculator.java
@@ -184,10 +184,8 @@ public final class RecordSingleTableInventoryCalculator 
extends AbstractStreamin
             for (Object each : uniqueKeysValues) {
                 preparedStatement.setObject(parameterIndex++, each);
             }
-            if (null != param.getShardingColumnsNames() && 
!param.getShardingColumnsNames().isEmpty()) {
+            if (!param.getShardingColumnsNames().isEmpty()) {
                 List<Object> shardingColumnsValues = 
param.getShardingColumnsValues();
-                ShardingSpherePreconditions.checkNotNull(shardingColumnsValues,
-                        () -> new 
PipelineTableDataConsistencyCheckLoadingFailedException(param.getTable(), new 
RuntimeException("Sharding columns values is null when names not empty.")));
                 for (Object each : shardingColumnsValues) {
                     preparedStatement.setObject(parameterIndex++, each);
                 }
diff --git 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/SingleTableInventoryCalculateParameter.java
 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/SingleTableInventoryCalculateParameter.java
index cb0d434de5d..00623221a3d 100644
--- 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/SingleTableInventoryCalculateParameter.java
+++ 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/SingleTableInventoryCalculateParameter.java
@@ -26,9 +26,10 @@ import 
org.apache.shardingsphere.data.pipeline.core.metadata.model.PipelineColum
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
 
-import org.jspecify.annotations.Nullable;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
@@ -163,8 +164,8 @@ public final class SingleTableInventoryCalculateParameter {
      *
      * @return sharding columns names
      */
-    public @Nullable List<String> getShardingColumnsNames() {
-        return shardingColumnsNames.get();
+    public List<String> getShardingColumnsNames() {
+        return 
Optional.ofNullable(shardingColumnsNames.get()).orElse(Collections.emptyList());
     }
     
     /**
@@ -181,8 +182,8 @@ public final class SingleTableInventoryCalculateParameter {
      *
      * @return sharding columns values
      */
-    public @Nullable List<Object> getShardingColumnsValues() {
-        return shardingColumnsValues.get();
+    public List<Object> getShardingColumnsValues() {
+        return 
Optional.ofNullable(shardingColumnsValues.get()).orElse(Collections.emptyList());
     }
     
     /**
diff --git 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineDataConsistencyCalculateSQLBuilder.java
 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineDataConsistencyCalculateSQLBuilder.java
index 5dd99e9d51b..36ef5cb96f7 100644
--- 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineDataConsistencyCalculateSQLBuilder.java
+++ 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineDataConsistencyCalculateSQLBuilder.java
@@ -24,7 +24,6 @@ import 
org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
 
-import org.jspecify.annotations.Nullable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -56,12 +55,12 @@ public final class 
PipelineDataConsistencyCalculateSQLBuilder {
      * @return built SQL
      */
     public String buildQueryRangeOrderingSQL(final QualifiedTable 
qualifiedTable, final Collection<String> columnNames, final List<String> 
uniqueKeys, final QueryRange queryRange,
-                                             @Nullable final List<String> 
shardingColumnsNames) {
+                                             final List<String> 
shardingColumnsNames) {
         return 
dialectSQLBuilder.wrapWithPageQuery(buildQueryRangeOrderingSQL0(qualifiedTable, 
columnNames, uniqueKeys, queryRange, shardingColumnsNames));
     }
     
     private String buildQueryRangeOrderingSQL0(final QualifiedTable 
qualifiedTable, final Collection<String> columnNames, final List<String> 
uniqueKeys, final QueryRange queryRange,
-                                               @Nullable final List<String> 
shardingColumnsNames) {
+                                               final List<String> 
shardingColumnsNames) {
         String qualifiedTableName = 
sqlSegmentBuilder.getQualifiedTableName(qualifiedTable);
         String queryColumns = 
columnNames.stream().map(sqlSegmentBuilder::getEscapedIdentifier).collect(Collectors.joining(","));
         String firstUniqueKey = uniqueKeys.get(0);
@@ -99,16 +98,15 @@ public final class 
PipelineDataConsistencyCalculateSQLBuilder {
      * @param shardingColumnsNames sharding columns names, nullable
      * @return built SQL
      */
-    public String buildPointQuerySQL(final QualifiedTable qualifiedTable, 
final Collection<String> columnNames, final List<String> uniqueKeys,
-                                     @Nullable final List<String> 
shardingColumnsNames) {
+    public String buildPointQuerySQL(final QualifiedTable qualifiedTable, 
final Collection<String> columnNames, final List<String> uniqueKeys, final 
List<String> shardingColumnsNames) {
         String qualifiedTableName = 
sqlSegmentBuilder.getQualifiedTableName(qualifiedTable);
         String queryColumns = 
columnNames.stream().map(sqlSegmentBuilder::getEscapedIdentifier).collect(Collectors.joining(","));
         String equalsConditions = joinColumns(uniqueKeys, 
shardingColumnsNames).stream().map(each -> 
sqlSegmentBuilder.getEscapedIdentifier(each) + 
"=?").collect(Collectors.joining(" AND "));
         return String.format("SELECT %s FROM %s WHERE %s", queryColumns, 
qualifiedTableName, equalsConditions);
     }
     
-    private List<String> joinColumns(final List<String> uniqueKeys, final 
@Nullable List<String> shardingColumnsNames) {
-        if (null == shardingColumnsNames || shardingColumnsNames.isEmpty()) {
+    private List<String> joinColumns(final List<String> uniqueKeys, final 
List<String> shardingColumnsNames) {
+        if (shardingColumnsNames.isEmpty()) {
             return uniqueKeys;
         }
         List<String> result = new ArrayList<>(uniqueKeys.size() + 
shardingColumnsNames.size());
diff --git 
a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineDataConsistencyCalculateSQLBuilderTest.java
 
b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineDataConsistencyCalculateSQLBuilderTest.java
index 189d213d87b..0644ad2c4ef 100644
--- 
a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineDataConsistencyCalculateSQLBuilderTest.java
+++ 
b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelineDataConsistencyCalculateSQLBuilderTest.java
@@ -63,7 +63,7 @@ class PipelineDataConsistencyCalculateSQLBuilderTest {
     
     @Test
     void assertBuildPointQuerySQLWithoutQueryCondition() {
-        String actual = sqlBuilder.buildPointQuerySQL(new QualifiedTable(null, 
"t_order"), COLUMN_NAMES, UNIQUE_KEYS, null);
+        String actual = sqlBuilder.buildPointQuerySQL(new QualifiedTable(null, 
"t_order"), COLUMN_NAMES, UNIQUE_KEYS, Collections.emptyList());
         assertThat(actual, is("SELECT order_id,user_id,status FROM t_order 
WHERE order_id=? AND status=?"));
         actual = sqlBuilder.buildPointQuerySQL(new QualifiedTable(null, 
"t_order"), COLUMN_NAMES, UNIQUE_KEYS, Collections.emptyList());
         assertThat(actual, is("SELECT order_id,user_id,status FROM t_order 
WHERE order_id=? AND status=?"));
diff --git a/kernel/sql-federation/compiler/pom.xml 
b/kernel/sql-federation/compiler/pom.xml
index e5ee882efdb..6a68c9d3216 100644
--- a/kernel/sql-federation/compiler/pom.xml
+++ b/kernel/sql-federation/compiler/pom.xml
@@ -121,12 +121,6 @@
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.google.code.findbugs</groupId>
-            <artifactId>jsr305</artifactId>
-            <version>${jsr305.version}</version>
-            <scope>provided</scope>
-        </dependency>
     </dependencies>
     
     <profiles>
diff --git a/pom.xml b/pom.xml
index 8f591305631..d4fceae3eed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -121,8 +121,8 @@
         <commons-logging.version>1.2</commons-logging.version>
         
         <lombok.version>1.18.38</lombok.version>
-        <immutables.version>2.10.1</immutables.version>
         <jsr305.version>3.0.2</jsr305.version>
+        <immutables.version>2.10.1</immutables.version>
         
         <postgresql.version>42.7.5</postgresql.version>
         <mysql-connector-java.version>8.3.0</mysql-connector-java.version>
@@ -441,6 +441,12 @@
                 <version>${lombok.version}</version>
                 <scope>provided</scope>
             </dependency>
+            <dependency>
+                <groupId>com.google.code.findbugs</groupId>
+                <artifactId>jsr305</artifactId>
+                <version>${jsr305.version}</version>
+                <scope>provided</scope>
+            </dependency>
             
             <dependency>
                 <groupId>commons-logging</groupId>
@@ -609,6 +615,10 @@
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+        </dependency>
         
         <dependency>
             <groupId>org.junit.jupiter</groupId>

Reply via email to