Airblader commented on a change in pull request #16984:
URL: https://github.com/apache/flink/pull/16984#discussion_r697334683
##########
File path:
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/rules/logical/PushProjectIntoTableSourceScanRuleTest.java
##########
@@ -243,4 +270,153 @@ public void testProjectFieldAccessWithITEM() {
+ "`outer_map`['item'] "
+ "FROM ItemTable");
}
+
+ @Test
+ public void testMetadataProjectionWithoutProjectionPushDownWhenSupported()
{
+ createMetadataTableWithoutProjectionPushDown("T1", true);
+
+ util().verifyRelPlan("SELECT m1, metadata FROM T1");
+ assertThat(
+
MetadataNoProjectionPushDownTableFactory.appliedMetadataKeys.get(),
+ contains("m1", "m2"));
+ }
+
+ @Test
+ public void
testMetadataProjectionWithoutProjectionPushDownWhenNotSupported() {
+ createMetadataTableWithoutProjectionPushDown("T2", false);
+
+ util().verifyRelPlan("SELECT m1, metadata FROM T2");
+ assertThat(
+
MetadataNoProjectionPushDownTableFactory.appliedMetadataKeys.get(),
+ contains("m1", "m2", "m3"));
+ }
+
+ @Test
+ public void
testMetadataProjectionWithoutProjectionPushDownWhenSupportedAndNoneSelected() {
+ createMetadataTableWithoutProjectionPushDown("T3", true);
+
+ util().verifyRelPlan("SELECT 1 FROM T3");
+
assertThat(MetadataNoProjectionPushDownTableFactory.appliedMetadataKeys.get(),
hasSize(0));
+ }
+
+ @Test
+ public void
testMetadataProjectionWithoutProjectionPushDownWhenNotSupportedAndNoneSelected()
{
+ createMetadataTableWithoutProjectionPushDown("T4", false);
+
+ util().verifyRelPlan("SELECT 1 FROM T4");
+ assertThat(
+
MetadataNoProjectionPushDownTableFactory.appliedMetadataKeys.get(),
+ contains("m1", "m2", "m3"));
+ }
+
+ //
---------------------------------------------------------------------------------------------
+
+ private void createMetadataTableWithoutProjectionPushDown(
+ String name, boolean supportsMetadataProjection) {
+ util().tableEnv()
+ .createTable(
+ name,
+ TableDescriptor.forConnector(
+
MetadataNoProjectionPushDownTableFactory.IDENTIFIER)
+ .schema(
+ Schema.newBuilder()
+ .columnByMetadata("m1",
STRING())
+ .columnByMetadata("metadata",
STRING(), "m2")
+ .columnByMetadata("m3",
STRING())
+ .build())
+ .option(SUPPORTS_METADATA_PROJECTION,
supportsMetadataProjection)
+ .build());
+ }
+
+ //
---------------------------------------------------------------------------------------------
+
+ /** Factory for {@link Source}. */
+ public static class MetadataNoProjectionPushDownTableFactory
+ implements DynamicTableSourceFactory {
+ public static final String IDENTIFIER = "metadataNoProjectionPushDown";
+
+ public static final ConfigOption<Boolean> SUPPORTS_METADATA_PROJECTION
=
+
ConfigOptions.key("supports-metadata-projection").booleanType().defaultValue(true);
+
+ public static ThreadLocal<List<String>> appliedMetadataKeys = new
ThreadLocal<>();
Review comment:
Now that we have the testing harness in the other PR, let's merge that
one first and then I can rebase this PR to make use of it.
--
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]