Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
com.cloudera.impala.analysis.QueryStmt Class Referenceabstract
Inheritance diagram for com.cloudera.impala.analysis.QueryStmt:
Collaboration diagram for com.cloudera.impala.analysis.QueryStmt:

Public Member Functions

Analyzer getAnalyzer ()
 
void analyze (Analyzer analyzer) throws AnalysisException
 
abstract ArrayList< String > getColLabels ()
 
abstract void getMaterializedTupleIds (ArrayList< TupleId > tupleIdList)
 
void setWithClause (WithClause withClause)
 
boolean hasWithClause ()
 
WithClause getWithClause ()
 
boolean hasOrderByClause ()
 
boolean hasLimit ()
 
long getLimit ()
 
boolean hasOffset ()
 
long getOffset ()
 
SortInfo getSortInfo ()
 
boolean evaluateOrderBy ()
 
ArrayList< ExprgetResultExprs ()
 
ArrayList< ExprgetBaseTblResultExprs ()
 
void setLimit (long limit) throws AnalysisException
 
abstract void materializeRequiredSlots (Analyzer analyzer) throws InternalException
 
ArrayList< OrderByElementcloneOrderByElements ()
 
WithClause cloneWithClause ()
 
abstract QueryStmt clone ()
 
String toSql ()
 
void setIsExplain ()
 
boolean isExplain ()
 

Protected Member Functions

void createSortInfo (Analyzer analyzer) throws AnalysisException
 
void createSortTupleInfo (Analyzer analyzer)
 
Expr getFirstAmbiguousAlias (List< Expr > exprs)
 
void substituteOrdinals (List< Expr > exprs, String errorPrefix, Analyzer analyzer) throws AnalysisException
 
void materializeSlots (Analyzer analyzer, List< Expr > exprs)
 

Protected Attributes

WithClause withClause_
 
ArrayList< OrderByElementorderByElements_
 
LimitElement limitElement_
 
ArrayList< ExprresultExprs_ = Lists.newArrayList()
 
ArrayList< ExprbaseTblResultExprs_ = Lists.newArrayList()
 
final ExprSubstitutionMap aliasSmap_ = new ExprSubstitutionMap()
 
final ArrayList< ExprambiguousAliasList_ = Lists.newArrayList()
 
SortInfo sortInfo_
 
boolean evaluateOrderBy_
 
Analyzer analyzer_
 
boolean isExplain_ = false
 

Package Functions

 QueryStmt (ArrayList< OrderByElement > orderByElements, LimitElement limitElement)
 

Private Member Functions

void analyzeLimit (Analyzer analyzer) throws AnalysisException
 

Detailed Description

Abstract base class for any statement that returns results via a list of result expressions, for example a SelectStmt or UnionStmt. Also maintains a map of expression substitutions for replacing expressions from ORDER BY or GROUP BY clauses with their corresponding result expressions. Used for sharing members/methods and some of the analysis code, in particular the analysis of the ORDER BY and LIMIT clauses.

Definition at line 41 of file QueryStmt.java.

Constructor & Destructor Documentation

com.cloudera.impala.analysis.QueryStmt.QueryStmt ( ArrayList< OrderByElement orderByElements,
LimitElement  limitElement 
)
inlinepackage

Member Function Documentation

void com.cloudera.impala.analysis.QueryStmt.analyze ( Analyzer  analyzer) throws AnalysisException
inline

Perform semantic analysis of node and all of its children. Throws exception if any errors found.

Parameters
analyzer
Exceptions
AnalysisException

Implements com.cloudera.impala.analysis.ParseNode.

Definition at line 92 of file QueryStmt.java.

References com.cloudera.impala.analysis.QueryStmt.analyzeLimit(), and com.cloudera.impala.analysis.QueryStmt.hasWithClause().

abstract QueryStmt com.cloudera.impala.analysis.QueryStmt.clone ( )
abstract
ArrayList<OrderByElement> com.cloudera.impala.analysis.QueryStmt.cloneOrderByElements ( )
inline
void com.cloudera.impala.analysis.QueryStmt.createSortInfo ( Analyzer  analyzer) throws AnalysisException
inlineprotected

Creates sortInfo by resolving aliases and ordinals in the orderingExprs. If the query stmt is an inline view/union operand, then order-by with no limit with offset is not allowed, since that requires a sort and merging-exchange, and subsequent query execution would occur on a single machine. Sets evaluateOrderBy_ to false for ignored order-by w/o limit/offset in nested queries.

Definition at line 115 of file QueryStmt.java.

References com.cloudera.impala.analysis.QueryStmt.aliasSmap_, com.cloudera.impala.analysis.QueryStmt.clone(), com.cloudera.impala.analysis.QueryStmt.evaluateOrderBy_, com.cloudera.impala.analysis.QueryStmt.getFirstAmbiguousAlias(), com.cloudera.impala.analysis.QueryStmt.hasLimit(), com.cloudera.impala.analysis.QueryStmt.hasOffset(), com.cloudera.impala.analysis.QueryStmt.orderByElements_, com.cloudera.impala.analysis.QueryStmt.sortInfo_, com.cloudera.impala.analysis.QueryStmt.substituteOrdinals(), com.cloudera.impala.analysis.StatementBase.toSql(), and com.cloudera.impala.analysis.Expr.toSql().

Referenced by com.cloudera.impala.analysis.SelectStmt.analyze(), and com.cloudera.impala.analysis.UnionStmt.analyze().

void com.cloudera.impala.analysis.QueryStmt.createSortTupleInfo ( Analyzer  analyzer)
inlineprotected

Create a tuple descriptor for the single tuple that is materialized, sorted and output by the exec node implementing the sort. Done by materializing slot refs in the order-by and result expressions. Those SlotRefs in the ordering and result exprs are substituted with SlotRefs into the new tuple. This simplifies sorting logic for total (no limit) sorts. Done after analyzeAggregation() since ordering and result exprs may refer to the outputs of aggregation. Invoked for UnionStmt as well since TODO: We could do something more sophisticated than simply copying input slotrefs - e.g. compute some order-by expressions.

Definition at line 185 of file QueryStmt.java.

References com.cloudera.impala.analysis.QueryStmt.evaluateOrderBy_, and com.cloudera.impala.analysis.QueryStmt.resultExprs_.

Referenced by com.cloudera.impala.analysis.SelectStmt.analyze(), and com.cloudera.impala.analysis.UnionStmt.analyze().

boolean com.cloudera.impala.analysis.QueryStmt.evaluateOrderBy ( )
inline
Analyzer com.cloudera.impala.analysis.QueryStmt.getAnalyzer ( )
inline
abstract ArrayList<String> com.cloudera.impala.analysis.QueryStmt.getColLabels ( )
abstract
Expr com.cloudera.impala.analysis.QueryStmt.getFirstAmbiguousAlias ( List< Expr exprs)
inlineprotected

Return the first expr in exprs that is a non-unique alias. Return null if none of exprs is an ambiguous alias.

Definition at line 219 of file QueryStmt.java.

References com.cloudera.impala.analysis.QueryStmt.ambiguousAliasList_.

Referenced by com.cloudera.impala.analysis.SelectStmt.analyzeAggregation(), and com.cloudera.impala.analysis.QueryStmt.createSortInfo().

long com.cloudera.impala.analysis.QueryStmt.getLimit ( )
inline

Definition at line 274 of file QueryStmt.java.

Referenced by com.cloudera.impala.analysis.QueryStmt.setLimit().

abstract void com.cloudera.impala.analysis.QueryStmt.getMaterializedTupleIds ( ArrayList< TupleId tupleIdList)
abstract

Returns the materialized tuple ids of the output of this stmt. Used in case this stmt is part of an , since we need to know the materialized tupls ids of a TableRef. This call must be idempotent because it may be called more than once for Union stmt. TODO: The name of this function has become outdated due to analytics producing logical (non-materialized) tuples. Re-think and clean up.

long com.cloudera.impala.analysis.QueryStmt.getOffset ( )
inline

Definition at line 276 of file QueryStmt.java.

SortInfo com.cloudera.impala.analysis.QueryStmt.getSortInfo ( )
inline

Definition at line 277 of file QueryStmt.java.

References com.cloudera.impala.analysis.QueryStmt.sortInfo_.

WithClause com.cloudera.impala.analysis.QueryStmt.getWithClause ( )
inline
boolean com.cloudera.impala.analysis.QueryStmt.hasOffset ( )
inline
boolean com.cloudera.impala.analysis.QueryStmt.hasOrderByClause ( )
inline
boolean com.cloudera.impala.analysis.QueryStmt.hasWithClause ( )
inline
boolean com.cloudera.impala.analysis.StatementBase.isExplain ( )
inlineinherited
abstract void com.cloudera.impala.analysis.QueryStmt.materializeRequiredSlots ( Analyzer  analyzer) throws InternalException
abstract

Mark all slots that need to be materialized for the execution of this stmt. This excludes slots referenced in resultExprs (it depends on the consumer of the output of the stmt whether they'll be accessed) and single-table predicates (the PlanNode that materializes that tuple can decide whether evaluating those predicates requires slot materialization). This is called prior to plan tree generation and allows tuple-materializing PlanNodes to compute their tuple's mem layout.

void com.cloudera.impala.analysis.QueryStmt.materializeSlots ( Analyzer  analyzer,
List< Expr exprs 
)
inlineprotected

Mark slots referenced in exprs as materialized.

Definition at line 303 of file QueryStmt.java.

Referenced by com.cloudera.impala.analysis.UnionStmt.materializeRequiredSlots(), and com.cloudera.impala.analysis.SelectStmt.materializeRequiredSlots().

void com.cloudera.impala.analysis.StatementBase.setIsExplain ( )
inlineinherited
void com.cloudera.impala.analysis.QueryStmt.setWithClause ( WithClause  withClause)
inline

Definition at line 269 of file QueryStmt.java.

void com.cloudera.impala.analysis.QueryStmt.substituteOrdinals ( List< Expr exprs,
String  errorPrefix,
Analyzer  analyzer 
) throws AnalysisException
inlineprotected
String com.cloudera.impala.analysis.StatementBase.toSql ( )
inlineinherited

Print SQL syntax corresponding to this node.

See Also
com.cloudera.impala.parser.ParseNode::toSql()

Implements com.cloudera.impala.analysis.ParseNode.

Definition at line 41 of file StatementBase.java.

Referenced by com.cloudera.impala.analysis.CreateUdaStmt.analyze(), and com.cloudera.impala.analysis.QueryStmt.createSortInfo().

Member Data Documentation

final ExprSubstitutionMap com.cloudera.impala.analysis.QueryStmt.aliasSmap_ = new ExprSubstitutionMap()
protected

Map of expression substitutions for replacing aliases in "order by" or "group by" clauses with their corresponding result expr.

Definition at line 62 of file QueryStmt.java.

Referenced by com.cloudera.impala.analysis.SelectStmt.analyzeAggregation(), com.cloudera.impala.analysis.UnionStmt.createMetadata(), and com.cloudera.impala.analysis.QueryStmt.createSortInfo().

final ArrayList<Expr> com.cloudera.impala.analysis.QueryStmt.ambiguousAliasList_ = Lists.newArrayList()
protected

Select list item alias does not have to be unique. This list contains all the non-unique aliases. For example, select int_col a, string_col a from alltypessmall; Both columns are using the same alias "a".

Definition at line 70 of file QueryStmt.java.

Referenced by com.cloudera.impala.analysis.QueryStmt.getFirstAmbiguousAlias().

Analyzer com.cloudera.impala.analysis.QueryStmt.analyzer_
protected

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