You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Non-count aggregate (sum/avg/min/max) over an empty input returns zero rows instead of one null/identity row (count(*) is special-cased) #6680
A non-count aggregate (sum/avg/min/max) over an empty input returns zero rows instead of the single row (with a null/identity aggregate) that SQL and Cypher callers expect. count(*) is special-cased to return 0, but the other aggregates are not, so the two behave inconsistently over an empty set.
Where (HEAD 86a704526)
engine/src/main/java/com/arcadedb/query/sql/executor/SelectExecutionPlanner.java:780-783: GuaranteeEmptyCountStep is chained only when a count-star projection is present andinfo.groupBy == null:
AggregateProjectionCalculationStep.executeAggregation emits nothing when the upstream is empty, so sum/avg/min/max produce no row.
Repro
SELECT max(x) FROM Foo WHERE 1=0 (or an empty type) → expected one row {max: null}; actual zero rows. SELECT count(*) FROM Foo WHERE 1=0 correctly returns one row {count: 0}, showing the inconsistency.
Suggested fix
Extend the guarantee step to emit a single all-null aggregate row for any no-group aggregation over an empty input (not just count-star).
Scope / confidence
Behavior confirmed at HEAD. Low severity — long-standing OrientDB-inherited behavior and the count-star special case shows it is a deliberate-if-incomplete design; filed as a semantic gap/consistency fix rather than a fresh defect.
sum(), avg(), min(), max() on an empty result now correctly return one row (with 0 or null), matching what count(*) already did. Before, you'd get zero rows instead.
❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
Activity
Merge pull request #6693 from ArcadeData/fix/6665-6680-6679-6676-6671…
lvca commentedon Aug 24, 2026
Fixed in #6693 (merged to main).
sum(),avg(),min(),max()on an empty result now correctly return one row (with0ornull), matching whatcount(*)already did. Before, you'd get zero rows instead.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
fix(ArcadeData#6680,ArcadeData#6679,ArcadeData#6676,ArcadeData#6671):…
fix(ArcadeData#6316,ArcadeData#6265,ArcadeData#6318,ArcadeData#6705):…