You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/10/19 10:47:08 UTC
[GitHub] [druid] suhassumukh opened a new issue #11813: Calcite leaves out nulls when negating filter expressions
suhassumukh opened a new issue #11813:
URL: https://github.com/apache/druid/issues/11813
This query -
```sql
select * from foo where dim is null or dim='a'
```
is translated to (just the `filter` part)-
```json
"filter": {
"type": "in",
"dimension": "dim",
"values": [
null,
"a"
]
}
```
which looks good.
However, the translation for this query -
```sql
select * from foo where not (dim is null or dim = 'a')
```
is -
```json
"filter": {
"type": "not",
"field": {
"type": "selector",
"dimension": "dim",
"value": "a",
"extractionFn": null
}
}
```
The `null` condition is lost in the translation and rows with `dim=null` are returned. This is not the expected outcome.
The expected query plan is thus,
```json
"filter": {
"type": "not",
"field": {
"type": "in",
"dimension": "dim",
"values": [
null,
"a"
]
}
}
```
Affected Version(s):
Apache Druid 0.19.0
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] suhassumukh commented on issue #11813: Unable to negating filter expressions involving nulls
Posted by GitBox <gi...@apache.org>.
suhassumukh commented on issue #11813:
URL: https://github.com/apache/druid/issues/11813#issuecomment-985999840
@kfaraz
After rewriting my query to -
```sql
select * from foo where dim is not null and dim <> 'a'
```
The query plan is still -
```json
"filter": {
"type": "not",
"field": {
"type": "selector",
"dimension": "dim",
"value": "a",
"extractionFn": null
}
}
```
Replacing `<>` with `!=` doesn't change anything either.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] kfaraz commented on issue #11813: Unable to negating filter expressions involving nulls
Posted by GitBox <gi...@apache.org>.
kfaraz commented on issue #11813:
URL: https://github.com/apache/druid/issues/11813#issuecomment-985982599
Negation with `IS NULL` is typically problematic because of how the expression `dim IS NULL` is evaluated.
That is why we have `IS NOT NULL`
Try re-writing your query like this:
```
select * from foo where dim is not null and dim <> 'a'
```
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org