| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| SELECT AGG(*), AGG(), AGG(a, b, c) FROM test |
| -- |
| SetOperationStatement |
| +-set_operation_query=SetOperation[set_operation_type=Select] |
| +-children= |
| +-Select |
| +-select_clause=SelectList |
| | +-SelectListItem |
| | | +-FunctionCall[name=AGG,is_star=true] |
| | +-SelectListItem |
| | | +-FunctionCall[name=AGG] |
| | +-SelectListItem |
| | +-FunctionCall[name=AGG] |
| | +-AttributeReference[attribute_name=a] |
| | +-AttributeReference[attribute_name=b] |
| | +-AttributeReference[attribute_name=c] |
| +-from_clause= |
| +-TableReference[table=test] |
| == |
| |
| SELECT AGG()+1, AGG()*2+1+AGG(a, b)/AGG(c, d) FROM test |
| -- |
| SetOperationStatement |
| +-set_operation_query=SetOperation[set_operation_type=Select] |
| +-children= |
| +-Select |
| +-select_clause=SelectList |
| | +-SelectListItem |
| | | +-Add |
| | | +-left_operand=FunctionCall[name=AGG] |
| | | +-right_operand=Literal |
| | | +-NumericLiteral[numeric_string=1,float_like=false] |
| | +-SelectListItem |
| | +-Add |
| | +-left_operand=Add |
| | | +-left_operand=Multiply |
| | | | +-left_operand=FunctionCall[name=AGG] |
| | | | +-right_operand=Literal |
| | | | +-NumericLiteral[numeric_string=2,float_like=false] |
| | | +-right_operand=Literal |
| | | +-NumericLiteral[numeric_string=1,float_like=false] |
| | +-right_operand=Divide |
| | +-left_operand=FunctionCall[name=AGG] |
| | | +-AttributeReference[attribute_name=a] |
| | | +-AttributeReference[attribute_name=b] |
| | +-right_operand=FunctionCall[name=AGG] |
| | +-AttributeReference[attribute_name=c] |
| | +-AttributeReference[attribute_name=d] |
| +-from_clause= |
| +-TableReference[table=test] |
| == |
| |
| # Function calls as arguments of another function calls. |
| # This is just for testing purpose. If agg is an aggregation, |
| # the query is not valid. The query resolver will capture the error. |
| SELECT AGG(AGG(AGG()+1)*2, AGG(*)/2.0) FROM test |
| -- |
| SetOperationStatement |
| +-set_operation_query=SetOperation[set_operation_type=Select] |
| +-children= |
| +-Select |
| +-select_clause=SelectList |
| | +-SelectListItem |
| | +-FunctionCall[name=AGG] |
| | +-Multiply |
| | | +-left_operand=FunctionCall[name=AGG] |
| | | | +-Add |
| | | | +-left_operand=FunctionCall[name=AGG] |
| | | | +-right_operand=Literal |
| | | | +-NumericLiteral[numeric_string=1,float_like=false] |
| | | +-right_operand=Literal |
| | | +-NumericLiteral[numeric_string=2,float_like=false] |
| | +-Divide |
| | +-left_operand=FunctionCall[name=AGG,is_star=true] |
| | +-right_operand=Literal |
| | +-NumericLiteral[numeric_string=2.0,float_like=true] |
| +-from_clause= |
| +-TableReference[table=test] |
| == |
| |
| SELECT AGG(*, a) FROM test |
| -- |
| ERROR: syntax error (1 : 13) |
| SELECT AGG(*, a) FROM test |
| ^ |
| == |
| |
| SELECT AGG()+1 FROM test GROUP BY a+1, AGG()+1 HAVING AGG()*2>1 |
| -- |
| SetOperationStatement |
| +-set_operation_query=SetOperation[set_operation_type=Select] |
| +-children= |
| +-Select |
| +-select_clause=SelectList |
| | +-SelectListItem |
| | +-Add |
| | +-left_operand=FunctionCall[name=AGG] |
| | +-right_operand=Literal |
| | +-NumericLiteral[numeric_string=1,float_like=false] |
| +-group_by=GroupBy |
| | +-Add |
| | | +-left_operand=AttributeReference[attribute_name=a] |
| | | +-right_operand=Literal |
| | | +-NumericLiteral[numeric_string=1,float_like=false] |
| | +-Add |
| | +-left_operand=FunctionCall[name=AGG] |
| | +-right_operand=Literal |
| | +-NumericLiteral[numeric_string=1,float_like=false] |
| +-having=HAVING |
| | +-Greater |
| | +-left_operand=Multiply |
| | | +-left_operand=FunctionCall[name=AGG] |
| | | +-right_operand=Literal |
| | | +-NumericLiteral[numeric_string=2,float_like=false] |
| | +-right_operand=Literal |
| | +-NumericLiteral[numeric_string=1,float_like=false] |
| +-from_clause= |
| +-TableReference[table=test] |
| == |
| |
| SELECT 1 FROM test HAVING AGG() > 1 AND 1=1 |
| -- |
| SetOperationStatement |
| +-set_operation_query=SetOperation[set_operation_type=Select] |
| +-children= |
| +-Select |
| +-select_clause=SelectList |
| | +-SelectListItem |
| | +-Literal |
| | +-NumericLiteral[numeric_string=1,float_like=false] |
| +-having=HAVING |
| | +-And |
| | +-Greater |
| | | +-left_operand=FunctionCall[name=AGG] |
| | | +-right_operand=Literal |
| | | +-NumericLiteral[numeric_string=1,float_like=false] |
| | +-Equal |
| | +-left_operand=Literal |
| | | +-NumericLiteral[numeric_string=1,float_like=false] |
| | +-right_operand=Literal |
| | +-NumericLiteral[numeric_string=1,float_like=false] |
| +-from_clause= |
| +-TableReference[table=test] |
| == |
| |
| SELECT 1 FROM test GROUP BY AGG()+1, AGG()/AGG() |
| -- |
| SetOperationStatement |
| +-set_operation_query=SetOperation[set_operation_type=Select] |
| +-children= |
| +-Select |
| +-select_clause=SelectList |
| | +-SelectListItem |
| | +-Literal |
| | +-NumericLiteral[numeric_string=1,float_like=false] |
| +-group_by=GroupBy |
| | +-Add |
| | | +-left_operand=FunctionCall[name=AGG] |
| | | +-right_operand=Literal |
| | | +-NumericLiteral[numeric_string=1,float_like=false] |
| | +-Divide |
| | +-left_operand=FunctionCall[name=AGG] |
| | +-right_operand=FunctionCall[name=AGG] |
| +-from_clause= |
| +-TableReference[table=test] |
| == |
| |
| SELECT AGG(DISTINCT x), AGG(y) FROM test GROUP BY z |
| -- |
| SetOperationStatement |
| +-set_operation_query=SetOperation[set_operation_type=Select] |
| +-children= |
| +-Select |
| +-select_clause=SelectList |
| | +-SelectListItem |
| | | +-FunctionCall[name=AGG,is_distinct=true] |
| | | +-AttributeReference[attribute_name=x] |
| | +-SelectListItem |
| | +-FunctionCall[name=AGG] |
| | +-AttributeReference[attribute_name=y] |
| +-group_by=GroupBy |
| | +-AttributeReference[attribute_name=z] |
| +-from_clause= |
| +-TableReference[table=test] |
| == |
| |
| SELECT AGG(DISTINCT FUN(x) + y) * AGG(z) |
| FROM test |
| GROUP BY z |
| HAVING AGG(DISTINCT w) + AGG(s) > 1 |
| -- |
| SetOperationStatement |
| +-set_operation_query=SetOperation[set_operation_type=Select] |
| +-children= |
| +-Select |
| +-select_clause=SelectList |
| | +-SelectListItem |
| | +-Multiply |
| | +-left_operand=FunctionCall[name=AGG,is_distinct=true] |
| | | +-Add |
| | | +-left_operand=FunctionCall[name=FUN] |
| | | | +-AttributeReference[attribute_name=x] |
| | | +-right_operand=AttributeReference[attribute_name=y] |
| | +-right_operand=FunctionCall[name=AGG] |
| | +-AttributeReference[attribute_name=z] |
| +-group_by=GroupBy |
| | +-AttributeReference[attribute_name=z] |
| +-having=HAVING |
| | +-Greater |
| | +-left_operand=Add |
| | | +-left_operand=FunctionCall[name=AGG,is_distinct=true] |
| | | | +-AttributeReference[attribute_name=w] |
| | | +-right_operand=FunctionCall[name=AGG] |
| | | +-AttributeReference[attribute_name=s] |
| | +-right_operand=Literal |
| | +-NumericLiteral[numeric_string=1,float_like=false] |
| +-from_clause= |
| +-TableReference[table=test] |
| == |