Package io.trino.plugin.hive.metastore
Class RecordingHiveMetastore
- java.lang.Object
-
- io.trino.plugin.hive.metastore.RecordingHiveMetastore
-
- All Implemented Interfaces:
HiveMetastore
public class RecordingHiveMetastore extends Object implements HiveMetastore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRecordingHiveMetastore.Pair<K,V>static classRecordingHiveMetastore.Recording
-
Constructor Summary
Constructors Constructor Description RecordingHiveMetastore(HiveMetastore delegate, RecordingMetastoreConfig config, io.airlift.json.JsonCodec<RecordingHiveMetastore.Recording> recordingCodec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColumn(HiveIdentity identity, String databaseName, String tableName, String columnName, HiveType columnType, String columnComment)voidaddPartitions(HiveIdentity identity, String databaseName, String tableName, List<PartitionWithStatistics> partitions)voidalterPartition(HiveIdentity identity, String databaseName, String tableName, PartitionWithStatistics partition)voidcommentColumn(HiveIdentity identity, String databaseName, String tableName, String columnName, Optional<String> comment)voidcommentTable(HiveIdentity identity, String databaseName, String tableName, Optional<String> comment)voidcreateDatabase(HiveIdentity identity, Database database)voidcreateRole(String role, String grantor)voidcreateTable(HiveIdentity identity, Table table, PrincipalPrivileges principalPrivileges)voiddropColumn(HiveIdentity identity, String databaseName, String tableName, String columnName)voiddropDatabase(HiveIdentity identity, String databaseName)voiddropPartition(HiveIdentity identity, String databaseName, String tableName, List<String> parts, boolean deleteData)voiddropRole(String role)voiddropTable(HiveIdentity identity, String databaseName, String tableName, boolean deleteData)List<String>getAllDatabases()List<String>getAllTables(String databaseName)List<String>getAllViews(String databaseName)Optional<Database>getDatabase(String databaseName)Optional<Partition>getPartition(HiveIdentity identity, Table table, List<String> partitionValues)Optional<List<String>>getPartitionNamesByFilter(HiveIdentity identity, String databaseName, String tableName, List<String> columnNames, TupleDomain<String> partitionKeysFilter)Return a list of partition names, with optional filtering (hint to improve performance if possible).Map<String,Optional<Partition>>getPartitionsByNames(HiveIdentity identity, Table table, List<String> partitionNames)Map<String,PartitionStatistics>getPartitionStatistics(HiveIdentity identity, Table table, List<Partition> partitions)Set<ColumnStatisticType>getSupportedColumnStatistics(Type type)Optional<Table>getTable(HiveIdentity identity, String databaseName, String tableName)PartitionStatisticsgetTableStatistics(HiveIdentity identity, Table table)List<String>getTablesWithParameter(String databaseName, String parameterKey, String parameterValue)voidgrantRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor)voidgrantTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, Set<HivePrivilegeInfo> privileges)booleanisImpersonationEnabled()Set<RoleGrant>listGrantedPrincipals(String role)Set<RoleGrant>listRoleGrants(HivePrincipal principal)Set<String>listRoles()Set<HivePrivilegeInfo>listTablePrivileges(String databaseName, String tableName, String tableOwner, Optional<HivePrincipal> principal)voidrenameColumn(HiveIdentity identity, String databaseName, String tableName, String oldColumnName, String newColumnName)voidrenameDatabase(HiveIdentity identity, String databaseName, String newDatabaseName)voidrenameTable(HiveIdentity identity, String databaseName, String tableName, String newDatabaseName, String newTableName)voidreplaceTable(HiveIdentity identity, String databaseName, String tableName, Table newTable, PrincipalPrivileges principalPrivileges)This should only be used if the semantic here is drop and add.voidrevokeRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor)voidrevokeTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, Set<HivePrivilegeInfo> privileges)voidsetDatabaseOwner(HiveIdentity identity, String databaseName, HivePrincipal principal)voidsetTableOwner(HiveIdentity identity, String databaseName, String tableName, HivePrincipal principal)voidupdatePartitionStatistics(HiveIdentity identity, Table table, String partitionName, Function<PartitionStatistics,PartitionStatistics> update)voidupdateTableStatistics(HiveIdentity identity, String databaseName, String tableName, AcidTransaction transaction, Function<PartitionStatistics,PartitionStatistics> update)voidwriteRecording()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.trino.plugin.hive.metastore.HiveMetastore
acquireSharedReadLock, acquireTableWriteLock, addDynamicPartitions, allocateWriteId, alterPartitions, alterTransactionalTable, commitTransaction, getConfigValue, getValidWriteIds, openTransaction, sendTransactionHeartbeat, updateTableWriteId
-
-
-
-
Constructor Detail
-
RecordingHiveMetastore
@Inject public RecordingHiveMetastore(HiveMetastore delegate, RecordingMetastoreConfig config, io.airlift.json.JsonCodec<RecordingHiveMetastore.Recording> recordingCodec) throws IOException
- Throws:
IOException
-
-
Method Detail
-
writeRecording
public void writeRecording() throws IOException- Throws:
IOException
-
getDatabase
public Optional<Database> getDatabase(String databaseName)
- Specified by:
getDatabasein interfaceHiveMetastore
-
getAllDatabases
public List<String> getAllDatabases()
- Specified by:
getAllDatabasesin interfaceHiveMetastore
-
getTable
public Optional<Table> getTable(HiveIdentity identity, String databaseName, String tableName)
- Specified by:
getTablein interfaceHiveMetastore
-
getSupportedColumnStatistics
public Set<ColumnStatisticType> getSupportedColumnStatistics(Type type)
- Specified by:
getSupportedColumnStatisticsin interfaceHiveMetastore
-
getTableStatistics
public PartitionStatistics getTableStatistics(HiveIdentity identity, Table table)
- Specified by:
getTableStatisticsin interfaceHiveMetastore
-
getPartitionStatistics
public Map<String,PartitionStatistics> getPartitionStatistics(HiveIdentity identity, Table table, List<Partition> partitions)
- Specified by:
getPartitionStatisticsin interfaceHiveMetastore
-
updateTableStatistics
public void updateTableStatistics(HiveIdentity identity, String databaseName, String tableName, AcidTransaction transaction, Function<PartitionStatistics,PartitionStatistics> update)
- Specified by:
updateTableStatisticsin interfaceHiveMetastore
-
updatePartitionStatistics
public void updatePartitionStatistics(HiveIdentity identity, Table table, String partitionName, Function<PartitionStatistics,PartitionStatistics> update)
- Specified by:
updatePartitionStatisticsin interfaceHiveMetastore
-
getAllTables
public List<String> getAllTables(String databaseName)
- Specified by:
getAllTablesin interfaceHiveMetastore
-
getTablesWithParameter
public List<String> getTablesWithParameter(String databaseName, String parameterKey, String parameterValue)
- Specified by:
getTablesWithParameterin interfaceHiveMetastore
-
getAllViews
public List<String> getAllViews(String databaseName)
- Specified by:
getAllViewsin interfaceHiveMetastore
-
createDatabase
public void createDatabase(HiveIdentity identity, Database database)
- Specified by:
createDatabasein interfaceHiveMetastore
-
dropDatabase
public void dropDatabase(HiveIdentity identity, String databaseName)
- Specified by:
dropDatabasein interfaceHiveMetastore
-
renameDatabase
public void renameDatabase(HiveIdentity identity, String databaseName, String newDatabaseName)
- Specified by:
renameDatabasein interfaceHiveMetastore
-
setDatabaseOwner
public void setDatabaseOwner(HiveIdentity identity, String databaseName, HivePrincipal principal)
- Specified by:
setDatabaseOwnerin interfaceHiveMetastore
-
createTable
public void createTable(HiveIdentity identity, Table table, PrincipalPrivileges principalPrivileges)
- Specified by:
createTablein interfaceHiveMetastore
-
dropTable
public void dropTable(HiveIdentity identity, String databaseName, String tableName, boolean deleteData)
- Specified by:
dropTablein interfaceHiveMetastore
-
replaceTable
public void replaceTable(HiveIdentity identity, String databaseName, String tableName, Table newTable, PrincipalPrivileges principalPrivileges)
Description copied from interface:HiveMetastoreThis should only be used if the semantic here is drop and add. Trying to alter one field of a table object previously acquired from getTable is probably not what you want.- Specified by:
replaceTablein interfaceHiveMetastore
-
renameTable
public void renameTable(HiveIdentity identity, String databaseName, String tableName, String newDatabaseName, String newTableName)
- Specified by:
renameTablein interfaceHiveMetastore
-
commentTable
public void commentTable(HiveIdentity identity, String databaseName, String tableName, Optional<String> comment)
- Specified by:
commentTablein interfaceHiveMetastore
-
setTableOwner
public void setTableOwner(HiveIdentity identity, String databaseName, String tableName, HivePrincipal principal)
- Specified by:
setTableOwnerin interfaceHiveMetastore
-
commentColumn
public void commentColumn(HiveIdentity identity, String databaseName, String tableName, String columnName, Optional<String> comment)
- Specified by:
commentColumnin interfaceHiveMetastore
-
addColumn
public void addColumn(HiveIdentity identity, String databaseName, String tableName, String columnName, HiveType columnType, String columnComment)
- Specified by:
addColumnin interfaceHiveMetastore
-
renameColumn
public void renameColumn(HiveIdentity identity, String databaseName, String tableName, String oldColumnName, String newColumnName)
- Specified by:
renameColumnin interfaceHiveMetastore
-
dropColumn
public void dropColumn(HiveIdentity identity, String databaseName, String tableName, String columnName)
- Specified by:
dropColumnin interfaceHiveMetastore
-
getPartition
public Optional<Partition> getPartition(HiveIdentity identity, Table table, List<String> partitionValues)
- Specified by:
getPartitionin interfaceHiveMetastore
-
getPartitionNamesByFilter
public Optional<List<String>> getPartitionNamesByFilter(HiveIdentity identity, String databaseName, String tableName, List<String> columnNames, TupleDomain<String> partitionKeysFilter)
Description copied from interface:HiveMetastoreReturn a list of partition names, with optional filtering (hint to improve performance if possible).- Specified by:
getPartitionNamesByFilterin interfaceHiveMetastoredatabaseName- the name of the databasetableName- the name of the tablecolumnNames- the list of partition column namespartitionKeysFilter- optional filter for the partition column values- Returns:
- a list of partition names as created by
MetastoreUtil.toPartitionName(java.util.List<java.lang.String>, java.util.List<java.lang.String>) - See Also:
TupleDomain
-
getPartitionsByNames
public Map<String,Optional<Partition>> getPartitionsByNames(HiveIdentity identity, Table table, List<String> partitionNames)
- Specified by:
getPartitionsByNamesin interfaceHiveMetastore
-
addPartitions
public void addPartitions(HiveIdentity identity, String databaseName, String tableName, List<PartitionWithStatistics> partitions)
- Specified by:
addPartitionsin interfaceHiveMetastore
-
dropPartition
public void dropPartition(HiveIdentity identity, String databaseName, String tableName, List<String> parts, boolean deleteData)
- Specified by:
dropPartitionin interfaceHiveMetastore
-
alterPartition
public void alterPartition(HiveIdentity identity, String databaseName, String tableName, PartitionWithStatistics partition)
- Specified by:
alterPartitionin interfaceHiveMetastore
-
listTablePrivileges
public Set<HivePrivilegeInfo> listTablePrivileges(String databaseName, String tableName, String tableOwner, Optional<HivePrincipal> principal)
- Specified by:
listTablePrivilegesin interfaceHiveMetastoreprincipal- when empty, all table privileges are returned
-
grantTablePrivileges
public void grantTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, Set<HivePrivilegeInfo> privileges)
- Specified by:
grantTablePrivilegesin interfaceHiveMetastore
-
revokeTablePrivileges
public void revokeTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, Set<HivePrivilegeInfo> privileges)
- Specified by:
revokeTablePrivilegesin interfaceHiveMetastore
-
createRole
public void createRole(String role, String grantor)
- Specified by:
createRolein interfaceHiveMetastore
-
dropRole
public void dropRole(String role)
- Specified by:
dropRolein interfaceHiveMetastore
-
listRoles
public Set<String> listRoles()
- Specified by:
listRolesin interfaceHiveMetastore
-
grantRoles
public void grantRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor)
- Specified by:
grantRolesin interfaceHiveMetastore
-
revokeRoles
public void revokeRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor)
- Specified by:
revokeRolesin interfaceHiveMetastore
-
listGrantedPrincipals
public Set<RoleGrant> listGrantedPrincipals(String role)
- Specified by:
listGrantedPrincipalsin interfaceHiveMetastore
-
listRoleGrants
public Set<RoleGrant> listRoleGrants(HivePrincipal principal)
- Specified by:
listRoleGrantsin interfaceHiveMetastore
-
isImpersonationEnabled
public boolean isImpersonationEnabled()
- Specified by:
isImpersonationEnabledin interfaceHiveMetastore
-
-