HeartSaVioR opened a new pull request, #60313: URL: https://github.com/apache/spark/pull/60313
### What changes were proposed in this pull request? This PR lets the external lookup join run in real-time mode. Until now, real-time mode rejected it, because `ExternalLookupJoinExec` was not in `RealTimeModeAllowlist`. This PR adds the operator to the allowlist. The operator itself does not change. This PR implements [SPARK-61403](https://issues.apache.org/jira/browse/SPARK-61403), part of [SPARK-60031](https://issues.apache.org/jira/browse/SPARK-60031) (SPIP: External Lookup Join; see the [SPIP](https://docs.google.com/document/d/1fBPM5cku8UJXacG2fw9df1zqALJ-WFm8E9-b9oiFP5M/edit?tab=t.0) and the [dev@ discussion](https://lists.apache.org/thread/7s6tgy9cm18jnzykr8htrtrw4nxyrhp1)). It builds on apache/spark#60198 (SPARK-60694, predicate pushdown). **Design and decisions.** The [design document](https://gist.github.com/HeartSaVioR/0143cdaad3079d1455be8004ee401ec4) explains the whole feature and the decisions behind it, including those agreed in the SPIP discussion. Read it first for the whole picture, before the details of this PR. **Scope.** This PR is one of seven stacked PRs for external lookup join. The connector API, #59908, is already merged. Please review only this PR's own commit, listed in its first comment. The commits of the PRs it builds on are reviewed there. | PR | What it delivers | |---|---| | #59909 | Planning rules. They are not registered yet, so no query changes. | | #59910 | Execution: stream-static equi-joins on lookup-only tables loaded with `spark.read`; Spark's check of returned rows and values; the reader lifecycle | | #60019 | The `EXTERNAL_LOOKUP` hint; lookup sides reached through aliases, temp views of DataFrames, SQL and catalog references | | #60055 | Lookup-side projections and filters; semi and anti joins; `<=>` and range comparisons; CHAR columns | | #60087 | The lookup cache | | #60198 | Predicate pushdown through lookup joins | | **This PR** | **Real-time mode** | Why the operator can run in real-time mode: - It is stateless and runs in its input's task. So it emits output during a batch, as its lookup requests complete, and needs no state store. - It keeps its input's determinism level. So a stateful operator after it can read it through a pipelined shuffle; the scheduler rejects a nondeterministic producer of a pipelined shuffle. - Real-time mode plans each batch with the same rules as a micro-batch. So the lookup join forms and is prepared in the same way, and the startup check still stops a query whose lookup join cannot be planned. **Known limitations.** The operator sends stream rows in lookup requests of up to as many rows as the connector accepts, at most 1000. Nothing sends a request early because time passes. In real-time mode, this means: - A stream row waits until its request is full or the batch ends. So its latency depends on the input rate of its partition and on the size of a request. - After a full request returns, its output waits for the next stream row of the partition. - A row whose key is cached waits in the same way, because the cache is checked when the request is formed. - The cache lives for one task, which in real-time mode is one batch. So each batch starts with an empty cache. - As in a micro-batch, the lookup table's schema and version are loaded once per batch, and `current_timestamp()` is fixed for the batch. A real-time batch runs for 5 minutes by default. A test pins the first limitation. Sending a request that is not full after a time bound is out of scope: when no new row arrives, only a timer or a second thread in the task could send it. ### Why are the changes needed? Real-time mode serves latency-sensitive queries, and enriching each event from a key-value store or a database is common in them. Without this PR, such a query fails in real-time mode. Its only stream-static join is a broadcast join, which reads the whole static side in each batch. ### Does this PR introduce _any_ user-facing change? Yes. A streaming query in real-time mode can use an external lookup join. Before, it failed with `STREAMING_REAL_TIME_MODE.OPERATOR_OR_SINK_NOT_IN_ALLOWLIST`. There is no new API or configuration. ### How was this patch tested? `ExternalLookupJoinRealTimeModeSuite` now runs the join in real-time mode, with a manual clock, instead of expecting the allowlist error: - Inner, left outer, left semi and left anti joins emit their output during the batch, once a request is full and the next stream row arrives. The last request, which is not full, is sent when the batch ends. - The cache serves keys within a batch, and the next batch starts with an empty cache. The connector metrics reach the driver when the batch ends. - A streaming aggregation after the join, and a shuffle of the stream before it, both run through pipelined shuffles. - Stopping the query during a lookup request closes the reader, with no error. - A test pins the known limitation: a request that is not full is sent only when the batch ends, and a full request's output waits for the next stream row. The startup-check test is unchanged. Without the allowlist entry, every new test fails with `STREAMING_REAL_TIME_MODE.OPERATOR_OR_SINK_NOT_IN_ALLOWLIST`. The suite passes with ANSI mode on and off, and `ExternalLookupJoinSuite` passes, on JDK 21 at the top of the PR stack. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 This pull request and its description were written by Isaac. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
