World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[MINOR] Add object concept pages and reduce the manage-* pages to the API (#12327)
Mark Hoerthe9bb6b7a6482
diff --git a/docs/catalogs-and-schemas.md b/docs/catalogs-and-schemas.mdnew file mode 100644index 0000000000..e987795753--- /dev/null+++ b/docs/catalogs-and-schemas.md@@ -0,0 +1,125 @@+---+title: "Catalogs and Schemas"+slug: "/catalogs-and-schemas"+keyword: "catalog, schema, namespace, metadata object, Gravitino"+license: "This software is licensed under the Apache License version 2."+---++## Introduction++A catalog is a connection to a system that holds data or metadata, and a schema is a namespace+inside it. Together they are the two levels between a metalake and the objects you actually work+with.++A catalog is where federation happens. Registering one tells Gravitino how to reach a Hive+metastore, an Iceberg REST catalog, a MySQL database, a Kafka cluster, or object storage, and from+that point the objects inside appear alongside everything else in the metalake. Gravitino does not+copy them. Listing a schema asks the source system, so what you see is what is there now.++A schema is the middle level, and what it means depends on the system underneath. In a relational+catalog it is a database. In a fileset catalog it groups filesets under a location. In a model+catalog it is a namespace for models with no physical counterpart at all.++Catalogs and schemas both carry tags and policies, and both are the level to attach them at when+something should apply broadly. A tag on a catalog reaches every object beneath it.++## Quick Start++**1. Create the catalog.** Catalogs are created from the catalog list in the UI, or over REST. A+catalog needs a name, a type, and for most types a provider, plus the properties that tell Gravitino+how to connect.++**2. Create or discover schemas.** Connecting to an existing system surfaces the schemas already+there. Creating a schema through Gravitino creates it in the source system too, where the source+supports that.++**3. Work with what is inside.** Tables, filesets, topics, models, and functions all live under a+schema and are reached the same way regardless of which system stores them.++## The Catalog Model++### Catalog Types and Providers++Every catalog has a type, which decides what kind of object lives inside it.++| Type | Contains |+|--------------|-----------------|+| `RELATIONAL` | Tables and views|+| `FILESET` | Filesets |+| `MESSAGING` | Topics |+| `MODEL` | Models |++Most types also need a provider, which names the system being connected: `hive`,+`lakehouse-iceberg`, `jdbc-mysql`, `kafka`, and so on. Fileset and model catalogs are the exception.+Gravitino manages their metadata itself, so the type is enough and the provider is inferred.++Each provider has its own connection properties and its own page describing them.++### Names and Properties++A catalog name is unique within its metalake, and a schema name is unique within its catalog.++Properties carry the connection details, and which ones apply depends entirely on the provider. Two+reserved keys behave the same everywhere. `in-use` records whether the catalog is available and+defaults to `true`. `location` sets a base path where the catalog type uses one.++### In Use and Not In Use++A catalog that is not in use can only be listed, loaded, enabled, or dropped. Every other operation+on it or on anything inside it fails, which makes disabling a way to take a connection out of+service without removing its metadata.++Disabling a catalog does not touch the source system. The tables and files it points at stay exactly+where they are.++### What Gravitino Stores++Gravitino stores the catalog registration, the schemas and objects created through it, and anything+attached to those objects such as tags, policies, and ownership. It does not store a copy of the+source system's contents.++Listing tables in a schema reaches the source system at request time, so a table created directly in+Hive appears the next time Gravitino is asked. The consequence worth knowing is that Gravitino+cannot answer questions about objects nothing has asked for yet.++## Working With Catalogs and Schemas in the UI++The catalog list holds every catalog in the current metalake. A catalog can be created, edited,+enabled or disabled, and deleted from there, and each one expands into its schemas and their+contents.++Tags and policies attach from the catalog and schema rows, which is the fastest way to classify a+whole subtree.++## Deleting Catalogs and Schemas++Deleting is guarded, and force changes what happens.++Without force, a catalog must have no schemas and a schema must have no objects. Either condition+fails the request rather than removing anything.++With force, Gravitino removes the registration and everything it holds about the contents. For+managed objects, such as a managed fileset or a model, that removes the data too. For federated+objects, the Hive tables or S3 files stay where they are and only Gravitino's record of them goes.++## Permissions++| Privilege | Grantable on | What it allows |+|------------------|-------------------------------|---------------------------------------|+| `CREATE_CATALOG` | Metalake | Creating catalogs in the metalake |+| `USE_CATALOG` | Metalake or catalog | Reaching a catalog and its contents |+| `CREATE_SCHEMA` | Metalake, catalog, or schema | Creating schemas |+| `USE_SCHEMA` | Metalake, catalog, or schema | Reaching a schema and its contents |++Granting at a wider scope covers everything beneath it, so `USE_CATALOG` on the metalake reaches+every catalog in it.++Altering and dropping a catalog or schema are reserved for the metalake owner and the object owner.+Ownership resolves down the hierarchy, so the owner of a catalog has the owner path to everything+beneath it.++## Using the API++Catalogs and schemas can be created, listed, altered, and dropped over REST and through the Java and+Python clients. Endpoints, payload shapes, and worked examples are in+[Manage Catalogs and Schemas](./manage-catalogs-and-schemas.md).diff --git a/docs/filesets.md b/docs/filesets.mdnew file mode 100644index 0000000000..06b52929d7--- /dev/null+++ b/docs/filesets.md@@ -0,0 +1,107 @@+---+title: "Filesets"+slug: "/filesets"+keyword: "fileset, files, storage location, GVFS, Gravitino"+license: "This software is licensed under the Apache License version 2."+---++## Introduction++A fileset is a named pointer to files. Where a table describes rows and columns, a fileset describes+a location, so unstructured and semi-structured data gets the same treatment as everything else in+the catalog: a name, a place in the hierarchy, tags, policies, and an owner.++The point is indirection. Code that reads a fileset by name does not carry a bucket path, so moving+data between clusters or storage systems changes the fileset rather than every job that reads it.++That indirection is delivered by the Gravitino Virtual File System, or GVFS. GVFS is a filesystem+implementation that resolves a fileset name to its storage location and then reads and writes+through to the underlying system, whether that is HDFS, S3, GCS, ADLS, or OSS. Paths take the form+`gvfs://fileset/{catalog_name}/{schema_name}/{fileset_name}`, so a Spark job, a pandas script, or a+Hadoop shell command reads a catalog name rather than a bucket URL.++GVFS comes in two implementations. The Java one implements the Hadoop Compatible File System+interface, so anything that already speaks HDFS paths works, and it requires Hadoop 3.3.1 or later.+The Python one is built on fsspec, so it works with pandas, PyArrow, and anything else in that+ecosystem. There is also a FUSE implementation for mounting a fileset as a local directory.++Credentials are the other half of it. A caller reaching storage through GVFS can be given+short-lived credentials vended by Gravitino rather than holding long-lived cloud keys of its own,+which is what makes the indirection a governance boundary rather than only a convenience. See+[Credential vending](./security/credential-vending.md).++Filesets live in a schema inside a fileset catalog. Gravitino manages that catalog itself rather+than federating an external one, so no provider is needed when creating it.++## Quick Start++**1. Create a fileset catalog and schema.** See+[Catalogs and Schemas](./catalogs-and-schemas.md). A fileset catalog usually carries a base+`location`, and schemas can narrow it further.++**2. Create the fileset.** Give it a name, a type, and a storage location. Creating a managed+fileset creates the directory; pointing at an existing path makes it external.++**3. Read it by name.** Engines reach the files through GVFS or the client rather than the raw path.+See [How to use GVFS](./how-to-use-gvfs.md).++## The Fileset Model++### Managed and External++A managed fileset belongs to Gravitino. Creating it creates the directory, and deleting it deletes+the data.++An external fileset points at a location that already exists and stays under someone else's control.+Deleting it removes the Gravitino record and leaves the files alone.++The distinction only matters at deletion time, and it is the single most important thing to get+right when creating one.++### Storage Locations++A fileset has at least one storage location and can have several, each with a name. The default is+chosen by the `default-location-name` property, and a location supplied without a name is recorded+as `unknown`.++Several locations on one fileset is how the same logical dataset is described across clusters or+regions, with readers selecting the one they should use rather than each carrying its own path.++Locations can also be inherited: a catalog or schema with a `location` property supplies a base, and+a fileset created beneath it can take its placement from that rather than spelling out a full path.++A location can be a template rather than a fixed path. Placeholders such as `{{catalog}}`,+`{{schema}}`, `{{user}}`, and `{{project}}` are filled in when the fileset is created, with values+supplied by `placeholder-` properties. One catalog-level template then generates a consistent+directory layout for every fileset created beneath it, rather than each one being spelled out by+hand.++### Properties++Properties are free-form, with `default-location-name` and the `location-{name}` keys reserved for+placement. Everything else is yours, and travels with the fileset.++## Working With Filesets in the UI++Opening a fileset catalog lists its schemas and the filesets inside them. A fileset shows its type,+its storage locations, and its properties.++Filesets display the tags they carry, including inherited ones, but cannot be tagged from the UI+today. Attaching a tag to a fileset goes through the API.++## Permissions++| Privilege | Grantable on | What it allows |+|------------------|---------------------------------------|-----------------------------|+| `CREATE_FILESET` | Metalake, catalog, schema, or fileset | Creating filesets |+| `READ_FILESET` | Metalake, catalog, schema, or fileset | Reading a fileset's files |+| `WRITE_FILESET` | Metalake, catalog, schema, or fileset | Writing a fileset's files |++Granting at a wider scope covers everything beneath it. Dropping a fileset is reserved for the+metalake owner and the object owner.++## Using the API++Filesets can be created, listed, altered, and dropped over REST and through the Java and Python+clients. Endpoints, payload shapes, and worked examples are in+[Manage Fileset Metadata](./manage-fileset-metadata-using-gravitino.md).diff --git a/docs/functions.md b/docs/functions.mdnew file mode 100644index 0000000000..e3c8fe383a--- /dev/null+++ b/docs/functions.md@@ -0,0 +1,93 @@+---+title: "Functions"+slug: "/functions"+keyword: "function, UDF, user-defined function, Gravitino"+license: "This software is licensed under the Apache License version 2."+---++## Introduction++A function is a piece of logic registered in the catalog so engines can find it and people can+govern it. Registering one puts it in the same hierarchy as tables, with a name, an owner, tags, and+permissions.++Gravitino stores the definition rather than executing it. Whether a function runs, and how, is a+question for the engine that reads it.++## Quick Start++**1. Open a catalog.** Functions live in a schema, alongside the tables they usually operate on. See+[Catalogs and Schemas](./catalogs-and-schemas.md).++**2. Register the function.** Registration is done through the API rather than the UI. A function+needs a name, its type, and at least one definition: a parameter list, a return type, and an+implementation in SQL, Python, or Java.++**3. Use it from an engine.** An engine reading through Gravitino resolves the function by name.++## The Function Model++### Function Types++| Type | Returns |+|-------------|----------------------------------------------------|+| `SCALAR` | One value per row |+| `AGGREGATE` | One value per group |+| `TABLE` | A set of rows, for table-valued operations |++The type is declared when the function is registered and tells an engine how to call it.++### Determinism++A function is marked deterministic or not. A deterministic function returns the same result for the+same arguments every time, which lets an engine cache, reorder, or eliminate calls to it. Marking a+function deterministic when it is not, such as one that reads the clock or a random source, invites+an engine to optimize in ways that change the answer.++Gravitino records the flag and does not verify it.++### Definitions and Implementations++A function has two levels beneath it.++A definition is an overload: one parameter list and one return type. A function with several+definitions is the same name accepting different arguments, the way `round(x)` and `round(x, digits)`+are one function in most engines.++An implementation is how a definition is expressed for a given engine. Each declares a language and+a runtime, so one definition can carry a SQL version for Trino and a Python version for Spark, and+each engine uses the one it can execute.++| Language | Carries |+|----------|--------------------------------------------------|+| `SQL` | The SQL text of the function body |+| `PYTHON` | A handler entrypoint, and optionally inline code |+| `JAVA` | A class name |++Runtimes are `SPARK` and `TRINO`. Java and Python implementations can also carry resources, such as+a jar or a package the runtime needs to load.++## Working With Functions in the UI++Opening a schema lists its functions, and selecting one shows its type, its determinism flag, its+parameters, and its definitions.++The UI displays functions but does not register them. Registering, altering, and dropping a function+all go through the API, as does attaching a tag, which the function page does not display either.++## Permissions++| Privilege | Grantable on | What it allows |+|---------------------|----------------------------------------|-----------------------------------|+| `REGISTER_FUNCTION` | Metalake, catalog, schema, or function | Registering functions |+| `EXECUTE_FUNCTION` | Metalake, catalog, schema, or function | Calling a function from an engine |+| `MODIFY_FUNCTION` | Metalake, catalog, schema, or function | Altering a registered function |++Granting at a wider scope covers everything beneath it. Dropping a function is reserved for the+metalake owner and the object owner.++## Using the API++Functions can be registered, listed, altered, and dropped over REST and through the Java and Python+clients. Endpoints, payload shapes, and worked examples are in+[Manage User-Defined Functions](./manage-user-defined-function-using-gravitino.md).diff --git a/docs/jobs.md b/docs/jobs.mdnew file mode 100644index 0000000000..54ca64a875--- /dev/null+++ b/docs/jobs.md@@ -0,0 +1,77 @@+---+title: "Jobs"+slug: "/jobs"+keyword: "job, job template, Spark job, shell job, Gravitino"+license: "This software is licensed under the Apache License version 2."+---++## Introduction++A job is a piece of work Gravitino runs on your behalf, and a job template is the reusable+definition it runs from. Registering a template once and running it many times is the shape, so the+command, its arguments, and its environment live in the catalog rather than in whoever launched it+last.++Jobs are how catalog-driven work gets done. Table maintenance uses them, and anything else that+should run against metadata Gravitino already knows about can use the same mechanism.++## Quick Start++**1. Register a template.** A template names the kind of job, the command or application to run, and+the arguments it takes.++**2. Run it.** Running a template creates a job, optionally with values for the template's+parameters.++**3. Watch it.** A job reports its status as it moves through the queue, and finished jobs keep their+outcome.++## The Job Model++### Templates and Runs++A template is the definition and a job is one execution of it. Templates are named and reusable,+jobs are individual and carry a status.++Two kinds of template exist. A `SHELL` template runs a command. A `SPARK` template submits a Spark+application.++### Job Status++| Status | Meaning |+|--------------|--------------------------------------------|+| `QUEUED` | Waiting to be executed |+| `STARTED` | Currently executing |+| `SUCCEEDED` | Finished successfully |+| `FAILED` | Finished with an error |+| `CANCELLING` | Cancellation requested, not yet complete |+| `CANCELLED` | Cancellation complete |++Cancellation is a request rather than an instant, which is why `CANCELLING` and `CANCELLED` are+separate. A job that finishes before the cancellation lands stays in its finished state.++### Parameters++A template can declare parameters, and a run supplies values for them. That is what makes one+template serve many cases, rather than a near-copy per variation.++## Working With Jobs in the UI++The jobs area lists job templates and the runs made from them, with each run's status. Templates can+be registered and jobs started from there.++## Permissions++| Privilege | Grantable on | What it allows |+|-------------------------|---------------------------|----------------------------------|+| `REGISTER_JOB_TEMPLATE` | Metalake | Registering job templates |+| `USE_JOB_TEMPLATE` | Metalake, or one template | Reading and using a job template |+| `RUN_JOB` | Metalake | Running a job |++Altering and deleting a job template are reserved for the metalake owner and the template owner.++## Using the API++Job templates and jobs can be registered, listed, run, and cancelled over REST and through the Java+and Python clients. Endpoints, payload shapes, and worked examples are in+[Manage Jobs](./manage-jobs-in-gravitino.md).diff --git a/docs/manage-catalogs-and-schemas.md b/docs/manage-catalogs-and-schemas.mdnew file mode 100644index 0000000000..27d0f43786--- /dev/null+++ b/docs/manage-catalogs-and-schemas.md@@ -0,0 +1,414 @@+---+title: "Manage Catalogs and Schemas"+slug: "/manage-catalogs-and-schemas"+keyword: "catalog management, schema management, catalog, schema, Gravitino"+license: "This software is licensed under the Apache License version 2."+---++import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++## Introduction++This page covers the Gravitino API for catalogs and schemas. For what a catalog and a schema are,+the catalog types, what Gravitino stores, permissions, and how to work with them in the UI, see+[Catalogs and Schemas](./catalogs-and-schemas.md).++Connection properties differ by provider and are documented on each catalog type's own page.++## Catalog Operations++### Create a Catalog++A catalog needs a name, a type, and for most types a provider. Properties carry the connection+details. The example below registers a Hive metastore; other providers take different properties.++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \+ -H "Content-Type: application/json" -d '{+ "name": "sales",+ "type": "RELATIONAL",+ "provider": "hive",+ "comment": "Sales estate",+ "properties": {"metastore.uris": "thrift://localhost:9083"}+}' http://localhost:8090/api/metalakes/example/catalogs+```++</TabItem>+<TabItem value="java" label="Java">++```java+GravitinoClient client = GravitinoClient+ .builder("http://localhost:8090")+ .withMetalake("example")+ .build();++Catalog catalog = client.createCatalog(+ "sales",+ Catalog.Type.RELATIONAL,+ "hive",+ "Sales estate",+ ImmutableMap.of("metastore.uris", "thrift://localhost:9083"));+```++</TabItem>+<TabItem value="python" label="Python">++```python+catalog = client.create_catalog(+ name="sales",+ catalog_type=Catalog.Type.RELATIONAL,+ provider="hive",+ comment="Sales estate",+ properties={"metastore.uris": "thrift://localhost:9083"})+```++</TabItem>+</Tabs>++Fileset and model catalogs are managed by Gravitino rather than federated, so they take no provider.++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \+ -H "Content-Type: application/json" -d '{+ "name": "landing",+ "type": "FILESET",+ "comment": "Landing zone",+ "properties": {"location": "s3a://example-bucket/landing"}+}' http://localhost:8090/api/metalakes/example/catalogs+```++</TabItem>+</Tabs>++### Load a Catalog++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \+ http://localhost:8090/api/metalakes/example/catalogs/sales+```++</TabItem>+<TabItem value="java" label="Java">++```java+Catalog catalog = client.loadCatalog("sales");+```++</TabItem>+<TabItem value="python" label="Python">++```python+catalog = client.load_catalog("sales")+```++</TabItem>+</Tabs>++### Alter a Catalog++Changes are applied as a list in one request.++| Change | JSON | Java | Python |+|--------------------|--------------------------------------------------------------|-----------------------------------------------|-------------------------------------------------|+| Rename | `{"@type":"rename","newName":"sales_v2"}` | `CatalogChange.rename("sales_v2")` | `CatalogChange.rename("sales_v2")` |+| Update the comment | `{"@type":"updateComment","newComment":"new_comment"}` | `CatalogChange.updateComment("new_comment")` | `CatalogChange.update_comment("new_comment")` |+| Set a property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `CatalogChange.setProperty("key1", "value1")` | `CatalogChange.set_property("key1", "value1")` |+| Remove a property | `{"@type":"removeProperty","property":"key1"}` | `CatalogChange.removeProperty("key1")` | `CatalogChange.remove_property("key1")` |++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \+ -H "Content-Type: application/json" -d '{+ "updates": [+ {"@type": "updateComment", "newComment": "Sales estate, production"}+ ]+}' http://localhost:8090/api/metalakes/example/catalogs/sales+```++</TabItem>+<TabItem value="java" label="Java">++```java+Catalog catalog = client.alterCatalog(+ "sales", CatalogChange.updateComment("Sales estate, production"));+```++</TabItem>+<TabItem value="python" label="Python">++```python+catalog = client.alter_catalog(+ "sales", CatalogChange.update_comment("Sales estate, production"))+```++</TabItem>+</Tabs>++### Enable or Disable a Catalog++A catalog that is not in use can only be listed, loaded, enabled, or dropped.++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X PATCH -H "Accept: application/vnd.gravitino.v1+json" \+ -H "Content-Type: application/json" -d '{"inUse": false}' \+ http://localhost:8090/api/metalakes/example/catalogs/sales+```++</TabItem>+<TabItem value="java" label="Java">++```java+client.disableCatalog("sales");+client.enableCatalog("sales");+```++</TabItem>+<TabItem value="python" label="Python">++```python+client.disable_catalog("sales")+client.enable_catalog("sales")+```++</TabItem>+</Tabs>++### Drop a Catalog++Without `force`, the catalog must have no schemas and must not be in use. With `force`, Gravitino+removes the registration and everything it holds about the contents.++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \+ "http://localhost:8090/api/metalakes/example/catalogs/sales?force=false"+```++</TabItem>+<TabItem value="java" label="Java">++```java+boolean dropped = client.dropCatalog("sales", false);+```++</TabItem>+<TabItem value="python" label="Python">++```python+dropped = client.drop_catalog("sales", force=False)+```++</TabItem>+</Tabs>++### List Catalogs++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \+ http://localhost:8090/api/metalakes/example/catalogs++curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \+ "http://localhost:8090/api/metalakes/example/catalogs?details=true"+```++</TabItem>+<TabItem value="java" label="Java">++```java+String[] catalogNames = client.listCatalogs();+Catalog[] catalogs = client.listCatalogsInfo();+```++</TabItem>+<TabItem value="python" label="Python">++```python+catalog_names = client.list_catalogs()+catalogs = client.list_catalogs_info()+```++</TabItem>+</Tabs>++## Schema Operations++Schema operations are the same for every catalog type. Creating a schema through Gravitino creates+it in the source system too, where the source supports that.++### Create a Schema++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \+ -H "Content-Type: application/json" -d '{+ "name": "public",+ "comment": "Shared datasets",+ "properties": {}+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas+```++</TabItem>+<TabItem value="java" label="Java">++```java+Catalog catalog = client.loadCatalog("sales");+Schema schema = catalog.asSchemas().createSchema(+ "public", "Shared datasets", Collections.emptyMap());+```++</TabItem>+<TabItem value="python" label="Python">++```python+catalog = client.load_catalog("sales")+schema = catalog.as_schemas().create_schema(+ schema_name="public", comment="Shared datasets", properties={})+```++</TabItem>+</Tabs>++### Load a Schema++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \+ http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public+```++</TabItem>+<TabItem value="java" label="Java">++```java+Schema schema = catalog.asSchemas().loadSchema("public");+```++</TabItem>+<TabItem value="python" label="Python">++```python+schema = catalog.as_schemas().load_schema("public")+```++</TabItem>+</Tabs>++### Alter a Schema++A schema takes property changes only. It cannot be renamed, and its comment cannot be changed.++| Change | JSON | Java | Python |+|-------------------|--------------------------------------------------------------|----------------------------------------------|-----------------------------------------------|+| Set a property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `SchemaChange.setProperty("key1", "value1")` | `SchemaChange.set_property("key1", "value1")` |+| Remove a property | `{"@type":"removeProperty","property":"key1"}` | `SchemaChange.removeProperty("key1")` | `SchemaChange.remove_property("key1")` |++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \+ -H "Content-Type: application/json" -d '{+ "updates": [+ {"@type": "setProperty", "property": "owner", "value": "sales-eng"}+ ]+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public+```++</TabItem>+<TabItem value="java" label="Java">++```java+Schema schema = catalog.asSchemas().alterSchema(+ "public", SchemaChange.setProperty("owner", "sales-eng"));+```++</TabItem>+<TabItem value="python" label="Python">++```python+schema = catalog.as_schemas().alter_schema(+ "public", SchemaChange.set_property("owner", "sales-eng"))+```++</TabItem>+</Tabs>++### Drop a Schema++Without `cascade`, the schema must be empty. With `cascade`, everything inside it goes as well.++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \+ "http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public?cascade=false"+```++</TabItem>+<TabItem value="java" label="Java">++```java+boolean dropped = catalog.asSchemas().dropSchema("public", false);+```++</TabItem>+<TabItem value="python" label="Python">++```python+dropped = catalog.as_schemas().drop_schema("public", cascade=False)+```++</TabItem>+</Tabs>++### List Schemas++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \+ http://localhost:8090/api/metalakes/example/catalogs/sales/schemas+```++</TabItem>+<TabItem value="java" label="Java">++```java+String[] schemaNames = catalog.asSchemas().listSchemas();+```++</TabItem>+<TabItem value="python" label="Python">++```python+schema_names = catalog.as_schemas().list_schemas()+```++</TabItem>+</Tabs>diff --git a/docs/manage-fileset-metadata-using-gravitino.md b/docs/manage-fileset-metadata-using-gravitino.mdold mode 100644new mode 100755index f5954f9e7c..4b725c74ba--- a/docs/manage-fileset-metadata-using-gravitino.md+++ b/docs/manage-fileset-metadata-using-gravitino.md@@ -1,8 +1,7 @@---title: "Manage Fileset Metadata"slug: "/manage-fileset-metadata-using-gravitino"-date: 2024-4-2-keyword: "Gravitino fileset metadata manage"+keyword: "fileset management, fileset, storage location, GVFS, Gravitino"license: "This software is licensed under the Apache License version 2."---@@ -11,638 +10,139 @@ import TabItem from '@theme/TabItem';## Introduction-This page introduces how to manage fileset metadata in Apache Gravitino. Filesets-are a collection of files and directories. Users can leverage-filesets to manage non-tabular data like training datasets and other raw data.+This page covers the Gravitino API for filesets. For what a fileset is, the difference between+managed and external, how storage locations and placeholders work, and how GVFS reads them, see+[Filesets](./filesets.md). For creating the catalog and schema a fileset lives in, see+[Manage Catalogs and Schemas](./manage-catalogs-and-schemas.md).-Typically, a fileset is mapped to a directory on a file system like HDFS, S3, ADLS, GCS, etc.-With the fileset managed by Gravitino, the non-tabular data can be managed as assets together with-tabular data in Gravitino in a unified way. The following operations will use HDFS as an example, for other-HCFS like S3, OSS, GCS, etc., refer to the corresponding operations [fileset-with-s3](./fileset-catalog-with-s3.md),-[fileset-with-oss](./fileset-catalog-with-oss.md), [fileset-with-gcs](./fileset-catalog-with-gcs.md) and-[fileset-with-adls](./fileset-catalog-with-adls.md).--After a fileset is created, users can easily access, manage the files/directories through-the fileset's identifier, without needing to know the physical path of the managed dataset. Also, with-unified access control mechanism, filesets can be managed via the same role based access-control mechanism without needing to set access controls across different storage systems.--To use filesets, make sure that:-- - Gravitino server has started, and the host and port is [http://localhost:8090](http://localhost:8090).- - A metalake has been created and [enabled](./manage-metalake-using-gravitino.md#enable-a-metalake)--## Catalog Operations--### Create a Catalog+## Fileset Operations-:::tip-For a fileset catalog, you must specify the catalog `type` as `FILESET` when creating the catalog.-:::+### Create a Fileset-Create a catalog by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs`-endpoint or use the Gravitino Java client. The following is an example of creating a catalog:+A fileset needs a name, a type, and a storage location. A `MANAGED` fileset is created and deleted+with its data; an `EXTERNAL` one points at a location that already exists.-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "catalog",- "type": "FILESET",- "comment": "comment",- "properties": {- "location": "file:///tmp/root"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs-+ -H "Content-Type: application/json" -d '{+ "name": "raw_events",+ "comment": "Raw event drops",+ "type": "MANAGED",+ "storageLocation": "s3a://example-bucket/landing/raw_events",+ "properties": {"retention": "30d"}+}' http://localhost:8090/api/metalakes/example/catalogs/landing/schemas/raw/filesets```</TabItem><TabItem value="java" label="Java">```java-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://localhost:8090")- .withMetalake("metalake")- .build();--Map<String, String> properties = ImmutableMap.<String, String>builder()- .put("location", "file:///tmp/root")- // Property "location" is optional. If specified, a managed fileset without- // a storage location will be stored under this location.- .build();--Catalog catalog = gravitinoClient.createCatalog("catalog",- Type.FILESET,- "This is a fileset catalog",- properties);-// ...+Catalog catalog = client.loadCatalog("landing");+FilesetCatalog filesets = catalog.asFilesetCatalog();+Fileset fileset = filesets.createFileset(+ NameIdentifier.of("raw", "raw_events"),+ "Raw event drops",+ Fileset.Type.MANAGED,+ "s3a://example-bucket/landing/raw_events",+ ImmutableMap.of("retention", "30d"));```</TabItem><TabItem value="python" label="Python">```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")-catalog = gravitino_client.create_catalog(name="catalog",- catalog_type=Catalog.Type.FILESET,- provider=None,- comment="This is a fileset catalog",- properties={"location": "/tmp/test1"})-```--</TabItem>-</Tabs>--Gravitino supports the following catalog providers:--| Catalog provider | Catalog property |-|---------------------|---------------------------------------------------------------------|-| `fileset` or `None` | [Fileset catalog property](./fileset-catalog.md#catalog-properties) |--### Load a Catalog--Refer to [Load a catalog](./manage-relational-metadata-using-gravitino.md#load-a-catalog)-in relational catalog for more details. For a fileset catalog, the load operation is the same.--### Alter a Catalog--Refer to [Alter a catalog](./manage-relational-metadata-using-gravitino.md#alter-a-catalog)-in relational catalog for more details. For a fileset catalog, the alter operation is the same.--### Drop a Catalog--Refer to [Drop a catalog](./manage-relational-metadata-using-gravitino.md#drop-a-catalog)-in relational catalog for more details. For a fileset catalog, the drop operation is the same.--:::note-- Gravitino doesn't support dropping a catalog with schemas and filesets under it. You have-to drop all the schemas and filesets under the catalog before dropping the catalog.-- The value of location property in a catalog should be a directory on a file system- (HDFS) or path prefix on a cloud storage (S3, GCS, etc.).** The same goes for schema and fileset.-:::--### List All Catalogs in a Metalake--Refer to [List all catalogs in a metalake](./manage-relational-metadata-using-gravitino.md#list-all-catalogs-in-a-metalake)-in relational catalog for more details. For a fileset catalog, the list operation is the same.--### List All Catalog Information in a Metalake--Refer to [List all catalog information in a metalake](./manage-relational-metadata-using-gravitino.md#list-all-catalog-information-in-a-metalake)-in relational catalog for more details. For a fileset catalog, the list operation is the same.+catalog = client.load_catalog("landing")+filesets = catalog.as_fileset_catalog()-## Schema Operations--`Schema` is a virtual namespace in a fileset catalog, which is used to organize the fileset. It-is similar to the concept of `schema` in relational catalog.--:::tip-Users should create a metalake and a catalog before creating a schema.-:::--### Create a Schema--Create a schema by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas`-endpoint or use the Gravitino Java client. The following is an example of creating a schema:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "schema",- "comment": "comment",- "properties": {- "location": "file:///tmp/root/schema"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas-```--</TabItem>-<TabItem value="java" label="Java">--```java-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://localhost:8090")- .withMetalake("metalake")- .build();--// Assuming you have just created a Fileset catalog named `catalog`-Catalog catalog = gravitinoClient.loadCatalog("catalog");--SupportsSchemas supportsSchemas = catalog.asSchemas();--Map<String, String> schemaProperties = ImmutableMap.<String, String>builder()- // Property "location" is optional, if specified all the managed fileset without- // specifying storage location will be stored under this location.- .put("location", "file:///tmp/root/schema")- .build();-Schema schema = supportsSchemas.createSchema("schema",- "This is a schema",- schemaProperties-);-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")--catalog: Catalog = gravitino_client.load_catalog(name="catalog")-catalog.as_schemas().create_schema(name="schema",- comment="This is a schema",- properties={"location": "/tmp/root/schema"})+fileset = filesets.create_fileset(+ ident=NameIdentifier.of("raw", "raw_events"),+ comment="Raw event drops",+ fileset_type=Fileset.Type.MANAGED,+ storage_location="s3a://example-bucket/landing/raw_events",+ properties={"retention": "30d"})```</TabItem></Tabs>-Gravitino supports the following schema property:--| Catalog provider | Schema property |-|------------------|-------------------------------------------------------------------|-| `fileset` | [Fileset schema property](./fileset-catalog.md#schema-properties) |--### Load a Schema--Refer to [Load a schema](./manage-relational-metadata-using-gravitino.md#load-a-schema)-in relational catalog for more details. For a fileset catalog, the schema load operation is the-same.--### Alter a Schema+### Create a Fileset With Several Locations-Refer to [Alter a schema](./manage-relational-metadata-using-gravitino.md#alter-a-schema)-in relational catalog for more details. For a fileset catalog, the schema alter operation is the-same.+`storageLocations` takes a map of location name to path. The name is what a reader selects, and+`default-location-name` picks the one used when none is named.-### Drop a Schema--Refer to [Drop a schema](./manage-relational-metadata-using-gravitino.md#drop-a-schema)-in relational catalog for more details. For a fileset catalog, the schema drop operation is the-same.--Note that the drop operation will delete all the fileset metadata under this schema if `cascade`-set to `true`. Besides, for `MANAGED` fileset, this drop operation will also **remove** all the-files/directories of this fileset; for `EXTERNAL` fileset, this drop operation will only delete-the metadata of this fileset.--### List All Schemas Under a Catalog--Refer to [List all schemas under a catalog](./manage-relational-metadata-using-gravitino.md#list-all-schemas-under-a-catalog)-in relational catalog for more details. For a fileset catalog, the schema list operation is the-same.--## Fileset Operations--:::tip- - Users should create a metalake, a catalog, and a schema before creating a fileset.- - Gravitino only supports managing Hadoop Compatible File System (HCFS) locations.-:::--### Create a Fileset--Create a fileset by sending a `POST` request to the `/api/metalakes/{metalake_name}-/catalogs/{catalog_name}/schemas/{schema_name}/filesets` endpoint or use the Gravitino Java-client. The following is an example of creating a fileset with single storage location:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "example_fileset",- "comment": "This is an example fileset",+ -H "Content-Type: application/json" -d '{+ "name": "raw_events",+ "comment": "Raw event drops, two regions","type": "MANAGED",- "storageLocation": "file:///tmp/root/schema/example_fileset",- "properties": {- "k1": "v1"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/filesets-```--</TabItem>-<TabItem value="java" label="Java">--```java-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://localhost:8090")- .withMetalake("metalake")- .build();--Catalog catalog = gravitinoClient.loadCatalog("catalog");-FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();--Map<String, String> propertiesMap = ImmutableMap.<String, String>builder()- .put("k1", "v1")- .build();--filesetCatalog.createFileset(- NameIdentifier.of("schema", "example_fileset"),- "This is an example fileset",- Fileset.Type.MANAGED,- "file:///tmp/root/schema/example_fileset",- propertiesMap,-);-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")--catalog: Catalog = gravitino_client.load_catalog(name="catalog")-catalog.as_fileset_catalog().create_fileset(ident=NameIdentifier.of("schema", "example_fileset"),- type=Fileset.Type.MANAGED,- comment="This is an example fileset",- storage_location="/tmp/root/schema/example_fileset",- properties={"k1": "v1"})+ "storageLocations": {+ "us": "s3a://example-us/landing/raw_events",+ "eu": "s3a://example-eu/landing/raw_events"+ },+ "properties": {"default-location-name": "us"}+}' http://localhost:8090/api/metalakes/example/catalogs/landing/schemas/raw/filesets```</TabItem></Tabs>-Gravitino supports two **types** of filesets:+### Create a Fileset From a Location Template- - `MANAGED`: The storage location of the fileset is managed by Gravitino when specified as- `MANAGED`, the physical location of the fileset will be deleted when this fileset is dropped.- - `EXTERNAL`: The storage location of the fileset is **not** managed by Gravitino, when- specified as `EXTERNAL`, the files of the fileset will **not** be deleted when- the fileset is dropped.+A catalog or schema can carry a location template, and a fileset created beneath it fills the+placeholders from its own `placeholder-` properties.-:::note-During fileset creation or deletion, Gravitino automatically creates or removes the corresponding filesystem directories for the fileset locations.-This behavior is skipped in either of these cases:-1. When the catalog property `disable-filesystem-ops` is set to `true`-2. When the location contains [placeholders](./manage-fileset-metadata-using-gravitino.md#placeholder)-:::--#### StorageLocation--The `storageLocation` is the physical location of the fileset. Users can specify this location-when creating a fileset, or follow the rules of the catalog/schema location if not specified.--For a `MANAGED` fileset, the storage location is determined in the following priority order:--1. If the user specifies `storageLocation` during fileset creation:- - This location is used, with any [placeholders](#placeholder) replaced by the corresponding fileset property values.--2. If the user doesn't specify `storageLocation`:- - If schema property `location` is specified:- - Use `<schema location>/<fileset name>` if schema location has no placeholders- - Use `<schema location>` with placeholders replaced by fileset property values-- - Otherwise, if catalog property `location` is specified:- - Use `<catalog location>/<schema name>/<fileset name>` if catalog location has no placeholders- - Use `<catalog location>` with placeholders replaced by fileset property values-- - If neither schema nor catalog location is specified:- - The user must provide `storageLocation` during fileset creation--For an `EXTERNAL` fileset, the user must always specify `storageLocation` during fileset creation.-If the provided location contains placeholders, they will be replaced by the corresponding fileset property values.--#### Placeholder--The `storageLocation` in each level can contain **placeholders**, format as `{{name}}`, which will-be replaced by the corresponding fileset property value when the fileset object is created. The-placeholder property in the fileset object is formed as `placeholder-{{name}}`. For example, if-the `storageLocation` is `file:///tmp/{{schema}}-{{fileset}}-{{verion}}`, and the fileset object-named "catalog1.schema1.fileset1" contains the properties `placeholder-version=v1`,-the actual `storageLocation` will be `file:///tmp/schema1-fileset1-v1`.--The following is an example of creating a fileset with placeholders in the `storageLocation`:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shell-# create a catalog firstcurl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "test_catalog",- "type": "FILESET",- "comment": "comment",- "properties": {- "location": "file:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs--# create a schema under the catalog-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "test_schema",- "comment": "comment",- "properties": {}-}' http://localhost:8090/api/metalakes/metalake/catalogs/test_catalog/schemas--# create a fileset by placeholders-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "example_fileset",- "comment": "This is an example fileset",+ -H "Content-Type: application/json" -d '{+ "name": "workspace","type": "MANAGED","properties": {- "placeholder-project": "test_project",- "placeholder-user": "test_user"+ "placeholder-project": "risk",+ "placeholder-user": "mhoerth"}-}' http://localhost:8090/api/metalakes/metalake/catalogs/test_catalog/schemas/test_schema/filesets--# the actual storage location of the fileset will be: file:///test_catalog/test_schema/workspace_test_project/test_user-```--</TabItem>-<TabItem value="java" label="Java">--```java-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://localhost:8090")- .withMetalake("metalake")- .build();-// create a catalog first-Catalog catalog = gravitinoClient.createCatalog(- "test_catalog",- Type.FILESET,- "comment",- ImmutableMap.of("location", "file:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"));-FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();--// create a schema under the catalog-filesetCatalog.createSchema("test_schema", "comment", null);--// create a fileset by placeholders-filesetCatalog.createFileset(- NameIdentifier.of("test_schema", "example_fileset"),- "This is an example fileset",- Fileset.Type.MANAGED,- null,- ImmutableMap.of("placeholder-project", "test_project", "placeholder-user", "test_user")-);--// the actual storage location of the fileset will be: file:///test_catalog/test_schema/workspace_test_project/test_user-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")--# create a catalog first-catalog: Catalog = gravitino_client.create_catalog(name="test_catalog",- catalog_type=Catalog.Type.FILESET,- provider=None,- comment="comment",- properties={"location": "file:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"})--# create a schema under the catalog-catalog.as_schemas().create_schema(name="test_schema", comment="comment", properties={})--# create a fileset by placeholders-catalog.as_fileset_catalog().create_fileset(ident=NameIdentifier.of("test_schema", "example_fileset"),- type=Fileset.Type.MANAGED,- comment="This is an example fileset",- storage_location=None,- properties={"placeholder-project": "test_project", "placeholder-user": "test_user"})--# the actual storage location of the fileset will be: file:///test_catalog/test_schema/workspace_test_project/test_user+}' http://localhost:8090/api/metalakes/example/catalogs/landing/schemas/raw/filesets```</TabItem></Tabs>-#### StorageLocations+With a catalog location of+`s3a://example-bucket/{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}`, that request resolves+to `s3a://example-bucket/landing/raw/workspace_risk/mhoerth`.-Create a fileset with multiple storage locations. The `storageLocations` is a map of location name to storage location.-The generation rules of each location follow the generation rules of a single location.-The following is an example of creating a fileset with multiple storage locations:+### Load a Fileset-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shell-# create a catalog first-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "test_catalog",- "type": "FILESET",- "comment": "comment",- "properties": {- "location-l1": "file:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}",- "location-l2": "hdfs:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs--# create a schema under the catalog-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "test_schema",- "comment": "comment",- "properties": {- "location-l3": "s3a://myBucket/{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs/test_catalog/schemas--# create a fileset by placeholders-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "example_fileset",- "comment": "This is an example fileset",- "type": "MANAGED",- "storageLocations": {- "l4": "gs://myBucket/{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"- },- "properties": {- "placeholder-project": "test_project",- "placeholder-user": "test_user",- "default-location-name": "l1"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs/test_catalog/schemas/test_schema/filesets--# the fileset will be created with 4 storage locations:-{- "name": "example_fileset",- "comment": "This is an example fileset",- "type": "MANAGED",- "storageLocation": null,- "storageLocations": {- "l1": "file:///test_catalog/test_schema/workspace_test_project/test_user",- "l2": "hdfs:///test_catalog/test_schema/workspace_test_project/test_user",- "l3": "s3a://myBucket/test_catalog/test_schema/workspace_test_project/test_user",- "l4": "gs://myBucket/test_catalog/test_schema/workspace_test_project/test_user"- },- "properties": {- "placeholder-project": "test_project",- "placeholder-user": "test_user",- "default-location-name": "l1"- }-}+curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \+ http://localhost:8090/api/metalakes/example/catalogs/landing/schemas/raw/filesets/raw_events```</TabItem><TabItem value="java" label="Java">```java-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://localhost:8090")- .withMetalake("metalake")- .build();-// create a catalog first-Catalog catalog = gravitinoClient.createCatalog(- "test_catalog",- Type.FILESET,- "comment",- ImmutableMap.of(- "location-l1", "file:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}",- "location-l2", "hdfs:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"));-FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();--// create a schema under the catalog-filesetCatalog.createSchema(- "test_schema",- "comment",- ImmutableMap.of("location-l3", "s3a://myBucket/{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"));--// create a fileset by placeholders-filesetCatalog.createMultipleLocationFileset(- NameIdentifier.of("test_schema", "example_fileset"),- "This is an example fileset",- Fileset.Type.MANAGED,- ImmutableMap.of("l4", "gs://myBucket/{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}"),- ImmutableMap.of(- "placeholder-project", "test_project",- "placeholder-user", "test_user",- "default-location-name", "l1")-);--// the fileset will be created with 4 storage locations:-{- "name": "example_fileset",- "comment": "This is an example fileset",- "type": "MANAGED",- "storageLocation": null,- "storageLocations": {- "l1": "file:///test_catalog/test_schema/workspace_test_project/test_user",- "l2": "hdfs:///test_catalog/test_schema/workspace_test_project/test_user",- "l3": "s3a://myBucket/test_catalog/test_schema/workspace_test_project/test_user",- "l4": "gs://myBucket/test_catalog/test_schema/workspace_test_project/test_user"- },- "properties": {- "placeholder-project": "test_project",- "placeholder-user": "test_user",- "default-location-name": "l1"- }-}+Fileset fileset = filesets.loadFileset(NameIdentifier.of("raw", "raw_events"));```</TabItem><TabItem value="python" label="Python">```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")--# create a catalog first-catalog: Catalog = gravitino_client.create_catalog(- name="test_catalog",- catalog_type=Catalog.Type.FILESET,- provider=None,- comment="comment",- properties={- "location-l1": "file:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}",- "location-l2": "hdfs:///{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}",- }-)--# create a schema under the catalog-catalog.as_schemas().create_schema(- name="test_schema",- comment="comment",- properties={- "location-l3": "s3a://myBucket/{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}",- }-)--# create a fileset by placeholders-catalog.as_fileset_catalog().create_multiple_location_fileset(- ident=NameIdentifier.of("test_schema", "example_fileset"),- type=Fileset.Type.MANAGED,- comment="This is an example fileset",- storage_locations={- "l4": "gs://myBucket/{{catalog}}/{{schema}}/workspace_{{project}}/{{user}}",- },- roperties={- "placeholder-project": "test_project",- "placeholder-user": "test_user",- "default-location-name": "l1",- }-)--# the fileset will be created with 4 storage locations:-{- "name": "example_fileset",- "comment": "This is an example fileset",- "type": "MANAGED",- "storageLocation": null,- "storageLocations": {- "l1": "file:///test_catalog/test_schema/workspace_test_project/test_user",- "l2": "hdfs:///test_catalog/test_schema/workspace_test_project/test_user",- "l3": "s3a://myBucket/test_catalog/test_schema/workspace_test_project/test_user",- "l4": "gs://myBucket/test_catalog/test_schema/workspace_test_project/test_user"- },- "properties": {- "placeholder-project": "test_project",- "placeholder-user": "test_user",- "default-location-name": "l1"- }-}+fileset = filesets.load_fileset(NameIdentifier.of("raw", "raw_events"))```</TabItem>@@ -650,316 +150,97 @@ catalog.as_fileset_catalog().create_multiple_location_fileset(### Alter a Fileset-Modify a fileset by sending a `PUT` request to the `/api/metalakes/{metalake_name}-/catalogs/{catalog_name}/schemas/{schema_name}/filesets/{fileset_name}` endpoint or just use the-Gravitino Java client. The following is an example of modifying a fileset:+Changes are applied as a list in one request. Storage locations cannot be changed after creation.++| Change | JSON | Java |+|--------------------|--------------------------------------------------------------|-----------------------------------------------|+| Rename | `{"@type":"rename","newName":"fileset_renamed"}` | `FilesetChange.rename("fileset_renamed")` |+| Update the comment | `{"@type":"updateComment","newComment":"new_comment"}` | `FilesetChange.updateComment("new_comment")` |+| Set a property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `FilesetChange.setProperty("key1", "value1")` |+| Remove a property | `{"@type":"removeProperty","property":"key1"}` | `FilesetChange.removeProperty("key1")` |-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{+ -H "Content-Type: application/json" -d '{"updates": [- {- "@type": "removeProperty",- "property": "key2"- }, {- "@type": "setProperty",- "property": "key3",- "value": "value3"- }+ {"@type": "setProperty", "property": "retention", "value": "90d"}]-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/filesets/fileset+}' http://localhost:8090/api/metalakes/example/catalogs/landing/schemas/raw/filesets/raw_events```</TabItem><TabItem value="java" label="Java">```java-// ...-// Assuming you have just created a Fileset catalog named `catalog`-Catalog catalog = gravitinoClient.loadCatalog("catalog");--FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();--Fileset f = filesetCatalog.alterFileset(NameIdentifier.of("schema", "fileset"),- FilesetChange.rename("fileset_renamed"), FilesetChange.updateComment("xxx"));-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")--catalog: Catalog = gravitino_client.load_catalog(name="catalog")-changes = (- FilesetChange.remove_property("fileset_properties_key1"),- FilesetChange.set_property("fileset_properties_key2", "fileset_properties_new_value"),-)-fileset_new = catalog.as_fileset_catalog().alter_fileset(NameIdentifier.of("schema", "fileset"),- *changes)+Fileset fileset = filesets.alterFileset(+ NameIdentifier.of("raw", "raw_events"),+ FilesetChange.setProperty("retention", "90d"));```</TabItem></Tabs>-Gravitino supports the following changes to a fileset:--| Supported modification | JSON | Java |-|-----------------------------|--------------------------------------------------------------|-----------------------------------------------|-| Rename a fileset | `{"@type":"rename","newName":"fileset_renamed"}` | `FilesetChange.rename("fileset_renamed")` |-| Update a comment | `{"@type":"updateComment","newComment":"new_comment"}` | `FilesetChange.updateComment("new_comment")` |-| Set a fileset property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `FilesetChange.setProperty("key1", "value1")` |-| Remove a fileset property | `{"@type":"removeProperty","property":"key1"}` | `FilesetChange.removeProperty("key1")` |-| Remove comment (deprecated) | `{"@type":"removeComment"}` | `FilesetChange.removeComment()` |-### Drop a Fileset-Remove a fileset by sending a `DELETE` request to the `/api/metalakes/{metalake_name}-/catalogs/{catalog_name}/schemas/{schema_name}/filesets/{fileset_name}` endpoint or by using the-Gravitino Java client. The following is an example of dropping a fileset:+Dropping a `MANAGED` fileset deletes its files. Dropping an `EXTERNAL` one removes only the+Gravitino record.-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/filesets/fileset+ http://localhost:8090/api/metalakes/example/catalogs/landing/schemas/raw/filesets/raw_events```</TabItem><TabItem value="java" label="Java">```java-// ...-// Assuming you have just created a Fileset catalog named `catalog`-Catalog catalog = gravitinoClient.loadCatalog("catalog");--FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();--// Drop a fileset-filesetCatalog.dropFileset(NameIdentifier.of("schema", "fileset"));-// ...+boolean dropped = filesets.dropFileset(NameIdentifier.of("raw", "raw_events"));```</TabItem><TabItem value="python" label="Python">```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")--catalog: Catalog = gravitino_client.load_catalog(name="catalog")-catalog.as_fileset_catalog().drop_fileset(ident=NameIdentifier.of("schema", "fileset"))+dropped = filesets.drop_fileset(NameIdentifier.of("raw", "raw_events"))```</TabItem></Tabs>-For a `MANAGED` fileset, the physical location of the fileset will be deleted when this fileset is-dropped. For `EXTERNAL` fileset, only the metadata of the fileset will be removed.-### List Filesets-List all filesets in a schema by sending a `GET` request to the `/api/metalakes/-{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/filesets` endpoint or by using the-Gravitino Java client. The following is an example of listing all the filesets in a schema:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/filesets+ http://localhost:8090/api/metalakes/example/catalogs/landing/schemas/raw/filesets```</TabItem><TabItem value="java" label="Java">```java-// ...-Catalog catalog = gravitinoClient.loadCatalog("catalog");--FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();-NameIdentifier[] identifiers =- filesetCatalog.listFilesets(Namespace.of("schema"));-// ...+NameIdentifier[] identifiers = filesets.listFilesets(Namespace.of("raw"));```</TabItem><TabItem value="python" label="Python">```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")--catalog: Catalog = gravitino_client.load_catalog(name="catalog")-fileset_list: List[NameIdentifier] = catalog.as_fileset_catalog().list_filesets(namespace=Namespace.of("schema")))+identifiers = filesets.list_filesets(Namespace.of("raw"))```</TabItem></Tabs>+### Reading and Writing Files-## Manage Filesets Across Multiple Clusters---In general, the locations of all schemas and filesets under a fileset-catalog belong to a single Hadoop cluster if they are HDFS location.--The example for creating a fileset is as follows:-```text-# create fileset catalog-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "fileset_catalog",- "type": "FILESET",- "comment": "This is a fileset catalog",- "provider": "fileset",- "properties": {- "location": "hdfs://172.17.0.2:9000/fileset_catalog"- }-}' http://localhost:8090/api/metalakes/test/catalogs--# create a fileset schema under the catalog with inherited properties-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "test_schema",- "comment": "This is a schema",- "properties": {- }-}' http://localhost:8090/api/metalakes/test/catalogs/fileset_catalog/schemas--# create a fileset under the schema with inherited properties-curl -X POST -H "Accept: application/vnd.gravitino.v1+json"--H "Content-Type: application/json" -d '{- "name": "fs1",- "comment": "This is an example fileset",- "type": "MANAGED",- "properties": {- }-}' http://localhost:8090/api/metalakes/test/catalogs/fileset_catalog/schemas/test_schema/filesets-```--Within a fileset catalog, schemas and filesets can automatically inherit configuration properties-from their parent catalog. For example, the location property can be inherited — a schema can inherit-the catalog’s location as its base path, and a fileset can in turn inherit the schema’s location as its base path.--The property inheritance priority is as follows: catalog < schema < fileset.--If a fileset needs to use a different storage path, it can specify its own location configuration to-override the inherited one.--The fileset catalog also supports multiple clusters. Each schema and fileset under a catalog can independently-specify their own cluster locations and connection configurations.--For example, a complex catalog structure might look like this:--```text-catalog1 -> hdfs://cluster1/catalog1- schema1 -> hdfs://cluster1/catalog1/schema1- fileset1 -> hdfs://cluster1/catalog1/schema1/fileset1- fileset2 -> hdfs://cluster1/catalog1/schema1/fileset2- schema2 -> hdfs://cluster2/tmp/schema2- fileset3 -> hdfs://cluster2/tmp/schema2/fsd- fileset4 -> hdfs://cluster3/customers-```--In this example, the default location of catalog1 is hdfs://cluster1/catalog1.-schema1 and its filesets are stored in the same cluster as defined by the catalog (cluster1).-However, schema2 and its filesets (fileset3, fileset4) are located in different clusters (cluster2 and cluster3, respectively).---The example for creating Filesets with different clusters as follows:--```text-# create fileset catalog-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "fileset_catalog",- "type": "FILESET",- "comment": "This is a fileset catalog",- "provider": "fileset",- "properties": {- "location": "hdfs://172.17.0.2:9000/fileset_catalog"- }-}' http://localhost:8090/api/metalakes/test/catalogs--# create a fileset schema under the catalog with inherited properties-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "test_schema",- "comment": "This is a schema",- "properties": {- }-}' http://localhost:8090/api/metalakes/test/catalogs/fileset_catalog/schemas---# create fileset fs1 in the default HDFS cluster-curl -X POST -H "Accept: application/vnd.gravitino.v1+json"--H "Content-Type: application/json" -d '{- "name": "fs1",- "comment": "This is an example fileset",- "type": "MANAGED",- "properties": {- }-}' http://localhost:8090/api/metalakes/test/catalogs/fileset_catalog/schemas/test_schema/filesets--# create fileset fs2 in another HDFS cluster-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "fs2",- "comment": "This is an example fileset",- "type": "MANAGED",- "storageLocation": "hdfs://172.17.0.3:9000/tmp/fs2",- "properties": {- "config.resources": "/etc/conf/cluster1/core-site.xml,/etc/conf/cluster1/hdfs-site.xml"- }-}' http://localhost:8090/api/metalakes/test/catalogs/fileset_catalog/schemas/test_schema/filesets-```--Alternatively, you can pass configurations for multiple clusters using the `fs.path.config.{cluster_name}.*` format when creating the fileset catalog.-All schemas and filesets under the catalog can inherit configuration based on the cluster name,-and the configuration can be overridden at the schema or fileset level if needed.-The system can automatically retrieve the appropriate configuration from `fs.path.config` configuration based on the fileset’s storage location-and override the corresponding fileset properties by key.--```text-# create fileset catalog with multiple cluster configurations, and specify HDFS and S3 clusters configurations by logical names-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "fileset_catalog",- "type": "FILESET",- "comment": "This is a fileset catalog",- "provider": "fileset",- "properties": {- "location": "hdfs://172.17.0.2:9000/fileset_catalog",- "fs.path.config.hadoop1"="hdfs://172.17.0.2:9000",- "fs.path.config.hadoop1.config.resources"="/etc/conf/cluster1/core-site.xml,/etc/conf/cluster1/hdfs-site.xml",- "fs.path.config.aws1"="s3://mybuctket",- "fs.path.config.aws1.access.key"="your_access_key",- "fs.path.config.aws1.secret.key"="your_secret_key"- }-}' http://localhost:8090/api/metalakes/test/catalogs--# create fileset fs1 in the default HDFS cluster, it will inherit the hadoop1 cluster configuration from the catalog-curl -X POST -H "Accept: application/vnd.gravitino.v1+json"--H "Content-Type: application/json" -d '{- "name": "fs1",- "comment": "This is an example fileset",- "type": "MANAGED",- "storageLocation": "hdfs://172.17.0.2:9000/datawarehouse/fs1"-}' http://localhost:8090/api/metalakes/test/catalogs/fileset_catalog/schemas/test_schema/filesets--# create fileset fs2 in another s3 cluster, it will inherit the aws1 cluster configuration from the catalog-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "fs2",- "comment": "This is an example fileset",- "type": "MANAGED",- "storageLocation": "s3://mybuctket/datawarehouse/fs2"-}' http://localhost:8090/api/metalakes/test/catalogs/fileset_catalog/schemas/test_schema/filesets-```+Fileset metadata operations do not move data. Reading and writing the files themselves goes through+GVFS. See [How to use GVFS](./how-to-use-gvfs.md).diff --git a/docs/manage-messaging-metadata-using-gravitino.md b/docs/manage-messaging-metadata-using-gravitino.mdold mode 100644new mode 100755index 589bfa8657..f557786332--- a/docs/manage-messaging-metadata-using-gravitino.md+++ b/docs/manage-messaging-metadata-using-gravitino.md@@ -1,8 +1,7 @@---title: "Manage Messaging Metadata"-slug: "/manage-massaging-metadata-using-gravitino"-date: 2024-4-22-keyword: "Gravitino massaging metadata manage"+slug: "/manage-messaging-metadata-using-gravitino"+keyword: "topic management, topic, messaging, Kafka, Gravitino"license: "This software is licensed under the Apache License version 2."---@@ -11,182 +10,74 @@ import TabItem from '@theme/TabItem';## Introduction-This page introduces how to manage messaging metadata using Apache Gravitino. Messaging metadata refers to-the topic metadata of the messaging system such as Apache Kafka, Apache Pulsar, Apache RocketMQ, etc.-Through Gravitino, you can create, update, delete, and list topics via unified RESTful APIs or Java client.+This page covers the Gravitino API for topics. For what a topic is, the default schema a messaging+catalog presents, topic properties, and what Gravitino does not cover, see [Topics](./topics.md). For+creating the catalog a topic lives in, see+[Manage Catalogs and Schemas](./manage-catalogs-and-schemas.md) and+[Apache Kafka catalog](./kafka-catalog.md).-To use the messaging catalog, make sure that:+A messaging catalog presents a single schema named `default`, so every path below uses it.- - Gravitino server has started, and the host and port is [http://localhost:8090](http://localhost:8090).- - A metalake has been created and [enabled](./manage-metalake-using-gravitino.md#enable-a-metalake).+The Python client does not cover topics. `as_topic_catalog()` exists but raises+`UnsupportedOperationException`, so the examples below are REST and Java only.-## Catalog Operations--### Create a Catalog+## Topic Operations-:::tip-For a messaging catalog, you must specify the `type` as `messaging` when creating a catalog.-:::+### Create a Topic-Create a catalog by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs`-endpoint or use the Gravitino Java client. The following is an example of creating a messaging catalog:+A topic needs a name. `partition-count` and `replication-factor` are optional and fall back to the+broker's own defaults.<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shellcurl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "catalog",- "type": "MESSAGING",- "comment": "comment",- "provider": "kafka",+ -H "Content-Type: application/json" -d '{+ "name": "orders",+ "comment": "Order events","properties": {- "bootstrap.servers": "localhost:9092",+ "partition-count": "3",+ "replication-factor": "1"}-}' http://localhost:8090/api/metalakes/metalake/catalogs+}' http://localhost:8090/api/metalakes/example/catalogs/events/schemas/default/topics```</TabItem><TabItem value="java" label="Java">```java-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://127.0.0.1:8090")- .withMetalake("metalake")- .build();--Map<String, String> properties = ImmutableMap.<String, String>builder()- // You should replace the following with your own Kafka bootstrap servers that Gravitino can connect to.- .put("bootstrap.servers", "localhost:9092")- .build();--Catalog catalog = gravitinoClient.createCatalog("catalog",- Type.MESSAGING,- "kafka", // provider, Gravitino only supports "kafka" for now.- "This is a Kafka catalog",- properties);-// ...+Catalog catalog = client.loadCatalog("events");+TopicCatalog topics = catalog.asTopicCatalog();++Topic topic = topics.createTopic(+ NameIdentifier.of("default", "orders"),+ "Order events",+ null,+ ImmutableMap.of("partition-count", "3", "replication-factor", "1"));```</TabItem></Tabs>-Gravitino supports the following catalog providers:--| Catalog provider | Catalog property |-|------------------|-----------------------------------------------------------------|-| `kafka` | [Kafka catalog property](./kafka-catalog.md#catalog-properties) |--### Load a Catalog--Refer to [Load a catalog](./manage-relational-metadata-using-gravitino.md#load-a-catalog)-in relational catalog for more details. For a messaging catalog, the load operation is the same.--### Alter a Catalog--Refer to [Alter a catalog](./manage-relational-metadata-using-gravitino.md#alter-a-catalog)-in relational catalog for more details. For a messaging catalog, the alter operation is the same.--### Drop a Catalog--Refer to [Drop a catalog](./manage-relational-metadata-using-gravitino.md#drop-a-catalog)-in relational catalog for more details. For a messaging catalog, the drop operation is the same.--### List All Catalogs in a Metalake--Refer to [List all catalogs in a metalake](./manage-relational-metadata-using-gravitino.md#list-all-catalogs-in-a-metalake)-in relational catalog for more details. For a messaging catalog, the list operation is the same.--### List All Catalog Information in a Metalake--Refer to [List all catalog information in a metalake](./manage-relational-metadata-using-gravitino.md#list-all-catalog-information-in-a-metalake)-in relational catalog for more details. For a messaging catalog, the list operation is the same.--## Schema Operations--`Schema` is a logical grouping of topics in a messaging catalog, if the messaging system does not support topics grouping,-schema operations are not supported but a "default" schema will be automatically created to include all topics--:::caution note-Gravitino supports only the Kafka catalog. Since Kafka does not support topic grouping, only list and load operations are supported for schema.-:::--### Create a Schema--Refer to [Create a schema](./manage-relational-metadata-using-gravitino.md#create-a-schema)-in relational catalog for more details. For a messaging catalog, the create operation is the same.--### Load a Schema--Refer to [Load a schema](./manage-relational-metadata-using-gravitino.md#load-a-schema)-in relational catalog for more details. For a messaging catalog, the load operation is the same.--### Alter a Schema--Refer to [Alter a schema](./manage-relational-metadata-using-gravitino.md#alter-a-schema)-in relational catalog for more details. For a messaging catalog, the alter operation is the same.--### Drop a Schema--Refer to [Drop a schema](./manage-relational-metadata-using-gravitino.md#drop-a-schema)-in relational catalog for more details. For a messaging catalog, the drop operation is the same.--### List All Schemas Under a Catalog--Refer to [List all schemas under a catalog](./manage-relational-metadata-using-gravitino.md#list-all-schemas-under-a-catalog)-in relational catalog for more details. For a messaging catalog, the list operation is the same.--## Topic Operations--:::tip-Users should create a metalake, a catalog and a schema, then ensure that the metalake and catalog are enabled before operating topics.-:::--### Create a Topic--Create a topic by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/topics`-endpoint or use the Gravitino Java client. The following is an example of creating a topic:+The third argument to `createTopic` is the message schema, which is not supported and is always+`null`.+### Load a Topic<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shell-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "example_topic",- "comment": "This is an example topic",- "properties": {- "partition-count": "3",- "replication-factor": 1- }-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/default/topics+curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \+ http://localhost:8090/api/metalakes/example/catalogs/events/schemas/default/topics/orders```</TabItem><TabItem value="java" label="Java">```java-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://127.0.0.1:8090")- .withMetalake("metalake")- .build();--Catalog catalog = gravitinoClient.loadCatalog("catalog");-TopicCatalog topicCatalog = catalog.asTopicCatalog();--Map<String, String> propertiesMap = ImmutableMap.<String, String>builder()- .put("partition-count": "3")- .put("replication-factor": "1")- .build();--topicCatalog.createTopic(- NameIdentifier.of("default", "example_topic"),- "This is an example topic",- null, // The message schema of the topic object. Always null because it's not supported yet.- propertiesMap,-);+Topic topic = topics.loadTopic(NameIdentifier.of("default", "orders"));```</TabItem>@@ -194,115 +85,77 @@ topicCatalog.createTopic(### Alter a Topic-Modify a topic by sending a `PUT` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/topics/{topic_name}`-endpoint or use the Gravitino Java client. The following is an example of altering a topic:+Changes are applied as a list in one request. `partition-count` can be increased through a property+change; `replication-factor` is immutable once the topic exists.+| Change | JSON | Java |+|--------------------|--------------------------------------------------------------|---------------------------------------------|+| Update the comment | `{"@type":"updateComment","newComment":"new_comment"}` | `TopicChange.updateComment("new_comment")` |+| Set a property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `TopicChange.setProperty("key1", "value1")` |+| Remove a property | `{"@type":"removeProperty","property":"key1"}` | `TopicChange.removeProperty("key1")` |<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shellcurl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{+ -H "Content-Type: application/json" -d '{"updates": [- {- "@type": "removeProperty",- "property": "key2"- }, {- "@type": "setProperty",- "property": "key3",- "value": "value3"- }+ {"@type": "setProperty", "property": "partition-count", "value": "6"}]-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/default/topics/topic+}' http://localhost:8090/api/metalakes/example/catalogs/events/schemas/default/topics/orders```</TabItem><TabItem value="java" label="Java">```java-// ...-// Assuming you have just created a Kafka catalog named `catalog`-Catalog catalog = gravitinoClient.loadCatalog("catalog");--TopicCatalog topicCatalog = catalog.asTopicCatalog();--Topic t = topicCatalog.alterTopic(NameIdentifier.of("default", "topic"),- TopicChange.removeProperty("key2"), TopicChange.setProperty("key3", "value3"));-// ...+Topic topic = topics.alterTopic(+ NameIdentifier.of("default", "orders"),+ TopicChange.setProperty("partition-count", "6"));```</TabItem></Tabs>-Gravitino supports the following changes to a topic:--| Supported modification | JSON | Java |-|-------------------------|--------------------------------------------------------------|---------------------------------------------|-| Update a comment | `{"@type":"updateComment","newComment":"new_comment"}` | `TopicChange.updateComment("new_comment")` |-| Set a topic property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `TopicChange.setProperty("key1", "value1")` |-| Remove a topic property | `{"@type":"removeProperty","property":"key1"}` | `TopicChange.removeProperty("key1")` |-### Drop a Topic-Remove a topic by sending a `DELETE` request to the `/api/metalakes/{metalake_name}-/catalogs/{catalog_name}/schemas/{schema_name}/topics/{topic_name}` endpoint or by using the-Gravitino Java client. The following is an example of dropping a topic:+Dropping a topic through Gravitino deletes it in the cluster, along with its messages.<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shellcurl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/default/topics/topic+ http://localhost:8090/api/metalakes/example/catalogs/events/schemas/default/topics/orders```</TabItem><TabItem value="java" label="Java">```java-// ...-// Assuming you have just created a Kafka catalog named `catalog`-Catalog catalog = gravitinoClient.loadCatalog("catalog");--TopicCatalog topicCatalog = catalog.asTopicCatalog();--// Drop a topic-topicCatalog.dropTopic(NameIdentifier.of("default", "topic"));-// ...+boolean dropped = topics.dropTopic(NameIdentifier.of("default", "orders"));```</TabItem></Tabs>-### List All Topics Under a Schema--List all topics in a schema by sending a `GET` request to the `/api/metalakes/-{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/topics` endpoint or by using the-Gravitino Java client. The following is an example of listing all the topics in a schema:+### List Topics<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shellcurl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/topics+ http://localhost:8090/api/metalakes/example/catalogs/events/schemas/default/topics```</TabItem><TabItem value="java" label="Java">```java-// ...-Catalog catalog = gravitinoClient.loadCatalog("catalog");--TopicCatalog topicCatalog = catalog.asTopicCatalog();-NameIdentifier[] identifiers =- topicCatalog.listTopics(Namespace.of("default"));-// ...+NameIdentifier[] identifiers = topics.listTopics(Namespace.of("default"));```</TabItem>-</Tabs>\ No newline at end of file+</Tabs>diff --git a/docs/manage-relational-metadata-using-gravitino.md b/docs/manage-relational-metadata-using-gravitino.mdindex f8e99974bd..92c78c355a 100644--- a/docs/manage-relational-metadata-using-gravitino.md+++ b/docs/manage-relational-metadata-using-gravitino.md@@ -1,8 +1,7 @@---title: "Manage Relational Metadata"slug: "/manage-relational-metadata-using-gravitino"-date: 2023-12-10-keyword: "Gravitino relational metadata manage"+keyword: "table management, table, column, relational metadata, Gravitino"license: "This software is licensed under the Apache License version 2."---@@ -11,1247 +10,262 @@ import TabItem from '@theme/TabItem';## Introduction-This page introduces how to manage relational metadata by Apache Gravitino, relational metadata refers-to relational catalog, schema, table, partitions, and views. Through Gravitino, you can create, edit, and-delete relational metadata via unified REST APIs or Java client.--For dedicated view examples and APIs, see [Manage view metadata using Gravitino](./manage-view-metadata-using-gravitino.md).--In this document, Gravitino uses Apache Hive catalog as an example to show how to manage-relational metadata by Gravitino. Other relational catalogs are similar to Hive catalog,-but they may have some differences, especially in catalog property, table property, and column type.-For more details, refer to the related doc.--- [**Apache Hive**](./apache-hive-catalog.md)-- [**MySQL**](./jdbc-mysql-catalog.md)-- [**PostgreSQL**](./jdbc-postgresql-catalog.md)-- [**Apache Doris**](./jdbc-doris-catalog.md)-- [**StarRocks**](./jdbc-starrocks-catalog.md)-- [**OceanBase**](./jdbc-oceanbase-catalog.md)-- [**Hologres**](./jdbc-hologres-catalog.md)-- [**ClickHouse**](./jdbc-clickhouse-catalog.md)-- [**Hologres**](./jdbc-hologres-catalog.md)-- [**Apache Iceberg**](./lakehouse-iceberg-catalog.md)-- [**Apache Paimon**](./lakehouse-paimon-catalog.md)-- [**Apache Hudi**](./lakehouse-hudi-catalog.md)-- [**Lakehouse generic**](./lakehouse-generic-catalog.md)--If you want to operate table and partition statistics, you can refer to the [document](./manage-statistics-in-gravitino.md).--Assuming:-- - Gravitino has just started, and the host and port is [http://localhost:8090](http://localhost:8090).- - A metalake has been created and [enabled](./manage-metalake-using-gravitino.md#enable-a-metalake).--## Catalog Operations--### Create a Catalog--:::caution-It is not recommended to use one data source to create multiple catalogs,-as multiple catalogs operating on the same source may result in unpredictable behavior.-:::--:::caution-If you plan to use the [Flink connector](./flink-connector/flink-connector.md), the catalog name **cannot start with a number**.-This is a Flink limitation. For example, `catalog_hive` is valid, but `1_catalog` is not.-:::--:::tip-The code below is an example of creating a Hive catalog. For other relational catalogs, the code is-similar, but the catalog type, provider, and properties may be different. For more details, refer to the related doc.--For relational catalog, you must specify the catalog `type` as `RELATIONAL` when creating a catalog.-:::--Create a catalog by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs` endpoint or use the Gravitino Java client. The following is an example of creating a catalog:--<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "catalog",- "type": "RELATIONAL",- "comment": "comment",- "provider": "hive",- "properties": {- "metastore.uris": "thrift://localhost:9083"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs-```--</TabItem>-<TabItem value="java" label="Java">--```java--// Assuming you have just created a metalake named `metalake`-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://127.0.0.1:8090")- .withMetalake("metalake")- .build();--Map<String, String> hiveProperties = ImmutableMap.<String, String>builder()- // You should replace the following with your own hive metastore uris that Gravitino can access- .put("metastore.uris", "thrift://localhost:9083")- .build();--Catalog catalog = gravitinoClient.createCatalog("catalog",- Type.RELATIONAL,- "hive", // provider, We support hive, jdbc-mysql, jdbc-postgresql, lakehouse-iceberg, lakehouse-paimon etc.- "This is a hive catalog",- hiveProperties); // Please change the properties according to the value of the provider.-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# Assuming you have just created a metalake named `metalake`-gravitino_client = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")-gravitino_client.create_catalog(name="catalog",- catalog_type=CatalogType.RELATIONAL,- provider="hive",- comment="This is a hive catalog",- properties={"metastore.uris": "thrift://localhost:9083"})-```--</TabItem>-</Tabs>--Gravitino supports the following catalog providers:--| Catalog provider | Catalog property |-|---------------------|-----------------------------------------------------------------------------------------|-| `hive` | [Hive catalog property](./apache-hive-catalog.md#catalog-properties) |-| `lakehouse-iceberg` | [Iceberg catalog property](./lakehouse-iceberg-catalog.md#catalog-properties) |-| `lakehouse-paimon` | [Paimon catalog property](./lakehouse-paimon-catalog.md#catalog-properties) |-| `lakehouse-hudi` | [Hudi catalog property](./lakehouse-hudi-catalog.md#catalog-properties) |-| `jdbc-mysql` | [MySQL catalog property](./jdbc-mysql-catalog.md#catalog-properties) |-| `jdbc-postgresql` | [PostgreSQL catalog property](./jdbc-postgresql-catalog.md#catalog-properties) |-| `jdbc-doris` | [Doris catalog property](./jdbc-doris-catalog.md#catalog-properties) |-| `jdbc-oceanbase` | [OceanBase catalog property](./jdbc-oceanbase-catalog.md#catalog-properties) |-| `jdbc-hologres` | [Hologres catalog property](./jdbc-hologres-catalog.md#catalog-properties) |-| `jdbc-starrocks` | [StarRocks catalog property](./jdbc-starrocks-catalog.md#catalog-properties) |-| `jdbc-clickhouse` | [ClickHouse catalog property](./jdbc-clickhouse-catalog.md#catalog-properties) |-| `jdbc-hologres` | [Hologres catalog property](./jdbc-hologres-catalog.md#catalog-properties) |-| `lakehouse-generic` | [Lakehouse generic catalog property](./lakehouse-generic-catalog.md#catalog-properties) |--### Load a Catalog--Load a catalog by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}` endpoint or use the Gravitino Java client. The following is an example of loading a catalog:--<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" http://localhost:8090/api/metalakes/metalake/catalogs/catalog-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have created a metalake named `metalake` and a catalog named `catalog`-Catalog catalog = gravitinoClient.loadCatalog("catalog");-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-# Assuming you have created a metalake named `metalake` and a catalog named `catalog`-catalog = gravitino_client.load_catalog("catalog")-```--</TabItem>-</Tabs>--### Alter a Catalog--Modify a catalog by sending a `PUT` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}` endpoint or use the Gravitino Java client. The following is an example of altering a catalog:--<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "updates": [- {- "@type": "rename",- "newName": "alter_catalog"- },- {- "@type": "setProperty",- "property": "key3",- "value": "value3"- }- ]-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have created a metalake named `metalake` and a catalog named `catalog`-Catalog catalog = gravitinoClient.alterCatalog("catalog",- CatalogChange.rename("alter_catalog"), CatalogChange.updateComment("new comment"));-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-# Assuming you have created a metalake named `metalake` and a catalog named `catalog`-changes = (CatalogChange.update_comment("new comment"))-catalog = gravitino_client.alterCatalog("catalog", *changes)-# ...-```--</TabItem>-</Tabs>--Gravitino supports the following changes to a catalog:--| Supported modification | JSON | Java |-|------------------------|--------------------------------------------------------------|-----------------------------------------------|-| Rename catalog | `{"@type":"rename","newName":"catalog_renamed"}` | `CatalogChange.rename("catalog_renamed")` |-| Update comment | `{"@type":"updateComment","newComment":"new_comment"}` | `CatalogChange.updateComment("new_comment")` |-| Set a property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `CatalogChange.setProperty("key1", "value1")` |-| Remove a property | `{"@type":"removeProperty","property":"key1"}` | `CatalogChange.removeProperty("key1")` |--:::warning--Most catalog-altering operations are generally safe. However, if you want to change the catalog's URI, you should proceed with caution. Changing the URI may point to a different cluster, rendering the metadata stored in Gravitino unusable.-For instance, if the old URI and the new URI point to different clusters that both have a database named db1, changing the URI might cause the old metadata, such as audit information, to be used when accessing db1, which is undesirable.--Therefore, do not change the catalog's URI unless you fully understand the consequences of such a modification.--:::--### Enable a Catalog--Catalog has a reserved property - `in-use`, which indicates whether the catalog is available for use. By default, the `in-use` property is set to `true`.-To enable a disabled catalog, you can send a `PATCH` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}` endpoint or use the Gravitino Java client.--The following is an example of enabling a catalog:--<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X PATCH -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{"inUse": true}' \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have created a metalake named `metalake` and a catalog named `catalog`-gravitinoClient.enableCatalog("catalog");-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-# Assuming you have created a metalake named `metalake` and a catalog named `catalog`-gravitino_client.enable_catalog("catalog")-# ...-```--</TabItem>-</Tabs>--:::info-This operation does nothing if the catalog is already enabled.-:::--### Disable a Catalog--Once a catalog is disabled:-- Users can only [list](#list-all-catalogs-in-a-metalake), [load](#load-a-catalog), [drop](#drop-a-catalog), or [enable](#enable-a-catalog) it.-- Any other operation on the catalog or its sub-entities will result in an error.--To disable a catalog, you can send a `PATCH` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}` endpoint or use the Gravitino Java client.--The following is an example of disabling a catalog:--<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X PATCH -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{"inUse": false}' \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have created a metalake named `metalake` and a catalog named `catalog`-gravitinoClient.disableCatalog("catalog");-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-# Assuming you have created a metalake named `metalake` and a catalog named `catalog`-gravitino_client.disable_catalog("catalog")-# ...-```--</TabItem>-</Tabs>--:::info-This operation does nothing if the catalog is already disabled.-:::--### Drop a Catalog--Deleting a catalog by "force" is not a default behavior, so make sure:--- There are no schemas under the catalog. Otherwise, you will get an error.-- The catalog is [disabled](#disable-a-catalog). Otherwise, you will get an error.--Deleting a catalog by "force" will:--- Delete all sub-entities (schemas, tables, etc.) under the catalog.-- Delete the catalog itself even if it is enabled.-- Not delete the external resources (such as database, table, etc.) associated with sub-entities unless they are managed (such as managed fileset).--Remove a catalog by sending a `DELETE` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}` endpoint or use the Gravitino Java client. The following is an example of dropping a catalog:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog?force=false-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have created a metalake named `metalake` and a catalog named `catalog`-// force can be true or false-gravitinoClient.dropCatalog("catalog", false);-// ...--```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-# Assuming you have created a metalake named `metalake` and a catalog named `catalog`-# force can be true or false-gravitino_client.drop_catalog(name="catalog", force=False)-# ...-```--</TabItem>-</Tabs>--### List All Catalogs in a Metalake--List all catalogs under a metalake by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs` endpoint or use the Gravitino Java client. The following is an example of listing all the catalogs in-a metalake:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have just created a metalake named `metalake`-String[] catalogNames = gravitinoClient.listCatalogs();-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-# Assuming you have created a metalake named `metalake` and a catalog named `catalog`-catalog_names = gravitino_client.list_catalogs()-# ...-```--</TabItem>-</Tabs>--### List All Catalog Information in a Metalake--List all catalogs' information under a metalake by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs?details=true` endpoint or use the Gravitino Java client. The following is an example of listing all the catalogs' information in a metalake:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs?details=true-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have just created a metalake named `metalake`-Catalog[] catalogsInfos = gravitinoMetaLake.listCatalogsInfo();-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-# Assuming you have created a metalake named `metalake` and a catalog named `catalog`-catalogs_info = gravitino_client.list_catalogs_info()-# ...-```--</TabItem>-</Tabs>---## Schema Operations--:::tip-Users should create a metalake and a catalog, then ensure that the metalake and catalog are enabled before operating schemas.-:::--### Create a Schema--Create a schema by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas` endpoint or use the Gravitino Java client. The following is an example of creating a schema:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "schema",- "comment": "comment",- "properties": {- "key1": "value1"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas-```--</TabItem>-<TabItem value="java" label="Java">--```java-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");--SupportsSchemas supportsSchemas = catalog.asSchemas();--Map<String, String> schemaProperties = ImmutableMap.<String, String>builder()- .build();-Schema schema = supportsSchemas.createSchema("schema",- "This is a schema",- schemaProperties-);-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://127.0.0.1:8090", metalake_name="metalake")-catalog: Catalog = gravitino_client.load_catalog(name="hive_catalog")-catalog.as_schemas().create_schema(name="schema",- comment="This is a schema",- properties={})-```--</TabItem>-</Tabs>--Gravitino supports the following schema property:--| Catalog provider | Schema property |-|---------------------|---------------------------------------------------------------------------------------|-| `hive` | [Hive schema property](./apache-hive-catalog.md#schema-properties) |-| `lakehouse-iceberg` | [Iceberg scheme property](./lakehouse-iceberg-catalog.md#schema-properties) |-| `lakehouse-paimon` | [Paimon scheme property](./lakehouse-paimon-catalog.md#schema-properties) |-| `lakehouse-hudi` | [Hudi scheme property](./lakehouse-hudi-catalog.md#schema-properties) |-| `jdbc-mysql` | [MySQL schema property](./jdbc-mysql-catalog.md#schema-properties) |-| `jdbc-postgresql` | [PostgreSQL schema property](./jdbc-postgresql-catalog.md#schema-properties) |-| `jdbc-doris` | [Doris schema property](./jdbc-doris-catalog.md#schema-properties) |-| `jdbc-oceanbase` | [OceanBase schema property](./jdbc-oceanbase-catalog.md#schema-properties) |-| `jdbc-hologres` | [Hologres schema property](./jdbc-hologres-catalog.md#schema-properties) |-| `jdbc-starrocks` | [StarRocks schema property](./jdbc-starrocks-catalog.md#schema-properties) |-| `jdbc-clickhouse` | [ClickHouse schema property](./jdbc-clickhouse-catalog.md#schema-properties) |-| `jdbc-hologres` | [Hologres schema property](./jdbc-hologres-catalog.md#schema-properties) |-| `lakehouse-generic` | [Lakehouse generic schema property](./lakehouse-generic-catalog.md#schema-properties) |--### Load a Schema--Create a schema by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}` endpoint or use the Gravitino Java client. The following is an example of loading a schema:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X GET \-H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");-SupportsSchemas supportsSchemas = catalog.asSchemas();-Schema schema = supportsSchemas.loadSchema("schema");-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://127.0.0.1:8090", metalake_name="metalake")-catalog: Catalog = gravitino_client.load_catalog(name="hive_catalog")-schema: Schema = catalog.as_schemas().load_schema(name="schema")-```--</TabItem>-</Tabs>--### Alter a Schema--Change a schema by sending a `PUT` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}` endpoint or use the Gravitino Java client. The following is an example of modifying a schema:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "updates": [- {- "@type": "removeProperty",- "property": "key2"- }, {- "@type": "setProperty",- "property": "key3",- "value": "value3"- }- ]-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");--SupportsSchemas supportsSchemas = catalog.asSchemas();--Schema schema = supportsSchemas.alterSchema("schema",- SchemaChange.removeProperty("key1"),- SchemaChange.setProperty("key2", "value2"));-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://127.0.0.1:8090", metalake_name="metalake")-catalog: Catalog = gravitino_client.load_catalog(name="hive_catalog")--changes = (- SchemaChange.remove_property("schema_properties_key1"),- SchemaChange.set_property("schema_properties_key2", "schema_properties_new_value"),-)-schema_new: Schema = catalog.as_schemas().alter_schema("schema",- *changes)-```--</TabItem>-</Tabs>--Gravitino supports the following changes to a schema:--| Supported modification | JSON | Java |-|------------------------|--------------------------------------------------------------|-----------------------------------------------|-| Set a property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `SchemaChange.setProperty("key1", "value1")` |-| Remove a property | `{"@type":"removeProperty","property":"key1"}` | `SchemaChange.removeProperty("key1")` |--### Drop a Schema--Remove a schema by sending a `DELETE` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}` endpoint or use the Gravitino Java client. The following is an example of dropping a schema:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-// cascade can be true or false-curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema?cascade=true-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");--SupportsSchemas supportsSchemas = catalog.asSchemas();-// cascade can be true or false-supportsSchemas.dropSchema("schema", true);-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://127.0.0.1:8090", metalake_name="metalake")-catalog: Catalog = gravitino_client.load_catalog(name="hive_catalog")--catalog.as_schemas().drop_schema("schema", cascade=True)-```--</TabItem>-</Tabs>--If `cascade` is true, Gravitino will drop all tables under the schema. Otherwise, Gravitino will throw an exception if there are tables under the schema.-Some catalogs may not support cascading deletion of a schema, refer to the related doc for more details.--### List All Schemas Under a Catalog--List all schemas under a catalog by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas` endpoint or use the Gravitino Java client. The following is an example of listing all the schemas- in a catalog:---<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");--SupportsSchemas supportsSchemas = catalog.asSchemas();-String[] schemas = supportsSchemas.listSchemas();-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://127.0.0.1:8090", metalake_name="metalake")-catalog: Catalog = gravitino_client.load_catalog(name="hive_catalog")--schema_list: List[NameIdentifier] = catalog.as_schemas().list_schemas()-```--</TabItem>-</Tabs>+This page covers the Gravitino API for tables. For what a table is, how columns and properties work,+the drop versus purge distinction, and how to work with tables in the UI, see [Tables and+Views](./tables-and-views.md). For creating the catalog and schema a table lives in, see [Manage+Catalogs and Schemas](./manage-catalogs-and-schemas.md). Views have their own page, [Manage View+Metadata](./manage-view-metadata-using-gravitino.md).++The examples below use a Hive catalog. Column types, table properties, and supported operations vary+by provider, and each catalog type documents its own: [Apache Hive](./apache-hive-catalog.md),+[MySQL](./jdbc-mysql-catalog.md), [PostgreSQL](./jdbc-postgresql-catalog.md), [Apache+Doris](./jdbc-doris-catalog.md), [StarRocks](./jdbc-starrocks-catalog.md),+[OceanBase](./jdbc-oceanbase-catalog.md), [Hologres](./jdbc-hologres-catalog.md),+[ClickHouse](./jdbc-clickhouse-catalog.md), [Apache Iceberg](./lakehouse-iceberg-catalog.md),+[Apache Paimon](./lakehouse-paimon-catalog.md), [Apache Hudi](./lakehouse-hudi-catalog.md), and+[Lakehouse generic](./lakehouse-generic-catalog.md).## Table Operations-:::tip-Users should create a metalake, a catalog and a schema, then ensure that the metalake and catalog are enabled before before operating tables.-:::-### Create a Table-Create a table by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/tables` endpoint or use the Gravitino Java client. The following is an example of creating a table:+A table needs a name and its columns. Partitioning, distribution, sort order, indexes, and+properties are all optional, and which of them a catalog accepts depends on the provider.<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shellcurl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "example_table",- "comment": "This is an example table",+ -H "Content-Type: application/json" -d '{+ "name": "customers",+ "comment": "Customer records","columns": [{"name": "id","type": "integer",- "comment": "id column comment",+ "comment": "Primary key","nullable": false,"autoIncrement": true},{"name": "name","type": "varchar(500)",- "comment": "name column comment",- "nullable": true,- "autoIncrement": false,- "defaultValue": {- "type": "literal",- "dataType": "null",- "value": "null"- }+ "comment": "Customer name",+ "nullable": true},{- "name": "StartingDate",+ "name": "created_at","type": "timestamp",- "comment": "StartingDate column comment","nullable": false,- "autoIncrement": false,"defaultValue": {"type": "function","funcName": "current_timestamp","funcArgs": []}- },- {- "name": "info",- "type": {- "type": "struct",- "fields": [- {- "name": "position",- "type": "string",- "nullable": true,- "comment": "position field comment"- },- {- "name": "contact",- "type": {- "type": "list",- "elementType": "integer",- "containsNull": false- },- "nullable": true,- "comment": "contact field comment"- },- {- "name": "rating",- "type": {- "type": "map",- "keyType": "string",- "valueType": "integer",- "valueContainsNull": false- },- "nullable": true,- "comment": "rating field comment"- }- ]- },- "comment": "info column comment",- "nullable": true- },- {- "name": "dt",- "type": "date",- "comment": "dt column comment",- "nullable": true- }- ],- "partitioning": [- {- "strategy": "identity",- "fieldName": [ "dt" ]- }- ],- "distribution": {- "strategy": "hash",- "number": 32,- "funcArgs": [- {- "type": "field",- "fieldName": [ "id" ]- }- ]- },- "sortOrders": [- {- "sortTerm": {- "type": "field",- "fieldName": [ "age" ]- },- "direction": "asc",- "nullOrdering": "nulls_first"- }- ],- "indexes": [- {- "indexType": "primary_key",- "name": "PRIMARY",- "fieldNames": [["id"]]}],- "properties": {- "format": "ORC"- }-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tables+ "properties": {"format": "ORC"}+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/tables```</TabItem><TabItem value="java" label="Java">```java-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");+Catalog catalog = client.loadCatalog("sales");-TableCatalog tableCatalog = catalog.asTableCatalog();+Column[] columns = new Column[] {+ Column.of("id", Types.IntegerType.get(), "Primary key", false, true, null),+ Column.of("name", Types.VarCharType.of(500), "Customer name"),+ Column.of("created_at", Types.TimestampType.withoutTimeZone(), null, false, false,+ FunctionExpression.of("current_timestamp"))+};-// This is an example of creating a Hive table, you should refer to the related doc to get the-// table properties of other catalogs.-Map<String, String> tablePropertiesMap = ImmutableMap.<String, String>builder()- .put("format", "ORC")- // For more table properties, refer to the related doc.- .build();--tableCatalog.createTable(- NameIdentifier.of("schema", "example_table"),- new Column[] {- Column.of("id", Types.IntegerType.get(), "id column comment", false, true, Column.DEFAULT_VALUE_NOT_SET),- Column.of("name", Types.VarCharType.of(500), "name column comment", true, false, Literals.NULL),- Column.of("StartingDate", Types.TimestampType.withoutTimeZone(), "StartingDate column comment", false, false, Column.DEFAULT_VALUE_OF_CURRENT_TIMESTAMP),- Column.of("info", Types.StructType.of(- Field.nullableField("position", Types.StringType.get(), "Position of the user"),- Field.nullableField("contact", Types.ListType.of(Types.IntegerType.get(), false), "contact field comment"),- Field.nullableField("rating", Types.MapType.of(Types.VarCharType.of(1000), Types.IntegerType.get(), false), "rating field comment")- ), "info column comment", true, false, null),- Column.of("dt", Types.DateType.get(), "dt column comment", true, false, null)- },- "This is an example table",- tablePropertiesMap,- new Transform[] {Transforms.identity("id")},- Distributions.of(Strategy.HASH, 32, NamedReference.field("id")),- new SortOrder[] {SortOrders.ascending(NamedReference.field("name"))},- new Index[] {Indexes.of(IndexType.PRIMARY_KEY, "PRIMARY", new String[][]{{"id"}}, Map.of())}-);+Table table = catalog.asTableCatalog().createTable(+ NameIdentifier.of("public", "customers"),+ columns,+ "Customer records",+ ImmutableMap.of("format", "ORC"));```</TabItem>-</Tabs>--:::caution-The provided example demonstrates table creation but isn't directly executable in Gravitino, since not all catalogs fully support these capabilities.-:::--To create a table, you need to provide the following information:--- Table column name and type-- Table column default value (optional)-- Table column auto-increment (optional)-- Table property (optional)--#### Table Column Type--The following types that Gravitino supports:--| Type | Java / Python | JSON | Description |-|---------------------------|--------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-| Boolean | `Types.BooleanType.get()` | `boolean` | Boolean type |-| Byte | `Types.ByteType.get()` | `byte` | Byte type, indicates a numerical value of 1 byte |-| Unsigned Byte | `Types.ByteType.unsigned()` | `byte unsigned` | Unsigned Byte type, indicates a unsigned numerical value of 1 byte |-| Short | `Types.ShortType.get()` | `short` | Short type, indicates a numerical value of 2 bytes |-| Unsigned Short | `Types.ShortType.unsigned()` | `short unsigned` | Unsigned Short type, indicates a unsigned numerical value of 2 bytes |-| Integer | `Types.IntegerType.get()` | `integer` | Integer type, indicates a numerical value of 4 bytes |-| Unsigned Integer | `Types.IntegerType.unsigned()` | `integer unsigned` | Unsigned Integer type, indicates a unsigned numerical value of 4 bytes |-| Long | `Types.LongType.get()` | `long` | Long type, indicates a numerical value of 8 bytes |-| Unsigned Long | `Types.LongType.unsigned()` | `long unsigned` | Unsigned Long type, indicates a unsigned numerical value of 8 bytes |-| Float | `Types.FloatType.get()` | `float` | Float type, indicates a single-precision floating point number |-| Double | `Types.DoubleType.get()` | `double` | Double type, indicates a double-precision floating point number |-| Decimal(precision, scale) | `Types.DecimalType.of(precision, scale)` | `decimal(p, s)` | Decimal type, indicates a fixed-precision decimal number with the constraint that the precision must be in range `[1, 38]` and the scala must be in range `[0, precision]` |-| String | `Types.StringType.get()` | `string` | String type |-| FixedChar(length) | `Types.FixedCharType.of(length)` | `char(l)` | Char type, indicates a fixed-length string |-| VarChar(length) | `Types.VarCharType.of(length)` | `varchar(l)` | Varchar type, indicates a variable-length string, the length is the maximum length of the string |-| Timestamp(p) | `Types.TimestampType.withoutTimeZone(p)` | `timestamp(p)` | Timestamp type, indicates a timestamp without timezone, where p is the precision of fractional seconds (0-12) |-| TimestampWithTimezone(p) | `Types.TimestampType.withTimeZone(p)` | `timestamp_tz(p)` | Timestamp with timezone type, indicates a timestamp with timezone, where p is the precision of fractional seconds (0-12) |-| Date | `Types.DateType.get()` | `date` | Date type |-| Time | `Types.TimeType.withoutTimeZone()` | `time` | Time type |-| IntervalToYearMonth | `Types.IntervalYearType.get()` | `interval_year` | Interval type, indicates an interval of year and month |-| IntervalToDayTime | `Types.IntervalDayType.get()` | `interval_day` | Interval type, indicates an interval of day and time |-| Fixed(length) | `Types.FixedType.of(length)` | `fixed(l)` | Fixed type, indicates a fixed-length binary array |-| Binary | `Types.BinaryType.get()` | `binary` | Binary type, indicates a arbitrary-length binary array |-| List | `Types.ListType.of(elementType, elementNullable)` | `{"type": "list", "containsNull": JSON Boolean, "elementType": type JSON}` | List type, indicate a list of elements with the same type |-| Map | `Types.MapType.of(keyType, valueType)` | `{"type": "map", "keyType": type JSON, "valueType": type JSON, "valueContainsNull": JSON Boolean}` | Map type, indicate a map of key-value pairs |-| Struct | `Types.StructType.of([Types.StructType.Field.of(name, type, nullable)])` | `{"type": "struct", "fields": [JSON StructField, {"name": string, "type": type JSON, "nullable": JSON Boolean, "comment": string}]}` | Struct type, indicate a struct of fields |-| Union | `Types.UnionType.of([type1, type2, ...])` | `{"type": "union", "types": [type JSON, ...]}` | Union type, indicates a union of types |-| UUID | `Types.UUIDType.get()` | `uuid` | UUID type, indicates a universally unique identifier |-| Variant | `Types.VariantType.get()` | `variant` | Variant type, indicates semi-structured data whose shape is not fixed by the schema |-| Null | `Types.NullType.get()` | `null` | Null type, indicates a column that holds only null values and whose concrete type is not yet known; it may be assigned a specific type later via schema evolution |-| Geometry | `Types.GeometryType.of(crs)` | `geometry` or `geometry(<crs>)` | Geometry type, indicates a geospatial shape (WKB-encoded) on a planar coordinate reference system (CRS), default `OGC:CRS84` |-| Geography | `Types.GeographyType.of(crs, algorithm)` | `geography` or `geography(<crs>,<algorithm>)` | Geography type, indicates a geospatial shape (WKB-encoded) on a spheroidal CRS (default `OGC:CRS84`) with an edge-interpolation algorithm (default `spherical`) |--The related java doc is [here](pathname:///docs/2.0.0-SNAPSHOT/api/java/org/apache/gravitino/rel/types/Type.html).--##### Null type--The null type represents a column that holds only null values and whose concrete type is not yet-known — it carries no usable data of its own, and the intent is that a more specific type is-assigned later through schema evolution. This mirrors the "null"/"void" type in engines such as-Spark, Flink, and Arrow, and maps to Apache Iceberg's V3 `unknown` type.--Support is connector-specific and still expanding: it is mapped natively by the Iceberg, Spark,-Flink, and Lance connectors, while connectors without an equivalent concept currently reject it.-Because a null column holds no usable data, engines should not populate it; it is meant to be-promoted to a concrete type before data is written.--##### External type--External type is a special type of column type, when you need to use a data type that is not in the Gravitino type-system, and you explicitly know its string representation in an external catalog (usually used in JDBC catalogs), then-you can use the ExternalType to represent the type. Similarly, if the original type is unsolvable, it will be-represented by ExternalType.-The following shows the data structure of an external type in JSON and Java, enabling easy retrieval of its string value.--<Tabs groupId='language' queryString>- <TabItem value="Json" label="JSON">--```json-{- "type": "external",- "catalogString": "user-defined"-}-```-- </TabItem>- <TabItem value="java" label="Java">--```java-// The result of the following type is a string "user-defined"-String typeString = ((ExternalType) type).catalogString();-```-- </TabItem>-</Tabs>--##### Unparsed type--Unparsed type is a special type of column type, it used to address compatibility issues in type serialization and-deserialization between the server and client. For instance, if a new column type is introduced on the Gravitino server-that the client does not recognize, it will be treated as an unparsed type on the client side.-The following shows the data structure of an unparsed type in JSON and Java, enabling easy retrieval of its value.--<Tabs groupId='language' queryString>- <TabItem value="Json" label="JSON">+<TabItem value="python" label="Python">-```json-{- "type": "unparsed",- "unparsedType": "unknown-type"-}-```+```python+catalog = client.load_catalog("sales")- </TabItem>- <TabItem value="java" label="Java">+columns = [+ Column.of("id", Types.IntegerType.get(), "Primary key", False, True, None),+ Column.of("name", Types.VarCharType.of(500), "Customer name"),+ Column.of("created_at", Types.TimestampType.without_time_zone(), None, False),+]-```java-// The result of the following type is a string "unknown-type"-String unparsedValue = ((UnparsedType) type).unparsedType();+table = catalog.as_table_catalog().create_table(+ ident=NameIdentifier.of("public", "customers"),+ columns=columns,+ comment="Customer records",+ properties={"format": "ORC"})```- </TabItem>+</TabItem></Tabs>-#### Table Column Default Value--When defining a table column, you can specify a [literal](./expression.md#literal) or an [expression](./expression.md) as the default value. The default value typically applies to new rows that are inserted into the table by the underlying catalog.--The following is a table of the column default value that Gravitino supports for different catalogs:--| Catalog provider | Supported default value |-|----------------------|-------------------------|-| `hive` | ✘ |-| `lakehouse-iceberg` | ✘ |-| `lakehouse-paimon` | ✘ |-| `lakehouse-hudi` | ✘ |-| `jdbc-mysql` | ✔ |-| `jdbc-postgresql` | ✔ |-| `jdbc-doris` | ✔ |-| `jdbc-oceanbase` | ✔ |-| `jdbc-hologres` | ✔ |-| `jdbc-starrocks` | ✔ |-| `jdbc-clickhouse` | ✔ |-| `jdbc-hologres` | ✔ |-| `lakehouse-generic` | ✘ |--#### Table Column Auto-increment--Auto-increment provides a convenient way to ensure that each row in a table has a unique identifier without the need for manually managing identifier allocation.-The following table shows the column auto-increment that Gravitino supports for different catalogs:--| Catalog provider | Supported auto-increment |-|---------------------|----------------------------------------------------------------------------------|-| `hive` | ✘ |-| `lakehouse-iceberg` | ✘ |-| `lakehouse-paimon` | ✘ |-| `lakehouse-hudi` | ✘ |-| `jdbc-mysql` | ✔([limitations](./jdbc-mysql-catalog.md#table-column-auto-increment)) |-| `jdbc-postgresql` | ✔ |-| `jdbc-doris` | ✘ |-| `jdbc-oceanbase` | ✔([limitations](./jdbc-oceanbase-catalog.md#table-column-auto-increment)) |-| `jdbc-hologres` | ✘ |-| `jdbc-starrocks` | ✔ |-| `jdbc-clickhouse` | ✘ |-| `jdbc-hologres` | ✘ |-| `lakehouse-generic` | ✘ |--#### Table Property and Type Mapping--The following is the table property that Gravitino supports:--| Catalog provider | Table property | Type mapping |-|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|-| `hive` | [Hive table property](./apache-hive-catalog.md#table-properties) | [Hive type mapping](./apache-hive-catalog.md#table-column-types) |-| `lakehouse-iceberg` | [Iceberg table property](./lakehouse-iceberg-catalog.md#table-properties) | [Iceberg type mapping](./lakehouse-iceberg-catalog.md#table-column-types) |-| `lakehouse-paimon` | [Paimon table property](./lakehouse-paimon-catalog.md#table-properties) | [Paimon type mapping](./lakehouse-paimon-catalog.md#table-column-types) |-| `lakehouse-hudi` | [Hudi table property](./lakehouse-hudi-catalog.md#table-properties) | [Hudi type mapping](./lakehouse-hudi-catalog.md#table-column-types) |-| `jdbc-mysql` | [MySQL table property](./jdbc-mysql-catalog.md#table-properties) | [MySQL type mapping](./jdbc-mysql-catalog.md#table-column-types) |-| `jdbc-postgresql` | [PostgreSQL table property](./jdbc-postgresql-catalog.md#table-properties) | [PostgreSQL type mapping](./jdbc-postgresql-catalog.md#table-column-types) |-| `jdbc-doris` | [Doris table property](./jdbc-doris-catalog.md#table-properties) | [Doris type mapping](./jdbc-doris-catalog.md#table-column-types) |-| `jdbc-oceanbase` | [OceanBase table property](./jdbc-oceanbase-catalog.md#table-properties) | [OceanBase type mapping](./jdbc-oceanbase-catalog.md#table-column-types) |-| `jdbc-hologres` | [Hologres table property](./jdbc-hologres-catalog.md#table-properties) | [Hologres type mapping](./jdbc-hologres-catalog.md#table-column-types) |-| `jdbc-starrocks` | [StarRocks table property](./jdbc-starrocks-catalog.md#table-properties) | [StarRocks type mapping](./jdbc-starrocks-catalog.md#table-column-types) |-| `jdbc-clickhouse` | [ClickHouse table property](./jdbc-clickhouse-catalog.md#table-properties) | [ClickHouse type mapping](./jdbc-clickhouse-catalog.md#table-column-types) |-| `jdbc-hologres` | [Hologres table property](./jdbc-hologres-catalog.md#table-properties) | [Hologres type mapping](./jdbc-hologres-catalog.md#table-column-types) |-| `lakehouse-generic` | Lakehouse generic table property depends on specific table implementation, for Lance table, refer to [doc](./lakehouse-generic-lance-table.md#table-properties), other table format, refer to related docs. | Lakehouse generic type mapping. Similar to table properties, for Lance table, refer to [docs](./lakehouse-generic-lance-table.md#data-type-mappings) |--#### Table Partitioning, Distribution, Sort Ordering and Indexes--In addition to the basic settings, Gravitino supports the following features:--| Feature | Description | Java doc |-|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|-| Table partitioning | Equal to `PARTITION BY` in Apache Hive, It is a partitioning strategy that is used to split a table into parts based on partition keys. Some table engine may not support this feature | [Partition](pathname:///docs/2.0.0-SNAPSHOT/api/java/org/apache/gravitino/dto/rel/partitioning/Partitioning.html) |-| Table distribution | Equal to `CLUSTERED BY` in Apache Hive, distribution a.k.a (Clustering) is a technique to split the data into more manageable files/parts, (By specifying the number of buckets to create). The value of the distribution column will be hashed by a user-defined number into buckets. | [Distribution](pathname:///docs/2.0.0-SNAPSHOT/api/java/org/apache/gravitino/rel/expressions/distributions/Distribution.html) |-| Table sort ordering | Equal to `SORTED BY` in Apache Hive, sort ordering is a method to sort the data in specific ways such as by a column or a function, and then store table data. it will highly improve the query performance under certain scenarios. | [SortOrder](pathname:///docs/2.0.0-SNAPSHOT/api/java/org/apache/gravitino/rel/expressions/sorts/SortOrder.html) |-| Table indexes | Equal to `KEY/INDEX` in MySQL , unique key enforces uniqueness of values in one or more columns within a table. It ensures that no two rows have identical values in specified columns, thereby facilitating data integrity and enabling efficient data retrieval and manipulation operations. | [Index](pathname:///docs/2.0.0-SNAPSHOT/api/java/org/apache/gravitino/rel/indexes/Index.html) |--For more information, see the related document on [partitioning, bucketing, sorting, and indexes](table-partitioning-distribution-sort-order-indexes.md).--:::note-The code above is an example of creating a Hive table. For other catalogs, the code is similar, but the supported column type, and table properties may be different. For more details, refer to the related doc.-:::+For partitioning, distribution, sort order, and indexes, see [Table partitioning, distribution, sort+order, and indexes](./table-partitioning-distribution-sort-order-indexes.md).### Load a Table-Load a table by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/tables/{table_name}` endpoint or use the Gravitino Java client. The following is an example of loading a table:-<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shellcurl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tables/table+ http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/tables/customers```</TabItem><TabItem value="java" label="Java">```java-// ...-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");+Table table = catalog.asTableCatalog().loadTable(+ NameIdentifier.of("public", "customers"));+```++</TabItem>+<TabItem value="python" label="Python">-TableCatalog tableCatalog = catalog.asTableCatalog();-tableCatalog.loadTable(NameIdentifier.of("schema", "table"));-// ...+```python+table = catalog.as_table_catalog().load_table(+ NameIdentifier.of("public", "customers"))```</TabItem></Tabs>-:::note-- When Gravitino loads a table from a catalog with various data types, if Gravitino is unable to parse the data type, it will use an **[External Type](#external-type)** to preserve the original data type, ensuring that the table can be loaded successfully.-- When Gravitino loads a table from a catalog that supports default value, if Gravitino is unable to parse the default value, it will use an **[Unparsed Expression](./expression.md#unparsed-expression)** to preserve the original default value, ensuring that the table can be loaded successfully.-:::-### Alter a Table-Modify a table by sending a `PUT` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/tables/{table_name}` endpoint or use the Gravitino Java client. The following is an example of modifying a table:+Changes are applied as a list in one request, and cover the table itself, its properties, and its+columns.++| Change | JSON | Java |+|-------------------------------|-------------------------------------------------------------------------------------------------|-----------------------------------------------|+| Rename the table | `{"@type":"rename","newName":"table_renamed"}` | `TableChange.rename(...)` |+| Move to another schema | `{"@type":"rename","newName":"table_renamed","newSchemaName":"new_schema"}` | `TableChange.rename(...)` |+| Update the comment | `{"@type":"updateComment","newComment":"new_comment"}` | `TableChange.updateComment(...)` |+| Set a property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `TableChange.setProperty(...)` |+| Remove a property | `{"@type":"removeProperty","property":"key1"}` | `TableChange.removeProperty(...)` |+| Add a column | `{"@type":"addColumn","fieldName":["position"],"type":"varchar(20)","position":"FIRST"}` | `TableChange.addColumn(...)` |+| Delete a column | `{"@type":"deleteColumn","fieldName":["name"],"ifExists":true}` | `TableChange.deleteColumn(...)` |+| Rename a column | `{"@type":"renameColumn","oldFieldName":["name_old"],"newFieldName":"name_new"}` | `TableChange.renameColumn(...)` |+| Update a column comment | `{"@type":"updateColumnComment","fieldName":["name"],"newComment":"new comment"}` | `TableChange.updateColumnComment(...)` |+| Update a column type | `{"@type":"updateColumnType","fieldName":["name"],"newType":"varchar(100)"}` | `TableChange.updateColumnType(...)` |+| Update a column's nullability | `{"@type":"updateColumnNullability","fieldName":["name"],"nullable":true}` | `TableChange.updateColumnNullability(...)` |+| Update a column position | `{"@type":"updateColumnPosition","fieldName":["name"],"newPosition":"default"}` | `TableChange.updateColumnPosition(...)` |+| Update a column default value | `{"@type":"updateColumnDefaultValue","fieldName":["name"],"newDefaultValue":{...}}` | `TableChange.updateColumnDefaultValue(...)` |++Not every provider accepts every change. Where one does not, the request is rejected rather than+silently ignored.<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shellcurl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{+ -H "Content-Type: application/json" -d '{"updates": [- {- "@type": "removeProperty",- "property": "key2"- }, {- "@type": "setProperty",- "property": "key3",- "value": "value3"- }- ]-}' http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tables/table+ {"@type": "updateComment", "newComment": "Customer records, curated"},+ {"@type": "addColumn", "fieldName": ["email"], "type": "varchar(320)", "nullable": true}+ ]+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/tables/customers```</TabItem><TabItem value="java" label="Java">```java-// ...-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");+Table table = catalog.asTableCatalog().alterTable(+ NameIdentifier.of("public", "customers"),+ TableChange.updateComment("Customer records, curated"),+ TableChange.addColumn(new String[] {"email"}, Types.VarCharType.of(320)));+```-TableCatalog tableCatalog = catalog.asTableCatalog();+</TabItem>+<TabItem value="python" label="Python">-Table t = tableCatalog.alterTable(NameIdentifier.of("schema", "table"),- TableChange.rename("table_renamed"), TableChange.updateComment("xxx"));-// ...+```python+table = catalog.as_table_catalog().alter_table(+ NameIdentifier.of("public", "customers"),+ TableChange.update_comment("Customer records, curated"),+ TableChange.add_column(["email"], Types.VarCharType.of(320)))```</TabItem></Tabs>-Gravitino supports the following changes to a table:--| Supported modification | JSON | Java |-|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|-| Rename table | `{"@type":"rename","newName":"table_renamed"}` or `{"@type":"rename","newName":"table_renamed, "newSchemaName":"new_schema"}` | `TableChange.rename("table_renamed")` or `TableChange.rename("table_renamed", "new_schema")` |-| Update comment | `{"@type":"updateComment","newComment":"new_comment"}` | `TableChange.updateComment("new_comment")` |-| Set a table property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `TableChange.setProperty("key1", "value1")` |-| Remove a table property | `{"@type":"removeProperty","property":"key1"}` | `TableChange.removeProperty("key1")` |-| Add a column | `{"@type":"addColumn","fieldName":["position"],"type":"varchar(20)","comment":"Position of user","position":"FIRST","nullable": true, "autoIncrement": false, "defaultValue" : {"type": "literal", "dataType": "varchar(20)", "value": "Default Position"}}` | `TableChange.addColumn(...)` |-| Delete a column | `{"@type":"deleteColumn","fieldName": ["name"], "ifExists": true}` | `TableChange.deleteColumn(...)` |-| Rename a column | `{"@type":"renameColumn","oldFieldName":["name_old"], "newFieldName":"name_new"}` | `TableChange.renameColumn(...)` |-| Update the column comment | `{"@type":"updateColumnComment", "fieldName": ["name"], "newComment": "new comment"}` | `TableChange.updateColumnCommment(...)` |-| Update the type of a column | `{"@type":"updateColumnType","fieldName": ["name"], "newType":"varchar(100)"}` | `TableChange.updateColumnType(...)` |-| Update the nullability of a column | `{"@type":"updateColumnNullability","fieldName": ["name"],"nullable":true}` | `TableChange.updateColumnNullability(...)` |-| Update the position of a column | `{"@type":"updateColumnPosition","fieldName": ["name"], "newPosition":"default"}` | `TableChange.updateColumnPosition(...)` |-| Update the default value of a column | `{"@type":"updateColumnDefaultValue","fieldName": ["name"], "newDefaultValue":{"type":"literal","dataType":"varchar(100)","value":"new default value}}` | `TableChange.updateColumnDefaultValue(...)` |--### Drop a Table+### Drop or Purge a Table-Remove a table by sending a `DELETE` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/tables/{table_name}` endpoint or use the Gravitino Java client. The following is an example of dropping a table:+Dropping removes the metadata, and for a managed table the underlying directory as well. For an+external table only the metadata goes. Purging removes the data completely and skips trash, is+rejected on external tables, and is not supported by every catalog.<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shell-## Purge can be true or false, if purge is true, Gravitino will remove the data from the table.-curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tables/table?purge=true+ "http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/tables/customers?purge=false"```</TabItem><TabItem value="java" label="Java">```java-// ...-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");--TableCatalog tableCatalog = catalog.asTableCatalog();--// Drop a table-tableCatalog.dropTable(NameIdentifier.of("schema", "table"));+boolean dropped = catalog.asTableCatalog().dropTable(+ NameIdentifier.of("public", "customers"));-// Purge a table-tableCatalog.purgeTable(NameIdentifier.of("schema", "table"));-// ...+boolean purged = catalog.asTableCatalog().purgeTable(+ NameIdentifier.of("public", "customers"));```</TabItem>-</Tabs>--There are two ways to remove a table: `dropTable` and `purgeTable`:+<TabItem value="python" label="Python">-* `dropTable` removes both the metadata and the directory associated with the table from the file system if the table is not an external table. In case of an external table, only the associated metadata is removed.-* `purgeTable` completely removes both the metadata and the directory associated with the table and skipping trash, if the table is an external table or the catalogs don't support purge table, `UnsupportedOperationException` is thrown.+```python+dropped = catalog.as_table_catalog().drop_table(+ NameIdentifier.of("public", "customers"))-Hive catalog and lakehouse-iceberg catalog supports `purgeTable` while jdbc-mysql, jdbc-postgresql and lakehouse-paimon catalog doesn't support.+purged = catalog.as_table_catalog().purge_table(+ NameIdentifier.of("public", "customers"))+```-### List All Tables Under a Schema+</TabItem>+</Tabs>-List all tables in a schema by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/tables` endpoint or use the Gravitino Java client. The following is an example of listing all the tables in a schema:+### List Tables<Tabs groupId='language' queryString>-<TabItem value="shell" label="Shell">+<TabItem value="shell" label="REST">```shellcurl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tables+ http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/tables```</TabItem><TabItem value="java" label="Java">```java-// ...-// Assuming you have just created a Hive catalog named `hive_catalog`-Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");--TableCatalog tableCatalog = catalog.asTableCatalog();-NameIdentifier[] identifiers =- tableCatalog.listTables(Namespace.of("schema"));-// ...+NameIdentifier[] identifiers = catalog.asTableCatalog().listTables(+ Namespace.of("public"));```</TabItem>-</Tabs>+<TabItem value="python" label="Python">-## View Operations+```python+identifiers = catalog.as_table_catalog().list_tables(Namespace.of("public"))+```-View metadata is documented separately in [Manage view metadata using Gravitino](./manage-view-metadata-using-gravitino.md),-including create, load, alter, drop, and list examples for the REST API and Java client.+</TabItem>+</Tabs>diff --git a/docs/manage-user-defined-function-using-gravitino.md b/docs/manage-user-defined-function-using-gravitino.mdold mode 100644new mode 100755index f371165b2b..b67068e536--- a/docs/manage-user-defined-function-using-gravitino.md+++ b/docs/manage-user-defined-function-using-gravitino.md@@ -1,7 +1,7 @@---title: "Manage User-Defined Functions"slug: "/manage-user-defined-function-using-gravitino"-keyword: "Gravitino user-defined function UDF manage"+keyword: "function management, UDF, user-defined function, Gravitino"license: "This software is licensed under the Apache License version 2."---@@ -10,103 +10,57 @@ import TabItem from '@theme/TabItem';## Introduction-This page introduces how to manage user-defined functions (UDFs) in Apache Gravitino. Gravitino-provides a centralized function registry that allows you to define custom functions once and-share them across multiple compute engines like Spark and Trino.--A function in Gravitino is characterized by:--- **Name**: The function identifier within a schema.-- **Function type**: `SCALAR` (row-by-row operations), `AGGREGATE` (group operations), or- `TABLE` (set-returning operations).-- **Deterministic**: Whether the function always returns the same result for the same input.-- **Definitions**: One or more overloads, each with a specific parameter list, return type- (or return columns for table functions), and one or more implementations for different- runtimes (e.g. Spark, Trino).--Each definition can have multiple implementations in different languages (SQL, Java, Python)-targeting different runtimes. **Each definition must have at most one implementation per-runtime** — for example, you cannot have two implementations both targeting `SPARK` in the-same definition. To replace an existing implementation, use `updateImpl` instead of `addImpl`.--| Language | Key fields | Description |-|----------|------------------------|------------------------------------------------------|-| SQL | `sql` | An inline SQL expression. |-| Java | `className` | Fully qualified Java class name. |-| Python | `handler`, `codeBlock` | Python handler entry point and optional inline code. |--To use function management, make sure that:-- - The Gravitino server has started and is serving at, e.g. [http://localhost:8090](http://localhost:8090).- - A metalake has been created.- - A catalog has been created within the metalake.- - A schema has been created within the catalog.+This page covers the Gravitino API for functions. For what a function is, the function types,+determinism, and how definitions and implementations relate, see [Functions](./functions.md). For+creating the catalog and schema a function lives in, see+[Manage Catalogs and Schemas](./manage-catalogs-and-schemas.md).## Function Operations-### Register a Function+### Register a SQL Function-Register a function by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/functions`-endpoint or use the Gravitino Java/Python client. The following is an example of registering-a scalar function:+A function needs a name, a type, a determinism flag, and at least one definition. A definition+carries its parameters, its return type, and one or more implementations.-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{+ -H "Content-Type: application/json" -d '{"name": "add_one","functionType": "SCALAR","deterministic": true,- "comment": "A scalar function that adds one to the input",+ "comment": "Adds one to the input","definitions": [{- "parameters": [- {"name": "x", "dataType": "integer"}- ],+ "parameters": [{"name": "x", "dataType": "integer"}],"returnType": "integer","impls": [- {- "language": "SQL",- "runtime": "TRINO",- "sql": "x + 1"- }+ {"language": "SQL", "runtime": "TRINO", "sql": "x + 1"}]}]-}' http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/functions```</TabItem><TabItem value="java" label="Java">```java-GravitinoClient gravitinoClient = GravitinoClient- .builder("http://localhost:8090")- .withMetalake("example")- .build();--Catalog catalog = gravitinoClient.loadCatalog("my_catalog");-FunctionCatalog functionCatalog = catalog.asFunctionCatalog();--// Define the function parameter-FunctionParam param = FunctionParams.of("x", Types.IntegerType.get());+Catalog catalog = client.loadCatalog("sales");+FunctionCatalog functions = catalog.asFunctionCatalog();-// Create a SQL implementation for Trino-FunctionImpl sqlImpl = FunctionImpls.ofSql(- FunctionImpl.RuntimeType.TRINO, "x + 1");+FunctionImpl sqlImpl = FunctionImpls.ofSql(FunctionImpl.RuntimeType.TRINO, "x + 1");-// Create the function definition with return typeFunctionDefinition definition = FunctionDefinitions.of(- new FunctionParam[] {param},+ new FunctionParam[] {FunctionParams.of("x", Types.IntegerType.get())},Types.IntegerType.get(),new FunctionImpl[] {sqlImpl});-// Register the function-Function function = functionCatalog.registerFunction(- NameIdentifier.of("my_schema", "add_one"),- "A scalar function that adds one to the input",+Function function = functions.registerFunction(+ NameIdentifier.of("public", "add_one"),+ "Adds one to the input",FunctionType.SCALAR,true,new FunctionDefinition[] {definition});@@ -116,15 +70,9 @@ Function function = functionCatalog.registerFunction(<TabItem value="python" label="Python">```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="example")+catalog = client.load_catalog("sales")+functions = catalog.as_function_catalog()-catalog: Catalog = gravitino_client.load_catalog(name="my_catalog")-function_catalog = catalog.as_function_catalog()--# Define the function parameter-param = FunctionParams.of("x", Types.IntegerType.get())--# Create a SQL implementation for Trinosql_impl = (SQLImpl.builder().with_runtime_type(SQLImpl.RuntimeType.TRINO)@@ -132,35 +80,72 @@ sql_impl = (.build())-# Create the function definition-definition = FunctionDefinitions.of([param], Types.IntegerType.get(), [sql_impl])+definition = FunctionDefinitions.of(+ [FunctionParams.of("x", Types.IntegerType.get())],+ Types.IntegerType.get(),+ [sql_impl])-# Register the function-function = function_catalog.register_function(- ident=NameIdentifier.of("my_schema", "add_one"),- comment="A scalar function that adds one to the input",+function = functions.register_function(+ ident=NameIdentifier.of("public", "add_one"),+ comment="Adds one to the input",function_type=FunctionType.SCALAR,deterministic=True,- definitions=[definition],-)+ definitions=[definition])```</TabItem></Tabs>-For table-valued functions, use `returnColumns` instead of `returnType` in the function-definition, and use `FunctionType.TABLE` as the function type:+### Register a Python Function++A Python implementation names a handler entrypoint, and can carry inline code and the packages the+runtime needs.-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{+ -H "Content-Type: application/json" -d '{+ "name": "normalize_phone",+ "functionType": "SCALAR",+ "deterministic": true,+ "comment": "Strips formatting from a phone number",+ "definitions": [+ {+ "parameters": [{"name": "raw", "dataType": "varchar(64)"}],+ "returnType": "varchar(64)",+ "impls": [+ {+ "language": "PYTHON",+ "runtime": "SPARK",+ "handler": "normalize.main",+ "codeBlock": "def main(raw):\n return \"\".join(c for c in raw if c.isdigit())"+ }+ ]+ }+ ]+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/functions+```++</TabItem>+</Tabs>++### Register a Java Function++A Java implementation names a class, and usually the jar that holds it. A table-valued function+declares `returnColumns` rather than a single `returnType`.++<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">++```shell+curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \+ -H "Content-Type: application/json" -d '{"name": "generate_series","functionType": "TABLE","deterministic": true,- "comment": "A table function that generates a series of integers",+ "comment": "Generates a range of integers","definitions": [{"parameters": [@@ -168,214 +153,113 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \{"name": "end_val", "dataType": "integer"}],"returnColumns": [- {"name": "value", "dataType": "integer", "comment": "The generated integer value"}+ {"name": "value", "dataType": "integer", "comment": "The generated value"}],"impls": [{"language": "JAVA","runtime": "SPARK","className": "com.example.GenerateSeriesFunction",- "resources": {- "jars": ["hdfs:///path/to/udtf.jar"]- }+ "resources": {"jars": ["hdfs:///path/to/udtf.jar"]}}]}]-}' http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-FunctionCatalog functionCatalog = catalog.asFunctionCatalog();--FunctionParam[] params = new FunctionParam[] {- FunctionParams.of("start_val", Types.IntegerType.get()),- FunctionParams.of("end_val", Types.IntegerType.get())-};--FunctionColumn[] returnColumns = new FunctionColumn[] {- FunctionColumn.of("value", Types.IntegerType.get(), "The generated integer value")-};--FunctionImpl javaImpl = FunctionImpls.ofJava(- FunctionImpl.RuntimeType.SPARK,- "com.example.GenerateSeriesFunction",- FunctionResources.of(- new String[] {"hdfs:///path/to/udtf.jar"}, null, null),- null);--FunctionDefinition definition = FunctionDefinitions.of(- params, returnColumns, new FunctionImpl[] {javaImpl});--Function function = functionCatalog.registerFunction(- NameIdentifier.of("my_schema", "generate_series"),- "A table function that generates a series of integers",- FunctionType.TABLE,- true,- new FunctionDefinition[] {definition});-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-function_catalog = catalog.as_function_catalog()--# Define the function parameters-param_start = FunctionParams.of("start_val", Types.IntegerType.get())-param_end = FunctionParams.of("end_val", Types.IntegerType.get())--# Define the return columns for the table function-return_columns = [- FunctionColumn.of("value", Types.IntegerType.get(), "The generated integer value")-]--java_impl = (- JavaImpl.builder()- .with_runtime_type(JavaImpl.RuntimeType.SPARK)- .with_class_name("com.example.GenerateSeriesFunction")- .build()-)--# Use of_table() for table-valued functions-definition = FunctionDefinitions.of_table([param_start, param_end], return_columns, [java_impl])--function = function_catalog.register_function(- ident=NameIdentifier.of("my_schema", "generate_series"),- comment="A table function that generates a series of integers",- function_type=FunctionType.TABLE,- deterministic=True,- definitions=[definition],-)+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/functions```</TabItem></Tabs>-### Get a Function+### Register Overloads-Get a function by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/functions/{function_name}`-endpoint or by using the Gravitino Java/Python client. The following is an example of getting-a function:+A function with several definitions accepts several parameter lists under one name. Each definition+carries its own return type and implementations.-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shell-curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions/add_one-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-Catalog catalog = gravitinoClient.loadCatalog("my_catalog");-FunctionCatalog functionCatalog = catalog.asFunctionCatalog();--Function function = functionCatalog.getFunction(- NameIdentifier.of("my_schema", "add_one"));-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="example")--catalog: Catalog = gravitino_client.load_catalog(name="my_catalog")-function = catalog.as_function_catalog().get_function(- ident=NameIdentifier.of("my_schema", "add_one"))+curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \+ -H "Content-Type: application/json" -d '{+ "name": "add",+ "functionType": "SCALAR",+ "deterministic": true,+ "comment": "Adds two or three integers",+ "definitions": [+ {+ "parameters": [+ {"name": "x", "dataType": "integer"},+ {"name": "y", "dataType": "integer"}+ ],+ "returnType": "integer",+ "impls": [{"language": "SQL", "runtime": "TRINO", "sql": "x + y"}]+ },+ {+ "parameters": [+ {"name": "x", "dataType": "integer"},+ {"name": "y", "dataType": "integer"},+ {"name": "z", "dataType": "integer"}+ ],+ "returnType": "integer",+ "impls": [{"language": "SQL", "runtime": "TRINO", "sql": "x + y + z"}]+ }+ ]+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/functions```</TabItem></Tabs>-### List Functions--List all the functions in a schema by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/functions`-endpoint or by using the Gravitino Java/Python client. The following is an example of listing-all the functions in a schema:+### Get a Function-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions+ http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/functions/add_one```</TabItem><TabItem value="java" label="Java">```java-// ...-Catalog catalog = gravitinoClient.loadCatalog("my_catalog");-FunctionCatalog functionCatalog = catalog.asFunctionCatalog();--NameIdentifier[] identifiers = functionCatalog.listFunctions(- Namespace.of("my_schema"));-// ...+Function function = functions.getFunction(NameIdentifier.of("public", "add_one"));```</TabItem><TabItem value="python" label="Python">```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="example")--catalog: Catalog = gravitino_client.load_catalog(name="my_catalog")-functions = catalog.as_function_catalog().list_functions(- namespace=Namespace.of("my_schema"))+function = functions.get_function(NameIdentifier.of("public", "add_one"))```</TabItem></Tabs>-List functions with detailed information by adding the `details` query parameter.-This returns the full function objects instead of just the identifiers.+### List Functions-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X GET -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-"http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions?details=true"+ http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/functions```</TabItem><TabItem value="java" label="Java">```java-// ...-Catalog catalog = gravitinoClient.loadCatalog("my_catalog");-FunctionCatalog functionCatalog = catalog.asFunctionCatalog();--Function[] functions = functionCatalog.listFunctionInfos(- Namespace.of("my_schema"));-// ...+NameIdentifier[] identifiers = functions.listFunctions(Namespace.of("public"));```</TabItem><TabItem value="python" label="Python">```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="example")--catalog: Catalog = gravitino_client.load_catalog(name="my_catalog")-functions = catalog.as_function_catalog().list_function_infos(- namespace=Namespace.of("my_schema"))+identifiers = functions.list_functions(Namespace.of("public"))```</TabItem>@@ -383,139 +267,34 @@ functions = catalog.as_function_catalog().list_function_infos(### Alter a Function-Modify a function by sending a `PUT` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/functions/{function_name}`-endpoint or using the Gravitino Java/Python client. The following is an example of updating a-function's comment:+Changes are applied as a list in one request.-<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+| Change | JSON | Java |+|--------------------|--------------------------------------------------------------|--------------------------------------------------|+| Rename | `{"@type":"rename","newName":"add_one_v2"}` | `FunctionChange.rename("add_one_v2")` |+| Update the comment | `{"@type":"updateComment","newComment":"new_comment"}` | `FunctionChange.updateComment("new_comment")` |+| Set a property | `{"@type":"setProperty","property":"key1","value":"value1"}` | `FunctionChange.setProperty("key1", "value1")` |+| Remove a property | `{"@type":"removeProperty","property":"key1"}` | `FunctionChange.removeProperty("key1")` |-```shell-curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "updates": [- {- "@type": "updateComment",- "newComment": "An improved scalar function that adds one"- }- ]-}' http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions/add_one-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-Catalog catalog = gravitinoClient.loadCatalog("my_catalog");-FunctionCatalog functionCatalog = catalog.asFunctionCatalog();--Function updated = functionCatalog.alterFunction(- NameIdentifier.of("my_schema", "add_one"),- FunctionChange.updateComment("An improved scalar function that adds one"));-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="example")--catalog: Catalog = gravitino_client.load_catalog(name="my_catalog")-function = catalog.as_function_catalog().alter_function(- NameIdentifier.of("my_schema", "add_one"),- FunctionChange.update_comment("An improved scalar function that adds one"),-)-```--</TabItem>-</Tabs>--#### Supported Modifications--The following operations are supported for altering a function:--| Operation | JSON Example | Java Method | Python Method |-|---------------------------|---------------------------------------------------------------------------------------------|--------------------------------------------------------|---------------------------------------------------------|-| **Update comment** | `{"@type":"updateComment","newComment":"new comment"}` | `FunctionChange.updateComment("new comment")` | `FunctionChange.update_comment("new comment")` |-| **Add definition** | `{"@type":"addDefinition","definition":{...}}` | `FunctionChange.addDefinition(definition)` | `FunctionChange.add_definition(definition)` |-| **Remove definition** | `{"@type":"removeDefinition","parameters":[{"name":"x","dataType":"integer"}]}` | `FunctionChange.removeDefinition(params)` | `FunctionChange.remove_definition(params)` |-| **Add implementation** | `{"@type":"addImpl","parameters":[...],"implementation":{...}}` | `FunctionChange.addImpl(params, impl)` | `FunctionChange.add_impl(params, impl)` |-| **Update implementation** | `{"@type":"updateImpl","parameters":[...],"runtime":"SPARK","implementation":{...}}` | `FunctionChange.updateImpl(params, runtime, impl)` | `FunctionChange.update_impl(params, runtime, impl)` |-| **Remove implementation** | `{"@type":"removeImpl","parameters":[{"name":"x","dataType":"integer"}],"runtime":"SPARK"}` | `FunctionChange.removeImpl(params, RuntimeType.SPARK)` | `FunctionChange.remove_impl(params, RuntimeType.SPARK)` |--:::note-When using `addImpl`, the runtime of the new implementation must not already exist in the- target definition. Use `updateImpl` to replace an existing implementation for a given runtime.-:::--The following is an example of adding a new implementation to an existing function definition:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{+ -H "Content-Type: application/json" -d '{"updates": [- {- "@type": "addImpl",- "parameters": [- {"name": "x", "dataType": "integer"}- ],- "implementation": {- "language": "JAVA",- "runtime": "TRINO",- "className": "com.example.AddOneFunction",- "resources": {- "jars": ["hdfs:///path/to/udf.jar"]- }- }- }+ {"@type": "updateComment", "newComment": "Adds one, reviewed"}]-}' http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions/add_one+}' http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/functions/add_one```</TabItem><TabItem value="java" label="Java">```java-// ...-FunctionParam[] params = new FunctionParam[] {- FunctionParams.of("x", Types.IntegerType.get())-};-FunctionImpl javaImpl = FunctionImpls.ofJava(- FunctionImpl.RuntimeType.TRINO,- "com.example.AddOneFunction",- FunctionResources.of(- new String[] {"hdfs:///path/to/udf.jar"}, null, null),- null);--Function updated = functionCatalog.alterFunction(- NameIdentifier.of("my_schema", "add_one"),- FunctionChange.addImpl(params, javaImpl));-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-# ...-param = FunctionParams.of("x", Types.IntegerType.get())--java_impl = (- JavaImpl.builder()- .with_runtime_type(JavaImpl.RuntimeType.TRINO)- .with_class_name("com.example.AddOneFunction")- .build()-)--function = catalog.as_function_catalog().alter_function(- NameIdentifier.of("my_schema", "add_one"),- FunctionChange.add_impl([param], java_impl),-)+Function function = functions.alterFunction(+ NameIdentifier.of("public", "add_one"),+ FunctionChange.updateComment("Adds one, reviewed"));```</TabItem>@@ -523,183 +302,27 @@ function = catalog.as_function_catalog().alter_function(### Drop a Function-Drop a function by sending a `DELETE` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/functions/{function_name}`-endpoint or by using the Gravitino Java/Python client. The following is an example of dropping-a function:--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">+<Tabs groupId='language' queryString>+<TabItem value="shell" label="REST">```shellcurl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" \-http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions/add_one-```--</TabItem>-<TabItem value="java" label="Java">--```java-// ...-Catalog catalog = gravitinoClient.loadCatalog("my_catalog");-boolean dropped = catalog.asFunctionCatalog().dropFunction(- NameIdentifier.of("my_schema", "add_one"));-// ...-```--</TabItem>-<TabItem value="python" label="Python">--```python-gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="example")--catalog: Catalog = gravitino_client.load_catalog(name="my_catalog")-dropped: bool = catalog.as_function_catalog().drop_function(- NameIdentifier.of("my_schema", "add_one"))-```--</TabItem>-</Tabs>--## Advanced Examples--### Register a Function with Multiple Overloads--A function can have multiple definitions (overloads) with different parameter lists. Each-definition has its own return type and implementations.--<Tabs groupId="language" queryString>-<TabItem value="shell" label="Shell">--```shell-curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \--H "Content-Type: application/json" -d '{- "name": "add",- "functionType": "SCALAR",- "deterministic": true,- "comment": "An overloaded add function",- "definitions": [- {- "parameters": [- {"name": "x", "dataType": "integer"},- {"name": "y", "dataType": "integer"}- ],- "returnType": "integer",- "impls": [- {- "language": "SQL",- "runtime": "TRINO",- "sql": "x + y"- }- ]- },- {- "parameters": [- {"name": "x", "dataType": "double"},- {"name": "y", "dataType": "double"}- ],- "returnType": "double",- "impls": [- {- "language": "SQL",- "runtime": "TRINO",- "sql": "x + y"- }- ]- }- ]-}' http://localhost:8090/api/metalakes/example/catalogs/my_catalog/schemas/my_schema/functions+ http://localhost:8090/api/metalakes/example/catalogs/sales/schemas/public/functions/add_one```</TabItem><TabItem value="java" label="Java">```java-// ...-FunctionCatalog functionCatalog = catalog.asFunctionCatalog();--// Definition 1: integer overload-FunctionDefinition intDef = FunctionDefinitions.of(- new FunctionParam[] {- FunctionParams.of("x", Types.IntegerType.get()),- FunctionParams.of("y", Types.IntegerType.get())- },- Types.IntegerType.get(),- new FunctionImpl[] {- FunctionImpls.ofSql(FunctionImpl.RuntimeType.TRINO, "x + y")- });--// Definition 2: double overload-FunctionDefinition doubleDef = FunctionDefinitions.of(- new FunctionParam[] {- FunctionParams.of("x", Types.DoubleType.get()),- FunctionParams.of("y", Types.DoubleType.get())- },- Types.DoubleType.get(),- new FunctionImpl[] {- FunctionImpls.ofSql(FunctionImpl.RuntimeType.TRINO, "x + y")- });--Function function = functionCatalog.registerFunction(- NameIdentifier.of("my_schema", "add"),- "An overloaded add function",- FunctionType.SCALAR,- true,- FunctionDefinitions.of(intDef, doubleDef));-// ...+boolean dropped = functions.dropFunction(NameIdentifier.of("public", "add_one"));```</TabItem><TabItem value="python" label="Python">```python-# ...-function_catalog = catalog.as_function_catalog()--# Definition 1: integer overload-int_param_x = FunctionParams.of("x", Types.IntegerType.get())-int_param_y = FunctionParams.of("y", Types.IntegerType.get())-sql_int = (- SQLImpl.builder()- .with_runtime_type(SQLImpl.RuntimeType.TRINO)- .with_sql("x + y")- .build()-)-int_def = FunctionDefinitions.of([int_param_x, int_param_y], Types.IntegerType.get(), [sql_int])--# Definition 2: double overload-double_param_x = FunctionParams.of("x", Types.DoubleType.get())-double_param_y = FunctionParams.of("y", Types.DoubleType.get())-sql_double = (- SQLImpl.builder()- .with_runtime_type(SQLImpl.RuntimeType.TRINO)- .with_sql("x + y")- .build()-)-double_def = FunctionDefinitions.of([double_param_x, double_param_y], Types.DoubleType.get(), [sql_double])--function = function_catalog.register_function(- ident=NameIdentifier.of("my_schema", "add"),- comment="An overloaded add function",- function_type=FunctionType.SCALAR,- deterministic=True,- definitions=[int_def, double_def],-)+dropped = functions.drop_function(NameIdentifier.of("public", "add_one"))```</TabItem></Tabs>--## Functions in Compute Engines--Once a function is registered in Gravitino, it can be used in supported compute engines.-The engine's connector loads the function from Gravitino and invokes the appropriate-implementation based on the runtime.--| Engine | Runtime | Documentation |-|--------|---------------------|------------------------------------------------------------------------------------|-| Spark | `RuntimeType.SPARK` | [Spark connector - User-defined functions](spark-connector/spark-connector-udf.md) |--:::note-Support for additional engines (e.g. Trino, Flink) will be documented as they become available.-:::diff --git a/docs/statistics.md b/docs/statistics.mdnew file mode 100644index 0000000000..b9d5ff18f7--- /dev/null+++ b/docs/statistics.md@@ -0,0 +1,72 @@+---+title: "Statistics"+slug: "/statistics"+keyword: "statistics, row count, partition statistics, Gravitino"+license: "This software is licensed under the Apache License version 2."+---++## Introduction++A statistic is a named measurement attached to a table or one of its partitions. Row counts, sizes,+and file counts are the obvious ones, and anything else you want to record about a dataset can sit+beside them.++Statistics are how the catalog answers questions about size and shape without touching the data.+That matters most on a federated estate, where asking each source system directly means a different+mechanism per system.++## Quick Start++**1. Open a table.** Statistics attach to tables and to partitions of tables. See+[Tables and Views](./tables-and-views.md).++**2. Read what is already there.** Some statistics are maintained by Gravitino or the source system,+and are visible without doing anything.++**3. Record your own.** A custom statistic carries whatever measurement matters to you, under a name+you choose.++## The Statistics Model++### Reserved and Custom++A reserved statistic is one Gravitino defines, such as `row_count`. The set can grow in future+releases, so reserved names are not available for your own use.++A custom statistic is yours, and its name must begin with `custom.` to keep it clear of anything+Gravitino may reserve later. The prefix is the only naming rule.++### Modifiable and Not++A statistic is marked modifiable or not. One derived by the system, such as a count maintained by+the source, is not something to overwrite by hand, and Gravitino rejects the attempt rather than+accepting a value that the next refresh discards.++Custom statistics are modifiable, since nothing else maintains them.++### Values++A value is typed rather than free text, so a row count is a number and a boolean is a boolean.+A statistic can also exist with no value at all, which means it is known but not currently set.++### Partition Statistics++Statistics attach to partitions as well as to whole tables, and partition statistics are read and+written over a range rather than one at a time. Where a table is large and partitioned, per-partition+measurements are what make pruning and planning decisions possible.++## Working With Statistics in the UI++Statistics are not surfaced in the UI today. Reading and writing them goes through the API.++## Permissions++Statistics follow the table they belong to. Reading them requires the privilege to read the table,+and writing them requires the privilege to modify it. See+[Tables and Views](./tables-and-views.md).++## Using the API++Statistics can be listed, set, and dropped over REST and through the Java client, for tables and for+partitions. Endpoints, payload shapes, and worked examples are in+[Manage Statistics](./manage-statistics-in-gravitino.md).diff --git a/docs/tables-and-views.md b/docs/tables-and-views.mdnew file mode 100644index 0000000000..af7490aa3a--- /dev/null+++ b/docs/tables-and-views.md@@ -0,0 +1,108 @@+---+title: "Tables and Views"+slug: "/tables-and-views"+keyword: "table, view, column, relational metadata, Gravitino"+license: "This software is licensed under the Apache License version 2."+---++## Introduction++A table is the object a relational catalog holds, and a view is a stored query over one or more+tables. Both live in a schema, and both are reached the same way no matter which system stores them.++Gravitino does not hold a copy of either. A table registered through a Hive, Iceberg, MySQL, or+Paimon catalog stays in that system, and Gravitino keeps the reference plus anything attached to it.+Creating a table through Gravitino creates it in the source system, and listing tables asks the+source at request time, so a table created directly in Hive appears the next time Gravitino is+asked.++What Gravitino adds is a single shape across all of them. The same call describes a Hive table and+an Iceberg table, columns carry the same type system, and tags, policies, ownership, and statistics+attach the same way regardless of the system underneath.++## Quick Start++**1. Open a catalog.** Tables live in a schema inside a relational catalog. See+[Catalogs and Schemas](./catalogs-and-schemas.md) for connecting one.++**2. Browse or create.** A connected catalog surfaces the tables already there. Creating a table+through Gravitino creates it in the source system, with the columns, partitioning, and properties+you specify.++**3. Classify what matters.** Tables and their columns both carry tags and policies, which is how a+classification set once reaches every engine that reads through Gravitino.++## The Table Model++### Columns++A column has a name and a type, and can carry a comment, nullability, an auto-increment flag, and a+default value. Types are Gravitino types rather than any one system's, so the same definition works+across catalogs and each provider maps them to its own.++Where a provider cannot represent a type, the provider's own page says so. Type mapping is the most+common place two catalogs of different providers differ.++### Table Properties++Properties are provider-specific and carry what the source system needs, such as the file format for+a Hive table or the write mode for an Iceberg table. Each catalog type's page documents its own set.++### Partitioning, Distribution, and Sort Order++A table can be created with a partitioning strategy, a distribution, a sort order, and indexes.+Which of those a catalog supports depends on the provider. See+[Table partitioning, distribution, sort order, and indexes](./table-partitioning-distribution-sort-order-indexes.md).++Once a table is partitioned, its partitions are metadata objects in their own right. See+[Manage table partitions](./manage-table-partition-using-gravitino.md).++### Dropping Versus Purging++Dropping a table removes the metadata, and for a managed table the underlying directory as well. For+an external table, only the metadata goes and the data stays where it is.++Purging removes the data completely and skips any trash the system would otherwise use. Not every+catalog supports it, and purging an external table is rejected rather than silently ignored.++The distinction matters most on Hive, where external tables are common and dropping one leaves the+files in place.++## Views++A view is a stored query, and Gravitino treats it as its own object type rather than a kind of+table. Views are supported by the Hive, Iceberg, and Paimon catalogs, and a relational catalog with+a provider that has no view concept simply has none.++A view carries the query text, the dialect the query is written in, and its own comment and+properties. Gravitino stores the definition and does not execute it, so whether a view resolves is a+question for the engine reading it.++Views can carry tags, and appear in listings alongside tables.++## Working With Tables and Views in the UI++Opening a schema lists its tables and views. Selecting a table shows its columns with their types,+its properties, and its tags.++Tags attach from the table row and from individual column rows, which is the fastest way to classify+a specific field rather than a whole table. Policies attach at the table level.++## Permissions++| Privilege | Grantable on | What it allows |+|----------------|-------------------------------------|---------------------------------|+| `CREATE_TABLE` | Metalake, catalog, or schema | Creating tables and views |+| `SELECT_TABLE` | Metalake, catalog, schema, or table | Reading a table or view |+| `MODIFY_TABLE` | Metalake, catalog, schema, or table | Writing to and altering a table |++Granting at a wider scope covers everything beneath it. Dropping a table is reserved for the+metalake owner and the object owner, and ownership resolves down the hierarchy, so the owner of a+catalog has the owner path to every table in it.++## Using the API++Tables and views can be created, listed, altered, and dropped over REST and through the Java and+Python clients. Endpoints, payload shapes, and worked examples are in+[Manage Relational Metadata](./manage-relational-metadata-using-gravitino.md) and+[Manage View Metadata](./manage-view-metadata-using-gravitino.md).diff --git a/docs/topics.md b/docs/topics.mdnew file mode 100644index 0000000000..53dfa9f926--- /dev/null+++ b/docs/topics.md@@ -0,0 +1,90 @@+---+title: "Topics"+slug: "/topics"+keyword: "topic, messaging, Kafka, streaming metadata, Gravitino"+license: "This software is licensed under the Apache License version 2."+---++## Introduction++A topic is a stream of messages, and in Gravitino it is a metadata object like any other. Registering+a Kafka cluster as a messaging catalog puts its topics in the same hierarchy as tables and filesets,+so a stream can be found, classified, and governed alongside the data it feeds.++Gravitino holds the reference rather than the messages. Listing topics asks the cluster at request+time, so a topic created directly in Kafka appears the next time Gravitino is asked, and deleting a+topic through Gravitino deletes it in the cluster.++The value is coverage rather than new capability. Without it, streams sit outside the catalog and+outside whatever classification and access rules apply to everything else.++## Quick Start++**1. Connect a messaging catalog.** A messaging catalog takes the `kafka` provider and the cluster's+bootstrap servers. See [Catalogs and Schemas](./catalogs-and-schemas.md) and+[Apache Kafka catalog](./kafka-catalog.md).++**2. Browse or create topics.** A connected cluster surfaces the topics already there. Creating one+through Gravitino creates it in the cluster.++**3. Classify what matters.** Topics carry tags and policies the same way tables do.++## The Topic Model++### Messaging Systems++Kafka is the only messaging system with a catalog today, connected with the `kafka` provider and the+cluster's `bootstrap.servers`. Anything speaking the Kafka protocol works through the same+connector. Other messaging systems have no catalog.++### The Default Schema++A messaging catalog presents one schema, named `default`, holding every topic in the cluster. Kafka+has no namespace of its own to map onto, so creating or dropping a schema in a messaging catalog is+rejected rather than silently ignored.++The consequence for a large cluster is that topics are not grouped in the catalog the way tables are+grouped by database. Tags are the way to organize them.++### Names and Properties++A topic name is unique within its schema, and matches the topic name in the cluster.++Two properties are settable at creation. `partition-count` sets the number of partitions and can be+changed afterward. `replication-factor` sets the replication and is immutable once the topic exists.+Leaving either unset takes the broker's own default, from `num.partition` and+`default.replication.factor` respectively.++### What Gravitino Stores and What It Does Not++Gravitino stores the topic's place in the hierarchy and anything attached to it, including tags,+policies, and ownership. Message content, offsets, consumer groups, and lag stay entirely in the+cluster.++Message schemas are also outside the catalog. Gravitino does not integrate with a schema registry,+so the structure of the messages in a topic is not described here and cannot be classified per field+the way table columns can. Tags and policies attach to the topic as a whole.++## Working With Topics in the UI++Opening a messaging catalog lists its topics, and selecting one shows its properties.++Topics display the tags and policies they carry, including inherited ones, but cannot be tagged from+the UI today. Attaching a tag to a topic goes through the API.++## Permissions++| Privilege | Grantable on | What it allows |+|-----------------|-------------------------------------|-----------------------|+| `CREATE_TOPIC` | Metalake, catalog, schema, or topic | Creating topics |+| `PRODUCE_TOPIC` | Metalake, catalog, schema, or topic | Writing to a topic |+| `CONSUME_TOPIC` | Metalake, catalog, schema, or topic | Reading from a topic |++Granting at a wider scope covers everything beneath it. Dropping a topic is reserved for the metalake+owner and the object owner.++## Using the API++Topics can be created, listed, altered, and dropped over REST and through the Java client. The+Python client does not cover topics. Endpoints, payload shapes, and worked examples are in+[Manage Messaging Metadata](./manage-messaging-metadata-using-gravitino.md).