Manage Fileset Metadata
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.
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-with-oss, fileset-with-gcs and fileset-with-adls.
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.
- A metalake has been created and enabled
Catalog Operations
Create a Catalog
For a fileset catalog, you must specify the catalog type as FILESET when creating the 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:
- Shell
- Java
- Python
curl -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
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);
// ...
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"})
Gravitino supports the following catalog providers:
| Catalog provider | Catalog property |
|---|---|
fileset or None | Fileset catalog property |
Load a Catalog
Refer to 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 in relational catalog for more details. For a fileset catalog, the alter operation is the same.
Drop a Catalog
Refer to Drop a catalog in relational catalog for more details. For a fileset catalog, the drop operation is the same.
- 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.