rdtr commented on PR #60311: URL: https://github.com/apache/spark/pull/60311#issuecomment-6842461502
Great to see this heading to an SPIP. @dtenedor @AlejandroMorgante, could I join the shared draft as a contributor? I work on Amazon EMR's Spark runtime, and large-scale batch inference over Spark is one of use cases I'm most interested in. +1 to a dedicated Catalyst expression with its own operator. One scope suggestion: share the engine-side execution layer with SPARK-60031 (External Lookup Join, SPIP vote passed) instead of building a separate one. Its DSv2 design already has the shape a partition-level `ai_query` backend needs: `ExternalLookupReader.lookupBatch(uniqueParameters)` (distinct-input batching), `maxParameterRowsPerRequest`, a task-local cache keyed on the input, a task-local client lifecycle, and results mapped back by input ordinal. To be clear, this isn't the user-facing async UDF rejected in that SPIP's Appendix C. It means one engine-internal layer for "call out per batch of distinct inputs", with `ai_query` (scalar) and lookup join (join strategy) as two front ends. Other engines expose the same generic primitive too (BigQuery remote functions, Snowflake external functions, Redshift Lambda UDFs). `ai_query` would need two extensions to that layer, and lookup join would benefit from both: 1. **Bounded concurrent in-flight requests.** The lookup reader is sequential (one cursor at a time), which is fine for a KV store but not for model calls that take seconds. 2. **Semantics beyond `isDeterministic`.** An "expensive external call" property: filters that don't reference the result, and limits, can go below the call. The call is never duplicated, speculation is disabled, and a result-cache hook that survives task retry avoids re-billing. (The lookup SPIP avoids the non-determinism question by scoping to stream-static. `ai_query` can't, since it's used in batch.) I'm happy to draft or review those two sections. -- 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]
