dynamobi/dynamobi — Issue #612: [FRG-260] Measure columns for GROUP BY with non-empty key should retain nullability of input columns
Author: dynamobi-build
Created: 2011-12-30 03:38:33+00:00
State: open
Labels: FRG, SQL Validator

[reporter="jvs", created="Fri, 23 Mar 2007 22:57:58 -0500 (GMT-05:00)"]
COUNT is always NOT NULL since it produces a count of zero even if all inputs were null. This is already correctly implemented.

However, currently we force SUM/MAX/MIN/AVG measure column outputs to nullable even when the input type is NOT NULL. The reason is that we don't discriminate between the case where the measure is being computed in a GROUP BY vs. a measure in a full-table aggregation (no GROUP BY or GROUP BY with empty column set). In the full-table case, it's necessary to force to nullable, since if there are no rows to be grouped, the result comes out as NULL.

This can't be fixed in just the validator alone, because some executor code is dependent on it since it has to produce matching physical tuple descriptors.

See fennel/exec/SortedAggExecStream.cpp, method prepare, and fennel/lucidera/hashexe/LhxAggExecStream.cpp, method setHashInfo.