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 CacheUsage |
cacheUsage |
protected CompilationOpContext |
cContext |
protected ColumnAccessInfo |
columnAccessInfo |
protected HiveConf |
conf |
protected SessionState.LogHelper |
console |
protected Context |
ctx |
protected Hive |
db |
protected FetchTask |
fetchTask |
static int |
HIVE_COLUMN_NULLS_FIRST |
static int |
HIVE_COLUMN_NULLS_LAST |
static int |
HIVE_COLUMN_ORDER_ASC |
static int |
HIVE_COLUMN_ORDER_DESC |
protected HashMap<String,String> |
idToTableNameMap |
protected HashSet<ReadEntity> |
inputs
ReadEntities that are passed to the hooks.
|
protected LineageInfo |
linfo
Lineage information for the query.
|
protected org.slf4j.Logger |
LOG |
protected HashSet<WriteEntity> |
outputs
List of WriteEntities that are passed to the hooks.
|
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 |
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 FetchTask |
createFetchTask(String schema)
Create a FetchTask for a given schema.
|
protected static Hive |
createHiveDB(HiveConf conf) |
static String |
escapeSQLString(String b)
Escapes the string for AST; doesn't enclose it in quotes, however.
|
DDLDesc.DDLDescWithWriteId |
getAcidDdlDesc() |
Set<FileSinkDesc> |
getAcidFileSinks() |
HashSet<ReadEntity> |
getAllInputs() |
HashSet<WriteEntity> |
getAllOutputs() |
List<Task<? extends Serializable>> |
getAllRootTasks() |
Boolean |
getAutoCommitValue() |
CacheUsage |
getCacheUsage() |
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.
|
protected org.apache.hadoop.hive.metastore.api.Database |
getDatabase(String dbName) |
protected org.apache.hadoop.hive.metastore.api.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() |
QueryState |
getQueryState() |
List<org.apache.hadoop.hive.metastore.api.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 HiveTxnManager |
getTxnMgr() |
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() |
protected boolean |
hasEnabledOrValidatedConstraints(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) |
boolean |
hasTransactionalInQuery() |
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')
|
protected static void |
processCheckConstraints(String catName,
String databaseName,
String tableName,
ASTNode child,
List<String> columnNames,
List<org.apache.hadoop.hive.metastore.api.SQLCheckConstraint> checkConstraints,
ASTNode typeChild,
org.antlr.runtime.TokenRewriteStream tokenRewriteStream) |
protected static void |
processDefaultConstraints(String catName,
String databaseName,
String tableName,
ASTNode child,
List<String> columnNames,
List<org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint> defaultConstraints,
ASTNode typeChild,
org.antlr.runtime.TokenRewriteStream tokenRewriteStream) |
protected static void |
processForeignKeys(String databaseName,
String tableName,
ASTNode child,
List<org.apache.hadoop.hive.metastore.api.SQLForeignKey> foreignKeys)
Process the foreign keys from the AST and populate the foreign keys in the SQLForeignKey list
|
protected static void |
processNotNullConstraints(String catName,
String databaseName,
String tableName,
ASTNode child,
List<String> columnNames,
List<org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint> notNullConstraints) |
protected static void |
processPrimaryKeys(String databaseName,
String tableName,
ASTNode child,
List<org.apache.hadoop.hive.metastore.api.SQLPrimaryKey> primaryKeys)
Process the primary keys from the ast node and populate the SQLPrimaryKey list.
|
protected static void |
processPrimaryKeys(String databaseName,
String tableName,
ASTNode child,
List<String> columnNames,
List<org.apache.hadoop.hive.metastore.api.SQLPrimaryKey> primaryKeys) |
protected static void |
processUniqueConstraints(String catName,
String databaseName,
String tableName,
ASTNode child,
List<org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint> uniqueConstraints)
Process the unique constraints from the ast node and populate the SQLUniqueConstraint list.
|
protected static void |
processUniqueConstraints(String catName,
String databaseName,
String tableName,
ASTNode child,
List<String> columnNames,
List<org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint> uniqueConstraints) |
static void |
readProps(ASTNode prop,
Map<String,String> mapProp)
Converts parsed key/value properties pairs into a map.
|
protected void |
reset(boolean clearPartsCache) |
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() |
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) |
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 |
validateCheckConstraint(List<org.apache.hadoop.hive.metastore.api.FieldSchema> cols,
List<org.apache.hadoop.hive.metastore.api.SQLCheckConstraint> checkConstraints,
org.apache.hadoop.conf.Configuration conf) |
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.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
public static final int HIVE_COLUMN_ORDER_ASC
public static final int HIVE_COLUMN_ORDER_DESC
public static final int HIVE_COLUMN_NULLS_FIRST
public static final int HIVE_COLUMN_NULLS_LAST
protected HashSet<ReadEntity> inputs
protected HashSet<WriteEntity> outputs
protected LineageInfo linfo
protected TableAccessInfo tableAccessInfo
protected ColumnAccessInfo columnAccessInfo
protected CacheUsage cacheUsage
protected ColumnAccessInfo updateColumnAccessInfo
public BaseSemanticAnalyzer(QueryState queryState) throws SemanticException
SemanticExceptionpublic BaseSemanticAnalyzer(QueryState queryState, Hive db) throws SemanticException
SemanticExceptionpublic Boolean getAutoCommitValue()
public boolean skipAuthorization()
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 void analyze(ASTNode ast, Context ctx) throws SemanticException
SemanticExceptionpublic void validate()
throws SemanticException
SemanticExceptionpublic 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
SemanticExceptionpublic 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
SemanticExceptionpublic static String getDotName(String[] qname) throws SemanticException
SemanticExceptionpublic 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<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
SemanticExceptionprotected static void processPrimaryKeys(String databaseName, String tableName, ASTNode child, List<org.apache.hadoop.hive.metastore.api.SQLPrimaryKey> primaryKeys) throws SemanticException
SemanticExceptionprotected static void processPrimaryKeys(String databaseName, String tableName, ASTNode child, List<String> columnNames, List<org.apache.hadoop.hive.metastore.api.SQLPrimaryKey> primaryKeys) throws SemanticException
SemanticExceptionprotected static void processUniqueConstraints(String catName, String databaseName, String tableName, ASTNode child, List<org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint> uniqueConstraints) throws SemanticException
SemanticExceptionprotected static void processUniqueConstraints(String catName, String databaseName, String tableName, ASTNode child, List<String> columnNames, List<org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint> uniqueConstraints) throws SemanticException
SemanticExceptionprotected static void processCheckConstraints(String catName, String databaseName, String tableName, ASTNode child, List<String> columnNames, List<org.apache.hadoop.hive.metastore.api.SQLCheckConstraint> checkConstraints, ASTNode typeChild, org.antlr.runtime.TokenRewriteStream tokenRewriteStream) throws SemanticException
SemanticExceptionprotected static void processDefaultConstraints(String catName, String databaseName, String tableName, ASTNode child, List<String> columnNames, List<org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint> defaultConstraints, ASTNode typeChild, org.antlr.runtime.TokenRewriteStream tokenRewriteStream) throws SemanticException
SemanticExceptionprotected static void processNotNullConstraints(String catName, String databaseName, String tableName, ASTNode child, List<String> columnNames, List<org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint> notNullConstraints) throws SemanticException
SemanticExceptionpublic static void validateCheckConstraint(List<org.apache.hadoop.hive.metastore.api.FieldSchema> cols, List<org.apache.hadoop.hive.metastore.api.SQLCheckConstraint> checkConstraints, org.apache.hadoop.conf.Configuration conf) throws SemanticException
SemanticExceptionprotected static void processForeignKeys(String databaseName, String tableName, ASTNode child, List<org.apache.hadoop.hive.metastore.api.SQLForeignKey> foreignKeys) throws SemanticException
child - Foreign Key token nodeforeignKeys - SQLForeignKey listSemanticExceptionprotected boolean hasEnabledOrValidatedConstraints(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)
public 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
SemanticExceptionprotected 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, HiveConf conf)
skewedColNames - skewedValues - skewedColValueLocationMaps - isStoredAsSubDirectories - protected List<String> getSkewedValueFromASTNode(ASTNode ast)
ast - protected List<String> getSkewedValuesFromASTNode(Node node) throws SemanticException
node - SemanticExceptionprotected List<String> analyzeSkewedTablDDLColNames(List<String> skewedColNames, ASTNode child) throws SemanticException
skewedColNames - child - SemanticExceptionprotected void analyzeDDLSkewedValues(List<List<String>> skewedValues, ASTNode child) throws SemanticException
skewedValues - child - SemanticExceptionprotected boolean analyzeStoredAdDirs(ASTNode child)
child - public static void validatePartSpec(Table tbl, Map<String,String> partSpec, ASTNode astNode, HiveConf conf, boolean shouldBeFull) throws SemanticException
SemanticExceptionpublic 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 Table getTable(String[] qualified) throws SemanticException
SemanticExceptionprotected Table getTable(String[] qualified, 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 Partition getPartition(Table table, Map<String,String> partSpec, boolean throwException) throws SemanticException
SemanticExceptionprotected List<Partition> getPartitions(Table table, Map<String,String> partSpec, boolean throwException) throws SemanticException
SemanticExceptionpublic List<Task<? extends Serializable>> getAllRootTasks()
public HashSet<ReadEntity> getAllInputs()
public HashSet<WriteEntity> getAllOutputs()
public QueryState getQueryState()
protected FetchTask createFetchTask(String schema)
schema - stringprotected HiveTxnManager getTxnMgr()
public CacheUsage getCacheUsage()
public void setCacheUsage(CacheUsage cacheUsage)
public DDLDesc.DDLDescWithWriteId getAcidDdlDesc()
Copyright © 2019 The Apache Software Foundation. All Rights Reserved.