Interface SupportsSchemas
-
Method Summary
Modifier and TypeMethodDescriptionalterSchema(String schemaName, SchemaChange... changes) Apply the metadata change to a schema in the catalog.Creates a schema in the catalog based on the provided details.booleandropSchema(String schemaName, boolean cascade) Drop a schema from the catalog.String[]List schemas under the entity.default String[]listSchemas(String parentSchema) List the schemas directly under the given parent schema.loadSchema(String schemaName) Load metadata properties for a schema.default booleanschemaExists(String schemaName) Check if a schema exists.
-
Method Details
-
listSchemas
List schemas under the entity.If an entity such as a table, view exists, its parent schemas must also exist and must be returned by this discovery method. For example, if table a.b.t exists, this method invoked as listSchemas(a) must return [b] in the result array
- Returns:
- An array of schema names under the namespace.
- Throws:
NoSuchCatalogException- If the catalog does not exist.
-
listSchemas
default String[] listSchemas(String parentSchema) throws NoSuchCatalogException, NoSuchSchemaException List the schemas directly under the given parent schema.This is only meaningful for catalogs that support hierarchical (multi-level) schemas, such as an Iceberg catalog accessed through the Gravitino REST server with a configured schema separator. For example, when the schemas
a,a:banda:b:cexist, this method invoked with parenta:breturns[a:b:c]. For a flat catalog, or a parent schema that has no children, an empty array is returned.- Parameters:
parentSchema- The parent (possibly hierarchical) schema name whose direct children are listed, e.g."a"or"a:b". Must not be null or blank.- Returns:
- An array of schema names directly under the given parent schema.
- Throws:
IllegalArgumentException- IfparentSchemais null or blank.NoSuchCatalogException- If the catalog does not exist.NoSuchSchemaException- If the parent schema does not exist.
-
schemaExists
Check if a schema exists.If an entity such as a table, view exists, its parent namespaces must also exist. For example, if table a.b.t exists, this method invoked as schemaExists(a.b) must return true.
- Parameters:
schemaName- The name of the schema.- Returns:
- True if the schema exists, false otherwise.
-
createSchema
Schema createSchema(String schemaName, String comment, Map<String, String> properties) throws NoSuchCatalogException, SchemaAlreadyExistsExceptionCreates a schema in the catalog based on the provided details.This method returns the schema as defined by the user without applying all defaults. If you need the schema with default values applied, use the
loadSchema(String)method after creation.- Parameters:
schemaName- The name of the schema.comment- The comment of the schema.properties- The properties of the schema.- Returns:
- The schema as defined by the caller, without all default values.
- Throws:
NoSuchCatalogException- If the catalog does not exist.SchemaAlreadyExistsException- If the schema already exists.
-
loadSchema
Load metadata properties for a schema.- Parameters:
schemaName- The name of the schema.- Returns:
- A schema.
- Throws:
NoSuchSchemaException- If the schema does not exist (optional).
-
alterSchema
Apply the metadata change to a schema in the catalog.- Parameters:
schemaName- The name of the schema.changes- The metadata changes to apply.- Returns:
- The altered schema.
- Throws:
NoSuchSchemaException- If the schema does not exist.
-
dropSchema
Drop a schema from the catalog. If cascade option is true, recursively drop all objects within the schema.If the catalog implementation does not support this operation, it may throw
UnsupportedOperationException.- Parameters:
schemaName- The name of the schema.cascade- If true, recursively drop all objects within the schema.- Returns:
- True if the schema exists and is dropped successfully, false if the schema doesn't exist.
- Throws:
NonEmptySchemaException- If the schema is not empty and cascade is false.
-