From d76a1bc725b543377d92ed1740a2006f357b2755 Mon Sep 17 00:00:00 2001 From: jaskaran27177 Date: Mon, 30 Nov 2026 22:49:06 -0700 Subject: [PATCH 1/2] Document that a VALUES relation does not force fallback The unsupported-operator page said any operator without a native matcher sends its whole query back to Flink. That holds for interior operators, but the island check only requires the operators between the host edges to be columnar: an input-less leaf is treated like a row-wise source. A constant VALUES relation is such a leaf, so it stays on Flink behind a row-to-Arrow transpose while the joins, unions, aggregates and Calcs above it run natively. Add SQL parity coverage for that boundary: VALUES joined with, unioned with and aggregated alongside a streaming input; a Calc directly over VALUES; widened DECIMAL, NULL, mixed-length string, BOOLEAN, DATE and TIMESTAMP literals; and VALUES filtered to zero rows. Each query must keep the Values node in its plan, route natively with no fallback reasons, and match stock Flink's changelog. No runtime behavior changes, so there is nothing to benchmark. Refs #239 Co-Authored-By: Claude Opus 5.5 --- docs/operators/index.md | 7 +- docs/operators/unsupported.md | 8 +- .../FlinkValuesLeafSqlHarnessTest.java | 91 +++++++++++++++++++ 3 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 streamfusion-runtime/src/test/java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java diff --git a/docs/operators/index.md b/docs/operators/index.md index 35366b18c..426368a75 100644 --- a/docs/operators/index.md +++ b/docs/operators/index.md @@ -18,9 +18,10 @@ admitted Doris Arrow writers. ## The all-or-nothing island A query accelerates only if it forms **one fully-columnar island**: every operator but a rowwise -source/sink runs natively, exchanging Arrow batches, with the row↔Arrow transpose paid once at -each host edge and never between native operators. **One unsupported interior operator drags the -whole query back to Flink** — there's no partial acceleration of a single query. Use +source (any input-less leaf, including a constant `VALUES` relation) or sink runs natively, +exchanging Arrow batches, with the row↔Arrow transpose paid once at each host edge and never +between native operators. **One unsupported interior operator drags the whole query back to +Flink** — there's no partial acceleration of a single query. Use `NativePlanner.explain(...)` to see the recorded reasons for a given plan. Completed planning passes also log concrete fallback reasons at INFO by default, including the Flink 2.2 stock compiled-plan lowering path. Identical reasons within a pass are combined with their occurrence diff --git a/docs/operators/unsupported.md b/docs/operators/unsupported.md index 684cbd3a2..5fd483a75 100644 --- a/docs/operators/unsupported.md +++ b/docs/operators/unsupported.md @@ -1,7 +1,9 @@ # Unsupported operators -**Status: Not supported.** These have no native matcher at all — a query containing one falls back -to Flink entirely, per the [all-or-nothing island rule](index.md#the-all-or-nothing-island). +**Status: Not supported.** These have no native matcher at all. An interior one sends the whole +query back to Flink, per the [all-or-nothing island rule](index.md#the-all-or-nothing-island); an +input-less leaf such as `Values` stays on Flink like a row-wise source, and the operators above it +can still run natively. | Operator | SQL surface | Why | |---|---|---| @@ -10,7 +12,7 @@ to Flink entirely, per the [all-or-nothing island rule](index.md#the-all-or-noth | `GroupWindowTableAggregate` | A `TableAggregateFunction` inside a legacy group window | No native path. Ordinary legacy `TUMBLE`/`HOP` aggregates and event-time `SESSION` are native — see [Window aggregate](window-aggregate.md). | | `IncrementalGroupAggregate` | The five-node chain a distinct aggregate plans to only when `table.optimizer.distinct-agg.split.enabled` is on (partial local → incremental → final global over a bucket key) | Deliberate non-goal: the knob mitigates state-backend hot-key skew that an in-process distinct set doesn't exhibit. The default mini-batch plan for distinct aggregates — `LocalGroupAggregate` + `GlobalGroupAggregate` with a distinct `MapView` partial — **is** native; see [GROUP BY](group-by.md). | | `GroupTableAggregate` | `TableAggregateFunction` | No native path. | -| `Values` | Constant relations | No native path. (A non-temporal `Sort` is parity, not a gap — Flink itself rejects it in streaming.) | +| `Values` | Constant relations | No native operator, but it does not force a fallback: as an input-less leaf it stays on Flink like a row-wise source, a transpose converts its rows to Arrow, and the joins, unions, aggregates and Calcs above it run natively. (A non-temporal `Sort` is parity, not a gap — Flink itself rejects it in streaming.) | | `DeltaJoin` | A join Flink rewrites into a delta join under `table.optimizer.delta-join.strategy` | No native path. A block containing a delta join is not rejected by the `FORCE` guard, but ordinary admission and island checks still apply; `DeltaJoin` remains unsupported. Under `FORCE`, a block containing an ordinary join and *no* delta join is left unchanged so Flink can perform its statement-wide validation — see [Global switches](index.md#global-switches). | | `LegacyTableSourceScan`, `LegacySink` | Legacy (pre-`DynamicTableSource`/`Sink`) connectors | The connectors stay on Flink. Verified direct integer collection groups may feed a legacy row sink through a transpose; see [Legacy row consumers](group-by.md#legacy-row-consumers). Other unverified legacy boundaries retain fallback. | | `Python*` (`PythonCalc`, `PythonCorrelate`, `PythonGroupAggregate`, `PythonOverAggregate`, …) | PyFlink UDFs | No native path — a Python UDF can't run inside a native island. | diff --git a/streamfusion-runtime/src/test/java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java b/streamfusion-runtime/src/test/java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java new file mode 100644 index 000000000..d1e6c805c --- /dev/null +++ b/streamfusion-runtime/src/test/java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java @@ -0,0 +1,91 @@ +package tech.streamfusion; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; +import org.apache.flink.api.common.RuntimeExecutionMode; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +/** + * A constant {@code VALUES} relation has no native operator, but as an input-less leaf it stays on + * Flink like a row-wise source: the operators above it still form a native island. + */ +class FlinkValuesLeafSqlHarnessTest { + private static final String COUNTRIES = + "(VALUES (1, 'Canada'), (2, 'India'), (3, 'Japan')) AS c(code, name)"; + + static Stream queries() { + return Stream.of( + Arguments.of( + "join", + "SELECT s.id, s.v, c.name FROM test_input s JOIN " + COUNTRIES + " ON s.id = c.code"), + Arguments.of( + "union all", + "SELECT id, k FROM test_input" + + " UNION ALL SELECT id, k FROM (VALUES (100, 'Z'), (101, 'Y')) AS t(id, k)"), + Arguments.of( + "group by over union all", + "SELECT k, COUNT(*) AS n, SUM(v) AS total FROM (SELECT k, v FROM test_input" + + " UNION ALL SELECT k, v FROM" + + " (VALUES ('A', CAST(100 AS BIGINT)), ('Z', CAST(5 AS BIGINT))) AS t(k, v))" + + " GROUP BY k"), + Arguments.of( + "group by over join", + "SELECT c.name, COUNT(*) AS n FROM test_input s JOIN " + COUNTRIES + + " ON s.id = c.code GROUP BY c.name"), + Arguments.of( + "calc directly over values", + "SELECT k, COUNT(*) AS n FROM (SELECT k FROM test_input UNION ALL SELECT UPPER(k) FROM" + + " (VALUES (100, 'a'), (101, 'b'), (102, 'z')) AS t(id, k) WHERE id > 100)" + + " GROUP BY k"), + Arguments.of( + "values only", + "SELECT code, UPPER(name) FROM " + COUNTRIES + " WHERE code > 1"), + Arguments.of( + "widened decimal literals", + "SELECT s.id, t.amount FROM test_input s JOIN" + + " (VALUES (1, 2.5), (2, 10), (3, 0.125)) AS t(id, amount) ON s.id = t.id"), + Arguments.of( + "null literal", + "SELECT s.id, t.label FROM test_input s JOIN" + + " (VALUES (1, CAST(NULL AS STRING)), (2, 'x')) AS t(id, label) ON s.id = t.id"), + Arguments.of( + "string literals of different lengths", + "SELECT s.id, c.name, CHAR_LENGTH(c.name) AS len, c.name = 'India' AS is_india" + + " FROM test_input s JOIN (VALUES (1, 'India'), (2, 'Canada')) AS c(code, name)" + + " ON s.id = c.code"), + Arguments.of( + "boolean and temporal literals", + "SELECT s.id, t.flag, t.d, t.ts FROM test_input s JOIN (VALUES" + + " (1, TRUE, DATE '2020-01-02', TIMESTAMP '2020-01-02 03:04:05.123')," + + " (2, FALSE, DATE '1999-12-31', TIMESTAMP '1999-12-31 23:59:59.999'))" + + " AS t(id, flag, d, ts) ON s.id = t.id"), + Arguments.of( + "union all with empty values", + "SELECT id, k FROM test_input UNION ALL SELECT id, k FROM" + + " (VALUES (1, 'x')) AS t(id, k) WHERE id < 0"), + Arguments.of( + "join with empty values", + "SELECT s.id, t.k FROM test_input s JOIN" + + " (SELECT id, k FROM (VALUES (1, 'x')) AS t(id, k) WHERE id < 0) t" + + " ON s.id = t.id")); + } + + @ParameterizedTest(name = "{0}") + @MethodSource("queries") + void operatorsAboveValuesRunNatively(String name, String sql) { + var runs = + NativeFailureParity.run( + () -> PortableSqlFixtures.environment(RuntimeExecutionMode.STREAMING, Map.of()), sql); + + runs.assertSuccess(NativeFailureParity.Route.NATIVE); + assertTrue( + runs.nativeRun().operatorTypes().contains("StreamPhysicalValues"), runs::toString); + assertEquals(List.of(), runs.nativeRun().fallbackReasons(), runs::toString); + } +} From 4ce10d66b07d84ef993bc532a124cc380c336612 Mon Sep 17 00:00:00 2001 From: jaskaran27177 Date: Mon, 30 Nov 2026 23:43:58 -0700 Subject: [PATCH 2/2] Keep the Calc-over-VALUES parity case independent of string casing The case that places a Calc directly over a VALUES relation also applied UPPER inside a UNION ALL branch. Current main keeps that casing shape on Flink even when both branches read the streaming input, so the case fell back for a reason unrelated to VALUES. A filter-only Calc still checks that the operator above the leaf runs natively; casing over VALUES remains covered by the VALUES-only case. Co-Authored-By: Claude Opus 5.5 --- .../java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/streamfusion-runtime/src/test/java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java b/streamfusion-runtime/src/test/java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java index d1e6c805c..1307d8e7d 100644 --- a/streamfusion-runtime/src/test/java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java +++ b/streamfusion-runtime/src/test/java/tech/streamfusion/FlinkValuesLeafSqlHarnessTest.java @@ -40,8 +40,8 @@ static Stream queries() { + " ON s.id = c.code GROUP BY c.name"), Arguments.of( "calc directly over values", - "SELECT k, COUNT(*) AS n FROM (SELECT k FROM test_input UNION ALL SELECT UPPER(k) FROM" - + " (VALUES (100, 'a'), (101, 'b'), (102, 'z')) AS t(id, k) WHERE id > 100)" + "SELECT k, COUNT(*) AS n FROM (SELECT k FROM test_input UNION ALL SELECT k FROM" + + " (VALUES (100, 'A'), (101, 'B'), (102, 'Z')) AS t(id, k) WHERE id > 100)" + " GROUP BY k"), Arguments.of( "values only",