Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/operators/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions docs/operators/unsupported.md
Original file line number Diff line number Diff line change
@@ -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 |
|---|---|---|
Expand All @@ -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. |
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Arguments> 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 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);
}
}