public class MetaStoreUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
MetaStoreUtils.FailoverEndpoint |
| Modifier and Type | Field and Description |
|---|---|
static int |
CAT_NAME
Position in the array returned by
parseDbName(java.lang.String, org.apache.hadoop.conf.Configuration) that has the catalog name. |
static String |
CATALOG_DB_SEPARATOR
This String is used to separate the catalog name from the database name.
|
static char |
CATALOG_DB_THRIFT_NAME_MARKER
This character is used to mark a database name as having a catalog name prepended.
|
static String |
DB_EMPTY_MARKER
Mark a database as being empty (as distinct from null).
|
static int |
DB_NAME
Position in the array returned by
parseDbName(java.lang.String, org.apache.hadoop.conf.Configuration) that has the database name. |
static String |
EXTERNAL_TABLE_PURGE |
static String |
NO_VAL |
static String |
TYPE_FROM_DESERIALIZER |
static String |
USER_NAME_HTTP_HEADER |
| Constructor and Description |
|---|
MetaStoreUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addPartitonSpecsToList(PartitionsSpecByExprResult r,
List<PartitionSpec> result) |
static ClassLoader |
addToClassPath(ClassLoader cloader,
String[] newPaths)
Add new elements to the classpath.
|
static boolean |
checkIfDbNeedsToBeSkipped(Database db) |
static boolean |
compareFieldColumns(List<FieldSchema> schema1,
List<FieldSchema> schema2) |
static List<Predicate<String>> |
compilePatternsToPredicates(List<String> patterns)
Compile a list of regex patterns and collect them as Predicates.
|
static String |
convertDateToString(Date date)
Converts java.sql.Date to String format date.
|
static Date |
convertStringToDate(String date)
Converts string format date to java.sql.Date.
|
static Timestamp |
convertStringToTimestamp(String timestamp)
Converts timestamp string format to java.sql.Timestamp.
|
static String |
convertTimestampToString(Timestamp timestamp)
Converts java.sql.Timestamp to string format timestamp.
|
static GetPartitionsByNamesRequest |
convertToGetPartitionsByNamesRequest(String dbName,
String tblName,
List<String> partNames) |
static GetPartitionsByNamesRequest |
convertToGetPartitionsByNamesRequest(String dbName,
String tblName,
List<String> partNames,
boolean getColStats,
String engine,
String validWriteIdList,
Long tableId) |
static <T> T |
createThriftPartitionsReq(Class<T> clazz,
org.apache.hadoop.conf.Configuration conf,
T... deepCopy) |
static String |
encodeTableName(String name) |
static <T> void |
filterMapkeys(Map<String,T> map,
List<Predicate<String>> predicates)
filters a given map with list of predicates.
|
static <T> void |
filterMapKeys(Map<String,T> map,
Predicate<String> predicate)
filters a given map with predicate provided.
|
static int |
getArchivingLevel(Partition part) |
static String |
getColumnCommentsFromFieldSchema(List<FieldSchema> fieldSchemas) |
static String |
getColumnNameDelimiter(List<FieldSchema> fieldSchemas) |
static List<String> |
getColumnNames(List<FieldSchema> schema) |
static List<String> |
getColumnNamesForTable(Table table) |
static String |
getColumnNamesFromFieldSchema(List<FieldSchema> fieldSchemas)
Convert FieldSchemas to columnNames.
|
static String |
getColumnTypesFromFieldSchema(List<FieldSchema> fieldSchemas) |
static String |
getColumnTypesFromFieldSchema(List<FieldSchema> fieldSchemas,
String delimiter)
Convert FieldSchemas to columnTypes.
|
static String |
getDbNameFromReplPolicy(String replPolicy) |
static String |
getDDLFromFieldSchema(String structName,
List<FieldSchema> fieldSchemas)
Convert FieldSchemas to Thrift DDL.
|
static String |
getDefaultCatalog(org.apache.hadoop.conf.Configuration conf) |
static String |
getHostFromId(String id) |
static String |
getHttpPath(String httpPath)
The config parameter can be like "path", "/path", "/path/", "path/*", "/path1/path2/*" and so on.
|
static Map<String,String> |
getMetaStoreSaslProperties(org.apache.hadoop.conf.Configuration conf,
boolean useSSL)
Read and return the meta store Sasl configuration.
|
static String |
getNoAutoCompact(Map<String,String> parameters)
Get no_auto_compact property by checking in both lower and upper cases
|
static org.apache.hadoop.fs.Path |
getOriginalLocation(Partition part) |
static Properties |
getPartitionMetadata(Partition partition,
Table table) |
static Properties |
getPartSchemaFromTableSchema(StorageDescriptor sd,
Map<String,String> parameters,
Properties tblSchema)
Get partition level schema from table level schema.
|
static List<String> |
getPvals(List<FieldSchema> partCols,
Map<String,String> partSpec)
Given a list of partition columns and a partial mapping from
some partition columns to values the function returns the values
for the column.
|
static List<String> |
getReplicationDbProps() |
static Properties |
getSchema(Partition part,
Table table) |
static Properties |
getSchema(StorageDescriptor sd,
StorageDescriptor tblsd,
Map<String,String> parameters,
String databaseName,
String tableName,
List<FieldSchema> partitionKeys) |
static Properties |
getSchemaWithoutCols(StorageDescriptor sd,
Map<String,String> parameters,
String databaseName,
String tableName,
List<FieldSchema> partitionKeys) |
static Properties |
getTableMetadata(Table table) |
static TableName |
getTableNameFor(Table table) |
static String |
getThreadIdFromId(String id) |
static boolean |
hasUnknownPartitions(PartitionsSpecByExprResult r) |
static boolean |
isArchived(Partition part) |
static boolean |
isBackgroundThreadsEnabledForRepl(Database db) |
static boolean |
isDbBeingPlannedFailedOver(Database db) |
static boolean |
isDbBeingPlannedFailedOverAtEndpoint(Database db,
MetaStoreUtils.FailoverEndpoint endPoint) |
static boolean |
isDbReplIncompatible(Database db) |
static boolean |
isExternal(Map<String,String> tableParams) |
static boolean |
isExternalTable(Table table)
Determines whether a table is an external table.
|
static boolean |
isExternalTablePurge(Table table)
Determines whether an table needs to be purged or not.
|
static boolean |
isIcebergTable(Map<String,String> params) |
static boolean |
isInsertOnlyTableParam(Map<String,String> params)
Duplicates AcidUtils; used in a couple places in metastore.
|
static boolean |
isMaterializedViewTable(Table table) |
static boolean |
isNoAutoCompactSet(Map<String,String> dbParameters,
Map<String,String> tblParameters)
Because TABLE_NO_AUTO_COMPACT was originally assumed to be NO_AUTO_COMPACT and then was moved
to no_auto_compact, we need to check it in both cases.
|
static boolean |
isNoCleanUpSet(Map<String,String> parameters) |
static boolean |
isNonNativeTable(Map<String,String> tblProps) |
static boolean |
isNonNativeTable(Table table) |
static boolean |
isPropertyTrue(Map<String,String> tableParams,
String prop) |
static boolean |
isSkipTrash(Map<String,String> tableParams)
Determines whether an table needs to be deleted completely or moved to trash directory.
|
static boolean |
isTargetOfReplication(Database db) |
static boolean |
isTranslatedToExternalTable(Table table) |
static boolean |
isValidSchedulingPolicy(String str) |
static boolean |
isView(Table table) |
static List<Object[]> |
makeOrderSpecs(String order)
Get order specs from a represented string.
|
static String |
makePartNameMatcher(Table table,
List<String> partVals,
String defaultStr) |
static MetaException |
newMetaException(Exception e)
convert Exception to MetaException, which sets the cause to such exception
|
static MetaException |
newMetaException(String errorMessage,
Exception e)
convert Exception to MetaException, which sets the cause to such exception
|
static String |
normalizeDate(String date)
Converts the string format date without a time-zone to
a time-zone based string format date
|
static String[] |
parseDbName(String dbName,
org.apache.hadoop.conf.Configuration conf)
Parse the catalog name out of the database name.
|
static WMPoolSchedulingPolicy |
parseSchedulingPolicy(String schedulingPolicy) |
static String |
prependCatalogToDbName(String dbName,
org.apache.hadoop.conf.Configuration conf)
Prepend the default 'hive' catalog onto the database name.
|
static String |
prependCatalogToDbName(String catalogName,
String dbName,
org.apache.hadoop.conf.Configuration conf)
Given a catalog name and database name cram them together into one string.
|
static String |
prependNotNullCatToDbName(String catalogName,
String dbName)
Given a catalog name and database name, cram them together into one string.
|
static void |
throwMetaException(Exception e)
Catches exceptions that cannot be handled and wraps them in MetaException.
|
static boolean |
validateName(String name,
org.apache.hadoop.conf.Configuration conf)
validateName
Checks the name conforms to our standars which are: "[a-zA-z_0-9]+".
|
static boolean |
validateTblStorage(StorageDescriptor sd) |
public static final String TYPE_FROM_DESERIALIZER
public static final char CATALOG_DB_THRIFT_NAME_MARKER
public static final String CATALOG_DB_SEPARATOR
CATALOG_DB_THRIFT_NAME_MARKER. # is
chosen because it is not used in regular expressions. this is only intended for use when
making old Thrift calls that do not support catalog names.public static final String DB_EMPTY_MARKER
public static final String EXTERNAL_TABLE_PURGE
public static final String NO_VAL
public static final String USER_NAME_HTTP_HEADER
public static final int CAT_NAME
parseDbName(java.lang.String, org.apache.hadoop.conf.Configuration) that has the catalog name.public static final int DB_NAME
parseDbName(java.lang.String, org.apache.hadoop.conf.Configuration) that has the database name.public static String convertDateToString(Date date)
date - - java.sql.Date object.public static Date convertStringToDate(String date)
date - Date in string format.public static String normalizeDate(String date)
date - the date without a time-zonepublic static String convertTimestampToString(Timestamp timestamp)
timestamp - java.sql.Timestamp object.public static Timestamp convertStringToTimestamp(String timestamp)
timestamp - Timestamp in string format.public static void throwMetaException(Exception e) throws MetaException
e - exception to wrap.MetaException - wrapper for the exceptionpublic static MetaException newMetaException(Exception e)
e - cause of the exceptionpublic static MetaException newMetaException(String errorMessage, Exception e)
errorMessage - the error message for this MetaExceptione - cause of the exceptionpublic static boolean validateTblStorage(StorageDescriptor sd)
public static boolean validateName(String name, org.apache.hadoop.conf.Configuration conf)
name - the name to validateconf - hive configurationpublic static boolean isExternalTable(Table table)
table - table of interestpublic static boolean isTranslatedToExternalTable(Table table)
public static boolean isDbReplIncompatible(Database db)
public static boolean isDbBeingPlannedFailedOver(Database db)
public static boolean isDbBeingPlannedFailedOverAtEndpoint(Database db, MetaStoreUtils.FailoverEndpoint endPoint)
public static boolean isTargetOfReplication(Database db)
public static boolean isBackgroundThreadsEnabledForRepl(Database db)
public static boolean checkIfDbNeedsToBeSkipped(Database db)
public static boolean isExternalTablePurge(Table table)
table - table of interestpublic static boolean isSkipTrash(Map<String,String> tableParams)
tableParams - parameters of the tablepublic static boolean isInsertOnlyTableParam(Map<String,String> params)
public static boolean isNonNativeTable(Table table)
public static List<String> getPvals(List<FieldSchema> partCols, Map<String,String> partSpec)
partCols - the list of table partition columnspartSpec - the partial mapping from partition column to valuespublic static String makePartNameMatcher(Table table, List<String> partVals, String defaultStr) throws MetaException
MetaExceptionpublic static boolean compareFieldColumns(List<FieldSchema> schema1, List<FieldSchema> schema2)
schema1: - The first schema to be comparedschema2: - The second schema to be comparedpublic static boolean isArchived(Partition part)
public static org.apache.hadoop.fs.Path getOriginalLocation(Partition part)
public static int getArchivingLevel(Partition part) throws MetaException
MetaExceptionpublic static Map<String,String> getMetaStoreSaslProperties(org.apache.hadoop.conf.Configuration conf, boolean useSSL)
conf - public static ClassLoader addToClassPath(ClassLoader cloader, String[] newPaths) throws Exception
newPaths - Array of classpath elementsExceptionpublic static String getDDLFromFieldSchema(String structName, List<FieldSchema> fieldSchemas)
public static Properties getTableMetadata(Table table)
public static Properties getPartitionMetadata(Partition partition, Table table)
public static Properties getSchema(Partition part, Table table)
public static Properties getPartSchemaFromTableSchema(StorageDescriptor sd, Map<String,String> parameters, Properties tblSchema)
sd - The Partition level Storage Descriptor.parameters - partition level parameterstblSchema - The table level schema from which this partition should be copied.public static Properties getSchemaWithoutCols(StorageDescriptor sd, Map<String,String> parameters, String databaseName, String tableName, List<FieldSchema> partitionKeys)
public static Properties getSchema(StorageDescriptor sd, StorageDescriptor tblsd, Map<String,String> parameters, String databaseName, String tableName, List<FieldSchema> partitionKeys)
public static String getColumnNameDelimiter(List<FieldSchema> fieldSchemas)
public static String getColumnNamesFromFieldSchema(List<FieldSchema> fieldSchemas)
public static String getColumnTypesFromFieldSchema(List<FieldSchema> fieldSchemas, String delimiter)
public static String getColumnTypesFromFieldSchema(List<FieldSchema> fieldSchemas)
public static String getColumnCommentsFromFieldSchema(List<FieldSchema> fieldSchemas)
public static boolean isMaterializedViewTable(Table table)
public static List<String> getColumnNames(List<FieldSchema> schema)
public static boolean isValidSchedulingPolicy(String str)
public static WMPoolSchedulingPolicy parseSchedulingPolicy(String schedulingPolicy)
public static String prependCatalogToDbName(@Nullable String catalogName, @Nullable String dbName, org.apache.hadoop.conf.Configuration conf)
parseDbName(String, Configuration).catalogName - catalog name, can be null if no known.dbName - database name, can be null or empty.conf - configuration object, used to determine default catalog if catalogName is nullpublic static String prependNotNullCatToDbName(String catalogName, String dbName)
parseDbName(String, Configuration).catalogName - catalog name. This cannot be null. If this might be null use
prependCatalogToDbName(String, String, Configuration) instead.dbName - database name.public static String prependCatalogToDbName(String dbName, org.apache.hadoop.conf.Configuration conf)
dbName - database nameconf - configuration object, used to determine default catalogpublic static String[] parseDbName(String dbName, org.apache.hadoop.conf.Configuration conf) throws MetaException
dbName - name of the database. This may or may not contain the catalog name.conf - configuration object, used to determine the default catalog if it is not present
in the database name.MetaException - if the name is not either just a database name or a catalog plus
database name with the proper delimiters.public static String getDefaultCatalog(org.apache.hadoop.conf.Configuration conf)
public static boolean isView(Table table)
public static <T> void filterMapKeys(Map<String,T> map, Predicate<String> predicate)
map - A map of String key-value pairspredicate - Predicate with pattern to filter the mappublic static <T> void filterMapkeys(Map<String,T> map, List<Predicate<String>> predicates)
map - A map of String key-value pairspredicates - List of predicates with patterns to filter the mappublic static List<Predicate<String>> compilePatternsToPredicates(List<String> patterns)
patterns - List of regex patterns to be compiledpublic static List<Object[]> makeOrderSpecs(String order)
order - specified in partColIndex[,partColIndex]*:[-|\+]+ patternpublic static void addPartitonSpecsToList(PartitionsSpecByExprResult r, List<PartitionSpec> result)
public static boolean hasUnknownPartitions(PartitionsSpecByExprResult r)
public static boolean isNoAutoCompactSet(Map<String,String> dbParameters, Map<String,String> tblParameters)
public static String getNoAutoCompact(Map<String,String> parameters)
parameters - public static GetPartitionsByNamesRequest convertToGetPartitionsByNamesRequest(String dbName, String tblName, List<String> partNames)
public static GetPartitionsByNamesRequest convertToGetPartitionsByNamesRequest(String dbName, String tblName, List<String> partNames, boolean getColStats, String engine, String validWriteIdList, Long tableId)
public static <T> T createThriftPartitionsReq(Class<T> clazz, org.apache.hadoop.conf.Configuration conf, T... deepCopy)
Copyright © 2024 The Apache Software Foundation. All rights reserved.