Search in sources :

Example 1 with TableDescriptor

use of org.apache.flink.table.api.TableDescriptor in project flink by apache.

the class PushProjectIntoTableSourceScanRuleTest method testMetadataProjectionWithoutProjectionPushDownWhenNotSupported.

@Test
public void testMetadataProjectionWithoutProjectionPushDownWhenNotSupported() {
    final SharedReference<List<String>> appliedKeys = sharedObjects.add(new ArrayList<>());
    final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(NoPushDownSource.SCHEMA).source(new NoPushDownSource(false, appliedKeys)).build();
    util().tableEnv().createTable("T2", sourceDescriptor);
    util().verifyRelPlan("SELECT m1, metadata FROM T2");
    assertThat(appliedKeys.get(), contains("m1", "m2", "m3"));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) TableDescriptor(org.apache.flink.table.api.TableDescriptor) Test(org.junit.Test)

Example 2 with TableDescriptor

use of org.apache.flink.table.api.TableDescriptor in project flink by apache.

the class PushProjectIntoTableSourceScanRuleTest method testMetadataProjectionWithoutProjectionPushDownWhenNotSupportedAndNoneSelected.

@Test
public void testMetadataProjectionWithoutProjectionPushDownWhenNotSupportedAndNoneSelected() {
    final SharedReference<List<String>> appliedKeys = sharedObjects.add(new ArrayList<>());
    final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(NoPushDownSource.SCHEMA).source(new NoPushDownSource(false, appliedKeys)).build();
    util().tableEnv().createTable("T4", sourceDescriptor);
    util().verifyRelPlan("SELECT 1 FROM T4");
    assertThat(appliedKeys.get(), contains("m1", "m2", "m3"));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) TableDescriptor(org.apache.flink.table.api.TableDescriptor) Test(org.junit.Test)

Example 3 with TableDescriptor

use of org.apache.flink.table.api.TableDescriptor in project flink by apache.

the class PushProjectIntoTableSourceScanRuleTest method testMetadataProjectionWithoutProjectionPushDownWhenSupportedAndNoneSelected.

@Test
public void testMetadataProjectionWithoutProjectionPushDownWhenSupportedAndNoneSelected() {
    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("T3", sourceDescriptor);
    util().verifyRelPlan("SELECT 1 FROM T3");
    assertThat(appliedKeys.get(), hasSize(0));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) TableDescriptor(org.apache.flink.table.api.TableDescriptor) Test(org.junit.Test)

Example 4 with TableDescriptor

use of org.apache.flink.table.api.TableDescriptor in project flink by apache.

the class RemoveUnreachableCoalesceArgumentsRuleTest method before.

@Before
public void before() {
    util = streamTestUtil(TableConfig.getDefault());
    final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(Schema.newBuilder().column("f0", STRING().nullable()).column("f1", STRING().notNull()).column("f2", STRING().nullable()).build()).unboundedScanSource().build();
    util.tableEnv().createTable("T", sourceDescriptor);
}
Also used : TableDescriptor(org.apache.flink.table.api.TableDescriptor) Before(org.junit.Before)

Example 5 with TableDescriptor

use of org.apache.flink.table.api.TableDescriptor in project flink by apache.

the class WrapJsonAggFunctionArgumentsRuleTest method testJsonObjectAggInGroupWindow.

@Test
public void testJsonObjectAggInGroupWindow() {
    final TableDescriptor sourceDescriptor = TableFactoryHarness.newBuilder().schema(Schema.newBuilder().column("f0", INT()).column("f1", STRING()).build()).unboundedScanSource().build();
    util.tableEnv().createTable("T", sourceDescriptor);
    util.verifyRelPlan("SELECT f0, JSON_OBJECTAGG(f1 VALUE f0) FROM T GROUP BY f0");
}
Also used : TableDescriptor(org.apache.flink.table.api.TableDescriptor) Test(org.junit.Test)

Aggregations

TableDescriptor (org.apache.flink.table.api.TableDescriptor)22 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)11 List (java.util.List)9 StreamTableEnvironment (org.apache.flink.table.api.bridge.java.StreamTableEnvironment)7 Row (org.apache.flink.types.Row)7 TableResult (org.apache.flink.table.api.TableResult)4 Instant (java.time.Instant)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 ExecutionException (java.util.concurrent.ExecutionException)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Collectors (java.util.stream.Collectors)2 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)2 SinkFunction (org.apache.flink.streaming.api.functions.sink.SinkFunction)2 SourceFunction (org.apache.flink.streaming.api.functions.source.SourceFunction)2 SinkV1Adapter (org.apache.flink.streaming.api.transformations.SinkV1Adapter)2 Watermark (org.apache.flink.streaming.api.watermark.Watermark)2 TestSink (org.apache.flink.streaming.runtime.operators.sink.TestSink)2