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

Public Member Functions

 InsertStmt (WithClause withClause, TableName targetTable, boolean overwrite, List< PartitionKeyValue > partitionKeyValues, List< String > planHints, QueryStmt queryStmt, List< String > columnPermutation)
 
 InsertStmt (InsertStmt other)
 
InsertStmt clone ()
 
void analyze (Analyzer analyzer) throws AnalysisException
 
List< String > getPlanHints ()
 
TableName getTargetTableName ()
 
Table getTargetTable ()
 
void setTargetTable (Table table)
 
boolean isOverwrite ()
 
QueryStmt getQueryStmt ()
 
void setQueryStmt (QueryStmt stmt)
 
List< ExprgetPartitionKeyExprs ()
 
Boolean isRepartition ()
 
ArrayList< ExprgetResultExprs ()
 
DataSink createDataSink ()
 
String toSql ()
 
void setIsExplain ()
 
boolean isExplain ()
 

Protected Attributes

boolean isExplain_ = false
 

Private Member Functions

void setTargetTable (Analyzer analyzer) throws AnalysisException
 
void checkColumnCoverage (ArrayList< Column > selectExprTargetColumns, Set< String > mentionedColumnNames, int numSelectListExprs, int numStaticPartitionExprs) throws AnalysisException
 
void prepareExpressions (List< Column > selectExprTargetColumns, List< Expr > selectListExprs, Table tbl, Analyzer analyzer) throws AnalysisException
 
Expr checkTypeCompatibility (Column column, Expr expr) throws AnalysisException
 
void analyzePlanHints (Analyzer analyzer) throws AnalysisException
 

Private Attributes

final WithClause withClause_
 
final TableName originalTableName_
 
TableName targetTableName_
 
final boolean overwrite_
 
final List< PartitionKeyValuepartitionKeyValues_
 
final List< String > planHints_
 
QueryStmt queryStmt_
 
final boolean needsGeneratedQueryStatement_
 
Table table_
 
final List< ExprpartitionKeyExprs_ = new ArrayList<Expr>()
 
Boolean isRepartition_ = null
 
final ArrayList< ExprresultExprs_ = new ArrayList<Expr>()
 
final List< String > columnPermutation_
 

Static Private Attributes

static final Logger LOG = LoggerFactory.getLogger(InsertStmt.class)
 

Detailed Description

Representation of a single insert statement, including the select statement whose results are to be inserted.

Definition at line 46 of file InsertStmt.java.

Constructor & Destructor Documentation

Member Function Documentation

void com.cloudera.impala.analysis.InsertStmt.checkColumnCoverage ( ArrayList< Column selectExprTargetColumns,
Set< String >  mentionedColumnNames,
int  numSelectListExprs,
int  numStaticPartitionExprs 
) throws AnalysisException
inlineprivate

Checks that the column permutation + select list + static partition exprs + dynamic partition exprs collectively cover exactly all columns in the target table (not more of fewer).

Definition at line 387 of file InsertStmt.java.

References com.cloudera.impala.analysis.InsertStmt.columnPermutation_, com.cloudera.impala.catalog.Table.getColumns(), com.cloudera.impala.catalog.Table.getFullName(), com.cloudera.impala.analysis.InsertStmt.partitionKeyValues_, and com.cloudera.impala.analysis.InsertStmt.table_.

Referenced by com.cloudera.impala.analysis.InsertStmt.analyze().

Expr com.cloudera.impala.analysis.InsertStmt.checkTypeCompatibility ( Column  column,
Expr  expr 
) throws AnalysisException
inlineprivate

Checks for type compatibility of column and expr. Returns compatible (possibly cast) expr.

Definition at line 559 of file InsertStmt.java.

References com.cloudera.impala.catalog.Type.isValid(), com.cloudera.impala.analysis.InsertStmt.targetTableName_, and com.cloudera.impala.analysis.TableName.toSql().

Referenced by com.cloudera.impala.analysis.InsertStmt.prepareExpressions().

InsertStmt com.cloudera.impala.analysis.InsertStmt.clone ( )
inline
List<Expr> com.cloudera.impala.analysis.InsertStmt.getPartitionKeyExprs ( )
inline
List<String> com.cloudera.impala.analysis.InsertStmt.getPlanHints ( )
inline
QueryStmt com.cloudera.impala.analysis.InsertStmt.getQueryStmt ( )
inline

Only valid after analysis

Definition at line 627 of file InsertStmt.java.

References com.cloudera.impala.analysis.InsertStmt.queryStmt_.

ArrayList<Expr> com.cloudera.impala.analysis.InsertStmt.getResultExprs ( )
inline
Table com.cloudera.impala.analysis.InsertStmt.getTargetTable ( )
inline

Definition at line 620 of file InsertStmt.java.

References com.cloudera.impala.analysis.InsertStmt.table_.

TableName com.cloudera.impala.analysis.InsertStmt.getTargetTableName ( )
inline
boolean com.cloudera.impala.analysis.StatementBase.isExplain ( )
inlineinherited
boolean com.cloudera.impala.analysis.InsertStmt.isOverwrite ( )
inline
Boolean com.cloudera.impala.analysis.InsertStmt.isRepartition ( )
inline
void com.cloudera.impala.analysis.InsertStmt.prepareExpressions ( List< Column selectExprTargetColumns,
List< Expr selectListExprs,
Table  tbl,
Analyzer  analyzer 
) throws AnalysisException
inlineprivate

Performs three final parts of the analysis:

  1. Checks type compatibility between all expressions and their targets
  2. Populates partitionKeyExprs with type-compatible expressions, in Hive partition-column order, for all partition columns
  3. Populates resultExprs_ with type-compatible expressions, in Hive column order, for all expressions in the select-list. Unmentioned columns are assigned NULL literal expressions.

If necessary, adds casts to the expressions to make them compatible with the type of the corresponding column.

Exceptions
AnalysisExceptionIf an expression is not compatible with its target column

Definition at line 467 of file InsertStmt.java.

References com.cloudera.impala.analysis.InsertStmt.checkTypeCompatibility(), com.cloudera.impala.catalog.Table.getColumns(), com.cloudera.impala.catalog.Table.getColumnsInHiveOrder(), com.cloudera.impala.catalog.Column.getPosition(), com.cloudera.impala.analysis.InsertStmt.needsGeneratedQueryStatement_, com.cloudera.impala.analysis.InsertStmt.partitionKeyExprs_, com.cloudera.impala.analysis.InsertStmt.partitionKeyValues_, com.cloudera.impala.analysis.InsertStmt.queryStmt_, com.cloudera.impala.analysis.InsertStmt.resultExprs_, and com.cloudera.impala.analysis.InsertStmt.table_.

Referenced by com.cloudera.impala.analysis.InsertStmt.analyze().

void com.cloudera.impala.analysis.StatementBase.setIsExplain ( )
inlineinherited
void com.cloudera.impala.analysis.InsertStmt.setQueryStmt ( QueryStmt  stmt)
inline
void com.cloudera.impala.analysis.InsertStmt.setTargetTable ( Analyzer  analyzer) throws AnalysisException
inlineprivate
void com.cloudera.impala.analysis.InsertStmt.setTargetTable ( Table  table)
inline

Definition at line 621 of file InsertStmt.java.

Member Data Documentation

Boolean com.cloudera.impala.analysis.InsertStmt.isRepartition_ = null
private
final Logger com.cloudera.impala.analysis.InsertStmt.LOG = LoggerFactory.getLogger(InsertStmt.class)
staticprivate

Definition at line 47 of file InsertStmt.java.

final TableName com.cloudera.impala.analysis.InsertStmt.originalTableName_
private
final List<Expr> com.cloudera.impala.analysis.InsertStmt.partitionKeyExprs_ = new ArrayList<Expr>()
private
final ArrayList<Expr> com.cloudera.impala.analysis.InsertStmt.resultExprs_ = new ArrayList<Expr>()
private
final WithClause com.cloudera.impala.analysis.InsertStmt.withClause_
private

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