You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/08/22 07:05:45 UTC

(shardingsphere) branch master updated: Fix binding table lookup for schema-qualified data nodes (#39549)

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

terrymanu 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 17ac1b0e75d Fix binding table lookup for schema-qualified data nodes (#39549)
17ac1b0e75d is described below

commit 17ac1b0e75dbe9af0f235a9da9924f69ba96f855
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Aug 22 15:05:39 2026 +0800

    Fix binding table lookup for schema-qualified data nodes (#39549)
    
    * Support parsing Oracle PARTITION BY REFERENCE sql
    
    For #27104
    
    * Fix binding table lookup for schema-qualified data nodes
    
    Normalize ShardingTable's private index keys while preserving schema
    information in actual data nodes.
---
 .../org/apache/shardingsphere/sharding/rule/ShardingTable.java   | 2 +-
 .../apache/shardingsphere/sharding/rule/ShardingTableTest.java   | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTable.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTable.java
index 256f93a0e74..65d87f8f888 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTable.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingTable.java
@@ -202,7 +202,7 @@ public final class ShardingTable {
                 throw new DataNodeGenerateException(each);
             }
             result.add(dataNode);
-            dataNodeIndexMap.put(dataNode, index);
+            dataNodeIndexMap.put(new DataNode(dataNode.getDataSourceName(), (String) null, dataNode.getTableName()), index);
             actualDataSourceNames.add(dataNode.getDataSourceName());
             addActualTable(dataNode.getDataSourceName(), dataNode.getTableName());
             index++;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableTest.java
index 0bf1203c145..82fd6da00ea 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableTest.java
@@ -31,6 +31,7 @@ import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
 import org.junit.jupiter.api.Test;
 
 import java.util.Arrays;
+import java.util.Collections;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
@@ -63,6 +64,14 @@ class ShardingTableTest {
         assertFalse(actual.containsDataNode("ds9", "table_0"));
     }
     
+    @Test
+    void assertFindActualTableIndex() {
+        ShardingTableRuleConfiguration config = new ShardingTableRuleConfiguration("foo_order", "foo_ds.public.foo_order_0");
+        ShardingTable actual = new ShardingTable(config, Collections.singleton("foo_ds"), null);
+        assertThat(actual.getActualDataNodes().get(0), is(new DataNode("foo_ds", "public", "foo_order_0")));
+        assertThat(actual.findActualTableIndex("foo_ds", "foo_order_0"), is(0));
+    }
+    
     private ShardingTable createShardingTable() {
         ShardingTableRuleConfiguration shardingTableRuleConfig = new ShardingTableRuleConfiguration("LOGIC_TABLE", "ds${0..1}.table_${0..2}");
         shardingTableRuleConfig.setDatabaseShardingStrategy(new NoneShardingStrategyConfiguration());