private void insertAggExpressionsToAggResultColumns ( List < AbstractExpression > aggColumns , ParsedColInfo cookedCol ) { for ( AbstractExpression expr : aggColumns ) { assert ( expr instanceof AggregateExpression ) ; if ( expr . hasSubquerySubexpression ( ) ) { throw new PlanningErrorException ( "SQL Aggregate function calls with subquery expression arguments are not allowed." ) ; } ParsedColInfo col = new ParsedColInfo ( ) ; col . m_expression = expr . clone ( ) ; assert ( col . m_expression instanceof AggregateExpression ) ; if ( col . m_expression . getExpressionType ( ) == ExpressionType . AGGREGATE_AVG ) { m_hasAverage = true ; } if ( aggColumns . size ( ) == 1 && cookedCol . m_expression . equals ( aggColumns . get ( 0 ) ) ) { col . m_alias = cookedCol . m_alias ; col . m_tableName = cookedCol . m_tableName ; col . m_tableAlias = cookedCol . m_tableAlias ; col . m_columnName = cookedCol . m_columnName ; if ( ! m_aggResultColumns . contains ( col ) ) { m_aggResultColumns . add ( col ) ; } return ; } // Try to check complexAggs earlier m_hasComplexAgg = true ; // Aggregation column use the the hacky stuff col . m_tableName = TEMP_TABLE_NAME ; col . m_tableAlias = TEMP_TABLE_NAME ; col . m_columnName = "" ; if ( ! m_aggResultColumns . contains ( col ) ) { m_aggResultColumns . add ( col ) ; } ExpressionUtil . finalizeValueTypes ( col . m_expression ) ; } }
ParseDisplayColumns and ParseOrderColumns will call this function to add Aggregation expressions to aggResultColumns