Search in sources :

Example 1 with SupportsWatermarkPushDown

use of org.apache.flink.table.connector.source.abilities.SupportsWatermarkPushDown in project flink by apache.

the class WatermarkPushDownSpec method apply.

@Override
public void apply(DynamicTableSource tableSource, SourceAbilityContext context) {
    if (tableSource instanceof SupportsWatermarkPushDown) {
        GeneratedWatermarkGenerator generatedWatermarkGenerator = WatermarkGeneratorCodeGenerator.generateWatermarkGenerator(context.getTableConfig(), context.getSourceRowType(), watermarkExpr, Option.apply("context"));
        Configuration configuration = context.getTableConfig().getConfiguration();
        WatermarkGeneratorSupplier<RowData> supplier = new GeneratedWatermarkGeneratorSupplier(configuration, generatedWatermarkGenerator);
        WatermarkStrategy<RowData> watermarkStrategy = WatermarkStrategy.forGenerator(supplier);
        if (idleTimeoutMillis > 0) {
            watermarkStrategy = watermarkStrategy.withIdleness(Duration.ofMillis(idleTimeoutMillis));
        }
        ((SupportsWatermarkPushDown) tableSource).applyWatermark(watermarkStrategy);
    } else {
        throw new TableException(String.format("%s does not support SupportsWatermarkPushDown.", tableSource.getClass().getName()));
    }
}
Also used : GeneratedWatermarkGenerator(org.apache.flink.table.runtime.generated.GeneratedWatermarkGenerator) RowData(org.apache.flink.table.data.RowData) TableException(org.apache.flink.table.api.TableException) Configuration(org.apache.flink.configuration.Configuration) GeneratedWatermarkGeneratorSupplier(org.apache.flink.table.runtime.generated.GeneratedWatermarkGeneratorSupplier) SupportsWatermarkPushDown(org.apache.flink.table.connector.source.abilities.SupportsWatermarkPushDown)

Example 2 with SupportsWatermarkPushDown

use of org.apache.flink.table.connector.source.abilities.SupportsWatermarkPushDown in project flink by apache.

the class PushWatermarkIntoTableSourceScanRuleBase method supportsWatermarkPushDown.

protected boolean supportsWatermarkPushDown(FlinkLogicalTableSourceScan scan) {
    TableSourceTable tableSourceTable = scan.getTable().unwrap(TableSourceTable.class);
    if (tableSourceTable == null) {
        return false;
    }
    final DynamicTableSource tableSource = tableSourceTable.tableSource();
    return (tableSource instanceof SupportsWatermarkPushDown) || (tableSource instanceof SupportsSourceWatermark && hasSourceWatermarkDeclaration(tableSourceTable));
}
Also used : SupportsSourceWatermark(org.apache.flink.table.connector.source.abilities.SupportsSourceWatermark) TableSourceTable(org.apache.flink.table.planner.plan.schema.TableSourceTable) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) SupportsWatermarkPushDown(org.apache.flink.table.connector.source.abilities.SupportsWatermarkPushDown)

Aggregations

SupportsWatermarkPushDown (org.apache.flink.table.connector.source.abilities.SupportsWatermarkPushDown)2 Configuration (org.apache.flink.configuration.Configuration)1 TableException (org.apache.flink.table.api.TableException)1 DynamicTableSource (org.apache.flink.table.connector.source.DynamicTableSource)1 SupportsSourceWatermark (org.apache.flink.table.connector.source.abilities.SupportsSourceWatermark)1 RowData (org.apache.flink.table.data.RowData)1 TableSourceTable (org.apache.flink.table.planner.plan.schema.TableSourceTable)1 GeneratedWatermarkGenerator (org.apache.flink.table.runtime.generated.GeneratedWatermarkGenerator)1 GeneratedWatermarkGeneratorSupplier (org.apache.flink.table.runtime.generated.GeneratedWatermarkGeneratorSupplier)1