@@ -25,6 +25,7 @@ import (
25
25
"github.com/pingcap/kvproto/pkg/metapb"
26
26
"github.com/pingcap/tidb/domain"
27
27
"github.com/pingcap/tidb/executor"
28
+ "github.com/pingcap/tidb/expression"
28
29
"github.com/pingcap/tidb/infoschema"
29
30
"github.com/pingcap/tidb/kv"
30
31
"github.com/pingcap/tidb/parser"
@@ -2615,3 +2616,36 @@ func TestAlwaysTruePredicateWithSubquery(t *testing.T) {
2615
2616
tk .MustQuery (ts ).Check (testkit .Rows (output [i ].Plan ... ))
2616
2617
}
2617
2618
}
2619
+
2620
+ func TestExchangeSenderResolveIndices (t * testing.T ) {
2621
+ schemaCols1 := make ([]* expression.Column , 0 , 4 )
2622
+ schemaCols1 = append (schemaCols1 , & expression.Column {UniqueID : 1 })
2623
+ schemaCols1 = append (schemaCols1 , & expression.Column {UniqueID : 2 })
2624
+ schemaCols1 = append (schemaCols1 , & expression.Column {UniqueID : 3 })
2625
+ schemaCols1 = append (schemaCols1 , & expression.Column {UniqueID : 4 })
2626
+ schema1 := expression .NewSchema (schemaCols1 ... )
2627
+
2628
+ schemaCols2 := make ([]* expression.Column , 0 , 2 )
2629
+ schemaCols2 = append (schemaCols2 , & expression.Column {UniqueID : 3 })
2630
+ schemaCols2 = append (schemaCols2 , & expression.Column {UniqueID : 4 })
2631
+ schema2 := expression .NewSchema (schemaCols2 ... )
2632
+
2633
+ partitionCol1 := & property.MPPPartitionColumn {Col : & expression.Column {UniqueID : 4 }}
2634
+
2635
+ // two exchange sender share the same MPPPartitionColumn
2636
+ exchangeSender1 := & core.PhysicalExchangeSender {
2637
+ HashCols : []* property.MPPPartitionColumn {partitionCol1 },
2638
+ }
2639
+ exchangeSender2 := & core.PhysicalExchangeSender {
2640
+ HashCols : []* property.MPPPartitionColumn {partitionCol1 },
2641
+ }
2642
+
2643
+ err := exchangeSender1 .ResolveIndicesItselfWithSchema (schema1 )
2644
+ require .NoError (t , err )
2645
+
2646
+ err = exchangeSender2 .ResolveIndicesItselfWithSchema (schema2 )
2647
+ require .NoError (t , err )
2648
+
2649
+ // after resolving, the partition col in two different exchange sender should have different index
2650
+ require .NotEqual (t , exchangeSender1 .HashCols [0 ].Col .Index , exchangeSender2 .HashCols [0 ].Col .Index )
2651
+ }
0 commit comments