Search in sources :

Example 1 with TemporalTableSourceSpec

use of org.apache.flink.table.planner.plan.nodes.exec.spec.TemporalTableSourceSpec in project flink by apache.

the class TemporalTableSourceSpecSerdeTest method testTemporalTableSourceSpecSerde.

public static Stream<TemporalTableSourceSpec> testTemporalTableSourceSpecSerde() {
    Map<String, String> options1 = new HashMap<>();
    options1.put("connector", "filesystem");
    options1.put("format", "testcsv");
    options1.put("path", "/tmp");
    final ResolvedSchema resolvedSchema1 = new ResolvedSchema(Collections.singletonList(Column.physical("a", DataTypes.BIGINT())), Collections.emptyList(), null);
    final CatalogTable catalogTable1 = CatalogTable.of(Schema.newBuilder().fromResolvedSchema(resolvedSchema1).build(), null, Collections.emptyList(), options1);
    ResolvedCatalogTable resolvedCatalogTable = new ResolvedCatalogTable(catalogTable1, resolvedSchema1);
    RelDataType relDataType1 = FACTORY.createSqlType(SqlTypeName.BIGINT);
    LookupTableSource lookupTableSource = new TestValuesTableFactory.MockedLookupTableSource();
    TableSourceTable tableSourceTable1 = new TableSourceTable(null, relDataType1, FlinkStatistic.UNKNOWN(), lookupTableSource, true, ContextResolvedTable.temporary(ObjectIdentifier.of("default_catalog", "default_db", "MyTable"), resolvedCatalogTable), FLINK_CONTEXT, new SourceAbilitySpec[] { new LimitPushDownSpec(100) });
    TemporalTableSourceSpec temporalTableSourceSpec1 = new TemporalTableSourceSpec(tableSourceTable1);
    return Stream.of(temporalTableSourceSpec1);
}
Also used : LimitPushDownSpec(org.apache.flink.table.planner.plan.abilities.source.LimitPushDownSpec) ResolvedCatalogTable(org.apache.flink.table.catalog.ResolvedCatalogTable) HashMap(java.util.HashMap) TemporalTableSourceSpec(org.apache.flink.table.planner.plan.nodes.exec.spec.TemporalTableSourceSpec) LookupTableSource(org.apache.flink.table.connector.source.LookupTableSource) RelDataType(org.apache.calcite.rel.type.RelDataType) CatalogTable(org.apache.flink.table.catalog.CatalogTable) ResolvedCatalogTable(org.apache.flink.table.catalog.ResolvedCatalogTable) TableSourceTable(org.apache.flink.table.planner.plan.schema.TableSourceTable) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema)

Example 2 with TemporalTableSourceSpec

use of org.apache.flink.table.planner.plan.nodes.exec.spec.TemporalTableSourceSpec in project flink by apache.

the class TemporalTableSourceSpecSerdeTest method testTemporalTableSourceSpecSerde.

@ParameterizedTest
@MethodSource("testTemporalTableSourceSpecSerde")
public void testTemporalTableSourceSpecSerde(TemporalTableSourceSpec spec) throws IOException {
    CatalogManager catalogManager = CatalogManagerMocks.createEmptyCatalogManager();
    catalogManager.createTemporaryTable(spec.getTableSourceSpec().getContextResolvedTable().getResolvedTable(), spec.getTableSourceSpec().getContextResolvedTable().getIdentifier(), false);
    SerdeContext serdeCtx = JsonSerdeTestUtil.configuredSerdeContext(catalogManager, new TableConfig());
    String json = JsonSerdeTestUtil.toJson(serdeCtx, spec);
    TemporalTableSourceSpec actual = JsonSerdeTestUtil.toObject(serdeCtx, json, TemporalTableSourceSpec.class);
    assertThat(actual.getTableSourceSpec().getContextResolvedTable()).isEqualTo(spec.getTableSourceSpec().getContextResolvedTable());
    assertThat(actual.getTableSourceSpec().getSourceAbilities()).isEqualTo(spec.getTableSourceSpec().getSourceAbilities());
    assertThat(actual.getOutputType()).isEqualTo(spec.getOutputType());
}
Also used : TemporalTableSourceSpec(org.apache.flink.table.planner.plan.nodes.exec.spec.TemporalTableSourceSpec) TableConfig(org.apache.flink.table.api.TableConfig) CatalogManager(org.apache.flink.table.catalog.CatalogManager) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

TemporalTableSourceSpec (org.apache.flink.table.planner.plan.nodes.exec.spec.TemporalTableSourceSpec)2 HashMap (java.util.HashMap)1 RelDataType (org.apache.calcite.rel.type.RelDataType)1 TableConfig (org.apache.flink.table.api.TableConfig)1 CatalogManager (org.apache.flink.table.catalog.CatalogManager)1 CatalogTable (org.apache.flink.table.catalog.CatalogTable)1 ResolvedCatalogTable (org.apache.flink.table.catalog.ResolvedCatalogTable)1 ResolvedSchema (org.apache.flink.table.catalog.ResolvedSchema)1 LookupTableSource (org.apache.flink.table.connector.source.LookupTableSource)1 LimitPushDownSpec (org.apache.flink.table.planner.plan.abilities.source.LimitPushDownSpec)1 TableSourceTable (org.apache.flink.table.planner.plan.schema.TableSourceTable)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1