OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
org.apache.calcite.sql2rel.SqlToRelConverter.AggregateFinder Class Reference
+ Inheritance diagram for org.apache.calcite.sql2rel.SqlToRelConverter.AggregateFinder:
+ Collaboration diagram for org.apache.calcite.sql2rel.SqlToRelConverter.AggregateFinder:

Public Member Functions

Void visit (SqlCall call)
 

Package Attributes

final SqlNodeList list = new SqlNodeList(SqlParserPos.ZERO)
 
final SqlNodeList filterList = new SqlNodeList(SqlParserPos.ZERO)
 
final SqlNodeList orderList = new SqlNodeList(SqlParserPos.ZERO)
 

Detailed Description

Visitor that collects all aggregate functions in a SqlNode tree.

Definition at line 5229 of file SqlToRelConverter.java.

Member Function Documentation

Void org.apache.calcite.sql2rel.SqlToRelConverter.AggregateFinder.visit ( SqlCall  call)
inline

Definition at line 5235 of file SqlToRelConverter.java.

References Void.

5235  {
5236  // ignore window aggregates and ranking functions (associated with OVER
5237  // operator)
5238  if (call.getOperator().getKind() == SqlKind.OVER) {
5239  return null;
5240  }
5241 
5242  if (call.getOperator().getKind() == SqlKind.FILTER) {
5243  // the WHERE in a FILTER must be tracked too so we can call replaceSubQueries on
5244  // it.
5245  // see https://issues.apache.org/jira/browse/CALCITE-1910
5246  final SqlNode aggCall = call.getOperandList().get(0);
5247  final SqlNode whereCall = call.getOperandList().get(1);
5248  list.add(aggCall);
5249  filterList.add(whereCall);
5250  return null;
5251  }
5252 
5253  if (call.getOperator().getKind() == SqlKind.WITHIN_GROUP) {
5254  // the WHERE in a WITHIN_GROUP must be tracked too so we can call
5255  // replaceSubQueries on it.
5256  // see https://issues.apache.org/jira/browse/CALCITE-1910
5257  final SqlNode aggCall = call.getOperandList().get(0);
5258  final SqlNodeList orderList = (SqlNodeList) call.getOperandList().get(1);
5259  list.add(aggCall);
5260  orderList.getList().forEach(this.orderList::add);
5261  return null;
5262  }
5263 
5264  if (call.getOperator().isAggregator()) {
5265  list.add(call);
5266  return null;
5267  }
5268 
5269  // Don't traverse into sub-queries, even if they contain aggregate
5270  // functions.
5271  if (call instanceof SqlSelect) {
5272  return null;
5273  }
5274 
5275  return call.getOperator().acceptCall(this, call);
5276  }

Member Data Documentation

final SqlNodeList org.apache.calcite.sql2rel.SqlToRelConverter.AggregateFinder.filterList = new SqlNodeList(SqlParserPos.ZERO)
package
final SqlNodeList org.apache.calcite.sql2rel.SqlToRelConverter.AggregateFinder.list = new SqlNodeList(SqlParserPos.ZERO)
package
final SqlNodeList org.apache.calcite.sql2rel.SqlToRelConverter.AggregateFinder.orderList = new SqlNodeList(SqlParserPos.ZERO)
package

The documentation for this class was generated from the following file: