public class ColumnarSQLRewriter extends Object implements QueryRewriter
Constructor and Description |
---|
ColumnarSQLRewriter()
Instantiates a new columnar sql rewriter.
|
Modifier and Type | Method and Description |
---|---|
void |
analyzeInternal(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.hive.conf.HiveConf hconf)
Analyze internal.
|
void |
buildDimSubqueries()
Build dimension table subqueries
|
void |
buildQuery(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.hive.conf.HiveConf hconf)
Builds the query.
|
void |
buildSubqueries(org.apache.hadoop.hive.ql.parse.ASTNode node)
Builds the subqueries.
|
StringBuilder |
constructJoinChain()
Construct join chain
|
void |
factFilterPushDown(org.apache.hadoop.hive.ql.parse.ASTNode node)
Get fact filters for pushdown
|
ArrayList<String> |
getAggregateColumns(org.apache.hadoop.hive.ql.parse.ASTNode node,
org.apache.commons.lang.mutable.MutableInt count)
Gets the aggregate columns.
|
void |
getAllDimColumns(org.apache.hadoop.hive.ql.parse.ASTNode node)
Get all columns used for dimmension tables
|
void |
getAllFactKeys()
Get all fact keys used in all ASTs
|
void |
getAllFilters(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the all filters.
|
String |
getClause() |
int |
getColumnCount(org.apache.hadoop.hive.ql.parse.ASTNode node)
Get the count of columns in a given select expression
|
String |
getFactAlias()
Get the fact alias
|
void |
getFactKeysFromNode(org.apache.hadoop.hive.ql.parse.ASTNode node)
Get fact keys used in the AST
|
String |
getFactNameAlias(org.apache.hadoop.hive.ql.parse.ASTNode fromAST)
Gets the fact name alias.
|
void |
getFilterInJoinCond(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the filter in join cond.
|
org.apache.hadoop.hive.ql.parse.ASTNode |
getFromAST()
The from ast.
|
org.apache.hadoop.hive.ql.parse.ASTNode |
getGroupByAST()
The group by ast.
|
org.apache.hadoop.hive.ql.parse.ASTNode |
getHavingAST()
The having ast.
|
org.apache.hadoop.hive.ql.parse.ASTNode |
getJoinAST()
The join ast.
|
void |
getJoinCond(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the join cond.
|
String |
getLimitClause(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the limit clause.
|
org.apache.hadoop.hive.ql.parse.ASTNode |
getOrderByAST()
The order by ast.
|
org.apache.hadoop.hive.ql.parse.ASTNode |
getSelectAST()
The select ast.
|
String |
getTableFromTabRefNode(org.apache.hadoop.hive.ql.parse.ASTNode tree)
Gets the table from tab ref node.
|
String |
getTableOrAlias(String keyString,
String type)
Get the table or alias from the given key string
|
ArrayList<String> |
getTablesAndColumns(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the tables and columns.
|
org.apache.hadoop.hive.ql.parse.ASTNode |
getWhereAST()
The where ast.
|
void |
init(org.apache.hadoop.conf.Configuration conf)
Set conf for the rewriter
|
boolean |
isExpressionsAnswerableFromFact(org.apache.hadoop.hive.ql.parse.ASTNode node)
Check if expression is answerable from fact, then push it to fact pushdown subquery
|
void |
replaceAliasInAST()
Replace alias in AST trees
|
String |
replaceUDFForDB(String query)
Replace udf for db.
|
void |
reset()
Reset.
|
String |
rewrite(String query,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.hive.conf.HiveConf metastoreConf)
Rewrite.
|
public ColumnarSQLRewriter()
public void init(org.apache.hadoop.conf.Configuration conf)
QueryRewriter
init
in interface QueryRewriter
conf
- Configuration required for rewriter initpublic String getClause()
public void analyzeInternal(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hive.conf.HiveConf hconf) throws org.apache.hadoop.hive.ql.parse.SemanticException
org.apache.hadoop.hive.ql.parse.SemanticException
- the semantic exceptionpublic String getTableFromTabRefNode(org.apache.hadoop.hive.ql.parse.ASTNode tree)
tree
- the treepublic void getJoinCond(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- the nodepublic StringBuilder constructJoinChain()
public int getColumnCount(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- public boolean isExpressionsAnswerableFromFact(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- public void getFilterInJoinCond(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- the nodepublic String getFactAlias()
public void factFilterPushDown(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- public void getFactKeysFromNode(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- public void getAllFactKeys()
public void getAllDimColumns(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- public void buildDimSubqueries()
public void buildSubqueries(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- the nodepublic String getTableOrAlias(String keyString, String type)
keyString
- type
- public ArrayList<String> getAggregateColumns(org.apache.hadoop.hive.ql.parse.ASTNode node, org.apache.commons.lang.mutable.MutableInt count)
node
- the nodepublic ArrayList<String> getTablesAndColumns(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- the nodepublic String getLimitClause(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- the nodepublic void getAllFilters(org.apache.hadoop.hive.ql.parse.ASTNode node)
node
- the nodepublic String getFactNameAlias(org.apache.hadoop.hive.ql.parse.ASTNode fromAST)
fromAST
- the from astpublic void reset()
public String replaceUDFForDB(String query)
query
- the querypublic void replaceAliasInAST()
public void buildQuery(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hive.conf.HiveConf hconf) throws org.apache.hadoop.hive.ql.parse.SemanticException
org.apache.hadoop.hive.ql.parse.SemanticException
public String rewrite(String query, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.hive.conf.HiveConf metastoreConf) throws LensException
QueryRewriter
rewrite
in interface QueryRewriter
query
- the queryconf
- the query configurationmetastoreConf
- The metastore configuration. If rewriters requires to access metastore, this configuration
needs to passedLensException
- the lens exception@Generated(value="lombok") public org.apache.hadoop.hive.ql.parse.ASTNode getJoinAST()
@Generated(value="lombok") public org.apache.hadoop.hive.ql.parse.ASTNode getHavingAST()
@Generated(value="lombok") public org.apache.hadoop.hive.ql.parse.ASTNode getSelectAST()
@Generated(value="lombok") public org.apache.hadoop.hive.ql.parse.ASTNode getWhereAST()
@Generated(value="lombok") public org.apache.hadoop.hive.ql.parse.ASTNode getOrderByAST()
@Generated(value="lombok") public org.apache.hadoop.hive.ql.parse.ASTNode getGroupByAST()
@Generated(value="lombok") public org.apache.hadoop.hive.ql.parse.ASTNode getFromAST()
Copyright © 2014–2018 Apache Software Foundation. All rights reserved.