PDGGK commented on PR #18267:
URL: https://github.com/apache/iotdb/pull/18267#issuecomment-5044359222
Thanks @Wei-hao-Li — that's cleaner, adopted. I switched to routing the
empty device set to the default aggregation operator in
`DataNodeTableOperatorGenerator.visitAggregationTableScan`, and reverted the
flag in `LastQueryAggTableScanOperator` entirely (net zero there now). As you
said, the empty-process logic is already there: `AbstractAggTableScanOperator`
builds an `EMPTY_DEVICE_ID` entry for an empty device set, and the default
operator's `hasNext()` is time-range-based, so the global aggregation over
empty input still runs its time range and emits the single all-NULL row.
One edge I wanted to flag: a plain `GROUP BY` tag `last_by` also qualifies
for the last-cache path (`canUseLastCacheOptimize` only NOOPs the date_bin
case, not a plain grouping key), so an unconditional `deviceEntries.isEmpty() ?
NOOP` would reroute `GROUP BY`-over-an-empty-device-set to the default operator
too — and that case was already returning 0 rows correctly via the last-cache
op. To leave that path untouched I scoped the NOOP to both conditions:
```java
OptimizeType optimizeType =
node.getDeviceEntries().isEmpty() && node.getGroupingKeys().isEmpty()
? OptimizeType.NOOP
: canUseLastCacheOptimize(
parameter.getTableAggregators(), node,
parameter.getTimeColumnName());
```
So the global (no-GROUP-BY) empty case falls to the default op and gets the
single NULL row, while `GROUP BY` over an empty device set stays on the
last-cache path (0 rows, unchanged). Happy to use the unconditional form if
you'd prefer it. The `IoTDBDeletionTableIT` cases (never-written device → one
NULL row, `GROUP BY` over empty → no rows, deleted-device unchanged) are kept
and exercise both paths. Updated the PR — thanks for the pointer.
--
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]