use of org.apache.flink.table.connector.source.DataStreamScanProvider in project flink by apache.
the class UpsertKafkaDynamicTableFactoryTest method assertKafkaSource.
private void assertKafkaSource(ScanTableSource.ScanRuntimeProvider provider) {
assertThat(provider, instanceOf(DataStreamScanProvider.class));
final DataStreamScanProvider dataStreamScanProvider = (DataStreamScanProvider) provider;
final Transformation<RowData> transformation = dataStreamScanProvider.produceDataStream(n -> Optional.empty(), StreamExecutionEnvironment.createLocalEnvironment()).getTransformation();
assertThat(transformation, instanceOf(SourceTransformation.class));
SourceTransformation<RowData, KafkaPartitionSplit, KafkaSourceEnumState> sourceTransformation = (SourceTransformation<RowData, KafkaPartitionSplit, KafkaSourceEnumState>) transformation;
assertThat(sourceTransformation.getSource(), instanceOf(KafkaSource.class));
}
use of org.apache.flink.table.connector.source.DataStreamScanProvider in project flink by apache.
the class KafkaDynamicTableFactoryTest method assertKafkaSource.
private KafkaSource<?> assertKafkaSource(ScanTableSource.ScanRuntimeProvider provider) {
assertThat(provider).isInstanceOf(DataStreamScanProvider.class);
final DataStreamScanProvider dataStreamScanProvider = (DataStreamScanProvider) provider;
final Transformation<RowData> transformation = dataStreamScanProvider.produceDataStream(n -> Optional.empty(), StreamExecutionEnvironment.createLocalEnvironment()).getTransformation();
assertThat(transformation).isInstanceOf(SourceTransformation.class);
SourceTransformation<RowData, KafkaPartitionSplit, KafkaSourceEnumState> sourceTransformation = (SourceTransformation<RowData, KafkaPartitionSplit, KafkaSourceEnumState>) transformation;
assertThat(sourceTransformation.getSource()).isInstanceOf(KafkaSource.class);
return (KafkaSource<?>) sourceTransformation.getSource();
}
use of org.apache.flink.table.connector.source.DataStreamScanProvider in project flink by apache.
the class CommonExecTableSourceScan method translateToPlanInternal.
@Override
protected Transformation<RowData> translateToPlanInternal(PlannerBase planner, ExecNodeConfig config) {
final StreamExecutionEnvironment env = planner.getExecEnv();
final TransformationMetadata meta = createTransformationMeta(SOURCE_TRANSFORMATION, config);
final InternalTypeInfo<RowData> outputTypeInfo = InternalTypeInfo.of((RowType) getOutputType());
final ScanTableSource tableSource = tableSourceSpec.getScanTableSource(planner.getFlinkContext());
ScanTableSource.ScanRuntimeProvider provider = tableSource.getScanRuntimeProvider(ScanRuntimeProviderContext.INSTANCE);
if (provider instanceof SourceFunctionProvider) {
final SourceFunctionProvider sourceFunctionProvider = (SourceFunctionProvider) provider;
final SourceFunction<RowData> function = sourceFunctionProvider.createSourceFunction();
final Transformation<RowData> transformation = createSourceFunctionTransformation(env, function, sourceFunctionProvider.isBounded(), meta.getName(), outputTypeInfo);
return meta.fill(transformation);
} else if (provider instanceof InputFormatProvider) {
final InputFormat<RowData, ?> inputFormat = ((InputFormatProvider) provider).createInputFormat();
final Transformation<RowData> transformation = createInputFormatTransformation(env, inputFormat, outputTypeInfo, meta.getName());
return meta.fill(transformation);
} else if (provider instanceof SourceProvider) {
final Source<RowData, ?, ?> source = ((SourceProvider) provider).createSource();
// TODO: Push down watermark strategy to source scan
final Transformation<RowData> transformation = env.fromSource(source, WatermarkStrategy.noWatermarks(), meta.getName(), outputTypeInfo).getTransformation();
return meta.fill(transformation);
} else if (provider instanceof DataStreamScanProvider) {
Transformation<RowData> transformation = ((DataStreamScanProvider) provider).produceDataStream(createProviderContext(), env).getTransformation();
meta.fill(transformation);
transformation.setOutputType(outputTypeInfo);
return transformation;
} else if (provider instanceof TransformationScanProvider) {
final Transformation<RowData> transformation = ((TransformationScanProvider) provider).createTransformation(createProviderContext());
meta.fill(transformation);
transformation.setOutputType(outputTypeInfo);
return transformation;
} else {
throw new UnsupportedOperationException(provider.getClass().getSimpleName() + " is unsupported now.");
}
}
Aggregations