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

java.lang.Object
  extended by org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer
Direct Known Subclasses:
DDLSemanticAnalyzer, ExplainSemanticAnalyzer, ExportSemanticAnalyzer, FunctionSemanticAnalyzer, ImportSemanticAnalyzer, LoadSemanticAnalyzer, MacroSemanticAnalyzer, SemanticAnalyzer

public abstract class BaseSemanticAnalyzer
extends Object

BaseSemanticAnalyzer.


Nested Class Summary
static class BaseSemanticAnalyzer.tableSpec
          tableSpec.
 
Field Summary
static int HIVE_COLUMN_ORDER_ASC
           
static int HIVE_COLUMN_ORDER_DESC
           
 
Constructor Summary
BaseSemanticAnalyzer(HiveConf conf)
           
BaseSemanticAnalyzer(HiveConf conf, Hive db)
           
 
Method Summary
 void analyze(ASTNode ast, Context ctx)
           
abstract  void analyzeInternal(ASTNode ast)
           
static String charSetString(String charSetName, String charSetString)
           
 ColumnAccessInfo getColumnAccessInfo()
          Gets the column access information.
static List<String> getColumnNames(ASTNode ast)
           
static List<org.apache.hadoop.hive.metastore.api.FieldSchema> getColumns(ASTNode ast, boolean lowerCase)
          Get the list of FieldSchema out of the ASTNode.
 Hive getDb()
           
 FetchTask getFetchTask()
           
 HashMap<String,String> getIdToTableNameMap()
           
 HashSet<ReadEntity> getInputs()
           
 LineageInfo getLineageInfo()
          Gets the lineage information.
 HashSet<WriteEntity> getOutputs()
           
 QueryProperties getQueryProperties()
           
 List<org.apache.hadoop.hive.metastore.api.FieldSchema> getResultSchema()
           
 List<Task<? extends Serializable>> getRootTasks()
           
 TableAccessInfo getTableAccessInfo()
          Gets the table access information.
static String getUnescapedName(ASTNode tableOrColumnNode)
          Get dequoted name from a table/column node.
static String getUnescapedName(ASTNode tableOrColumnNode, String currentDatabase)
           
static String getUnescapedUnqualifiedTableName(ASTNode node)
          Get the unqualified name from a table node.
 void init()
           
 void initCtx(Context ctx)
           
 boolean isValidPrefixSpec(Table tTable, Map<String,String> spec)
          Checks if given specification is proper specification for prefix of partition cols, for table partitioned by ds, hr, min valid ones are (ds='2008-04-08'), (ds='2008-04-08', hr='12'), (ds='2008-04-08', hr='12', min='30') invalid one is for example (ds='2008-04-08', min='30')
static void readProps(ASTNode prop, Map<String,String> mapProp)
          Converts parsed key/value properties pairs into a map.
 void setColumnAccessInfo(ColumnAccessInfo columnAccessInfo)
          Sets the column access information.
 void setFetchTask(FetchTask fetchTask)
           
 void setLineageInfo(LineageInfo linfo)
          Sets the lineage information.
 void setTableAccessInfo(TableAccessInfo tableAccessInfo)
          Sets the table access information.
static String stripIdentifierQuotes(String val)
           
static String stripQuotes(String val)
           
static String unescapeIdentifier(String val)
          Remove the encapsulating "`" pair from the identifier.
static String unescapeSQLString(String b)
           
 void validate()
           
static void validatePartSpec(Table tbl, Map<String,String> partSpec, ASTNode astNode, HiveConf conf, boolean shouldBeFull)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIVE_COLUMN_ORDER_ASC

public static int HIVE_COLUMN_ORDER_ASC

HIVE_COLUMN_ORDER_DESC

public static int HIVE_COLUMN_ORDER_DESC
Constructor Detail

BaseSemanticAnalyzer

public BaseSemanticAnalyzer(HiveConf conf)
                     throws SemanticException
Throws:
SemanticException

BaseSemanticAnalyzer

public BaseSemanticAnalyzer(HiveConf conf,
                            Hive db)
                     throws SemanticException
Throws:
SemanticException
Method Detail

getIdToTableNameMap

public HashMap<String,String> getIdToTableNameMap()

analyzeInternal

public abstract void analyzeInternal(ASTNode ast)
                              throws SemanticException
Throws:
SemanticException

init

public void init()

initCtx

public void initCtx(Context ctx)

analyze

public void analyze(ASTNode ast,
                    Context ctx)
             throws SemanticException
Throws:
SemanticException

validate

public void validate()
              throws SemanticException
Throws:
SemanticException

getRootTasks

public List<Task<? extends Serializable>> getRootTasks()

getFetchTask

public FetchTask getFetchTask()
Returns:
the fetchTask

setFetchTask

public void setFetchTask(FetchTask fetchTask)
Parameters:
fetchTask - the fetchTask to set

stripIdentifierQuotes

public static String stripIdentifierQuotes(String val)

stripQuotes

public static String stripQuotes(String val)

charSetString

public static String charSetString(String charSetName,
                                   String charSetString)
                            throws SemanticException
Throws:
SemanticException

getUnescapedName

public static String getUnescapedName(ASTNode tableOrColumnNode)
Get dequoted name from a table/column node.

Parameters:
tableOrColumnNode - the table or column node
Returns:
for table node, db.tab or tab. for column node column.

getUnescapedName

public static String getUnescapedName(ASTNode tableOrColumnNode,
                                      String currentDatabase)

getUnescapedUnqualifiedTableName

public static String getUnescapedUnqualifiedTableName(ASTNode node)
Get the unqualified name from a table node. This method works for table names qualified with their schema (e.g., "db.table") and table names without schema qualification. In both cases, it returns the table name without the schema.

Parameters:
node - the table node
Returns:
the table name without schema qualification (i.e., if name is "db.table" or "table", returns "table")

unescapeIdentifier

public static String unescapeIdentifier(String val)
Remove the encapsulating "`" pair from the identifier. We allow users to use "`" to escape identifier for table names, column names and aliases, in case that coincide with Hive language keywords.


readProps

public static void readProps(ASTNode prop,
                             Map<String,String> mapProp)
Converts parsed key/value properties pairs into a map.

Parameters:
prop - ASTNode parent of the key/value pairs
mapProp - property map which receives the mappings

unescapeSQLString

public static String unescapeSQLString(String b)

getInputs

public HashSet<ReadEntity> getInputs()

getOutputs

public HashSet<WriteEntity> getOutputs()

getResultSchema

public List<org.apache.hadoop.hive.metastore.api.FieldSchema> getResultSchema()
Returns:
the schema for the fields which will be produced when the statement is executed, or null if not known

getColumns

public static List<org.apache.hadoop.hive.metastore.api.FieldSchema> getColumns(ASTNode ast,
                                                                                boolean lowerCase)
                                                                         throws SemanticException
Get the list of FieldSchema out of the ASTNode.

Throws:
SemanticException

getColumnNames

public static List<String> getColumnNames(ASTNode ast)

getLineageInfo

public LineageInfo getLineageInfo()
Gets the lineage information.

Returns:
LineageInfo associated with the query.

setLineageInfo

public void setLineageInfo(LineageInfo linfo)
Sets the lineage information.

Parameters:
linfo - The LineageInfo structure that is set in the optimization phase.

getTableAccessInfo

public TableAccessInfo getTableAccessInfo()
Gets the table access information.

Returns:
TableAccessInfo associated with the query.

setTableAccessInfo

public void setTableAccessInfo(TableAccessInfo tableAccessInfo)
Sets the table access information.

Parameters:
taInfo - The TableAccessInfo structure that is set in the optimization phase.

getColumnAccessInfo

public ColumnAccessInfo getColumnAccessInfo()
Gets the column access information.

Returns:
ColumnAccessInfo associated with the query.

setColumnAccessInfo

public void setColumnAccessInfo(ColumnAccessInfo columnAccessInfo)
Sets the column access information.

Parameters:
columnAccessInfo - The ColumnAccessInfo structure that is set immediately after the optimization phase.

isValidPrefixSpec

public final boolean isValidPrefixSpec(Table tTable,
                                       Map<String,String> spec)
                                throws HiveException
Checks if given specification is proper specification for prefix of partition cols, for table partitioned by ds, hr, min valid ones are (ds='2008-04-08'), (ds='2008-04-08', hr='12'), (ds='2008-04-08', hr='12', min='30') invalid one is for example (ds='2008-04-08', min='30')

Parameters:
spec - specification key-value map
Returns:
true if the specification is prefix; never returns false, but throws
Throws:
HiveException

getDb

public Hive getDb()

getQueryProperties

public QueryProperties getQueryProperties()

validatePartSpec

public static void validatePartSpec(Table tbl,
                                    Map<String,String> partSpec,
                                    ASTNode astNode,
                                    HiveConf conf,
                                    boolean shouldBeFull)
                             throws SemanticException
Throws:
SemanticException


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