zhangfengcdt opened a new pull request, #2357:
URL: https://github.com/apache/sedona/pull/2357

   ## Did you read the Contributor Guide?
   
   - Yes, I have read the [Contributor 
Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor 
Development Guide](https://sedona.apache.org/latest/community/develop/)
   
   ## Is this PR related to a ticket?
   
   - Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes 
#<issue_number>
   
   ## What changes were proposed in this PR?
   Implements a new `barrier` UDF function to prevent filter pushdown and 
control predicate evaluation order in complex spatial joins, particularly KNN 
joins where evaluation order affects query semantics.
   
     - Adds `Barrier` expression with boolean parser supporting comparison 
operators (=, !=, <>, <, <=, >, >=), logical operators (AND, OR, NOT), and 
parentheses
     - Registers barrier function in Sedona SQL catalog
     - Provides Scala and Python API wrappers
     - Includes comprehensive test coverage with KNN spatial join scenarios
     - Documents usage in NearestNeighbourSearching.md
   
     In KNN spatial joins, filter placement changes query semantics:
     - **Filter before KNN**: "What are the K nearest high-rated restaurants?"
     - **Filter after KNN**: "Of the K nearest restaurants, which are 
high-rated?"
   
     Query optimizers may push filters down, changing intended semantics. The 
barrier function prevents this by
     evaluating expressions at runtime.
   
     ## Usage Example
   
     ```sql
     SELECT h.name, r.name, r.rating
     FROM hotels h
     JOIN restaurants r ON ST_KNN(h.geometry, r.geometry, 3, false)
     WHERE barrier('rating > 4.0 AND stars >= 4',
                   'rating', r.rating,
                   'stars', h.stars)
   ```
   
   ## How was this patch tested?
     - All existing tests pass
     - 11 new barrier function tests covering basic functionality and KNN 
scenarios
     - Python API tests
     - Documentation updated
   
   ## Did this PR include necessary documentation updates?
   
   - Yes, I am adding a new API. I am using the [current SNAPSHOT version 
number](https://github.com/apache/sedona/blob/99239524f17389fc4ae9548ea88756f8ea538bb9/pom.xml#L29)
 in `vX.Y.Z` format.
   - Yes, I have updated the documentation.
   - No, this PR does not affect any public API so no need to change the 
documentation.
   


-- 
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]

Reply via email to