Skip to content

Fix KNN input binding for computed geometry operands - #3529

Draft
jiayuasu wants to merge 1 commit into
apache:masterfrom
jiayuasu:codex/oss-knn-shape-binding
Draft

jiayuasu wants to merge 1 commit into
apache:masterfrom
jiayuasu:codex/oss-knn-shape-binding

Conversation

@jiayuasu

@jiayuasu jiayuasu commented Nov 7, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this PR?

Computed geometry operands in ST_KNN, such as ST_Buffer(q.geom, ...), can fail with an attribute-binding error. The physical join currently chooses the query input by searching its printed plan for the expression text. A computed expression need not appear in that input plan, so the join can select the wrong side.

Match both operands using their referenced attribute identities, consistent with the logical planner. This covers partitioned KNN and both broadcast orientations, preserves original left/right output rows, and retains the existing rejection of reference-free operands. The KNN algorithms, partitioning, and serializers are unchanged.

How was this patch tested?

  • On unchanged Apache base 20efe7d4c4f, the new Spark 4.1 regression suite ran 16 cases: four computed-geometry cases reproduced INTERNAL_ERROR_ATTRIBUTE_NOT_FOUND; the other 12 controls passed.
  • After the fix, all 16 regression cases and all 80 existing KnnJoinSuite cases passed on Spark 4.1.1 / Scala 2.13 and on a clean Spark 3.5.8 / Scala 2.12 build (192 passing checks total).
  • Maven verify included Spotless and Scalastyle; repository pre-commit and commit hooks passed.

Did this PR include necessary documentation updates?

No public API changes; no documentation changes are needed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant