@@ -32,83 +32,83 @@ public void testStringMatchPushdown()
3232 SessionHolder sessionHolder = new SessionHolder ();
3333
3434 // Exact match
35- testFilter ("city.Name = 'hello world'" , Optional . of ( "city.Name: \" hello world\" " ), Optional . empty () , sessionHolder );
36- testFilter ("'hello world' = city.Name" , Optional . of ( "city.Name: \" hello world\" " ), Optional . empty () , sessionHolder );
35+ testFilter ("city.Name = 'hello world'" , "city.Name: \" hello world\" " , null , sessionHolder );
36+ testFilter ("'hello world' = city.Name" , "city.Name: \" hello world\" " , null , sessionHolder );
3737
3838 // Like predicates that are transformed into substring match
39- testFilter ("city.Name like 'hello%'" , Optional . of ( "city.Name: \" hello*\" " ), Optional . empty () , sessionHolder );
40- testFilter ("city.Name like '%hello'" , Optional . of ( "city.Name: \" *hello\" " ), Optional . empty () , sessionHolder );
39+ testFilter ("city.Name like 'hello%'" , "city.Name: \" hello*\" " , null , sessionHolder );
40+ testFilter ("city.Name like '%hello'" , "city.Name: \" *hello\" " , null , sessionHolder );
4141
4242 // Like predicates that are transformed into CARDINALITY(SPLIT(x, 'some string', 2)) = 2 form, and they are not pushed down for now
43- testFilter ("city.Name like '%hello%'" , Optional . empty (), Optional . of ( "city.Name like '%hello%'" ) , sessionHolder );
43+ testFilter ("city.Name like '%hello%'" , null , "city.Name like '%hello%'" , sessionHolder );
4444
4545 // Like predicates that are kept in the original forms
46- testFilter ("city.Name like 'hello_'" , Optional . of ( "city.Name: \" hello?\" " ), Optional . empty () , sessionHolder );
47- testFilter ("city.Name like '_hello'" , Optional . of ( "city.Name: \" ?hello\" " ), Optional . empty () , sessionHolder );
48- testFilter ("city.Name like 'hello_w%'" , Optional . of ( "city.Name: \" hello?w*\" " ), Optional . empty () , sessionHolder );
49- testFilter ("city.Name like '%hello_w'" , Optional . of ( "city.Name: \" *hello?w\" " ), Optional . empty () , sessionHolder );
50- testFilter ("city.Name like 'hello%world'" , Optional . of ( "city.Name: \" hello*world\" " ), Optional . empty () , sessionHolder );
51- testFilter ("city.Name like 'hello%wor%ld'" , Optional . of ( "city.Name: \" hello*wor*ld\" " ), Optional . empty () , sessionHolder );
46+ testFilter ("city.Name like 'hello_'" , "city.Name: \" hello?\" " , null , sessionHolder );
47+ testFilter ("city.Name like '_hello'" , "city.Name: \" ?hello\" " , null , sessionHolder );
48+ testFilter ("city.Name like 'hello_w%'" , "city.Name: \" hello?w*\" " , null , sessionHolder );
49+ testFilter ("city.Name like '%hello_w'" , "city.Name: \" *hello?w\" " , null , sessionHolder );
50+ testFilter ("city.Name like 'hello%world'" , "city.Name: \" hello*world\" " , null , sessionHolder );
51+ testFilter ("city.Name like 'hello%wor%ld'" , "city.Name: \" hello*wor*ld\" " , null , sessionHolder );
5252 }
5353
5454 @ Test
5555 public void testSubStringPushdown ()
5656 {
5757 SessionHolder sessionHolder = new SessionHolder ();
5858
59- testFilter ("substr(city.Name, 1, 2) = 'he'" , Optional . of ( "city.Name: \" he*\" " ), Optional . empty () , sessionHolder );
60- testFilter ("substr(city.Name, 5, 2) = 'he'" , Optional . of ( "city.Name: \" ????he*\" " ), Optional . empty () , sessionHolder );
61- testFilter ("substr(city.Name, 5) = 'he'" , Optional . of ( "city.Name: \" ????he\" " ), Optional . empty () , sessionHolder );
62- testFilter ("substr(city.Name, -2) = 'he'" , Optional . of ( "city.Name: \" *he\" " ), Optional . empty () , sessionHolder );
59+ testFilter ("substr(city.Name, 1, 2) = 'he'" , "city.Name: \" he*\" " , null , sessionHolder );
60+ testFilter ("substr(city.Name, 5, 2) = 'he'" , "city.Name: \" ????he*\" " , null , sessionHolder );
61+ testFilter ("substr(city.Name, 5) = 'he'" , "city.Name: \" ????he\" " , null , sessionHolder );
62+ testFilter ("substr(city.Name, -2) = 'he'" , "city.Name: \" *he\" " , null , sessionHolder );
6363
6464 // Invalid substring index is not pushed down
65- testFilter ("substr(city.Name, 1, 5) = 'he'" , Optional . empty (), Optional . of ( "substr(city.Name, 1, 5) = 'he'" ) , sessionHolder );
66- testFilter ("substr(city.Name, -5) = 'he'" , Optional . empty (), Optional . of ( "substr(city.Name, -5) = 'he'" ) , sessionHolder );
65+ testFilter ("substr(city.Name, 1, 5) = 'he'" , null , "substr(city.Name, 1, 5) = 'he'" , sessionHolder );
66+ testFilter ("substr(city.Name, -5) = 'he'" , null , "substr(city.Name, -5) = 'he'" , sessionHolder );
6767 }
6868
6969 @ Test
7070 public void testNumericComparisonPushdown ()
7171 {
7272 SessionHolder sessionHolder = new SessionHolder ();
7373
74- testFilter ("fare > 0" , Optional . of ( "fare > 0" ), Optional . empty () , sessionHolder );
75- testFilter ("fare >= 0" , Optional . of ( "fare >= 0" ), Optional . empty () , sessionHolder );
76- testFilter ("fare < 0" , Optional . of ( "fare < 0" ), Optional . empty () , sessionHolder );
77- testFilter ("fare <= 0" , Optional . of ( "fare <= 0" ), Optional . empty () , sessionHolder );
78- testFilter ("fare = 0" , Optional . of ( "fare: 0" ), Optional . empty () , sessionHolder );
79- testFilter ("fare != 0" , Optional . of ( "NOT fare: 0" ), Optional . empty () , sessionHolder );
80- testFilter ("fare <> 0" , Optional . of ( "NOT fare: 0" ), Optional . empty () , sessionHolder );
81- testFilter ("0 < fare" , Optional . of ( "fare > 0" ), Optional . empty () , sessionHolder );
82- testFilter ("0 <= fare" , Optional . of ( "fare >= 0" ), Optional . empty () , sessionHolder );
83- testFilter ("0 > fare" , Optional . of ( "fare < 0" ), Optional . empty () , sessionHolder );
84- testFilter ("0 >= fare" , Optional . of ( "fare <= 0" ), Optional . empty () , sessionHolder );
85- testFilter ("0 = fare" , Optional . of ( "fare: 0" ), Optional . empty () , sessionHolder );
86- testFilter ("0 != fare" , Optional . of ( "NOT fare: 0" ), Optional . empty () , sessionHolder );
87- testFilter ("0 <> fare" , Optional . of ( "NOT fare: 0" ), Optional . empty () , sessionHolder );
74+ testFilter ("fare > 0" , "fare > 0" , null , sessionHolder );
75+ testFilter ("fare >= 0" , "fare >= 0" , null , sessionHolder );
76+ testFilter ("fare < 0" , "fare < 0" , null , sessionHolder );
77+ testFilter ("fare <= 0" , "fare <= 0" , null , sessionHolder );
78+ testFilter ("fare = 0" , "fare: 0" , null , sessionHolder );
79+ testFilter ("fare != 0" , "NOT fare: 0" , null , sessionHolder );
80+ testFilter ("fare <> 0" , "NOT fare: 0" , null , sessionHolder );
81+ testFilter ("0 < fare" , "fare > 0" , null , sessionHolder );
82+ testFilter ("0 <= fare" , "fare >= 0" , null , sessionHolder );
83+ testFilter ("0 > fare" , "fare < 0" , null , sessionHolder );
84+ testFilter ("0 >= fare" , "fare <= 0" , null , sessionHolder );
85+ testFilter ("0 = fare" , "fare: 0" , null , sessionHolder );
86+ testFilter ("0 != fare" , "NOT fare: 0" , null , sessionHolder );
87+ testFilter ("0 <> fare" , "NOT fare: 0" , null , sessionHolder );
8888 }
8989
9090 @ Test
9191 public void testOrPushdown ()
9292 {
9393 SessionHolder sessionHolder = new SessionHolder ();
9494
95- testFilter ("fare > 0 OR city.Name like 'b%'" , Optional . of ( "(fare > 0 OR city.Name: \" b*\" )" ), Optional . empty () , sessionHolder );
95+ testFilter ("fare > 0 OR city.Name like 'b%'" , "(fare > 0 OR city.Name: \" b*\" )" , null , sessionHolder );
9696 testFilter (
9797 "lower(city.Region.Name) = 'hello world' OR city.Region.Id != 1" ,
98- Optional . empty () ,
99- Optional . of ( "(lower(city.Region.Name) = 'hello world' OR city.Region.Id != 1)" ) ,
98+ null ,
99+ "(lower(city.Region.Name) = 'hello world' OR city.Region.Id != 1)" ,
100100 sessionHolder );
101101
102102 // Multiple ORs
103103 testFilter (
104104 "fare > 0 OR city.Name like 'b%' OR lower(city.Region.Name) = 'hello world' OR city.Region.Id != 1" ,
105- Optional . empty () ,
106- Optional . of ( "fare > 0 OR city.Name like 'b%' OR lower(city.Region.Name) = 'hello world' OR city.Region.Id != 1" ) ,
105+ null ,
106+ "fare > 0 OR city.Name like 'b%' OR lower(city.Region.Name) = 'hello world' OR city.Region.Id != 1" ,
107107 sessionHolder );
108108 testFilter (
109109 "fare > 0 OR city.Name like 'b%' OR city.Region.Id != 1" ,
110- Optional . of ( "((fare > 0 OR city.Name: \" b*\" ) OR NOT city.Region.Id: 1)" ) ,
111- Optional . empty () ,
110+ "((fare > 0 OR city.Name: \" b*\" ) OR NOT city.Region.Id: 1)" ,
111+ null ,
112112 sessionHolder );
113113 }
114114
@@ -117,23 +117,23 @@ public void testAndPushdown()
117117 {
118118 SessionHolder sessionHolder = new SessionHolder ();
119119
120- testFilter ("fare > 0 AND city.Name like 'b%'" , Optional . of ( "(fare > 0 AND city.Name: \" b*\" )" ), Optional . empty () , sessionHolder );
120+ testFilter ("fare > 0 AND city.Name like 'b%'" , "(fare > 0 AND city.Name: \" b*\" )" , null , sessionHolder );
121121 testFilter (
122122 "lower(city.Region.Name) = 'hello world' AND city.Region.Id != 1" ,
123- Optional . of ( "(NOT city.Region.Id: 1)" ) ,
124- Optional . of ( "lower(city.Region.Name) = 'hello world'" ) ,
123+ "(NOT city.Region.Id: 1)" ,
124+ "lower(city.Region.Name) = 'hello world'" ,
125125 sessionHolder );
126126
127127 // Multiple ANDs
128128 testFilter (
129129 "fare > 0 AND city.Name like 'b%' AND lower(city.Region.Name) = 'hello world' AND city.Region.Id != 1" ,
130- Optional . of ( "(((fare > 0 AND city.Name: \" b*\" )) AND NOT city.Region.Id: 1)" ) ,
131- Optional . of ( "(lower(city.Region.Name) = 'hello world')" ) ,
130+ "(((fare > 0 AND city.Name: \" b*\" )) AND NOT city.Region.Id: 1)" ,
131+ "(lower(city.Region.Name) = 'hello world')" ,
132132 sessionHolder );
133133 testFilter (
134134 "fare > 0 AND city.Name like '%b%' AND lower(city.Region.Name) = 'hello world' AND city.Region.Id != 1" ,
135- Optional . of ( "(((fare > 0)) AND NOT city.Region.Id: 1)" ) ,
136- Optional . of ( "city.Name like '%b%' AND lower(city.Region.Name) = 'hello world'" ) ,
135+ "(((fare > 0)) AND NOT city.Region.Id: 1)" ,
136+ "city.Name like '%b%' AND lower(city.Region.Name) = 'hello world'" ,
137137 sessionHolder );
138138 }
139139
@@ -142,37 +142,37 @@ public void testNotPushdown()
142142 {
143143 SessionHolder sessionHolder = new SessionHolder ();
144144
145- testFilter ("city.Region.Name NOT LIKE 'hello%'" , Optional . of ( "NOT city.Region.Name: \" hello*\" " ), Optional . empty () , sessionHolder );
146- testFilter ("NOT (city.Region.Name LIKE 'hello%')" , Optional . of ( "NOT city.Region.Name: \" hello*\" " ), Optional . empty () , sessionHolder );
147- testFilter ("city.Name != 'hello world'" , Optional . of ( "NOT city.Name: \" hello world\" " ), Optional . empty () , sessionHolder );
148- testFilter ("city.Name <> 'hello world'" , Optional . of ( "NOT city.Name: \" hello world\" " ), Optional . empty () , sessionHolder );
149- testFilter ("NOT (city.Name = 'hello world')" , Optional . of ( "NOT city.Name: \" hello world\" " ), Optional . empty () , sessionHolder );
150- testFilter ("fare != 0" , Optional . of ( "NOT fare: 0" ), Optional . empty () , sessionHolder );
151- testFilter ("fare <> 0" , Optional . of ( "NOT fare: 0" ), Optional . empty () , sessionHolder );
152- testFilter ("NOT (fare = 0)" , Optional . of ( "NOT fare: 0" ), Optional . empty () , sessionHolder );
145+ testFilter ("city.Region.Name NOT LIKE 'hello%'" , "NOT city.Region.Name: \" hello*\" " , null , sessionHolder );
146+ testFilter ("NOT (city.Region.Name LIKE 'hello%')" , "NOT city.Region.Name: \" hello*\" " , null , sessionHolder );
147+ testFilter ("city.Name != 'hello world'" , "NOT city.Name: \" hello world\" " , null , sessionHolder );
148+ testFilter ("city.Name <> 'hello world'" , "NOT city.Name: \" hello world\" " , null , sessionHolder );
149+ testFilter ("NOT (city.Name = 'hello world')" , "NOT city.Name: \" hello world\" " , null , sessionHolder );
150+ testFilter ("fare != 0" , "NOT fare: 0" , null , sessionHolder );
151+ testFilter ("fare <> 0" , "NOT fare: 0" , null , sessionHolder );
152+ testFilter ("NOT (fare = 0)" , "NOT fare: 0" , null , sessionHolder );
153153
154154 // Multiple NOTs
155- testFilter ("NOT (NOT fare = 0)" , Optional . of ( "NOT NOT fare: 0" ), Optional . empty () , sessionHolder );
156- testFilter ("NOT (fare = 0 AND city.Name = 'hello world')" , Optional . of ( "NOT (fare: 0 AND city.Name: \" hello world\" )" ), Optional . empty () , sessionHolder );
157- testFilter ("NOT (fare = 0 OR city.Name = 'hello world')" , Optional . of ( "NOT (fare: 0 OR city.Name: \" hello world\" )" ), Optional . empty () , sessionHolder );
155+ testFilter ("NOT (NOT fare = 0)" , "NOT NOT fare: 0" , null , sessionHolder );
156+ testFilter ("NOT (fare = 0 AND city.Name = 'hello world')" , "NOT (fare: 0 AND city.Name: \" hello world\" )" , null , sessionHolder );
157+ testFilter ("NOT (fare = 0 OR city.Name = 'hello world')" , "NOT (fare: 0 OR city.Name: \" hello world\" )" , null , sessionHolder );
158158 }
159159
160160 @ Test
161161 public void testInPushdown ()
162162 {
163163 SessionHolder sessionHolder = new SessionHolder ();
164164
165- testFilter ("city.Name IN ('hello world', 'hello world 2')" , Optional . of ( "(city.Name: \" hello world\" OR city.Name: \" hello world 2\" )" ), Optional . empty () , sessionHolder );
165+ testFilter ("city.Name IN ('hello world', 'hello world 2')" , "(city.Name: \" hello world\" OR city.Name: \" hello world 2\" )" , null , sessionHolder );
166166 }
167167
168168 @ Test
169169 public void testIsNullPushdown ()
170170 {
171171 SessionHolder sessionHolder = new SessionHolder ();
172172
173- testFilter ("city.Name IS NULL" , Optional . of ( "NOT city.Name: *" ), Optional . empty () , sessionHolder );
174- testFilter ("city.Name IS NOT NULL" , Optional . of ( "NOT NOT city.Name: *" ), Optional . empty () , sessionHolder );
175- testFilter ("NOT (city.Name IS NULL)" , Optional . of ( "NOT NOT city.Name: *" ), Optional . empty () , sessionHolder );
173+ testFilter ("city.Name IS NULL" , "NOT city.Name: *" , null , sessionHolder );
174+ testFilter ("city.Name IS NOT NULL" , "NOT NOT city.Name: *" , null , sessionHolder );
175+ testFilter ("NOT (city.Name IS NULL)" , "NOT NOT city.Name: *" , null , sessionHolder );
176176 }
177177
178178 @ Test
@@ -182,30 +182,30 @@ public void testComplexPushdown()
182182
183183 testFilter (
184184 "(fare > 0 OR city.Name like 'b%') AND (lower(city.Region.Name) = 'hello world' OR city.Name IS NULL)" ,
185- Optional . of ( "((fare > 0 OR city.Name: \" b*\" ))" ) ,
186- Optional . of ( "(lower(city.Region.Name) = 'hello world' OR city.Name IS NULL)" ) ,
185+ "((fare > 0 OR city.Name: \" b*\" ))" ,
186+ "(lower(city.Region.Name) = 'hello world' OR city.Name IS NULL)" ,
187187 sessionHolder );
188188 testFilter (
189189 "city.Region.Id = 1 AND (fare > 0 OR city.Name NOT like 'b%') AND (lower(city.Region.Name) = 'hello world' OR city.Name IS NULL)" ,
190- Optional . of ( "((city.Region.Id: 1 AND (fare > 0 OR NOT city.Name: \" b*\" )))" ) ,
191- Optional . of ( "lower(city.Region.Name) = 'hello world' OR city.Name IS NULL" ) ,
190+ "((city.Region.Id: 1 AND (fare > 0 OR NOT city.Name: \" b*\" )))" ,
191+ "lower(city.Region.Name) = 'hello world' OR city.Name IS NULL" ,
192192 sessionHolder );
193193 }
194194
195- private void testFilter (String sqlExpression , Optional < String > expectedKqlExpression , Optional < String > expectedRemainingExpression , SessionHolder sessionHolder )
195+ private void testFilter (String sqlExpression , String expectedKqlExpression , String expectedRemainingExpression , SessionHolder sessionHolder )
196196 {
197197 RowExpression pushDownExpression = getRowExpression (sqlExpression , sessionHolder );
198198 ClpExpression clpExpression = pushDownExpression .accept (new ClpFilterToKqlConverter (standardFunctionResolution , functionAndTypeManager , variableToColumnHandleMap ), null );
199199 Optional <String > kqlExpression = clpExpression .getDefinition ();
200200 Optional <RowExpression > remainingExpression = clpExpression .getRemainingExpression ();
201- if (expectedKqlExpression . isPresent () ) {
201+ if (expectedKqlExpression != null ) {
202202 assertTrue (kqlExpression .isPresent ());
203- assertEquals (kqlExpression .get (), expectedKqlExpression . get () );
203+ assertEquals (kqlExpression .get (), expectedKqlExpression );
204204 }
205205
206- if (expectedRemainingExpression . isPresent () ) {
206+ if (expectedRemainingExpression != null ) {
207207 assertTrue (remainingExpression .isPresent ());
208- assertEquals (remainingExpression .get (), getRowExpression (expectedRemainingExpression . get () , sessionHolder ));
208+ assertEquals (remainingExpression .get (), getRowExpression (expectedRemainingExpression , sessionHolder ));
209209 }
210210 else {
211211 assertFalse (remainingExpression .isPresent ());
0 commit comments