Class DynamicSourceUtils
java.lang.Object
org.apache.flink.table.planner.connectors.DynamicSourceUtils
Utilities for dealing with
DynamicTableSource.-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanchangelogNormalizeEnabled(boolean eventTimeSnapshotRequired, org.apache.flink.table.catalog.ResolvedSchema resolvedSchema, org.apache.flink.table.connector.source.DynamicTableSource tableSource, org.apache.flink.table.api.TableConfig tableConfig) Returns true if the changelogNormalize should be enabled.static org.apache.calcite.rel.RelNodeconvertDataStreamToRel(boolean isBatchMode, org.apache.flink.configuration.ReadableConfig config, FlinkRelBuilder relBuilder, org.apache.flink.table.catalog.ContextResolvedTable contextResolvedTable, org.apache.flink.streaming.api.datastream.DataStream<?> dataStream, org.apache.flink.table.types.DataType physicalDataType, boolean isTopLevelRecord, org.apache.flink.table.connector.ChangelogMode changelogMode) Converts a givenDataStreamto aRelNode.static org.apache.calcite.rel.RelNodeconvertSourceToRel(boolean isBatchMode, org.apache.flink.configuration.ReadableConfig config, FlinkRelBuilder relBuilder, org.apache.flink.table.catalog.ContextResolvedTable contextResolvedTable, FlinkStatistic statistic, List<org.apache.calcite.rel.hint.RelHint> hints, org.apache.flink.table.connector.source.DynamicTableSource tableSource) Converts a givenDynamicTableSourceto aRelNode.createMetadataKeysToMetadataColumnsMap(org.apache.flink.table.catalog.ResolvedSchema schema) Returns a map record the mapping relation between metadataKeys to metadataColumns in input schema.static org.apache.flink.table.types.logical.RowTypecreateProducedType(org.apache.flink.table.catalog.ResolvedSchema schema, org.apache.flink.table.connector.source.DynamicTableSource source) Returns theDataTypethat a source should produce as the input into the runtime.static List<org.apache.flink.table.catalog.Column.MetadataColumn>createRequiredMetadataColumns(org.apache.flink.table.catalog.ResolvedSchema schema, org.apache.flink.table.connector.source.DynamicTableSource source) Returns a list of required metadata columns.static List<org.apache.flink.table.catalog.Column.MetadataColumn>extractMetadataColumns(org.apache.flink.table.catalog.ResolvedSchema schema) extractMetadataMap(org.apache.flink.table.connector.source.DynamicTableSource source) static booleanisSourceChangeEventsDuplicate(org.apache.flink.table.catalog.ResolvedSchema resolvedSchema, org.apache.flink.table.connector.source.DynamicTableSource tableSource, org.apache.flink.table.api.TableConfig tableConfig) Returns true if the table source produces duplicate change events.static booleanisUpsertSource(org.apache.flink.table.catalog.ResolvedSchema resolvedSchema, org.apache.flink.table.connector.source.DynamicTableSource tableSource) Returns true if the table is an upsert source.static voidprepareDynamicSource(String tableDebugName, org.apache.flink.table.catalog.ResolvedCatalogTable table, org.apache.flink.table.connector.source.DynamicTableSource source, boolean isBatchMode, org.apache.flink.configuration.ReadableConfig config, List<SourceAbilitySpec> sourceAbilities) Prepares the givenDynamicTableSource.static voidvalidateAndApplyMetadata(String tableDebugName, org.apache.flink.table.catalog.ResolvedSchema schema, org.apache.flink.table.connector.source.DynamicTableSource source, List<SourceAbilitySpec> sourceAbilities)
-
Method Details
-
convertDataStreamToRel
public static org.apache.calcite.rel.RelNode convertDataStreamToRel(boolean isBatchMode, org.apache.flink.configuration.ReadableConfig config, FlinkRelBuilder relBuilder, org.apache.flink.table.catalog.ContextResolvedTable contextResolvedTable, org.apache.flink.streaming.api.datastream.DataStream<?> dataStream, org.apache.flink.table.types.DataType physicalDataType, boolean isTopLevelRecord, org.apache.flink.table.connector.ChangelogMode changelogMode) Converts a givenDataStreamto aRelNode. It adds helper projections if necessary. -
convertSourceToRel
public static org.apache.calcite.rel.RelNode convertSourceToRel(boolean isBatchMode, org.apache.flink.configuration.ReadableConfig config, FlinkRelBuilder relBuilder, org.apache.flink.table.catalog.ContextResolvedTable contextResolvedTable, FlinkStatistic statistic, List<org.apache.calcite.rel.hint.RelHint> hints, org.apache.flink.table.connector.source.DynamicTableSource tableSource) Converts a givenDynamicTableSourceto aRelNode. It adds helper projections if necessary. -
prepareDynamicSource
public static void prepareDynamicSource(String tableDebugName, org.apache.flink.table.catalog.ResolvedCatalogTable table, org.apache.flink.table.connector.source.DynamicTableSource source, boolean isBatchMode, org.apache.flink.configuration.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<org.apache.flink.table.catalog.Column.MetadataColumn> createRequiredMetadataColumns(org.apache.flink.table.catalog.ResolvedSchema schema, org.apache.flink.table.connector.source.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,org.apache.flink.table.catalog.Column.MetadataColumn> createMetadataKeysToMetadataColumnsMap(org.apache.flink.table.catalog.ResolvedSchema schema) Returns a map record the mapping relation between metadataKeys to metadataColumns in input schema. -
createProducedType
public static org.apache.flink.table.types.logical.RowType createProducedType(org.apache.flink.table.catalog.ResolvedSchema schema, org.apache.flink.table.connector.source.DynamicTableSource source) Returns theDataTypethat a source should produce as the input into the runtime.The format looks as follows:
PHYSICAL COLUMNS + METADATA COLUMNSPhysical columns use the table schema's name. Metadata column use the metadata key as name.
-
isUpsertSource
public static boolean isUpsertSource(org.apache.flink.table.catalog.ResolvedSchema resolvedSchema, org.apache.flink.table.connector.source.DynamicTableSource tableSource) Returns true if the table is an upsert source. -
isSourceChangeEventsDuplicate
public static boolean isSourceChangeEventsDuplicate(org.apache.flink.table.catalog.ResolvedSchema resolvedSchema, org.apache.flink.table.connector.source.DynamicTableSource tableSource, org.apache.flink.table.api.TableConfig tableConfig) Returns true if the table source produces duplicate change events. -
changelogNormalizeEnabled
public static boolean changelogNormalizeEnabled(boolean eventTimeSnapshotRequired, org.apache.flink.table.catalog.ResolvedSchema resolvedSchema, org.apache.flink.table.connector.source.DynamicTableSource tableSource, org.apache.flink.table.api.TableConfig tableConfig) Returns true if the changelogNormalize should be enabled. -
extractMetadataMap
-
extractMetadataColumns
public static List<org.apache.flink.table.catalog.Column.MetadataColumn> extractMetadataColumns(org.apache.flink.table.catalog.ResolvedSchema schema) -
validateAndApplyMetadata
public static void validateAndApplyMetadata(String tableDebugName, org.apache.flink.table.catalog.ResolvedSchema schema, org.apache.flink.table.connector.source.DynamicTableSource source, List<SourceAbilitySpec> sourceAbilities)
-