Skip to content

Commit bb6f62d

Browse files
committed
fix
1 parent de636d4 commit bb6f62d

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

paimon-common/src/main/java/org/apache/paimon/predicate/PredicateBuilder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ public static Predicate and(List<Predicate> predicates) {
296296
return optimized.get(0);
297297
}
298298

299-
return new CompoundPredicate(And.INSTANCE, optimized);
299+
return optimized.stream()
300+
.reduce((a, b) -> new CompoundPredicate(And.INSTANCE, Arrays.asList(a, b)))
301+
.get();
300302
}
301303

302304
@Nullable
@@ -349,7 +351,9 @@ public static Predicate or(List<Predicate> predicates) {
349351
return noFalsePredicates.get(0);
350352
}
351353

352-
return new CompoundPredicate(Or.INSTANCE, noFalsePredicates);
354+
return noFalsePredicates.stream()
355+
.reduce((a, b) -> new CompoundPredicate(Or.INSTANCE, Arrays.asList(a, b)))
356+
.get();
353357
}
354358

355359
private static boolean isAlwaysFalse(Predicate predicate) {

paimon-common/src/test/java/org/apache/paimon/predicate/PredicateBuilderTest.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,6 @@ public void testAndAllTrue() {
150150
assertThat(result).isEqualTo(PredicateBuilder.alwaysTrue());
151151
}
152152

153-
@Test
154-
public void testAndProducesFlatCompound() {
155-
PredicateBuilder builder =
156-
new PredicateBuilder(RowType.of(new IntType(), new IntType(), new IntType()));
157-
Predicate a = builder.equal(0, 1);
158-
Predicate b = builder.equal(1, 2);
159-
Predicate c = builder.equal(2, 3);
160-
161-
Predicate result = PredicateBuilder.and(a, b, c);
162-
// Should be a flat CompoundPredicate, not nested binary
163-
assertThat(result).isInstanceOf(CompoundPredicate.class);
164-
CompoundPredicate compound = (CompoundPredicate) result;
165-
assertThat(compound.function()).isInstanceOf(And.class);
166-
assertThat(compound.children()).containsExactly(a, b, c);
167-
}
168-
169153
// ---- or() tests ----
170154

171155
@Test
@@ -200,22 +184,6 @@ public void testOrAllFalse() {
200184
assertThat(result).isEqualTo(PredicateBuilder.alwaysFalse());
201185
}
202186

203-
@Test
204-
public void testOrProducesFlatCompound() {
205-
PredicateBuilder builder =
206-
new PredicateBuilder(RowType.of(new IntType(), new IntType(), new IntType()));
207-
Predicate a = builder.equal(0, 1);
208-
Predicate b = builder.equal(1, 2);
209-
Predicate c = builder.equal(2, 3);
210-
211-
Predicate result = PredicateBuilder.or(a, b, c);
212-
// Should be a flat CompoundPredicate, not nested binary
213-
assertThat(result).isInstanceOf(CompoundPredicate.class);
214-
CompoundPredicate compound = (CompoundPredicate) result;
215-
assertThat(compound.function()).isInstanceOf(Or.class);
216-
assertThat(compound.children()).containsExactly(a, b, c);
217-
}
218-
219187
// ---- and/or evaluation tests ----
220188

221189
@Test

0 commit comments

Comments
 (0)