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 b4c73368e98 Support multi-columns unique key non-first column nullable 
(#37647)
b4c73368e98 is described below

commit b4c73368e9897d49dc7c80517363dddce7329903
Author: Hongsheng Zhong <[email protected]>
AuthorDate: Mon Jan 5 17:43:51 2026 +0800

    Support multi-columns unique key non-first column nullable (#37647)
    
    * Support multi-columns unique key non-first column nullable
    
    * Update RELEASE-NOTES.md
---
 RELEASE-NOTES.md                                   |  1 +
 .../loader/PipelineTableMetaDataUtils.java         |  2 +-
 .../loader/PipelineTableMetaDataUtilsTest.java     | 23 ++++++++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 044e0587291..4768e761a1f 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -71,6 +71,7 @@
 1. Pipeline: Support unique key first integer column exact or estimated 
splitting based on data sparseness - 
[#37542](https://github.com/apache/shardingsphere/pull/37542)
 1. Pipeline: Support unique key first big integer column splitting - 
[#37574](https://github.com/apache/shardingsphere/pull/37574)
 1. Pipeline: Support unique key first string column exact splitting - 
[#37543](https://github.com/apache/shardingsphere/pull/37543)
+1. Pipeline: Support multi-columns unique key non-first column nullable - 
[#37647](https://github.com/apache/shardingsphere/pull/37647)
 1. Encrypt: Support handling show create view result decoration in encrypt - 
[#37299](https://github.com/apache/shardingsphere/pull/37299)
 1. JDBC: Enhance ResultSetUtils to support flexible string date/time 
conversions - [37424](https://github.com/apache/shardingsphere/pull/37424)
 
diff --git 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataUtils.java
 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataUtils.java
index 61a9c4546d4..9fe46772f33 100644
--- 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataUtils.java
+++ 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataUtils.java
@@ -55,7 +55,7 @@ public final class PipelineTableMetaDataUtils {
             return 
primaryKeys.stream().map(tableMetaData::getColumnMetaData).collect(Collectors.toList());
         }
         for (PipelineIndexMetaData each : tableMetaData.getUniqueIndexes()) {
-            if 
(each.getColumns().stream().anyMatch(PipelineColumnMetaData::isNullable)) {
+            if (each.getColumns().get(0).isNullable()) {
                 continue;
             }
             return each.getColumns();
diff --git 
a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataUtilsTest.java
 
b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataUtilsTest.java
index 49dd34c60f5..9f5ff8d627a 100644
--- 
a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataUtilsTest.java
+++ 
b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/loader/PipelineTableMetaDataUtilsTest.java
@@ -61,6 +61,29 @@ class PipelineTableMetaDataUtilsTest {
         assertThat(actual.get(0), is(columnMetaData));
     }
     
+    @Test
+    void assertGetUniqueKeyColumnsWithUniqueIndexNullable() {
+        PipelineIndexMetaData pipelineIndexMetaData = 
mock(PipelineIndexMetaData.class, RETURNS_DEEP_STUBS);
+        PipelineColumnMetaData columnMetaData = 
mock(PipelineColumnMetaData.class);
+        when(columnMetaData.isNullable()).thenReturn(true);
+        
when(pipelineIndexMetaData.getColumns()).thenReturn(Collections.singletonList(columnMetaData));
+        
when(tableMetaData.getUniqueIndexes()).thenReturn(Collections.singletonList(pipelineIndexMetaData));
+        List<PipelineColumnMetaData> actual = 
PipelineTableMetaDataUtils.getUniqueKeyColumns("foo_schema", "foo_tbl", 
metaDataLoader);
+        assertThat(actual.size(), is(0));
+    }
+    
+    @Test
+    void assertGetUniqueKeyColumnsWithUniqueIndexNotNull() {
+        PipelineIndexMetaData pipelineIndexMetaData = 
mock(PipelineIndexMetaData.class, RETURNS_DEEP_STUBS);
+        PipelineColumnMetaData columnMetaData = 
mock(PipelineColumnMetaData.class);
+        when(columnMetaData.isNullable()).thenReturn(false);
+        
when(pipelineIndexMetaData.getColumns()).thenReturn(Collections.singletonList(columnMetaData));
+        
when(tableMetaData.getUniqueIndexes()).thenReturn(Collections.singletonList(pipelineIndexMetaData));
+        List<PipelineColumnMetaData> actual = 
PipelineTableMetaDataUtils.getUniqueKeyColumns("foo_schema", "foo_tbl", 
metaDataLoader);
+        assertThat(actual.size(), is(1));
+        assertThat(actual.get(0), is(columnMetaData));
+    }
+    
     @Test
     void assertGetUniqueKeyColumnsWithUniqueIndexes() {
         PipelineIndexMetaData pipelineIndexMetaData1 = 
mock(PipelineIndexMetaData.class, RETURNS_DEEP_STUBS);

Reply via email to