Skip to content

feat: Add Adaptive Kafka watermark generator#346

Open
ferenc-csaky wants to merge 1 commit into
mainfrom
feat/adaptive-watermark-gen
Open

feat: Add Adaptive Kafka watermark generator#346
ferenc-csaky wants to merge 1 commit into
mainfrom
feat/adaptive-watermark-gen

Conversation

@ferenc-csaky
Copy link
Copy Markdown
Collaborator

@ferenc-csaky ferenc-csaky commented Jun 1, 2026

Summary

  • Added Kafka SOURCE_WATERMARK() support to kafka-safe and upsert-kafka-safe.
  • Added adaptive watermarking from Kafka record timestamps.
  • Preserved precedence: user/pushed watermarks override source watermarks.
  • Added unit and end-to-end integration coverage.

Changes

  • Implemented KafkaRecordTimestampWatermarkStrategy.

    • Uses Kafka record timestamps.
    • Waits for a 250-record warmup before emitting.
    • Estimates out-of-orderness from rolling lateness samples.
    • Uses the 95th percentile delay.
    • Emits monotonic watermarks.
  • Updated SafeKafkaDynamicSource.

    • Implements SupportsSourceWatermark.
    • Uses Kafka source watermark only when SOURCE_WATERMARK() is requested.
    • Falls back to WatermarkStrategy.noWatermarks() otherwise.
  • Added KafkaSourceWatermarkIT.

    • Produces timestamped Kafka records via Flink SQL.
    • Validates event-time windows close and write to Postgres.
  • Updated Redpanda test setup.

    • Fixed advertised listener for Docker networking.

Validation

mvn -pl connectors/kafka-safe-connector -Dtest=KafkaRecordTimestampWatermarkStrategyTest test
mvn -pl flink-sql-runner -am -Dtest=NoSuchTest -Dit.test=KafkaSourceWatermarkIT verify

@ferenc-csaky ferenc-csaky force-pushed the feat/adaptive-watermark-gen branch from f5dd621 to 0c3a726 Compare June 1, 2026 14:50
Comment on lines +35 to +40
static final int MIN_RECORDS = 250;
static final int SAMPLE_SIZE = 4096;
static final long MIN_OUT_OF_ORDERNESS_MILLIS = 50L;
static final long MAX_OUT_OF_ORDERNESS_MILLIS = Duration.ofDays(1).toMillis();

private static final double OUT_OF_ORDERNESS_QUANTILE = 0.95D;
Copy link
Copy Markdown
Collaborator Author

@ferenc-csaky ferenc-csaky Jun 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly we can make these (or some) configurable, and have the current hardcoded values as defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant