use of org.apache.flink.table.catalog.WatermarkSpec in project flink by apache.
the class ResolvedSchemaJsonDeserializer method deserialize.
@Override
public ResolvedSchema deserialize(JsonParser jsonParser, DeserializationContext ctx) throws IOException {
ObjectNode jsonNode = jsonParser.readValueAsTree();
List<Column> columns = ctx.readValue(traverse(jsonNode.required(COLUMNS), jsonParser.getCodec()), ctx.getTypeFactory().constructCollectionType(List.class, Column.class));
List<WatermarkSpec> watermarkSpecs = ctx.readValue(traverse(jsonNode.required(WATERMARK_SPECS), jsonParser.getCodec()), ctx.getTypeFactory().constructCollectionType(List.class, WatermarkSpec.class));
UniqueConstraint primaryKey = deserializeOptionalField(jsonNode, PRIMARY_KEY, UniqueConstraint.class, jsonParser.getCodec(), ctx).orElse(null);
return new ResolvedSchema(columns, watermarkSpecs, primaryKey);
}
use of org.apache.flink.table.catalog.WatermarkSpec in project flink by apache.
the class PushWatermarkIntoTableSourceScanRuleBase method hasSourceWatermarkDeclaration.
private boolean hasSourceWatermarkDeclaration(TableSourceTable table) {
final ResolvedSchema schema = table.contextResolvedTable().getResolvedSchema();
final List<WatermarkSpec> specs = schema.getWatermarkSpecs();
// we only support one watermark spec for now
if (specs.size() != 1) {
return false;
}
final ResolvedExpression watermarkExpr = specs.get(0).getWatermarkExpression();
final FunctionDefinition function = unwrapFunctionDefinition(watermarkExpr);
return function == BuiltInFunctionDefinitions.SOURCE_WATERMARK;
}
use of org.apache.flink.table.catalog.WatermarkSpec in project flink by apache.
the class DynamicSourceUtils method pushWatermarkAssigner.
// --------------------------------------------------------------------------------------------
/**
* Creates a specialized node for assigning watermarks.
*/
private static void pushWatermarkAssigner(FlinkRelBuilder relBuilder, ResolvedSchema schema) {
final ExpressionConverter converter = new ExpressionConverter(relBuilder);
final RelDataType inputRelDataType = relBuilder.peek().getRowType();
// schema resolver has checked before that only one spec exists
final WatermarkSpec watermarkSpec = schema.getWatermarkSpecs().get(0);
final String rowtimeColumn = watermarkSpec.getRowtimeAttribute();
final int rowtimeColumnIdx = inputRelDataType.getFieldNames().indexOf(rowtimeColumn);
final RexNode watermarkRexNode = watermarkSpec.getWatermarkExpression().accept(converter);
relBuilder.watermark(rowtimeColumnIdx, watermarkRexNode);
}
Aggregations