Skip to main content
Version: 0.7.x

Migrating from Flink SQL

Flink SQL is a streaming SQL dialect with continuous queries over unbounded tables. ArkFlow's SQL is DataFusion: the processor runs one query per Arrow batch. That single difference explains most of the migration work.

The core difference: per-batch vs continuous​

Flink SQLArkFlow sql processor
Query modeContinuous: stateful operators over unbounded inputPer batch: stateless query over one MessageBatch
AggregationsMaintained incrementally, emit updatesComputed within the batch; use windows/jobs for continuous aggregates
JoinsStream-stream joins with state retentionBatch-internal joins, or the Job DAG keyed interval join
WatermarksDeclared on tables, drive windowsDeclared on Job sources (see event time)
GROUP BY without windowContinuous stateful aggregationAggregates the batch only

A Flink query like SELECT user, COUNT(*) FROM orders GROUP BY user is a continuous aggregation. In ArkFlow the equivalent is a Job with event-time windows (or a session window buffer) whose window output can then be SQL-shaped — see the windowed aggregation recipe.

What translates directly​

  • SELECT/WHERE/ORDER BY/LIMIT projections and filters.
  • Expressions, CAST, string/date functions (DataFusion function set; check the function reference for names).
  • JOINs between the batch and a temporary dimension table (see temporal join cookbook).
  • Window functions over the batch (row_number, lag, lead — see the cookbook patterns).

What needs a redesign​

Flink SQL featureArkFlow equivalent
Continuous GROUP BY aggregationJob event-time window + aggregation
Stream-stream interval joinJob DAG keyed interval join
MATCH_RECOGNIZE / CEPNot supported; express with chained processors or a custom plugin
Flink UDFs (Java/Scala)Python or VRL processor
Exactly-once checkpoints (2PC sinks)Transactional Kafka output / idempotent sinks (see exactly-once)

Watermarks and allowed lateness​

Flink declares watermarks per table (WATERMARK FOR ts AS ts - INTERVAL '5' SECOND). ArkFlow declares them per Job source:

sources:
- operator_id: orders
input_type: kafka
config:
type: kafka
brokers: ["localhost:9092"]
topics: ["orders"]
consumer_group: orders-fleet
start_from_latest: false
codec:
type: json
time:
mode: event_time
timestamp_field: ts
watermark:
strategy: bounded_out_of_orderness
out_of_orderness_ms: 5000
idle_timeout_ms: 60000

Late policies (drop / route / update) and allowed lateness are declared next to the watermark — see event time and watermarks.

Verification​

  1. Run the Flink job and the ArkFlow job over the same replay window; compare window outputs (counts and sums per window boundary).
  2. Test a late event: confirm the declared policy fires as expected.
  3. Load-test the batch path; per-batch SQL is stateless, so throughput scales with thread_num where Flink scales with parallelism.