public abstract class BaseSemanticAnalyzer extends Object
| Modifier and Type | Class and Description |
|---|---|
static 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 CacheUsage |
cacheUsage |
protected CompilationOpContext |
cContext |
protected ColumnAccessInfo |
columnAccessInfo |
protected HiveConf |
conf |
protected SessionState.LogHelper |
console |
protected Context |
ctx |
protected Hive |
db |
protected FetchTask |
fetchTask |
protected Map<String,String> |
idToTableNameMap |
protected Set<ReadEntity> |
inputs
ReadEntities that are passed to the hooks.
|
protected LineageInfo |
linfo
Lineage information for the query.
|
protected org.slf4j.Logger |
LOG |
protected Set<WriteEntity> |
outputs
List of WriteEntities that are passed to the hooks.
|
protected Boolean |
prepareQuery |
protected QueryProperties |
queryProperties |
protected QueryState |
queryState |
protected List<Task<?>> |
rootTasks |
protected static org.slf4j.Logger |
STATIC_LOG |
protected TableAccessInfo |
tableAccessInfo |
protected boolean |
transactionalInQuery |
protected HiveTxnManager |
txnManager |
protected ColumnAccessInfo |
updateColumnAccessInfo
Columns accessed by updates
|
| Constructor and Description |
|---|
BaseSemanticAnalyzer(QueryState queryState) |
BaseSemanticAnalyzer(QueryState queryState,
Hive db) |
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyReadEntry(Map<String,String> tblProps,
Set<ReadEntity> inputs) |
void |
analyze(ASTNode ast,
Context ctx) |
abstract void |
analyzeInternal(ASTNode ast) |
protected boolean |
analyzeStoredAdDirs(ASTNode child)
process stored as directories
|
static String |
charSetString(String charSetName,
String charSetString) |
static void |
checkColumnName(String columnName) |
protected ListBucketingCtx |
constructListBucketingCtx(List<String> skewedColNames,
List<List<String>> skewedValues,
Map<List<String>,String> skewedColValueLocationMaps,
boolean isStoredAsSubDirectories) |
protected FetchTask |
createFetchTask(String tableSchema)
Create a FetchTask for a given schema.
|
protected static Hive |
createHiveDB(HiveConf conf) |
void |
endAnalysis()
Called when we end analysis of a query.
|
static String |
escapeSQLString(String b)
Escapes the string for AST; doesn't enclose it in quotes, however.
|
protected void |
executeUnparseTranlations()
Unparses the analyzed statement
|
protected static int[] |
findTabRefIdxs(ASTNode tabref) |
WriteEntity |
getAcidAnalyzeTable() |
DDLDesc.DDLDescWithWriteId |
getAcidDdlDesc() |
Set<FileSinkDesc> |
getAcidFileSinks() |
Set<ReadEntity> |
getAllInputs() |
Set<WriteEntity> |
getAllOutputs() |
List<Task<?>> |
getAllRootTasks() |
Boolean |
getAutoCommitValue() |
CacheUsage |
getCacheUsage() |
String |
getCboInfo() |
ColumnAccessInfo |
getColumnAccessInfo()
Gets the column access information.
|
static List<String> |
getColumnNames(ASTNode ast) |
protected List<org.apache.hadoop.hive.metastore.api.Order> |
getColumnNamesOrder(ASTNode ast) |
protected List<org.apache.hadoop.hive.metastore.api.FieldSchema> |
getColumns(ASTNode ast) |
static List<org.apache.hadoop.hive.metastore.api.FieldSchema> |
getColumns(ASTNode ast,
boolean lowerCase,
org.apache.hadoop.conf.Configuration conf)
Get the list of FieldSchema out of the ASTNode.
|
static List<org.apache.hadoop.hive.metastore.api.FieldSchema> |
getColumns(ASTNode ast,
boolean lowerCase,
org.antlr.runtime.TokenRewriteStream tokenRewriteStream,
List<org.apache.hadoop.hive.metastore.api.SQLPrimaryKey> primaryKeys,
List<org.apache.hadoop.hive.metastore.api.SQLForeignKey> foreignKeys,
List<org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint> uniqueConstraints,
List<org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint> notNullConstraints,
List<org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint> defaultConstraints,
List<org.apache.hadoop.hive.metastore.api.SQLCheckConstraint> checkConstraints,
org.apache.hadoop.conf.Configuration conf)
Get the list of FieldSchema out of the ASTNode.
|
Context |
getCtx() |
protected org.apache.hadoop.hive.metastore.api.Database |
getDatabase(String dbName) |
protected org.apache.hadoop.hive.metastore.api.Database |
getDatabase(String dbName,
boolean throwException) |
protected org.apache.hadoop.hive.metastore.api.DataConnector |
getDataConnector(String dbName) |
protected org.apache.hadoop.hive.metastore.api.DataConnector |
getDataConnector(String dcName,
boolean throwException) |
Hive |
getDb() |
static Map.Entry<String,String> |
getDbTableNamePair(ASTNode tableNameNode) |
FetchTask |
getFetchTask() |
Map<String,String> |
getIdToTableNameMap() |
Set<ReadEntity> |
getInputs() |
LineageInfo |
getLineageInfo()
Gets the lineage information.
|
Set<WriteEntity> |
getOutputs() |
ParseContext |
getParseContext() |
List<Map<String,String>> |
getPartitionSpecs(Table tbl,
org.antlr.runtime.tree.CommonTree ast)
Get the partition specs from the tree.
|
static Map<String,String> |
getPartSpec(ASTNode node) |
static Map<String,String> |
getProps(ASTNode prop) |
static TableName |
getQualifiedTableName(ASTNode tabNameNode)
Get the name reference of a DB table node.
|
static TableName |
getQualifiedTableName(ASTNode tabNameNode,
String catalogName)
Get the name reference of a DB table node.
|
QueryProperties |
getQueryProperties() |
QueryState |
getQueryState() |
List<org.apache.hadoop.hive.metastore.api.FieldSchema> |
getResultSchema() |
List<Task<?>> |
getRootTasks() |
protected static String |
getSimpleTableNameBase(ASTNode n) |
protected Table |
getTable(String tblName) |
protected Table |
getTable(String tblName,
boolean throwException) |
protected Table |
getTable(String database,
String tblName,
boolean throwException) |
protected Table |
getTable(String database,
String tblName,
String metaTableName,
boolean throwException) |
protected Table |
getTable(TableName tn) |
protected Table |
getTable(TableName tn,
boolean throwException) |
TableAccessInfo |
getTableAccessInfo()
Gets the table access information.
|
static String |
getTableAlias(ASTNode node) |
protected HiveTxnManager |
getTxnMgr() |
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() |
static Map<String,String> |
getValidatedPartSpec(Table table,
ASTNode astNode,
HiveConf conf,
boolean shouldBeFull) |
boolean |
hasTransactionalInQuery() |
void |
init(boolean clearPartsCache) |
void |
initCtx(Context ctx) |
boolean |
isPrepareQuery() |
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')
|
protected static IllegalArgumentException |
raiseWrongType(String expectedTokName,
ASTNode n) |
static void |
readProps(ASTNode prop,
Map<String,String> mapProp)
Converts parsed key/value properties pairs into a map.
|
protected void |
reset(boolean clearPartsCache) |
void |
setAutoCommitValue(Boolean autoCommit) |
void |
setCacheUsage(CacheUsage cacheUsage) |
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() |
void |
startAnalysis()
Called when we start analysis of a query.
|
static String |
stripQuotes(String val) |
protected ReadEntity |
toReadEntity(org.apache.hadoop.fs.Path location) |
static ReadEntity |
toReadEntity(org.apache.hadoop.fs.Path location,
HiveConf conf) |
protected ReadEntity |
toReadEntity(String location) |
protected WriteEntity |
toWriteEntity(org.apache.hadoop.fs.Path location) |
static WriteEntity |
toWriteEntity(org.apache.hadoop.fs.Path location,
HiveConf conf) |
protected WriteEntity |
toWriteEntity(String location) |
static org.apache.hadoop.fs.Path |
tryQualifyPath(org.apache.hadoop.fs.Path path,
HiveConf conf) |
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 void |
validateUnsupportedPartitionClause(Table tbl,
boolean partitionClausePresent)
Throws an UnsupportedOperationException in case the query has a partition clause but the table is never partitioned
on the HMS-level.
|
protected static final org.slf4j.Logger STATIC_LOG
protected final Hive db
protected final HiveConf conf
protected final QueryState queryState
protected FetchTask fetchTask
protected final org.slf4j.Logger LOG
protected final SessionState.LogHelper console
protected CompilationOpContext cContext
protected Context ctx
protected QueryProperties queryProperties
protected Set<FileSinkDesc> acidFileSinks
protected boolean transactionalInQuery
protected HiveTxnManager txnManager
protected Set<ReadEntity> inputs
protected Set<WriteEntity> outputs
protected LineageInfo linfo
protected TableAccessInfo tableAccessInfo
protected ColumnAccessInfo columnAccessInfo
protected CacheUsage cacheUsage
protected ColumnAccessInfo updateColumnAccessInfo
protected Boolean prepareQuery
public BaseSemanticAnalyzer(QueryState queryState) throws SemanticException
SemanticExceptionpublic BaseSemanticAnalyzer(QueryState queryState, Hive db) throws SemanticException
SemanticExceptionpublic Boolean getAutoCommitValue()
public void setAutoCommitValue(Boolean autoCommit)
public boolean skipAuthorization()
public String getCboInfo()
public boolean isPrepareQuery()
protected static Hive createHiveDB(HiveConf conf) throws SemanticException
SemanticExceptionpublic abstract void analyzeInternal(ASTNode ast) throws SemanticException
SemanticExceptionpublic void init(boolean clearPartsCache)
public void initCtx(Context ctx)
public Context getCtx()
public void analyze(ASTNode ast, Context ctx) throws SemanticException
SemanticExceptionpublic void validate()
throws SemanticException
SemanticExceptionpublic 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
SemanticExceptionpublic static String getUnescapedName(ASTNode tableOrColumnNode) throws SemanticException
tableOrColumnNode - the table or column nodeSemanticExceptionpublic static Map.Entry<String,String> getDbTableNamePair(ASTNode tableNameNode) throws SemanticException
SemanticExceptionpublic static String getUnescapedName(ASTNode tableOrColumnNode, String currentDatabase) throws SemanticException
SemanticExceptionpublic static TableName getQualifiedTableName(ASTNode tabNameNode) throws SemanticException
tabNameNode - TableName, not null. The catalog will be missing from this.SemanticExceptionpublic static TableName getQualifiedTableName(ASTNode tabNameNode, String catalogName) throws SemanticException
tabNameNode - catalogName - the catalog of the DB/objectTableName, not null. The catalog will be missing from this.SemanticExceptionpublic static String getUnescapedUnqualifiedTableName(ASTNode node) throws SemanticException
node - the table nodeSemanticExceptionpublic static String getTableAlias(ASTNode node) throws SemanticException
SemanticExceptionprotected static String getSimpleTableNameBase(ASTNode n) throws SemanticException
SemanticExceptionprotected static IllegalArgumentException raiseWrongType(String expectedTokName, ASTNode n)
protected static int[] findTabRefIdxs(ASTNode tabref)
public 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 Set<ReadEntity> getInputs()
public Set<WriteEntity> getOutputs()
public List<org.apache.hadoop.hive.metastore.api.FieldSchema> getResultSchema()
protected List<org.apache.hadoop.hive.metastore.api.FieldSchema> getColumns(ASTNode ast) throws SemanticException
SemanticExceptionpublic static List<org.apache.hadoop.hive.metastore.api.FieldSchema> getColumns(ASTNode ast, boolean lowerCase, org.apache.hadoop.conf.Configuration conf) throws SemanticException
SemanticExceptionpublic static void checkColumnName(String columnName) throws SemanticException
SemanticExceptionpublic static List<org.apache.hadoop.hive.metastore.api.FieldSchema> getColumns(ASTNode ast, boolean lowerCase, org.antlr.runtime.TokenRewriteStream tokenRewriteStream, List<org.apache.hadoop.hive.metastore.api.SQLPrimaryKey> primaryKeys, List<org.apache.hadoop.hive.metastore.api.SQLForeignKey> foreignKeys, List<org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint> uniqueConstraints, List<org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint> notNullConstraints, List<org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint> defaultConstraints, List<org.apache.hadoop.hive.metastore.api.SQLCheckConstraint> checkConstraints, org.apache.hadoop.conf.Configuration conf) throws SemanticException
SemanticExceptionprotected List<org.apache.hadoop.hive.metastore.api.Order> getColumnNamesOrder(ASTNode ast) throws SemanticException
SemanticExceptionpublic static String getTypeStringFromAST(ASTNode typeNode) throws SemanticException
SemanticExceptionpublic 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 mapHiveExceptionpublic Hive getDb()
public QueryProperties getQueryProperties()
public Set<FileSinkDesc> getAcidFileSinks()
public boolean hasTransactionalInQuery()
protected ListBucketingCtx constructListBucketingCtx(List<String> skewedColNames, List<List<String>> skewedValues, Map<List<String>,String> skewedColValueLocationMaps, boolean isStoredAsSubDirectories)
protected boolean analyzeStoredAdDirs(ASTNode child)
child - public List<Map<String,String>> getPartitionSpecs(Table tbl, org.antlr.runtime.tree.CommonTree ast) throws SemanticException
ast - Tree to extract partitions from.SemanticExceptionpublic static Map<String,String> getValidatedPartSpec(Table table, ASTNode astNode, HiveConf conf, boolean shouldBeFull) throws SemanticException
SemanticExceptionpublic static Map<String,String> getPartSpec(ASTNode node) throws SemanticException
SemanticExceptionpublic static void validatePartSpec(Table tbl, Map<String,String> partSpec, ASTNode astNode, HiveConf conf, boolean shouldBeFull) throws SemanticException
SemanticExceptionprotected static void validateUnsupportedPartitionClause(Table tbl, boolean partitionClausePresent)
tbl - The table object, should not be null.partitionClausePresent - Whether a partition clause is present in the query (e.g. PARTITION(last_name='Don'))public static void validatePartColumnType(Table tbl, Map<String,String> partSpec, ASTNode astNode, HiveConf conf) throws SemanticException
SemanticExceptionprotected WriteEntity toWriteEntity(String location) throws SemanticException
SemanticExceptionprotected WriteEntity toWriteEntity(org.apache.hadoop.fs.Path location) throws SemanticException
SemanticExceptionpublic static WriteEntity toWriteEntity(org.apache.hadoop.fs.Path location, HiveConf conf) throws SemanticException
SemanticExceptionprotected ReadEntity toReadEntity(String location) throws SemanticException
SemanticExceptionprotected ReadEntity toReadEntity(org.apache.hadoop.fs.Path location) throws SemanticException
SemanticExceptionpublic static ReadEntity toReadEntity(org.apache.hadoop.fs.Path location, HiveConf conf) throws SemanticException
SemanticExceptionpublic static org.apache.hadoop.fs.Path tryQualifyPath(org.apache.hadoop.fs.Path path,
HiveConf conf)
throws IOException
IOExceptionprotected org.apache.hadoop.hive.metastore.api.Database getDatabase(String dbName) throws SemanticException
SemanticExceptionprotected org.apache.hadoop.hive.metastore.api.Database getDatabase(String dbName, boolean throwException) throws SemanticException
SemanticExceptionprotected org.apache.hadoop.hive.metastore.api.DataConnector getDataConnector(String dbName) throws SemanticException
SemanticExceptionprotected org.apache.hadoop.hive.metastore.api.DataConnector getDataConnector(String dcName, boolean throwException) throws SemanticException
SemanticExceptionprotected Table getTable(TableName tn) throws SemanticException
SemanticExceptionprotected Table getTable(TableName tn, boolean throwException) throws SemanticException
SemanticExceptionprotected Table getTable(String tblName) throws SemanticException
SemanticExceptionprotected Table getTable(String tblName, boolean throwException) throws SemanticException
SemanticExceptionprotected Table getTable(String database, String tblName, boolean throwException) throws SemanticException
SemanticExceptionprotected Table getTable(String database, String tblName, String metaTableName, boolean throwException) throws SemanticException
SemanticExceptionpublic Set<ReadEntity> getAllInputs()
public Set<WriteEntity> getAllOutputs()
public QueryState getQueryState()
protected FetchTask createFetchTask(String tableSchema)
protected HiveTxnManager getTxnMgr()
public CacheUsage getCacheUsage()
public void setCacheUsage(CacheUsage cacheUsage)
public DDLDesc.DDLDescWithWriteId getAcidDdlDesc()
public WriteEntity getAcidAnalyzeTable()
public void addPropertyReadEntry(Map<String,String> tblProps, Set<ReadEntity> inputs) throws SemanticException
SemanticExceptionprotected void executeUnparseTranlations()
public void startAnalysis()
public void endAnalysis()
public ParseContext getParseContext()
Copyright © 2022 The Apache Software Foundation. All rights reserved.