3333import org .apache .arrow .vector .types .pojo .Schema ;
3434import org .junit .After ;
3535import org .junit .Before ;
36- import org .junit .Rule ;
3736import org .junit .Test ;
38- import org .junit .rules .ExpectedException ;
3937import org .junit .runner .RunWith ;
4038import org .mockito .junit .MockitoJUnitRunner ;
4139import java .util .Collections ;
@@ -55,9 +53,6 @@ public class PredicateBuilderTest {
5553 private HashMap <String , PredicateBuilder .TypeAndValue > accumulator ;
5654 private BlockAllocator allocator ;
5755
58- @ Rule
59- public ExpectedException thrown = ExpectedException .none ();
60-
6156 @ Before
6257 public void setUp () {
6358 allocator = new BlockAllocatorImpl ();
@@ -73,6 +68,7 @@ public void setUp() {
7368 public void tearDown () {
7469 allocator .close ();
7570 }
71+
7672 @ Test
7773 public void quote_SimpleName_ReturnsQuotedString () {
7874 assertEquals ("\" simpleName\" " , PredicateBuilder .quote ("simpleName" ));
@@ -134,15 +130,15 @@ public void toConjuncts_EmptyConstraints_ReturnsEmptyList() {
134130
135131 @ Test
136132 public void toConjuncts_NonExistentColumn_ReturnsEmptyList () {
137- Constraints constraints = createConstraints (ImmutableMap .of ("non_existent_col" , singleValue (col1Int .getType (), 10 , false )));
133+ Constraints constraints = createConstraints (ImmutableMap .of ("non_existent_col" , singleValue (col1Int .getType (), 10 )));
138134 List <String > conjuncts = PredicateBuilder .toConjuncts (schema .getFields (), constraints , accumulator );
139135 assertTrue (conjuncts .isEmpty ());
140136 assertTrue (accumulator .isEmpty ());
141137 }
142138
143139 @ Test
144140 public void toConjuncts_SingleEqualValue_ReturnsEqualityPredicate () {
145- Constraints constraints = createConstraints (ImmutableMap .of ("col1" , singleValue (col1Int .getType (), 123 , false )));
141+ Constraints constraints = createConstraints (ImmutableMap .of ("col1" , singleValue (col1Int .getType (), 123 )));
146142 List <String > conjuncts = PredicateBuilder .toConjuncts (schema .getFields (), constraints , accumulator );
147143 assertEquals (1 , conjuncts .size ());
148144 assertEquals ("(\" col1\" = <col1> )" , conjuncts .get (0 ));
@@ -173,7 +169,7 @@ public void toConjuncts_MultipleValuesWithNull_ReturnsInOrNullPredicate() {
173169
174170 @ Test
175171 public void toConjuncts_GreaterThanValue_ReturnsGreaterThanPredicate () {
176- Constraints constraints = createConstraints (ImmutableMap .of ("col3" , greaterThan (col3Double .getType (), 10.5 , false )));
172+ Constraints constraints = createConstraints (ImmutableMap .of ("col3" , greaterThan (col3Double .getType (), 10.5 )));
177173 List <String > conjuncts = PredicateBuilder .toConjuncts (schema .getFields (), constraints , accumulator );
178174 assertEquals (1 , conjuncts .size ());
179175 assertEquals ("((\" col3\" > <col3> ))" , conjuncts .get (0 ));
@@ -183,7 +179,7 @@ public void toConjuncts_GreaterThanValue_ReturnsGreaterThanPredicate() {
183179
184180 @ Test
185181 public void toConjuncts_InclusiveRange_ReturnsRangePredicate () {
186- Constraints constraints = createConstraints (ImmutableMap .of ("col1" , betweenInclusive (col1Int .getType (), 10 , 20 , false )));
182+ Constraints constraints = createConstraints (ImmutableMap .of ("col1" , betweenInclusive (col1Int .getType ())));
187183 List <String > conjuncts = PredicateBuilder .toConjuncts (schema .getFields (), constraints , accumulator );
188184 assertEquals (1 , conjuncts .size ());
189185 assertEquals ("((\" col1\" >= <col1> AND \" col1\" \\ <= <col1> ))" , conjuncts .get (0 ));
@@ -212,8 +208,8 @@ public void toConjuncts_NotNullValue_ReturnsIsNotNullPredicate() {
212208 @ Test
213209 public void toConjuncts_MultipleColumns_ReturnsMultiplePredicates () {
214210 Map <String , ValueSet > summary = ImmutableMap .of (
215- "col1" , greaterThan (col1Int .getType (), 10 , false ),
216- "col2" , singleValue (col2Varchar .getType (), "ACTIVE" , false )
211+ "col1" , greaterThan (col1Int .getType (), 10 ),
212+ "col2" , singleValue (col2Varchar .getType (), "ACTIVE" )
217213 );
218214 Constraints constraints = createConstraints (summary );
219215 List <String > conjuncts = PredicateBuilder .toConjuncts (schema .getFields (), constraints , accumulator );
@@ -236,40 +232,26 @@ public void TypeAndValue_ValidInput_ReturnsCorrectValues() {
236232
237233
238234 private Constraints createConstraints (Map <String , ValueSet > summary ) {
239- return new Constraints (summary , Collections .emptyList (), Collections .emptyList (), Constraints .DEFAULT_NO_LIMIT );
235+ return new Constraints (summary , Collections .emptyList (), Collections .emptyList (), Constraints .DEFAULT_NO_LIMIT , Collections . emptyMap () );
240236 }
241237
242- private ValueSet singleValue (ArrowType type , Object value , boolean nullAllowed ) {
238+ private ValueSet singleValue (ArrowType type , Object value ) {
243239 Range range = Range .equal (allocator , type , value );
244- return SortedRangeSet .newBuilder (type , nullAllowed )
240+ return SortedRangeSet .newBuilder (type , false )
245241 .add (range )
246242 .build ();
247243 }
248244
249- private ValueSet greaterThan (ArrowType type , Object value , boolean nullAllowed ) {
245+ private ValueSet greaterThan (ArrowType type , Object value ) {
250246 Range range = Range .greaterThan (allocator , type , value );
251- return SortedRangeSet .newBuilder (type , nullAllowed )
252- .add (range )
253- .build ();
254- }
255-
256- private ValueSet lessThanOrEqual (ArrowType type , Object value , boolean nullAllowed ) {
257- Range range = Range .lessThanOrEqual (allocator , type , value );
258- return SortedRangeSet .newBuilder (type , nullAllowed )
259- .add (range )
260- .build ();
261- }
262-
263- private ValueSet between (ArrowType type , Object lower , Object upper , boolean nullAllowed ) {
264- Range range = Range .range (allocator , type , lower , false , upper , false );
265- return SortedRangeSet .newBuilder (type , nullAllowed )
247+ return SortedRangeSet .newBuilder (type , false )
266248 .add (range )
267249 .build ();
268250 }
269251
270- private ValueSet betweenInclusive (ArrowType type , Object lower , Object upper , boolean nullAllowed ) {
271- Range range = Range .range (allocator , type , lower , true , upper , true );
272- return SortedRangeSet .newBuilder (type , nullAllowed )
252+ private ValueSet betweenInclusive (ArrowType type ) {
253+ Range range = Range .range (allocator , type , 10 , true , 20 , true );
254+ return SortedRangeSet .newBuilder (type , false )
273255 .add (range )
274256 .build ();
275257 }
0 commit comments