@@ -564,6 +564,39 @@ func TestInternFuncOpDef(t *testing.T) {
564
564
test (funcDef2 , funcDef3 , false )
565
565
}
566
566
567
+ func TestInternSubqueryDef (t * testing.T ) {
568
+ var ps privateStorage
569
+ ps .init ()
570
+
571
+ test := func (left , right * SubqueryDef , expected bool ) {
572
+ t .Helper ()
573
+ leftID := ps .internSubqueryDef (left )
574
+ rightID := ps .internSubqueryDef (right )
575
+ if (leftID == rightID ) != expected {
576
+ t .Errorf ("%v == %v, expected %v, got %v" , left , right , expected , ! expected )
577
+ }
578
+ }
579
+
580
+ expr1 := & tree.Subquery {}
581
+ expr2 := & tree.Subquery {}
582
+
583
+ defs := []SubqueryDef {
584
+ {},
585
+ {OriginalExpr : expr1 },
586
+ {OriginalExpr : expr2 },
587
+ {Cmp : opt .LeOp },
588
+ {Cmp : opt .GtOp },
589
+ {OriginalExpr : expr1 , Cmp : opt .GtOp },
590
+ {OriginalExpr : expr1 , Cmp : opt .LeOp },
591
+ {OriginalExpr : expr2 , Cmp : opt .GtOp },
592
+ }
593
+ for i := range defs {
594
+ for j := range defs {
595
+ test (& defs [i ], & defs [j ], i == j )
596
+ }
597
+ }
598
+ }
599
+
567
600
func TestInternSetOpColMap (t * testing.T ) {
568
601
var ps privateStorage
569
602
ps .init ()
@@ -883,6 +916,7 @@ func TestPrivateStorageAllocations(t *testing.T) {
883
916
}
884
917
indexJoinDef := & IndexJoinDef {Table : 1 , Cols : colSet }
885
918
lookupJoinDef := & LookupJoinDef {Table : 1 , Index : 2 , KeyCols : colList , LookupCols : colSet }
919
+ subqueryDef := & SubqueryDef {OriginalExpr : & tree.Subquery {}, Cmp : opt .LtOp }
886
920
setOpColMap := & SetOpColMap {Left : colList , Right : colList , Out : colList }
887
921
datum := tree .NewDInt (1 )
888
922
typ := types .Int
@@ -903,6 +937,7 @@ func TestPrivateStorageAllocations(t *testing.T) {
903
937
ps .internMergeOnDef (mergeOnDef )
904
938
ps .internIndexJoinDef (indexJoinDef )
905
939
ps .internLookupJoinDef (lookupJoinDef )
940
+ ps .internSubqueryDef (subqueryDef )
906
941
ps .internSetOpColMap (setOpColMap )
907
942
ps .internDatum (datum )
908
943
ps .internType (typ )
@@ -943,6 +978,7 @@ func BenchmarkPrivateStorage(b *testing.B) {
943
978
}
944
979
indexJoinDef := & IndexJoinDef {Table : 1 , Cols : colSet }
945
980
lookupJoinDef := & LookupJoinDef {Table : 1 , Index : 2 , KeyCols : colList , LookupCols : colSet }
981
+ subqueryDef := & SubqueryDef {OriginalExpr : & tree.Subquery {}, Cmp : opt .LtOp }
946
982
setOpColMap := & SetOpColMap {Left : colList , Right : colList , Out : colList }
947
983
datum := tree .NewDInt (1 )
948
984
typ := types .Int
@@ -965,6 +1001,7 @@ func BenchmarkPrivateStorage(b *testing.B) {
965
1001
ps .internMergeOnDef (mergeOnDef )
966
1002
ps .internIndexJoinDef (indexJoinDef )
967
1003
ps .internLookupJoinDef (lookupJoinDef )
1004
+ ps .internSubqueryDef (subqueryDef )
968
1005
ps .internSetOpColMap (setOpColMap )
969
1006
ps .internDatum (datum )
970
1007
ps .internType (typ )
0 commit comments