org.apache.lens.driver.jdbc
Class ColumnarSQLRewriter

java.lang.Object
  extended by org.apache.lens.driver.jdbc.ColumnarSQLRewriter
All Implemented Interfaces:
QueryRewriter

public class ColumnarSQLRewriter
extends Object
implements QueryRewriter

The Class ColumnarSQLRewriter.


Constructor Summary
ColumnarSQLRewriter()
          Instantiates a new columnar sql rewriter.
 
Method Summary
 void analyzeInternal()
          Analyze internal.
 void buildQuery(org.apache.hadoop.hive.conf.HiveConf queryConf)
          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)
          Gets the aggregate columns.
 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()
           
 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.
 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.
 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.
 void init(org.apache.hadoop.conf.Configuration conf)
          Set conf for the rewriter
 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)
          Rewrite.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnarSQLRewriter

public ColumnarSQLRewriter()
Instantiates a new columnar sql rewriter.

Method Detail

init

public void init(org.apache.hadoop.conf.Configuration conf)
Description copied from interface: QueryRewriter
Set conf for the rewriter

Specified by:
init in interface QueryRewriter
Parameters:
conf - Configuration required for rewriter init

getClause

public String getClause()

analyzeInternal

public void analyzeInternal()
                     throws org.apache.hadoop.hive.ql.parse.SemanticException
Analyze internal.

Throws:
org.apache.hadoop.hive.ql.parse.SemanticException - the semantic exception

getTableFromTabRefNode

public String getTableFromTabRefNode(org.apache.hadoop.hive.ql.parse.ASTNode tree)
Gets the table from tab ref node.

Parameters:
tree - the tree
Returns:
the table from tab ref node

getJoinCond

public void getJoinCond(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the join cond.

Parameters:
node - the node

constructJoinChain

public StringBuilder constructJoinChain()
Construct join chain

Returns:

getFilterInJoinCond

public void getFilterInJoinCond(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the filter in join cond.

Parameters:
node - the node

getFactAlias

public String getFactAlias()
Get the fact alias

Returns:

factFilterPushDown

public void factFilterPushDown(org.apache.hadoop.hive.ql.parse.ASTNode node)
Get fact filters for pushdown

Parameters:
node -

getFactKeysFromNode

public void getFactKeysFromNode(org.apache.hadoop.hive.ql.parse.ASTNode node)
Get fact keys used in the AST

Parameters:
node -

getAllFactKeys

public void getAllFactKeys()
Get all fact keys used in all ASTs


buildSubqueries

public void buildSubqueries(org.apache.hadoop.hive.ql.parse.ASTNode node)
Builds the subqueries.

Parameters:
node - the node

getTableOrAlias

public String getTableOrAlias(String keyString,
                              String type)
Get the table or alias from the given key string

Parameters:
keyString -
type -
Returns:

getAggregateColumns

public ArrayList<String> getAggregateColumns(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the aggregate columns.

Parameters:
node - the node
Returns:
the aggregate columns

getTablesAndColumns

public ArrayList<String> getTablesAndColumns(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the tables and columns.

Parameters:
node - the node
Returns:
the tables and columns

getLimitClause

public String getLimitClause(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the limit clause.

Parameters:
node - the node
Returns:
the limit clause

getAllFilters

public void getAllFilters(org.apache.hadoop.hive.ql.parse.ASTNode node)
Gets the all filters.

Parameters:
node - the node

getFactNameAlias

public String getFactNameAlias(org.apache.hadoop.hive.ql.parse.ASTNode fromAST)
Gets the fact name alias.

Parameters:
fromAST - the from ast
Returns:
the fact name alias

reset

public void reset()
Reset.


replaceUDFForDB

public String replaceUDFForDB(String query)
Replace udf for db.

Parameters:
query - the query
Returns:
the string

replaceAliasInAST

public void replaceAliasInAST()
                       throws org.apache.hadoop.hive.ql.metadata.HiveException
Replace alias in AST trees

Throws:
org.apache.hadoop.hive.ql.metadata.HiveException

buildQuery

public void buildQuery(org.apache.hadoop.hive.conf.HiveConf queryConf)
                throws org.apache.hadoop.hive.ql.metadata.HiveException
Builds the query.

Throws:
org.apache.hadoop.hive.ql.metadata.HiveException - the hive exception

rewrite

public String rewrite(String query,
                      org.apache.hadoop.conf.Configuration conf)
               throws LensException
Description copied from interface: QueryRewriter
Rewrite.

Specified by:
rewrite in interface QueryRewriter
Parameters:
query - the query
conf - the query configuration
Returns:
the string
Throws:
LensException - the lens exception


Copyright © 2014–2015 Apache Software Foundation. All rights reserved.