public abstract class BaseSemanticAnalyzer extends Object
Modifier and Type | Class and Description |
---|---|
class |
BaseSemanticAnalyzer.AnalyzeRewriteContext |
static class |
BaseSemanticAnalyzer.TableSpec
TableSpec.
|
Modifier and Type | Field and Description |
---|---|
protected Set<FileSinkDesc> |
acidFileSinks
A set of FileSinkOperators being written to in an ACID compliant way.
|
protected ColumnAccessInfo |
columnAccessInfo |
protected HiveConf |
conf |
protected SessionState.LogHelper |
console |
protected Context |
ctx |
protected Hive |
db |
protected FetchTask |
fetchTask |
static int |
HIVE_COLUMN_ORDER_ASC |
static int |
HIVE_COLUMN_ORDER_DESC |
protected HashMap<String,String> |
idToTableNameMap |
protected HashSet<ReadEntity> |
inputs
ReadEntitites that are passed to the hooks.
|
protected LineageInfo |
linfo
Lineage information for the query.
|
protected org.apache.commons.logging.Log |
LOG |
protected HashSet<WriteEntity> |
outputs
List of WriteEntities that are passed to the hooks.
|
protected QueryProperties |
queryProperties |
protected List<Task<? extends Serializable>> |
rootTasks |
protected static org.apache.commons.logging.Log |
STATIC_LOG |
protected TableAccessInfo |
tableAccessInfo |
protected ColumnAccessInfo |
updateColumnAccessInfo
Columns accessed by updates
|
Constructor and Description |
---|
BaseSemanticAnalyzer(HiveConf conf) |
BaseSemanticAnalyzer(HiveConf conf,
Hive db) |
Modifier and Type | Method and Description |
---|---|
void |
analyze(ASTNode ast,
Context ctx) |
protected void |
analyzeDDLSkewedValues(List<List<String>> skewedValues,
ASTNode child)
Handle skewed values in DDL.
|
abstract void |
analyzeInternal(ASTNode ast) |
protected List<String> |
analyzeSkewedTablDDLColNames(List<String> skewedColNames,
ASTNode child)
Analyze list bucket column names
|
protected boolean |
analyzeStoredAdDirs(ASTNode child)
process stored as directories
|
static String |
charSetString(String charSetName,
String charSetString) |
protected ListBucketingCtx |
constructListBucketingCtx(List<String> skewedColNames,
List<List<String>> skewedValues,
Map<List<String>,String> skewedColValueLocationMaps,
boolean isStoredAsSubDirectories,
HiveConf conf)
Construct list bucketing context.
|
protected static Hive |
createHiveDB(HiveConf conf) |
static String |
escapeSQLString(String b)
Escapes the string for AST; doesn't enclose it in quotes, however.
|
Set<FileSinkDesc> |
getAcidFileSinks() |
ColumnAccessInfo |
getColumnAccessInfo()
Gets the column access information.
|
static List<String> |
getColumnNames(ASTNode ast) |
protected List<Order> |
getColumnNamesOrder(ASTNode ast) |
protected List<FieldSchema> |
getColumns(ASTNode ast) |
static List<FieldSchema> |
getColumns(ASTNode ast,
boolean lowerCase)
Get the list of FieldSchema out of the ASTNode.
|
protected Database |
getDatabase(String dbName) |
protected Database |
getDatabase(String dbName,
boolean throwException) |
Hive |
getDb() |
static Map.Entry<String,String> |
getDbTableNamePair(ASTNode tableNameNode) |
static String |
getDotName(String[] qname) |
FetchTask |
getFetchTask() |
HashMap<String,String> |
getIdToTableNameMap() |
HashSet<ReadEntity> |
getInputs() |
LineageInfo |
getLineageInfo()
Gets the lineage information.
|
HashSet<WriteEntity> |
getOutputs() |
protected Partition |
getPartition(Table table,
Map<String,String> partSpec,
boolean throwException) |
protected List<Partition> |
getPartitions(Table table,
Map<String,String> partSpec,
boolean throwException) |
static String[] |
getQualifiedTableName(ASTNode tabNameNode) |
QueryProperties |
getQueryProperties() |
List<FieldSchema> |
getResultSchema() |
List<Task<? extends Serializable>> |
getRootTasks() |
protected List<String> |
getSkewedValueFromASTNode(ASTNode ast)
Given a ASTNode, return list of values.
|
protected List<String> |
getSkewedValuesFromASTNode(Node node)
Retrieve skewed values from ASTNode.
|
protected Table |
getTable(String tblName) |
protected Table |
getTable(String[] qualified) |
protected Table |
getTable(String[] qualified,
boolean throwException) |
protected Table |
getTable(String tblName,
boolean throwException) |
protected Table |
getTable(String database,
String tblName,
boolean throwException) |
TableAccessInfo |
getTableAccessInfo()
Gets the table access information.
|
protected static String |
getTypeStringFromAST(ASTNode typeNode) |
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.
|
ColumnAccessInfo |
getUpdateColumnAccessInfo() |
void |
init(boolean clearPartsCache) |
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.
|
protected void |
reset(boolean clearPartsCache) |
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.
|
void |
setUpdateColumnAccessInfo(ColumnAccessInfo updateColumnAccessInfo) |
boolean |
skipAuthorization() |
static String |
stripIdentifierQuotes(String val) |
static String |
stripQuotes(String val) |
protected String |
toMessage(ErrorMsg message,
Object detail) |
protected ReadEntity |
toReadEntity(org.apache.hadoop.fs.Path location) |
protected ReadEntity |
toReadEntity(String location) |
protected WriteEntity |
toWriteEntity(org.apache.hadoop.fs.Path location) |
protected WriteEntity |
toWriteEntity(String location) |
static String |
unescapeIdentifier(String val)
Remove the encapsulating "`" pair from the identifier.
|
static String |
unescapeSQLString(String b) |
void |
validate() |
static void |
validatePartColumnType(Table tbl,
Map<String,String> partSpec,
ASTNode astNode,
HiveConf conf) |
static void |
validatePartSpec(Table tbl,
Map<String,String> partSpec,
ASTNode astNode,
HiveConf conf,
boolean shouldBeFull) |
protected static final org.apache.commons.logging.Log STATIC_LOG
protected final Hive db
protected final HiveConf conf
protected List<Task<? extends Serializable>> rootTasks
protected FetchTask fetchTask
protected final org.apache.commons.logging.Log LOG
protected final SessionState.LogHelper console
protected Context ctx
protected QueryProperties queryProperties
protected Set<FileSinkDesc> acidFileSinks
public static int HIVE_COLUMN_ORDER_ASC
public static int HIVE_COLUMN_ORDER_DESC
protected HashSet<ReadEntity> inputs
protected HashSet<WriteEntity> outputs
protected LineageInfo linfo
protected TableAccessInfo tableAccessInfo
protected ColumnAccessInfo columnAccessInfo
protected ColumnAccessInfo updateColumnAccessInfo
public BaseSemanticAnalyzer(HiveConf conf) throws SemanticException
SemanticException
public BaseSemanticAnalyzer(HiveConf conf, Hive db) throws SemanticException
SemanticException
public boolean skipAuthorization()
protected static Hive createHiveDB(HiveConf conf) throws SemanticException
SemanticException
public abstract void analyzeInternal(ASTNode ast) throws SemanticException
SemanticException
public void init(boolean clearPartsCache)
public void initCtx(Context ctx)
public void analyze(ASTNode ast, Context ctx) throws SemanticException
SemanticException
public void validate() throws SemanticException
SemanticException
public List<Task<? extends Serializable>> getRootTasks()
public FetchTask getFetchTask()
public void setFetchTask(FetchTask fetchTask)
fetchTask
- the fetchTask to setprotected void reset(boolean clearPartsCache)
public static String charSetString(String charSetName, String charSetString) throws SemanticException
SemanticException
public static String getUnescapedName(ASTNode tableOrColumnNode)
tableOrColumnNode
- the table or column nodepublic static String getUnescapedName(ASTNode tableOrColumnNode, String currentDatabase)
public static String[] getQualifiedTableName(ASTNode tabNameNode) throws SemanticException
SemanticException
public static String getDotName(String[] qname) throws SemanticException
SemanticException
public static String getUnescapedUnqualifiedTableName(ASTNode node)
node
- the table nodepublic static String unescapeIdentifier(String val)
public static void readProps(ASTNode prop, Map<String,String> mapProp)
prop
- ASTNode parent of the key/value pairsmapProp
- property map which receives the mappingspublic static String escapeSQLString(String b)
public HashSet<ReadEntity> getInputs()
public HashSet<WriteEntity> getOutputs()
public List<FieldSchema> getResultSchema()
protected List<FieldSchema> getColumns(ASTNode ast) throws SemanticException
SemanticException
public static List<FieldSchema> getColumns(ASTNode ast, boolean lowerCase) throws SemanticException
SemanticException
protected static String getTypeStringFromAST(ASTNode typeNode) throws SemanticException
SemanticException
public LineageInfo getLineageInfo()
public void setLineageInfo(LineageInfo linfo)
linfo
- The LineageInfo structure that is set in the optimization phase.public TableAccessInfo getTableAccessInfo()
public void setTableAccessInfo(TableAccessInfo tableAccessInfo)
tableAccessInfo
- The TableAccessInfo structure that is set in the optimization phase.public ColumnAccessInfo getColumnAccessInfo()
public void setColumnAccessInfo(ColumnAccessInfo columnAccessInfo)
columnAccessInfo
- The ColumnAccessInfo structure that is set immediately after
the optimization phase.public ColumnAccessInfo getUpdateColumnAccessInfo()
public void setUpdateColumnAccessInfo(ColumnAccessInfo updateColumnAccessInfo)
public final boolean isValidPrefixSpec(Table tTable, Map<String,String> spec) throws HiveException
spec
- specification key-value mapHiveException
public Hive getDb()
public QueryProperties getQueryProperties()
public Set<FileSinkDesc> getAcidFileSinks()
protected ListBucketingCtx constructListBucketingCtx(List<String> skewedColNames, List<List<String>> skewedValues, Map<List<String>,String> skewedColValueLocationMaps, boolean isStoredAsSubDirectories, HiveConf conf)
skewedColNames
- skewedValues
- skewedColValueLocationMaps
- isStoredAsSubDirectories
- protected List<String> getSkewedValueFromASTNode(ASTNode ast)
ast
- protected List<String> getSkewedValuesFromASTNode(Node node) throws SemanticException
node
- SemanticException
protected List<String> analyzeSkewedTablDDLColNames(List<String> skewedColNames, ASTNode child) throws SemanticException
skewedColNames
- child
- SemanticException
protected void analyzeDDLSkewedValues(List<List<String>> skewedValues, ASTNode child) throws SemanticException
skewedValues
- child
- SemanticException
protected boolean analyzeStoredAdDirs(ASTNode child)
child
- public static void validatePartSpec(Table tbl, Map<String,String> partSpec, ASTNode astNode, HiveConf conf, boolean shouldBeFull) throws SemanticException
SemanticException
public static void validatePartColumnType(Table tbl, Map<String,String> partSpec, ASTNode astNode, HiveConf conf) throws SemanticException
SemanticException
protected WriteEntity toWriteEntity(String location) throws SemanticException
SemanticException
protected WriteEntity toWriteEntity(org.apache.hadoop.fs.Path location) throws SemanticException
SemanticException
protected ReadEntity toReadEntity(String location) throws SemanticException
SemanticException
protected ReadEntity toReadEntity(org.apache.hadoop.fs.Path location) throws SemanticException
SemanticException
protected Database getDatabase(String dbName) throws SemanticException
SemanticException
protected Database getDatabase(String dbName, boolean throwException) throws SemanticException
SemanticException
protected Table getTable(String[] qualified) throws SemanticException
SemanticException
protected Table getTable(String[] qualified, boolean throwException) throws SemanticException
SemanticException
protected Table getTable(String tblName) throws SemanticException
SemanticException
protected Table getTable(String tblName, boolean throwException) throws SemanticException
SemanticException
protected Table getTable(String database, String tblName, boolean throwException) throws SemanticException
SemanticException
protected Partition getPartition(Table table, Map<String,String> partSpec, boolean throwException) throws SemanticException
SemanticException
protected List<Partition> getPartitions(Table table, Map<String,String> partSpec, boolean throwException) throws SemanticException
SemanticException
Copyright © 2017 The Apache Software Foundation. All rights reserved.