use of org.apache.flink.table.api.TableDescriptor in project flink by apache.
the class PushProjectIntoTableSourceScanRuleTest method testMetadataProjectionWithoutProjectionPushDownWhenSupported.
@Test
public void testMetadataProjectionWithoutProjectionPushDownWhenSupported() {
final SharedReference<List<String>> appliedKeys = sharedObjects.add(new ArrayList<>());
final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(NoPushDownSource.SCHEMA).source(new NoPushDownSource(true, appliedKeys)).build();
util().tableEnv().createTable("T1", sourceDescriptor);
util().verifyRelPlan("SELECT m1, metadata FROM T1");
assertThat(appliedKeys.get(), contains("m1", "m2"));
}
use of org.apache.flink.table.api.TableDescriptor in project flink by apache.
the class PushProjectIntoTableSourceScanRuleTest method testProjectionIncludingOnlyMetadata.
@Test
public void testProjectionIncludingOnlyMetadata() {
final AtomicReference<DataType> appliedProjectionDataType = new AtomicReference<>(null);
final AtomicReference<DataType> appliedMetadataDataType = new AtomicReference<>(null);
final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(PushDownSource.SCHEMA).source(new PushDownSource(appliedProjectionDataType, appliedMetadataDataType)).build();
util().tableEnv().createTable("T5", sourceDescriptor);
util().verifyRelPlan("SELECT metadata FROM T5");
assertThat(appliedProjectionDataType.get(), notNullValue());
assertThat(appliedMetadataDataType.get(), notNullValue());
assertThat(DataType.getFieldNames(appliedProjectionDataType.get()), equalTo(Collections.emptyList()));
assertThat(DataType.getFieldNames(appliedMetadataDataType.get()), equalTo(Collections.singletonList("m2")));
}
use of org.apache.flink.table.api.TableDescriptor in project flink by apache.
the class PushProjectIntoTableSourceScanRuleTest method testProjectionWithMetadataAndPhysicalFields.
@Test
public void testProjectionWithMetadataAndPhysicalFields() {
final AtomicReference<DataType> appliedProjectionDataType = new AtomicReference<>(null);
final AtomicReference<DataType> appliedMetadataDataType = new AtomicReference<>(null);
final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(PushDownSource.SCHEMA).source(new PushDownSource(appliedProjectionDataType, appliedMetadataDataType)).build();
util().tableEnv().createTable("T5", sourceDescriptor);
util().verifyRelPlan("SELECT metadata, f1 FROM T5");
assertThat(appliedProjectionDataType.get(), notNullValue());
assertThat(appliedMetadataDataType.get(), notNullValue());
assertThat(DataType.getFieldNames(appliedProjectionDataType.get()), equalTo(Collections.singletonList("f1")));
assertThat(DataType.getFieldNames(appliedMetadataDataType.get()), equalTo(Arrays.asList("f1", "m2")));
}
use of org.apache.flink.table.api.TableDescriptor in project flink by apache.
the class PushFilterPastChangelogNormalizeRuleTest method testWithMultiplePrimaryKeyColumns.
@Test
public void testWithMultiplePrimaryKeyColumns() {
final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(Schema.newBuilder().column("f0", STRING()).column("f1", INT().notNull()).column("f2", BIGINT().notNull()).primaryKey("f1", "f2").build()).unboundedScanSource(ChangelogMode.upsert()).build();
util.tableEnv().createTable("T", sourceDescriptor);
util.verifyRelPlan("SELECT f0, f1 FROM T WHERE (f1 < 1 OR f2 > 10) AND f0 IS NOT NULL");
}
use of org.apache.flink.table.api.TableDescriptor in project flink by apache.
the class WrapJsonAggFunctionArgumentsRuleTest method testJsonObjectAgg.
@Test
public void testJsonObjectAgg() {
final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(Schema.newBuilder().column("f0", STRING()).build()).unboundedScanSource(ChangelogMode.all()).build();
util.tableEnv().createTable("T", sourceDescriptor);
util.verifyRelPlan("SELECT JSON_OBJECTAGG(f0 VALUE f0) FROM T");
}
Aggregations