Class DynamicSourceUtils
- java.lang.Object
-
- org.apache.flink.table.planner.connectors.DynamicSourceUtils
-
@Internal public final class DynamicSourceUtils extends Object
Utilities for dealing withDynamicTableSource
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
changelogNormalizeEnabled(boolean eventTimeSnapshotRequired, ResolvedSchema resolvedSchema, DynamicTableSource tableSource, TableConfig tableConfig)
Returns true if the changelogNormalize should be enabled.static org.apache.calcite.rel.RelNode
convertDataStreamToRel(boolean isBatchMode, ReadableConfig config, FlinkRelBuilder relBuilder, ContextResolvedTable contextResolvedTable, DataStream<?> dataStream, DataType physicalDataType, boolean isTopLevelRecord, ChangelogMode changelogMode)
Converts a givenDataStream
to aRelNode
.static org.apache.calcite.rel.RelNode
convertSourceToRel(boolean isBatchMode, ReadableConfig config, FlinkRelBuilder relBuilder, ContextResolvedTable contextResolvedTable, org.apache.flink.table.planner.plan.stats.FlinkStatistic statistic, List<org.apache.calcite.rel.hint.RelHint> hints, DynamicTableSource tableSource)
Converts a givenDynamicTableSource
to aRelNode
.static Map<String,Column.MetadataColumn>
createMetadataKeysToMetadataColumnsMap(ResolvedSchema schema)
Returns a map record the mapping relation between metadataKeys to metadataColumns in input schema.static RowType
createProducedType(ResolvedSchema schema, DynamicTableSource source)
Returns theDataType
that a source should produce as the input into the runtime.static List<Column.MetadataColumn>
createRequiredMetadataColumns(ResolvedSchema schema, DynamicTableSource source)
Returns a list of required metadata columns.static List<Column.MetadataColumn>
extractMetadataColumns(ResolvedSchema schema)
static boolean
isSourceChangeEventsDuplicate(ResolvedSchema resolvedSchema, DynamicTableSource tableSource, TableConfig tableConfig)
Returns true if the table source produces duplicate change events.static boolean
isUpsertSource(ResolvedSchema resolvedSchema, DynamicTableSource tableSource)
Returns true if the table is an upsert source.static void
prepareDynamicSource(String tableDebugName, ResolvedCatalogTable table, DynamicTableSource source, boolean isBatchMode, ReadableConfig config, List<SourceAbilitySpec> sourceAbilities)
Prepares the givenDynamicTableSource
.static void
validateAndApplyMetadata(String tableDebugName, ResolvedSchema schema, DynamicTableSource source, List<SourceAbilitySpec> sourceAbilities)
-
-
-
Method Detail
-
convertDataStreamToRel
public static org.apache.calcite.rel.RelNode convertDataStreamToRel(boolean isBatchMode, ReadableConfig config, FlinkRelBuilder relBuilder, ContextResolvedTable contextResolvedTable, DataStream<?> dataStream, DataType physicalDataType, boolean isTopLevelRecord, ChangelogMode changelogMode)
Converts a givenDataStream
to aRelNode
. It adds helper projections if necessary.
-
convertSourceToRel
public static org.apache.calcite.rel.RelNode convertSourceToRel(boolean isBatchMode, ReadableConfig config, FlinkRelBuilder relBuilder, ContextResolvedTable contextResolvedTable, org.apache.flink.table.planner.plan.stats.FlinkStatistic statistic, List<org.apache.calcite.rel.hint.RelHint> hints, DynamicTableSource tableSource)
Converts a givenDynamicTableSource
to aRelNode
. It adds helper projections if necessary.
-
prepareDynamicSource
public static void prepareDynamicSource(String tableDebugName, ResolvedCatalogTable table, DynamicTableSource source, boolean isBatchMode, ReadableConfig config, List<SourceAbilitySpec> sourceAbilities)
Prepares the givenDynamicTableSource
. It check whether the source is compatible with the given schema and applies initial parameters.
-
createRequiredMetadataColumns
public static List<Column.MetadataColumn> createRequiredMetadataColumns(ResolvedSchema schema, DynamicTableSource source)
Returns a list of required metadata columns. Ordered by the iteration order ofSupportsReadingMetadata.listReadableMetadata()
.This method assumes that source and schema have been validated via
prepareDynamicSource(String, ResolvedCatalogTable, DynamicTableSource, boolean, ReadableConfig, List)
.
-
createMetadataKeysToMetadataColumnsMap
public static Map<String,Column.MetadataColumn> createMetadataKeysToMetadataColumnsMap(ResolvedSchema schema)
Returns a map record the mapping relation between metadataKeys to metadataColumns in input schema.
-
createProducedType
public static RowType createProducedType(ResolvedSchema schema, DynamicTableSource source)
Returns theDataType
that a source should produce as the input into the runtime.The format looks as follows:
PHYSICAL COLUMNS + METADATA COLUMNS
Physical columns use the table schema's name. Metadata column use the metadata key as name.
-
isUpsertSource
public static boolean isUpsertSource(ResolvedSchema resolvedSchema, DynamicTableSource tableSource)
Returns true if the table is an upsert source.
-
isSourceChangeEventsDuplicate
public static boolean isSourceChangeEventsDuplicate(ResolvedSchema resolvedSchema, DynamicTableSource tableSource, TableConfig tableConfig)
Returns true if the table source produces duplicate change events.
-
changelogNormalizeEnabled
public static boolean changelogNormalizeEnabled(boolean eventTimeSnapshotRequired, ResolvedSchema resolvedSchema, DynamicTableSource tableSource, TableConfig tableConfig)
Returns true if the changelogNormalize should be enabled.
-
extractMetadataColumns
public static List<Column.MetadataColumn> extractMetadataColumns(ResolvedSchema schema)
-
validateAndApplyMetadata
public static void validateAndApplyMetadata(String tableDebugName, ResolvedSchema schema, DynamicTableSource source, List<SourceAbilitySpec> sourceAbilities)
-
-