@@ -747,132 +747,151 @@ func (s *testRangerSuite) TestColumnRange(c *C) {
747
747
accessConds string
748
748
filterConds string
749
749
resultStr string
750
+ length int
750
751
}{
751
752
{
752
753
colPos : 0 ,
753
754
exprStr : "a = 1 and b > 1" ,
754
755
accessConds : "[eq(test.t.a, 1)]" ,
755
756
filterConds : "[gt(test.t.b, 1)]" ,
756
757
resultStr : "[[1,1]]" ,
758
+ length : types .UnspecifiedLength ,
757
759
},
758
760
{
759
761
colPos : 1 ,
760
762
exprStr : "b > 1" ,
761
763
accessConds : "[gt(test.t.b, 1)]" ,
762
764
filterConds : "[]" ,
763
765
resultStr : "[(1,+inf]]" ,
766
+ length : types .UnspecifiedLength ,
764
767
},
765
768
{
766
769
colPos : 0 ,
767
770
exprStr : "1 = a" ,
768
771
accessConds : "[eq(1, test.t.a)]" ,
769
772
filterConds : "[]" ,
770
773
resultStr : "[[1,1]]" ,
774
+ length : types .UnspecifiedLength ,
771
775
},
772
776
{
773
777
colPos : 0 ,
774
778
exprStr : "a != 1" ,
775
779
accessConds : "[ne(test.t.a, 1)]" ,
776
780
filterConds : "[]" ,
777
781
resultStr : "[[-inf,1) (1,+inf]]" ,
782
+ length : types .UnspecifiedLength ,
778
783
},
779
784
{
780
785
colPos : 0 ,
781
786
exprStr : "1 != a" ,
782
787
accessConds : "[ne(1, test.t.a)]" ,
783
788
filterConds : "[]" ,
784
789
resultStr : "[[-inf,1) (1,+inf]]" ,
790
+ length : types .UnspecifiedLength ,
785
791
},
786
792
{
787
793
colPos : 0 ,
788
794
exprStr : "a > 1" ,
789
795
accessConds : "[gt(test.t.a, 1)]" ,
790
796
filterConds : "[]" ,
791
797
resultStr : "[(1,+inf]]" ,
798
+ length : types .UnspecifiedLength ,
792
799
},
793
800
{
794
801
colPos : 0 ,
795
802
exprStr : "1 < a" ,
796
803
accessConds : "[lt(1, test.t.a)]" ,
797
804
filterConds : "[]" ,
798
805
resultStr : "[(1,+inf]]" ,
806
+ length : types .UnspecifiedLength ,
799
807
},
800
808
{
801
809
colPos : 0 ,
802
810
exprStr : "a >= 1" ,
803
811
accessConds : "[ge(test.t.a, 1)]" ,
804
812
filterConds : "[]" ,
805
813
resultStr : "[[1,+inf]]" ,
814
+ length : types .UnspecifiedLength ,
806
815
},
807
816
{
808
817
colPos : 0 ,
809
818
exprStr : "1 <= a" ,
810
819
accessConds : "[le(1, test.t.a)]" ,
811
820
filterConds : "[]" ,
812
821
resultStr : "[[1,+inf]]" ,
822
+ length : types .UnspecifiedLength ,
813
823
},
814
824
{
815
825
colPos : 0 ,
816
826
exprStr : "a < 1" ,
817
827
accessConds : "[lt(test.t.a, 1)]" ,
818
828
filterConds : "[]" ,
819
829
resultStr : "[[-inf,1)]" ,
830
+ length : types .UnspecifiedLength ,
820
831
},
821
832
{
822
833
colPos : 0 ,
823
834
exprStr : "1 > a" ,
824
835
accessConds : "[gt(1, test.t.a)]" ,
825
836
filterConds : "[]" ,
826
837
resultStr : "[[-inf,1)]" ,
838
+ length : types .UnspecifiedLength ,
827
839
},
828
840
{
829
841
colPos : 0 ,
830
842
exprStr : "a <= 1" ,
831
843
accessConds : "[le(test.t.a, 1)]" ,
832
844
filterConds : "[]" ,
833
845
resultStr : "[[-inf,1]]" ,
846
+ length : types .UnspecifiedLength ,
834
847
},
835
848
{
836
849
colPos : 0 ,
837
850
exprStr : "1 >= a" ,
838
851
accessConds : "[ge(1, test.t.a)]" ,
839
852
filterConds : "[]" ,
840
853
resultStr : "[[-inf,1]]" ,
854
+ length : types .UnspecifiedLength ,
841
855
},
842
856
{
843
857
colPos : 0 ,
844
858
exprStr : "(a)" ,
845
859
accessConds : "[test.t.a]" ,
846
860
filterConds : "[]" ,
847
861
resultStr : "[[-inf,0) (0,+inf]]" ,
862
+ length : types .UnspecifiedLength ,
848
863
},
849
864
{
850
865
colPos : 0 ,
851
866
exprStr : "a in (1, 3, NULL, 2)" ,
852
867
accessConds : "[in(test.t.a, 1, 3, <nil>, 2)]" ,
853
868
filterConds : "[]" ,
854
869
resultStr : "[[1,1] [2,2] [3,3]]" ,
870
+ length : types .UnspecifiedLength ,
855
871
},
856
872
{
857
873
colPos : 0 ,
858
874
exprStr : `a IN (8,8,81,45)` ,
859
875
accessConds : "[in(test.t.a, 8, 8, 81, 45)]" ,
860
876
filterConds : "[]" ,
861
877
resultStr : `[[8,8] [45,45] [81,81]]` ,
878
+ length : types .UnspecifiedLength ,
862
879
},
863
880
{
864
881
colPos : 0 ,
865
882
exprStr : "a between 1 and 2" ,
866
883
accessConds : "[ge(test.t.a, 1) le(test.t.a, 2)]" ,
867
884
filterConds : "[]" ,
868
885
resultStr : "[[1,2]]" ,
886
+ length : types .UnspecifiedLength ,
869
887
},
870
888
{
871
889
colPos : 0 ,
872
890
exprStr : "a not between 1 and 2" ,
873
891
accessConds : "[or(lt(test.t.a, 1), gt(test.t.a, 2))]" ,
874
892
filterConds : "[]" ,
875
893
resultStr : "[[-inf,1) (2,+inf]]" ,
894
+ length : types .UnspecifiedLength ,
876
895
},
877
896
//{
878
897
// `a > null` will be converted to `castAsString(a) > null` which can not be extracted as access condition.
@@ -885,97 +904,119 @@ func (s *testRangerSuite) TestColumnRange(c *C) {
885
904
accessConds : "[ge(test.t.a, 2) le(test.t.a, 1)]" ,
886
905
filterConds : "[]" ,
887
906
resultStr : "[]" ,
907
+ length : types .UnspecifiedLength ,
888
908
},
889
909
{
890
910
colPos : 0 ,
891
911
exprStr : "a not between 2 and 1" ,
892
912
accessConds : "[or(lt(test.t.a, 2), gt(test.t.a, 1))]" ,
893
913
filterConds : "[]" ,
894
914
resultStr : "[[-inf,+inf]]" ,
915
+ length : types .UnspecifiedLength ,
895
916
},
896
917
{
897
918
colPos : 0 ,
898
919
exprStr : "a IS NULL" ,
899
920
accessConds : "[isnull(test.t.a)]" ,
900
921
filterConds : "[]" ,
901
922
resultStr : "[[NULL,NULL]]" ,
923
+ length : types .UnspecifiedLength ,
902
924
},
903
925
{
904
926
colPos : 0 ,
905
927
exprStr : "a IS NOT NULL" ,
906
928
accessConds : "[not(isnull(test.t.a))]" ,
907
929
filterConds : "[]" ,
908
930
resultStr : "[[-inf,+inf]]" ,
931
+ length : types .UnspecifiedLength ,
909
932
},
910
933
{
911
934
colPos : 0 ,
912
935
exprStr : "a IS TRUE" ,
913
936
accessConds : "[istrue(test.t.a)]" ,
914
937
filterConds : "[]" ,
915
938
resultStr : "[[-inf,0) (0,+inf]]" ,
939
+ length : types .UnspecifiedLength ,
916
940
},
917
941
{
918
942
colPos : 0 ,
919
943
exprStr : "a IS NOT TRUE" ,
920
944
accessConds : "[not(istrue(test.t.a))]" ,
921
945
filterConds : "[]" ,
922
946
resultStr : "[[NULL,NULL] [0,0]]" ,
947
+ length : types .UnspecifiedLength ,
923
948
},
924
949
{
925
950
colPos : 0 ,
926
951
exprStr : "a IS FALSE" ,
927
952
accessConds : "[isfalse(test.t.a)]" ,
928
953
filterConds : "[]" ,
929
954
resultStr : "[[0,0]]" ,
955
+ length : types .UnspecifiedLength ,
930
956
},
931
957
{
932
958
colPos : 0 ,
933
959
exprStr : "a IS NOT FALSE" ,
934
960
accessConds : "[not(isfalse(test.t.a))]" ,
935
961
filterConds : "[]" ,
936
962
resultStr : "[[NULL,0) (0,+inf]]" ,
963
+ length : types .UnspecifiedLength ,
937
964
},
938
965
{
939
966
colPos : 1 ,
940
967
exprStr : `b in (1, '2.1')` ,
941
968
accessConds : "[in(test.t.b, 1, 2.1)]" ,
942
969
filterConds : "[]" ,
943
970
resultStr : "[[1,1] [2.1,2.1]]" ,
971
+ length : types .UnspecifiedLength ,
944
972
},
945
973
{
946
974
colPos : 0 ,
947
975
exprStr : `a > 9223372036854775807` ,
948
976
accessConds : "[gt(test.t.a, 9223372036854775807)]" ,
949
977
filterConds : "[]" ,
950
978
resultStr : "[(9223372036854775807,+inf]]" ,
979
+ length : types .UnspecifiedLength ,
951
980
},
952
981
{
953
982
colPos : 2 ,
954
983
exprStr : `c > 111.11111111` ,
955
984
accessConds : "[gt(test.t.c, 111.11111111)]" ,
956
985
filterConds : "[]" ,
957
986
resultStr : "[[111.111115,+inf]]" ,
987
+ length : types .UnspecifiedLength ,
958
988
},
959
989
{
960
990
colPos : 3 ,
961
991
exprStr : `d > 'aaaaaaaaaaaaaa'` ,
962
992
accessConds : "[gt(test.t.d, aaaaaaaaaaaaaa)]" ,
963
993
filterConds : "[]" ,
964
994
resultStr : "[(\" aaaaaaaaaaaaaa\" ,+inf]]" ,
995
+ length : types .UnspecifiedLength ,
965
996
},
966
997
{
967
998
colPos : 4 ,
968
999
exprStr : `e > 18446744073709500000` ,
969
1000
accessConds : "[gt(test.t.e, 18446744073709500000)]" ,
970
1001
filterConds : "[]" ,
971
1002
resultStr : "[(18446744073709500000,+inf]]" ,
1003
+ length : types .UnspecifiedLength ,
972
1004
},
973
1005
{
974
1006
colPos : 4 ,
975
1007
exprStr : `e > -2147483648` ,
976
1008
accessConds : "[gt(test.t.e, -2147483648)]" ,
977
1009
filterConds : "[]" ,
978
1010
resultStr : "[[0,+inf]]" ,
1011
+ length : types .UnspecifiedLength ,
1012
+ },
1013
+ {
1014
+ colPos : 3 ,
1015
+ exprStr : "d = 'aab' or d = 'aac'" ,
1016
+ accessConds : "[or(eq(test.t.d, aab), eq(test.t.d, aac))]" ,
1017
+ filterConds : "[]" ,
1018
+ resultStr : "[[\" a\" ,\" a\" ]]" ,
1019
+ length : 1 ,
979
1020
},
980
1021
}
981
1022
@@ -1002,7 +1043,7 @@ func (s *testRangerSuite) TestColumnRange(c *C) {
1002
1043
c .Assert (col , NotNil )
1003
1044
conds = ranger .ExtractAccessConditionsForColumn (conds , col .UniqueID )
1004
1045
c .Assert (fmt .Sprintf ("%s" , conds ), Equals , tt .accessConds , Commentf ("wrong access conditions for expr: %s" , tt .exprStr ))
1005
- result , err := ranger .BuildColumnRange (conds , new (stmtctx.StatementContext ), col .RetType , types . UnspecifiedLength )
1046
+ result , err := ranger .BuildColumnRange (conds , new (stmtctx.StatementContext ), col .RetType , tt . length )
1006
1047
c .Assert (err , IsNil )
1007
1048
got := fmt .Sprintf ("%v" , result )
1008
1049
c .Assert (got , Equals , tt .resultStr , Commentf ("different for expr %s, col: %v" , tt .exprStr , col ))
0 commit comments