Aggregation on empty table yields empty table
Aklakan opened this issue · 1 comments
Aklakan commented
If we have
(Project Count(foo)
emptySqlOp
)
Then the SqlOpStringSerializerImpl incorrectly returns null to indicate a query with no result rows.
The solution is to properly keep track of whether aggregations are being used in a query, and if so, serialize the empty table as e.g. SELECT NULL WHERE FALSE
.
Aklakan commented
Added a somewhat hacky fix to SqlOpSelectBlock's isEmpty() method:
The method now checks if the projection contains a single argument that is a count function.
However, the isEmpty() method for SqlOpProjection and SqlOpExtend are currently still broken - i.e. they would incorrectly return true.