Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type casts and NULL about IsInListPredicate #971

Closed
kunlinyu opened this issue Dec 27, 2024 · 2 comments
Closed

type casts and NULL about IsInListPredicate #971

kunlinyu opened this issue Dec 27, 2024 · 2 comments
Labels

Comments

@kunlinyu
Copy link

I am develping a c++ parser and evaluator for CQL2. https://github.com/IndoorSpatial/cql2cpp
When I handling the IsInListPredicate, I go through the document and have two questions:

According to Requirement 7.B
https://github.com/opengeospatial/ogcapi-features/blob/master/cql2/standard/requirements/advanced-comparison-operators/REQ_in-predicate.adoc

My understanding is, all queries below are invalid

speed IN ('black', 'happy', TRUE)
3 IN ('color', FALSE)
3+2 IN ('x', 'y')

But according to Permission 2.A
https://github.com/opengeospatial/ogcapi-features/blob/master/cql2/standard/recommendations/basic-cql2/PER_type-casts.adoc
"the server MAY either return an error or it MAY cast the operands to compatible data types"

I Want to confirm that:
Question 1: Can I (and should I) do some type cast in my libray to handle this and return TRUE?

3.2 IN (3.2)    // TRUE
3.2 IN ('3.2')    // TRUE
3.2 IN ('+3.2')    // TRUE

Question 2: What should I do if the value of left part is NULL?
for example

name IN ('Alice', 'Bob')  // the "name" is not a queryable in the data source.
unknow_func('A', TRUE) IN ('Alice', 'Bob', unknow_func('B', FALSE))  // Null IN ('Alice', 'Bob', Null)
@cportele
Copy link
Member

Yes, the three IN expressions are all invalid as their semantics is undefined, but the permission allows that implementations can cast values so that all values are compatible with each other.

Whether your implementation rejects the last two expressions in Question 1 or not and the strings are cast to a number or the number is cast to a string is your decision.

With respect to NULL (Question 2) the usual rules apply. If the left-hand side is NULL, the IN predicate evaluates to NULL.

By the way, if "name" is not a queryable the result could also be an error as "name" is not a valid property reference.

@kunlinyu
Copy link
Author

@cportele Thank you! I will consider about it.

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

No branches or pull requests

2 participants