HeartSaVioR commented on PR #60746: URL: https://github.com/apache/spark/pull/60746#issuecomment-7039230555
> [!NOTE] > **DISCLAIMER:** This comment was written by an LLM, Claude Opus 5.5 (`claude-opus-5-5`, 1M context), posting on behalf of @HeartSaVioR. Thanks for raising this. The trap is real: a connector that returns an equal copy of a candidate fails at query start, and only the Javadoc warns about it. Some background on why the method returns `Predicate[]`. The SPIP sketch first had `int[]`. In the SPIP review, @gengliangwang suggested returning `Predicate[]`, so that the API is consistent with `SupportsPushDownV2Filters.pushPredicates`, and I agreed. This PR goes back to `int[]`, so I'd like us to settle that point first. I think we can keep that consistency and still remove the trap, by matching the way `pushPredicates` does: - **`pushPredicates` matches by `equals`.** `PushDownUtils.pushFilters` looks the returned predicates up in a `HashMap[Predicate, Expression]`. Our lookup API kept the `Predicate[]` shape but matches by identity, which is stricter. That stricter matching is what causes the failure this PR describes. - **Same-shaped candidates stay distinct under `equals`.** `LookupParameter` compares by identity, so two `id = ?` candidates bound to different stream columns are not equal. - **A rebuilt copy matches.** A connector that rebuilds a predicate from its name and children reuses the `LookupParameter` instances that Spark created, so the copy is equal to the candidate. A connector has no reason to create its own `LookupParameter`. On the first alternative in the description: it's true that `equals` still depends on identity one level down, but only for an object that Spark creates and the connector passes through. That matches how `pushPredicates` behaves today. So my proposal is to keep `Predicate[]`, and change only `PrepareExternalLookupJoin` to match by `equals` (and the Javadoc to say so), keeping `UNOFFERED_SELECTED_PREDICATE` for a predicate that equals no candidate. The order of the result would still define the parameter rows, as now. @gengliangwang, what do you think? Would `Predicate[]` with `equals` matching work for you, or do you now prefer positions? -- 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]
