public class PrivilegedCatalog extends DelegateCatalog
Catalog
which supports privilege system.Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException, Catalog.DatabaseAlreadyExistException, Catalog.DatabaseNoPermissionException, Catalog.DatabaseNotEmptyException, Catalog.DatabaseNotExistException, Catalog.ProcessSystemDatabaseException, Catalog.TableAlreadyExistException, Catalog.TableNoPermissionException, Catalog.TableNotExistException, Catalog.ViewAlreadyExistException, Catalog.ViewNotExistException
Modifier and Type | Field and Description |
---|---|
static ConfigOption<String> |
PASSWORD |
static ConfigOption<String> |
USER |
wrapped
COMMENT_PROP, DB_LOCATION_PROP, DB_SUFFIX, DEFAULT_DATABASE, LAST_UPDATE_TIME_PROP, NUM_FILES_PROP, NUM_ROWS_PROP, OWNER_PROP, SYSTEM_BRANCH_PREFIX, SYSTEM_DATABASE_NAME, SYSTEM_TABLE_SPLITTER, TABLE_DEFAULT_OPTION_PREFIX, TOTAL_SIZE_PROP
Constructor and Description |
---|
PrivilegedCatalog(Catalog wrapped,
PrivilegeManagerLoader privilegeManagerLoader) |
Modifier and Type | Method and Description |
---|---|
void |
alterDatabase(String name,
List<PropertyChange> changes,
boolean ignoreIfNotExists)
Alter a database.
|
void |
alterPartitions(Identifier identifier,
List<Partition> partitions)
Alter partitions of the specify table.
|
void |
alterTable(Identifier identifier,
List<SchemaChange> changes,
boolean ignoreIfNotExists)
Modify an existing table from
SchemaChange s. |
CatalogLoader |
catalogLoader()
Serializable loader to create catalog.
|
void |
createDatabase(String name,
boolean ignoreIfExists,
Map<String,String> properties)
Create a database with properties.
|
void |
createPartitions(Identifier identifier,
List<Map<String,String>> partitions)
Create partitions of the specify table.
|
void |
createPrivilegedUser(String user,
String password) |
void |
createTable(Identifier identifier,
Schema schema,
boolean ignoreIfExists)
Create a new table.
|
void |
dropDatabase(String name,
boolean ignoreIfNotExists,
boolean cascade)
Drop a database.
|
void |
dropPartitions(Identifier identifier,
List<Map<String,String>> partitions)
Drop partitions of the specify table.
|
void |
dropPrivilegedUser(String user) |
void |
dropTable(Identifier identifier,
boolean ignoreIfNotExists)
Drop a table.
|
Table |
getTable(Identifier identifier)
Return a
Table identified by the given Identifier . |
void |
grantPrivilegeOnCatalog(String user,
PrivilegeType privilege) |
void |
grantPrivilegeOnDatabase(String user,
String databaseName,
PrivilegeType privilege) |
void |
grantPrivilegeOnTable(String user,
Identifier identifier,
PrivilegeType privilege) |
void |
markDonePartitions(Identifier identifier,
List<Map<String,String>> partitions)
Mark partitions done of the specify table.
|
PrivilegeManager |
privilegeManager() |
void |
renameTable(Identifier fromTable,
Identifier toTable,
boolean ignoreIfNotExists)
Rename a table.
|
int |
revokePrivilegeOnCatalog(String user,
PrivilegeType privilege)
Returns the number of privilege revoked.
|
int |
revokePrivilegeOnDatabase(String user,
String databaseName,
PrivilegeType privilege)
Returns the number of privilege revoked.
|
int |
revokePrivilegeOnTable(String user,
Identifier identifier,
PrivilegeType privilege)
Returns the number of privilege revoked.
|
static Catalog |
tryToCreate(Catalog catalog,
Options options) |
caseSensitive, close, createView, dropView, getDatabase, getView, listDatabases, listPartitions, listTables, listViews, options, renameView, repairCatalog, repairDatabase, repairTable, rootCatalog, wrapped
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
alterTable, createDatabase, invalidateTable
public static final ConfigOption<String> USER
public static final ConfigOption<String> PASSWORD
public PrivilegedCatalog(Catalog wrapped, PrivilegeManagerLoader privilegeManagerLoader)
public PrivilegeManager privilegeManager()
public CatalogLoader catalogLoader()
Catalog
public void createDatabase(String name, boolean ignoreIfExists, Map<String,String> properties) throws Catalog.DatabaseAlreadyExistException
Catalog
createDatabase
in interface Catalog
createDatabase
in class DelegateCatalog
name
- Name of the database to be createdignoreIfExists
- Flag to specify behavior when a database with the given name already
exists: if set to false, throw a DatabaseAlreadyExistException, if set to true, do
nothing.properties
- properties to be associated with the databaseCatalog.DatabaseAlreadyExistException
- if the given database already exists and ignoreIfExists
is falsepublic void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws Catalog.DatabaseNotExistException, Catalog.DatabaseNotEmptyException
Catalog
dropDatabase
in interface Catalog
dropDatabase
in class DelegateCatalog
name
- Name of the database to be dropped.ignoreIfNotExists
- Flag to specify behavior when the database does not exist: if set to
false, throw an exception, if set to true, do nothing.cascade
- Flag to specify behavior when the database contains table or function: if set
to true, delete all tables and functions in the database and then delete the database, if
set to false, throw an exception.Catalog.DatabaseNotEmptyException
- if the given database is not empty and isRestrict is trueCatalog.DatabaseNotExistException
public void alterDatabase(String name, List<PropertyChange> changes, boolean ignoreIfNotExists) throws Catalog.DatabaseNotExistException
Catalog
alterDatabase
in interface Catalog
alterDatabase
in class DelegateCatalog
name
- Name of the database to alter.changes
- the property changesignoreIfNotExists
- Flag to specify behavior when the database does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.DatabaseNotExistException
- if the given database is not exist and ignoreIfNotExists is
falsepublic void dropTable(Identifier identifier, boolean ignoreIfNotExists) throws Catalog.TableNotExistException
Catalog
NOTE: System tables can not be dropped.
dropTable
in interface Catalog
dropTable
in class DelegateCatalog
identifier
- Path of the table to be droppedignoreIfNotExists
- Flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException
- if the table does not existpublic void createTable(Identifier identifier, Schema schema, boolean ignoreIfExists) throws Catalog.TableAlreadyExistException, Catalog.DatabaseNotExistException
Catalog
NOTE: System tables can not be created.
createTable
in interface Catalog
createTable
in class DelegateCatalog
identifier
- path of the table to be createdschema
- the table definitionignoreIfExists
- flag to specify behavior when a table already exists at the given path:
if set to false, it throws a TableAlreadyExistException, if set to true, do nothing.Catalog.TableAlreadyExistException
- if table already exists and ignoreIfExists is falseCatalog.DatabaseNotExistException
- if the database in identifier doesn't existpublic void renameTable(Identifier fromTable, Identifier toTable, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.TableAlreadyExistException
Catalog
NOTE: If you use object storage, such as S3 or OSS, please use this syntax carefully, because the renaming of object storage is not atomic, and only partial files may be moved in case of failure.
NOTE: System tables can not be renamed.
renameTable
in interface Catalog
renameTable
in class DelegateCatalog
fromTable
- the name of the table which need to renametoTable
- the new tableignoreIfNotExists
- Flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException
- if the fromTable does not existCatalog.TableAlreadyExistException
- if the toTable already existspublic void alterTable(Identifier identifier, List<SchemaChange> changes, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException
Catalog
SchemaChange
s.
NOTE: System tables can not be altered.
alterTable
in interface Catalog
alterTable
in class DelegateCatalog
identifier
- path of the table to be modifiedchanges
- the schema changesignoreIfNotExists
- flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException
- if the table does not existCatalog.ColumnAlreadyExistException
Catalog.ColumnNotExistException
public Table getTable(Identifier identifier) throws Catalog.TableNotExistException
Catalog
getTable
in interface Catalog
getTable
in class DelegateCatalog
identifier
- Path of the tableCatalog.TableNotExistException
- if the target does not existpublic void createPartitions(Identifier identifier, List<Map<String,String>> partitions) throws Catalog.TableNotExistException
Catalog
Only catalog with metastore can support this method, and only table with 'metastore.partitioned-table' can support this method.
createPartitions
in interface Catalog
createPartitions
in class DelegateCatalog
identifier
- path of the table to create partitionspartitions
- partitions to be createdCatalog.TableNotExistException
- if the table does not existpublic void dropPartitions(Identifier identifier, List<Map<String,String>> partitions) throws Catalog.TableNotExistException
Catalog
dropPartitions
in interface Catalog
dropPartitions
in class DelegateCatalog
identifier
- path of the table to drop partitionspartitions
- partitions to be deletedCatalog.TableNotExistException
- if the table does not existpublic void alterPartitions(Identifier identifier, List<Partition> partitions) throws Catalog.TableNotExistException
Catalog
Only catalog with metastore can support this method, and only table with 'metastore.partitioned-table' can support this method.
alterPartitions
in interface Catalog
alterPartitions
in class DelegateCatalog
identifier
- path of the table to alter partitionspartitions
- partitions to be alteredCatalog.TableNotExistException
- if the table does not existpublic void markDonePartitions(Identifier identifier, List<Map<String,String>> partitions) throws Catalog.TableNotExistException
Catalog
Only catalog with metastore can support this method, and only table with 'metastore.partitioned-table' can support this method.
markDonePartitions
in interface Catalog
markDonePartitions
in class DelegateCatalog
identifier
- path of the table to mark done partitionspartitions
- partitions to be marked doneCatalog.TableNotExistException
- if the table does not existpublic void dropPrivilegedUser(String user)
public void grantPrivilegeOnCatalog(String user, PrivilegeType privilege)
public void grantPrivilegeOnDatabase(String user, String databaseName, PrivilegeType privilege)
public void grantPrivilegeOnTable(String user, Identifier identifier, PrivilegeType privilege)
public int revokePrivilegeOnCatalog(String user, PrivilegeType privilege)
public int revokePrivilegeOnDatabase(String user, String databaseName, PrivilegeType privilege)
public int revokePrivilegeOnTable(String user, Identifier identifier, PrivilegeType privilege)
Copyright © 2023–2025 The Apache Software Foundation. All rights reserved.