snuyanzin commented on code in PR #28162:
URL: https://github.com/apache/flink/pull/28162#discussion_r3320305792


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/rules/logical/MetadataFilterInReadingMetadataTest.java:
##########
@@ -204,6 +206,78 @@ void testPhysicalAndMetadataNameCollision() {
         
assertThat(receivedFilters.get().toString()).isEqualTo("[greaterThan(offset, 
5)]");
     }
 
+    @Test
+    void testBestEffortMetadataPruning() {
+        // Exercises a source that performs best-effort pruning: every input 
predicate goes
+        // into `accepted` (so the source can use it for file/partition 
pruning) AND into
+        // `remaining` (so a runtime Calc still re-evaluates it for 
correctness). The
+        // resulting plan therefore carries `metadataFilter=[...]` on the scan 
plus a
+        // `LogicalFilter` above it.
+        SharedReference<List<ResolvedExpression>> receivedFilters =
+                sharedObjects.add(new ArrayList<>());
+        TableDescriptor descriptor =
+                TableFactoryHarness.newBuilder()
+                        .schema(MetadataFilterSource.SCHEMA)
+                        .source(new BestEffortPruningSource(receivedFilters))
+                        .build();
+        util.tableEnv().createTable("T8", descriptor);
+
+        util.verifyRelPlan("SELECT id FROM T8 WHERE event_time > TIMESTAMP 
'2024-01-01 00:00:00'");
+
+        assertThat(receivedFilters.get().toString())
+                .isEqualTo("[greaterThan(event_time, 2024-01-01T00:00)]");
+    }
+
+    @Test
+    void testNonContiguousSubsetAcceptance() {
+        // The source receives three metadata predicates (on m0, m1, m2) and 
accepts the
+        // ones referencing m0 and m2 while rejecting the one on m1. After the 
rule fires,
+        // the spec must carry exactly the m0 and m2 predicates and the 
LogicalFilter above
+        // the scan must carry exactly the m1 predicate. A purely positional 
convention
+        // (accepted-prefix / remaining-suffix) could not express this layout.
+        SharedReference<List<ResolvedExpression>> receivedFilters =
+                sharedObjects.add(new ArrayList<>());
+        TableDescriptor descriptor =
+                TableFactoryHarness.newBuilder()
+                        .schema(NonContiguousAcceptingSource.SCHEMA)
+                        .source(new 
NonContiguousAcceptingSource(receivedFilters))
+                        .build();
+        util.tableEnv().createTable("T9", descriptor);
+
+        // Three metadata predicates in input order: m0, m1, m2.
+        util.verifyRelPlan("SELECT id FROM T9 WHERE m0 > 0 AND m1 > 1 AND m2 > 
2");
+
+        // The source receives all three filters in input order, but accepts 
only m0 and m2.
+        assertThat(receivedFilters.get().toString())
+                .isEqualTo("[greaterThan(m0, 0), greaterThan(m1, 1), 
greaterThan(m2, 2)]");
+    }

Review Comment:
   looks like it is still present in latest version
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to