org.apache.hadoop.hive.ql.parse
Class RowResolver

java.lang.Object
  extended by org.apache.hadoop.hive.ql.parse.RowResolver
All Implemented Interfaces:
Serializable

public class RowResolver
extends Object
implements Serializable

Implementation of the Row Resolver.

See Also:
Serialized Form

Constructor Summary
RowResolver()
           
 
Method Summary
 void checkColumn(String tableAlias, String columnAlias)
          check if column name is already exist in RR
 ColumnInfo get(String tab_alias, String col_alias)
          Gets the column Info to tab_alias.col_alias type of a column reference.
 String[] getAlternateMappings(String internalName)
           
 ArrayList<ColumnInfo> getColumnInfos()
           
 ColumnInfo getExpression(ASTNode node)
          Retrieves the ColumnInfo corresponding to a source expression which exactly matches the string rendering of the given ASTNode.
 Map<String,ASTNode> getExpressionMap()
           
 ASTNode getExpressionSource(ASTNode node)
          Retrieves the source expression matching a given ASTNode's string rendering exactly.
 HashMap<String,ColumnInfo> getFieldMap(String tabAlias)
           
 HashMap<String,String[]> getInvRslvMap()
           
 boolean getIsExprResolver()
           
 int getPosition(String internalName)
           
 List<String> getReferenceableColumnAliases(String tableAlias, int max)
          Get a list of aliases for non-hidden columns
 RowSchema getRowSchema()
           
 HashMap<String,LinkedHashMap<String,ColumnInfo>> getRslvMap()
           
 Set<String> getTableNames()
           
 boolean hasTableAlias(String tab_alias)
           
 void put(String tab_alias, String col_alias, ColumnInfo colInfo)
           
 void putExpression(ASTNode node, ColumnInfo colInfo)
          Puts a resolver entry corresponding to a source expression which is to be used for identical expression recognition (e.g.
 String[] reverseLookup(String internalName)
           
 void setExpressionMap(Map<String,ASTNode> expressionMap)
           
 void setExprResolver(boolean isExprResolver)
           
 void setInvRslvMap(HashMap<String,String[]> invRslvMap)
           
 void setIsExprResolver(boolean isExprResolver)
           
 void setRowSchema(RowSchema rowSchema)
           
 void setRslvMap(HashMap<String,LinkedHashMap<String,ColumnInfo>> rslvMap)
           
 String[] toColumnDesc()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RowResolver

public RowResolver()
Method Detail

putExpression

public void putExpression(ASTNode node,
                          ColumnInfo colInfo)
Puts a resolver entry corresponding to a source expression which is to be used for identical expression recognition (e.g. for matching expressions in the SELECT list with the GROUP BY clause). The convention for such entries is an empty-string ("") as the table alias together with the string rendering of the ASTNode as the column alias.


getExpression

public ColumnInfo getExpression(ASTNode node)
                         throws SemanticException
Retrieves the ColumnInfo corresponding to a source expression which exactly matches the string rendering of the given ASTNode.

Throws:
SemanticException

getExpressionSource

public ASTNode getExpressionSource(ASTNode node)
Retrieves the source expression matching a given ASTNode's string rendering exactly.


put

public void put(String tab_alias,
                String col_alias,
                ColumnInfo colInfo)

hasTableAlias

public boolean hasTableAlias(String tab_alias)

get

public ColumnInfo get(String tab_alias,
                      String col_alias)
               throws SemanticException
Gets the column Info to tab_alias.col_alias type of a column reference. I the tab_alias is not provided as can be the case with an non aliased column, this function looks up the column in all the table aliases in this row resolver and returns the match. It also throws an exception if the column is found in multiple table aliases. If no match is found a null values is returned. This allows us to interpret both select t.c1 type of references and select c1 kind of references. The later kind are what we call non aliased column references in the query.

Parameters:
tab_alias - The table alias to match (this is null if the column reference is non aliased)
col_alias - The column name that is being searched for
Returns:
ColumnInfo
Throws:
SemanticException

checkColumn

public void checkColumn(String tableAlias,
                        String columnAlias)
                 throws SemanticException
check if column name is already exist in RR

Throws:
SemanticException

getColumnInfos

public ArrayList<ColumnInfo> getColumnInfos()

getReferenceableColumnAliases

public List<String> getReferenceableColumnAliases(String tableAlias,
                                                  int max)
Get a list of aliases for non-hidden columns

Parameters:
max - the maximum number of columns to return
Returns:
a list of non-hidden column names no greater in size than max

getFieldMap

public HashMap<String,ColumnInfo> getFieldMap(String tabAlias)

getPosition

public int getPosition(String internalName)

getTableNames

public Set<String> getTableNames()

reverseLookup

public String[] reverseLookup(String internalName)

setIsExprResolver

public void setIsExprResolver(boolean isExprResolver)

getIsExprResolver

public boolean getIsExprResolver()

getAlternateMappings

public String[] getAlternateMappings(String internalName)

toString

public String toString()
Overrides:
toString in class Object

getRowSchema

public RowSchema getRowSchema()

getRslvMap

public HashMap<String,LinkedHashMap<String,ColumnInfo>> getRslvMap()

getInvRslvMap

public HashMap<String,String[]> getInvRslvMap()

getExpressionMap

public Map<String,ASTNode> getExpressionMap()

setExprResolver

public void setExprResolver(boolean isExprResolver)

setRowSchema

public void setRowSchema(RowSchema rowSchema)

setRslvMap

public void setRslvMap(HashMap<String,LinkedHashMap<String,ColumnInfo>> rslvMap)

setInvRslvMap

public void setInvRslvMap(HashMap<String,String[]> invRslvMap)

setExpressionMap

public void setExpressionMap(Map<String,ASTNode> expressionMap)

toColumnDesc

public String[] toColumnDesc()


Copyright © 2014 The Apache Software Foundation. All rights reserved.