@@ -1075,6 +1075,31 @@ func TestTiFlashFineGrainedShuffleWithMaxTiFlashThreads(t *testing.T) {
1075
1075
require .Equal (t , uint64 (16 ), streamCount [0 ])
1076
1076
}
1077
1077
1078
+ func TestIssue37986 (t * testing.T ) {
1079
+ store := testkit .CreateMockStore (t )
1080
+ tk := testkit .NewTestKit (t , store )
1081
+ tk .MustExec ("use test" )
1082
+
1083
+ tk .MustExec (`drop table if exists t3` )
1084
+ tk .MustExec (`CREATE TABLE t3(c0 INT, primary key(c0))` )
1085
+ tk .MustExec (`insert into t3 values(1), (2), (3), (4), (5), (6), (7), (8), (9), (10)` )
1086
+ rs := tk .MustQuery (`SELECT v2.c0 FROM (select rand() as c0 from t3) v2 order by v2.c0 limit 10` ).Rows ()
1087
+ lastVal := - 1.0
1088
+ for _ , r := range rs {
1089
+ v := r [0 ].(string )
1090
+ val , err := strconv .ParseFloat (v , 64 )
1091
+ require .NoError (t , err )
1092
+ require .True (t , val >= lastVal )
1093
+ lastVal = val
1094
+ }
1095
+
1096
+ tk .MustQuery (`explain format='brief' SELECT v2.c0 FROM (select rand() as c0 from t3) v2 order by v2.c0 limit 10` ).
1097
+ Check (testkit .Rows (`TopN 10.00 root Column#2, offset:0, count:10` ,
1098
+ `└─Projection 10000.00 root rand()->Column#2` ,
1099
+ ` └─TableReader 10000.00 root data:TableFullScan` ,
1100
+ ` └─TableFullScan 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo` ))
1101
+ }
1102
+
1078
1103
func TestIssue33175 (t * testing.T ) {
1079
1104
store := testkit .CreateMockStore (t )
1080
1105
tk := testkit .NewTestKit (t , store )
0 commit comments