kgyrtkirk opened a new pull request, #14893:
URL: https://github.com/apache/druid/pull/14893
After #14510 some queries become unplannable; like:
```sql
select count(1) filter (where __time > date '2023-01-01')
from druid.foo where 'a' = 'b'
```
The reason behind it was that the initial plan of
```
LogicalAggregate(group=[{}], EXPR$0=[COUNT() FILTER $0])
LogicalProject($f1=[>($0, 2023-01-01 00:00:00)])
LogicalFilter(condition=[=('a', 'b')])
LogicalTableScan(table=[[druid, foo]])
```
was simplified by some `RelBuilder` usage and
`PruneEmptyRules.PROJECT_INSTANCE` into
```
LogicalAggregate(group=[{}], EXPR$0=[COUNT() FILTER $0])
LogicalValues(tuples=[[]])
```
which become unplannable because the `FILTER` clause processing put a hard
constraint on the existence of a `Project` in the actual plan
[here](https://github.com/apache/druid/blob/92906059d2997a6902eac03b2a5198e5164043df/sql/src/main/java/org/apache/druid/sql/calcite/rule/GroupByRules.java#L78)
Proposed solution is to use `Expressions.fromFieldAccess` to optionally use
the `project` - or use a direct field access that's absent.
This PR has:
- [ ] been self-reviewed.
- [ ] added unit tests or modified existing tests to cover new code paths,
ensuring the threshold for [code
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
is met.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]