You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by lz...@apache.org on 2022/07/19 06:58:17 UTC
[flink-table-store] branch master updated: [FLINK-28580] Predicate supports unknown stats
This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-table-store.git
The following commit(s) were added to refs/heads/master by this push:
new d761f210 [FLINK-28580] Predicate supports unknown stats
d761f210 is described below
commit d761f210c5e6dd9dc3e8cf1a7e46c1bf3a32ef66
Author: Jingsong Lee <ji...@gmail.com>
AuthorDate: Tue Jul 19 14:58:12 2022 +0800
[FLINK-28580] Predicate supports unknown stats
This closes #222
---
.../flink/table/store/file/predicate/LeafPredicate.java | 11 ++++++++++-
.../flink/table/store/file/predicate/PredicateTest.java | 13 +++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/file/predicate/LeafPredicate.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/file/predicate/LeafPredicate.java
index 5e48776a..9ffdaf19 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/file/predicate/LeafPredicate.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/file/predicate/LeafPredicate.java
@@ -85,7 +85,16 @@ public class LeafPredicate implements Predicate {
@Override
public boolean test(long rowCount, FieldStats[] fieldStats) {
- return function.test(type, rowCount, fieldStats[fieldIndex], literals);
+ FieldStats stats = fieldStats[fieldIndex];
+ if (rowCount != stats.nullCount()) {
+ // not all null
+ // min or max is null
+ // unknown stats
+ if (stats.minValue() == null || stats.maxValue() == null) {
+ return true;
+ }
+ }
+ return function.test(type, rowCount, stats, literals);
}
@Override
diff --git a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/predicate/PredicateTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/predicate/PredicateTest.java
index 5e58e73b..77f28551 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/predicate/PredicateTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/predicate/PredicateTest.java
@@ -506,4 +506,17 @@ public class PredicateTest {
assertThat(predicate.negate().orElse(null))
.isEqualTo(PredicateBuilder.and(builder.notEqual(0, 3), builder.notEqual(1, 5)));
}
+
+ @Test
+ public void testUnknownStats() {
+ PredicateBuilder builder = new PredicateBuilder(RowType.of(new IntType()));
+ Predicate predicate = builder.equal(0, 5);
+
+ assertThat(predicate.test(3, new FieldStats[] {new FieldStats(null, null, 3)}))
+ .isEqualTo(false);
+
+ // unknown stats, we don't know, likely to hit
+ assertThat(predicate.test(3, new FieldStats[] {new FieldStats(null, null, 4)}))
+ .isEqualTo(true);
+ }
}