Package io.trino.plugin.hive.metastore
Class MetastoreUtil
- java.lang.Object
-
- io.trino.plugin.hive.metastore.MetastoreUtil
-
public final class MetastoreUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,String>adjustRowCount(Map<String,String> parameters, String description, long rowCountAdjustment)static PrincipalPrivilegesbuildInitialPrivilegeSet(String tableOwner)static booleancanConvertSqlTypeToStringForParts(Type type, boolean assumeCanonicalPartitionKeys)static TupleDomain<String>computePartitionKeyFilter(List<HiveColumnHandle> partitionKeys, TupleDomain<HiveColumnHandle> effectivePredicate)This method creates a TupleDomain for each partitionKey specifiedstatic PropertiesgetHiveSchema(Partition partition, Table table)static PropertiesgetHiveSchema(Table table)static StringgetPartitionLocation(Table table, Optional<Partition> partition)static org.apache.hadoop.hive.metastore.ProtectModegetProtectMode(Partition partition)static org.apache.hadoop.hive.metastore.ProtectModegetProtectMode(Table table)static booleanisAvroTableWithSchemaSet(Table table)static StringmakePartitionName(Table table, Partition partition)static StringmakePartitionName(List<Column> partitionColumns, List<String> values)static Optional<List<String>>partitionKeyFilterToStringList(List<String> columnNames, TupleDomain<String> partitionKeysFilter, boolean assumeCanonicalPartitionKeys)static StringsqlScalarToString(Type type, Object value, String nullString)static StringsqlScalarToStringForParts(Type type, Object value, boolean assumeCanonicalPartitionKeys, String partitionWildcardString)static StringtoPartitionName(List<String> names, List<String> values)static voidverifyCanDropColumn(HiveMetastore metastore, HiveIdentity identity, String databaseName, String tableName, String columnName)static voidverifyOnline(SchemaTableName tableName, Optional<String> partitionName, org.apache.hadoop.hive.metastore.ProtectMode protectMode, Map<String,String> parameters)
-
-
-
Method Detail
-
getHiveSchema
public static Properties getHiveSchema(Table table)
-
getHiveSchema
public static Properties getHiveSchema(Partition partition, Table table)
-
getProtectMode
public static org.apache.hadoop.hive.metastore.ProtectMode getProtectMode(Partition partition)
-
getProtectMode
public static org.apache.hadoop.hive.metastore.ProtectMode getProtectMode(Table table)
-
isAvroTableWithSchemaSet
public static boolean isAvroTableWithSchemaSet(Table table)
-
makePartitionName
public static String makePartitionName(List<Column> partitionColumns, List<String> values)
-
getPartitionLocation
public static String getPartitionLocation(Table table, Optional<Partition> partition)
-
verifyOnline
public static void verifyOnline(SchemaTableName tableName, Optional<String> partitionName, org.apache.hadoop.hive.metastore.ProtectMode protectMode, Map<String,String> parameters)
-
verifyCanDropColumn
public static void verifyCanDropColumn(HiveMetastore metastore, HiveIdentity identity, String databaseName, String tableName, String columnName)
-
buildInitialPrivilegeSet
public static PrincipalPrivileges buildInitialPrivilegeSet(String tableOwner)
-
partitionKeyFilterToStringList
public static Optional<List<String>> partitionKeyFilterToStringList(List<String> columnNames, TupleDomain<String> partitionKeysFilter, boolean assumeCanonicalPartitionKeys)
- Parameters:
assumeCanonicalPartitionKeys- allow conversion of non-char types (eg BIGINT, timestamp) to canonical string formats. If false, non-char types will be replaced with the wildcard- Returns:
- the domain for each partition key to either the wildcard or an equals check, or empty if
TupleDomain.isNone()
-
canConvertSqlTypeToStringForParts
public static boolean canConvertSqlTypeToStringForParts(Type type, boolean assumeCanonicalPartitionKeys)
-
sqlScalarToStringForParts
public static String sqlScalarToStringForParts(Type type, Object value, boolean assumeCanonicalPartitionKeys, String partitionWildcardString)
- Returns:
- canonical string representation of a given value according to its type. If there isn't a valid conversion, returns ""
-
sqlScalarToString
public static String sqlScalarToString(Type type, Object value, String nullString)
- Returns:
- canonical string representation of a given value according to its type.
- Throws:
TrinoException- if the type is not supported
-
computePartitionKeyFilter
public static TupleDomain<String> computePartitionKeyFilter(List<HiveColumnHandle> partitionKeys, TupleDomain<HiveColumnHandle> effectivePredicate)
This method creates a TupleDomain for each partitionKey specified- Returns:
- filtered version of relevant Domains in effectivePredicate.
-
-