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

[BUG] Cast_to_boolean behaviour is different in OpenSearch SQL and Spark SQL #3443

Open
LantaoJin opened this issue Mar 18, 2025 · 2 comments
Labels
breaking bug Something isn't working calcite calcite migration releated untriaged

Comments

@LantaoJin
Copy link
Member

LantaoJin commented Mar 18, 2025

What is the bug?
In OpenSearch SQL/PPL V2 engine:
POST /_plugins/_ppl
{
"query" : """
source = opensearch_dashboards_sample_data_flights
| eval a = cast(1 as boolean) -- true
| eval b = cast(2 as boolean) -- true
| eval c = cast(0 as boolean) -- false
| eval d = cast('1' as boolean) -- false
| eval e = cast('2' as boolean) -- false
| eval f = cast('0' as boolean) -- false
| eval g = cast('aa' as boolean) -- false
| fields a,b,c,d,e,f,g | head 1
"""
}
But in Spark and Postgres

select cast(1 as boolean); -- true
select cast(2 as boolean); -- true
select cast(0 as boolean); -- false
select cast('1' as boolean); -- true
select cast('2' as boolean); -- null
select cast('0' as boolean); -- false
select cast('aa' as boolean); -- null;

In V3, what behaviour should we align with? IMO, return null is more reasonable.

@LantaoJin LantaoJin added bug Something isn't working calcite calcite migration releated breaking labels Mar 18, 2025
@LantaoJin
Copy link
Member Author

LantaoJin commented Mar 18, 2025

What's the expected behaviour for OpenSearch SQL/PPL v3? @penghuo , it might be a breaking change if we not decide to align with V2 behaviour.

@penghuo
Copy link
Collaborator

penghuo commented Mar 18, 2025

In V3, what behaviour should we align with? IMO, return null is more reasonable.

agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking bug Something isn't working calcite calcite migration releated untriaged
Projects
None yet
Development

No branches or pull requests

2 participants