Closed jmbredenberg closed 4 years ago
Looks good. I pushed some changes that make an explicit CaseWhenExpression
enum nested inside a new FunctionArguments
in FunctionExpression
. This way, no special-purpose function variants are required for count/sum with a conditional. In addition, this extends (parsing) support for CASE WHEN to other aggregation types and supports both columns and literals in both THEN and ELSE clauses. (We do not intend to support all of those features in Noria, but the parser remains general this way.)
Adds parsing support for statements of the forms
COUNT/SUM (CASE WHEN condition THEN column END) COUNT/SUM (CASE WHEN condition THEN column ELSE literal END)
and tests for them.
This allows direct creation of the upcoming filter-aggregate operator in noria.
(A more complete version of this feature might support literals after the THEN and columns after the ELSE, or even more complex selections for both, but we decided this was not a good use of time.)