World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#2230] feat(client-python): Add doc and support publishing Gravitino Python client to Pypi (#2932)
SophieTech8812c32c70f0e2
diff --git a/clients/client-python/.gitignore b/clients/client-python/.gitignoreindex 03a9c5f2e9..cde90b4f0a 100644--- a/clients/client-python/.gitignore+++ b/clients/client-python/.gitignore@@ -9,3 +9,6 @@ venv.vevn.venv.idea+dist+build+README.mddiff --git a/clients/client-python/README.md b/clients/client-python/README.mddeleted file mode 100644index 50428c7519..0000000000--- a/clients/client-python/README.md+++ /dev/null@@ -1,25 +0,0 @@-<!---- Copyright 2024 Datastrato Pvt Ltd.-- This software is licensed under the Apache License version 2.--->--# Quick Start--1. Install current library in your local machine.- ```bash- pip install -e .- ```--# Development Environment--1. Install dependency- ```bash- pip install -e '.[dev]'- ```--2. Run integration tests- ```bash- cd gravitino- ./gradlew compileDistribution -x test- ./gradlew :clients:client-python:test- ```diff --git a/clients/client-python/build.gradle.kts b/clients/client-python/build.gradle.ktsindex 915c49aa99..11ee3444bb 100644--- a/clients/client-python/build.gradle.kts+++ b/clients/client-python/build.gradle.kts@@ -32,6 +32,62 @@ fun gravitinoServer(operation: String) {}}+fun generatePypiProjectHomePage() {+ try {+ val inputFile = file("${project.rootDir}/docs/how-to-use-python-client.md")+ val outputFile = file("README.md")++ // Copy the contents of the how-to-use-python-client.md file to the README.md file for PyPi+ // release, remove the front matter as PyPi doesn't support README file contains front+ // matter.+ val lines = inputFile.readLines()+ var skipFrontMatterHead = false+ var skipFrontMatterEnd = false+ for (line in lines) {+ if (line.trim() == "---") {+ if (!skipFrontMatterHead) {+ skipFrontMatterHead = true+ continue+ } else if (!skipFrontMatterEnd) {+ skipFrontMatterEnd = true+ continue+ }+ }+ if (skipFrontMatterHead && skipFrontMatterEnd) {+ outputFile.appendText(line + "\n")+ }+ }++ // Because the README.md file is generated from the how-to-use-python-client.md file, the+ // relative path of the images in the how-to-use-python-client.md file is incorrect. We need+ // to fix the relative path of the images/markdown to the absolute path.+ val content = outputFile.readText()+ val docsUrl = "https://datastrato.ai/docs/latest"++ // Use regular expression to match the `[](./a/b/c.md#arg1)` link in the content+ val patternDocs = "(?<!!)\\[([^]]+)]\\(\\.\\/([^)]*\\.md(?:#[^)]*)?)\\)".toRegex()+ val contentUpdateDocs = patternDocs.replace(content) { matchResult ->+ val linkText = matchResult.groupValues[1]+ val relativePath = matchResult.groupValues[2].replace(".md", "/")+ "[$linkText]($docsUrl/$relativePath)"+ }++ // Use regular expression to match the `` link in the content+ val assertUrl = "https://raw.githubusercontent.com/datastrato/gravitino/main/docs"+ val patternImage = """!\[([^\]]+)]\(\./assets/([^)]+)\)""".toRegex()+ val contentUpdateImage = patternImage.replace(contentUpdateDocs) { matchResult ->+ val altText = matchResult.groupValues[1]+ val fileName = matchResult.groupValues[2]+ ""+ }++ val readmeFile = file("README.md")+ readmeFile.writeText(contentUpdateImage)+ } catch (e: Exception) {+ throw GradleException("client-python README.md file not generated!")+ }+}+tasks {val pipInstall by registering(VenvTask::class) {venvExec = "pip"@@ -89,8 +145,31 @@ tasks {val build by registering(VenvTask::class) {}+ val distribution by registering(VenvTask::class) {+ doFirst {+ generatePypiProjectHomePage()+ delete("dist")+ }++ venvExec = "Python3"+ args = listOf("setup.py", "sdist")++ doLast {+ delete("README.md")+ }+ }++ // Deploy to https://pypi.org/project/gravitino/+ val deploy by registering(VenvTask::class) {+ dependsOn(distribution)+ val twine_password = System.getenv("TWINE_PASSWORD")+ venvExec = "twine"+ args = listOf("upload", "dist/*", "-p${twine_password}")+ }+val clean by registering(Delete::class) {delete("build")+ delete("dist")delete("gravitino.egg-info")doLast {diff --git a/clients/client-python/gravitino/__init__.py b/clients/client-python/gravitino/__init__.pyindex fdd4d199d3..24db62a279 100644--- a/clients/client-python/gravitino/__init__.py+++ b/clients/client-python/gravitino/__init__.py@@ -3,11 +3,13 @@ Copyright 2024 Datastrato Pvt Ltd.This software is licensed under the Apache License version 2."""-from gravitino.gravitino_client import (- GravitinoClient,- gravitino_metalake,- MetaLake,- Catalog,- Schema,- Table,-)+from gravitino.api.catalog import Catalog+from gravitino.api.schema import Schema+from gravitino.api.fileset import Fileset+from gravitino.api.fileset_change import FilesetChange+from gravitino.api.metalake_change import MetalakeChange+from gravitino.api.schema_change import SchemaChange+from gravitino.client.gravitino_client import GravitinoClient+from gravitino.client.gravitino_admin_client import GravitinoAdminClient+from gravitino.client.gravitino_metalake import GravitinoMetalake+from gravitino.name_identifier import NameIdentifierdiff --git a/clients/client-python/gravitino/catalog/__init__.py b/clients/client-python/gravitino/catalog/__init__.pynew file mode 100644index 0000000000..5779a3ad25--- /dev/null+++ b/clients/client-python/gravitino/catalog/__init__.py@@ -0,0 +1,4 @@+"""+Copyright 2024 Datastrato Pvt Ltd.+This software is licensed under the Apache License version 2.+"""diff --git a/clients/client-python/gravitino/catalog/base_schema_catalog.py b/clients/client-python/gravitino/catalog/base_schema_catalog.pyindex c0a6c1d9b1..034e53a470 100644--- a/clients/client-python/gravitino/catalog/base_schema_catalog.py+++ b/clients/client-python/gravitino/catalog/base_schema_catalog.py@@ -152,13 +152,13 @@ class BaseSchemaCatalog(CatalogDTO, SupportsSchemas):reqs = [BaseSchemaCatalog.to_schema_update_request(change) for change in changes]- updatesRequest = SchemaUpdatesRequest(reqs)- updatesRequest.validate()+ updates_request = SchemaUpdatesRequest(reqs)+ updates_request.validate()resp = self.rest_client.put(BaseSchemaCatalog.format_schema_request_path(ident.namespace())+ "/"+ ident.name(),- updatesRequest,+ updates_request,)schema_response = SchemaResponse.from_json(resp.body, infer_missing=True)schema_response.validate()@@ -189,8 +189,8 @@ class BaseSchemaCatalog(CatalogDTO, SupportsSchemas):drop_resp = DropResponse.from_json(resp.body, infer_missing=True)drop_resp.validate()return drop_resp.dropped()- except Exception as e:- logger.warning(f"Failed to drop schema {ident}")+ except Exception:+ logger.warning("Failed to drop schema %s", ident)return False@staticmethod@@ -203,7 +203,6 @@ class BaseSchemaCatalog(CatalogDTO, SupportsSchemas):return SchemaUpdateRequest.SetSchemaPropertyRequest(change.property(), change.value())- elif isinstance(change, SchemaChange.RemoveProperty):+ if isinstance(change, SchemaChange.RemoveProperty):return SchemaUpdateRequest.RemoveSchemaPropertyRequest(change.property())- else:- raise ValueError(f"Unknown change type: {type(change).__name__}")+ raise ValueError(f"Unknown change type: {type(change).__name__}")diff --git a/clients/client-python/gravitino/catalog/fileset_catalog.py b/clients/client-python/gravitino/catalog/fileset_catalog.pyindex a270844167..d716c6539a 100644--- a/clients/client-python/gravitino/catalog/fileset_catalog.py+++ b/clients/client-python/gravitino/catalog/fileset_catalog.py@@ -188,7 +188,7 @@ class FilesetCatalog(BaseSchemaCatalog):return drop_resp.dropped()except Exception as e:- logger.warning(f"Failed to drop fileset {ident}: {e}")+ logger.warning("Failed to drop fileset %s: %s", ident, e)return False@staticmethod@@ -200,15 +200,14 @@ class FilesetCatalog(BaseSchemaCatalog):def to_fileset_update_request(change: FilesetChange):if isinstance(change, FilesetChange.RenameFileset):return FilesetUpdateRequest.RenameFilesetRequest(change.new_name())- elif isinstance(change, FilesetChange.UpdateFilesetComment):+ if isinstance(change, FilesetChange.UpdateFilesetComment):return FilesetUpdateRequest.UpdateFilesetCommentRequest(change.new_comment())- elif isinstance(change, FilesetChange.SetProperty):+ if isinstance(change, FilesetChange.SetProperty):return FilesetUpdateRequest.SetFilesetPropertyRequest(change.property(), change.value())- elif isinstance(change, FilesetChange.RemoveProperty):+ if isinstance(change, FilesetChange.RemoveProperty):return FilesetUpdateRequest.RemoveFilesetPropertyRequest(change.property())- else:- raise ValueError(f"Unknown change type: {type(change).__name__}")+ raise ValueError(f"Unknown change type: {type(change).__name__}")diff --git a/clients/client-python/gravitino/rest/__init__.py b/clients/client-python/gravitino/rest/__init__.pynew file mode 100644index 0000000000..5779a3ad25--- /dev/null+++ b/clients/client-python/gravitino/rest/__init__.py@@ -0,0 +1,4 @@+"""+Copyright 2024 Datastrato Pvt Ltd.+This software is licensed under the Apache License version 2.+"""diff --git a/clients/client-python/requirements-dev.txt b/clients/client-python/requirements-dev.txtindex 0918af70f1..696d0d99f8 100644--- a/clients/client-python/requirements-dev.txt+++ b/clients/client-python/requirements-dev.txt@@ -3,4 +3,5 @@requestsdataclasses-jsonpylint-black\ No newline at end of file+black+twinediff --git a/clients/client-python/requirements.txt b/clients/client-python/requirements.txtindex 2cfa42afe2..e4e72675b8 100644--- a/clients/client-python/requirements.txt+++ b/clients/client-python/requirements.txt@@ -1,2 +1,6 @@# Copyright 2024 Datastrato Pvt Ltd.-# This software is licensed under the Apache License version 2.\ No newline at end of file+# This software is licensed under the Apache License version 2.++# the tools to publish the python client to Pypi+requests+dataclasses-json\ No newline at end of filediff --git a/clients/client-python/setup.py b/clients/client-python/setup.pyindex 04dd35ffc9..fee40e0a73 100644--- a/clients/client-python/setup.py+++ b/clients/client-python/setup.py@@ -6,16 +6,33 @@ This software is licensed under the Apache License version 2.from setuptools import find_packages, setup+try:+ with open("README.md") as f:+ long_description = f.read()+except FileNotFoundError:+ long_description = "Gravitino Python client"+setup(name="gravitino",description="Python lib/client for Gravitino",- version="0.5.0",- long_description=open("README.md").read(),+ version="0.5.0.dev12",+ long_description=long_description,long_description_content_type="text/markdown",url="https://github.com/datastrato/gravitino",author="datastrato",+ author_email="[email protected]",python_requires=">=3.8",- packages=find_packages(include=["gravitino", ".*"]),+ packages=find_packages(exclude=["tests*"]),+ classifiers=[+ 'Development Status :: 3 - Alpha',+ 'Intended Audience :: Developers',+ 'License :: OSI Approved :: Apache Software License',+ 'Programming Language :: Python :: 3.8',+ 'Programming Language :: Python :: 3.9',+ 'Programming Language :: Python :: 3.10',+ 'Programming Language :: Python :: 3.11',+ 'Programming Language :: Python :: 3.12',+ ],install_requires=open("requirements.txt").read(),extras_require={"dev": open("requirements-dev.txt").read(),diff --git a/clients/client-python/tests/integration/test_fileset_catalog.py b/clients/client-python/tests/integration/test_fileset_catalog.pyindex 9eafd351f8..df2be7c897 100644--- a/clients/client-python/tests/integration/test_fileset_catalog.py+++ b/clients/client-python/tests/integration/test_fileset_catalog.py@@ -7,12 +7,14 @@ import loggingfrom random import randintfrom typing import Dict, List-from gravitino.api.fileset import Fileset-from gravitino.api.fileset_change import FilesetChange-from gravitino.client.gravitino_admin_client import GravitinoAdminClient-from gravitino.client.gravitino_client import GravitinoClient-from gravitino.dto.catalog_dto import CatalogDTO-from gravitino.name_identifier import NameIdentifier+from gravitino import (+ NameIdentifier,+ GravitinoAdminClient,+ GravitinoClient,+ Catalog,+ Fileset,+ FilesetChange,+)from tests.integration.integration_test_env import IntegrationTestEnvlogger = logging.getLogger(__name__)@@ -21,7 +23,7 @@ logger = logging.getLogger(__name__)class TestFilesetCatalog(IntegrationTestEnv):metalake_name: str = "TestFilesetCatalog-metalake" + str(randint(1, 10000))catalog_name: str = "catalog"- catalog_location_pcatarop: str = "location" # Fileset Catalog must set `location`+ catalog_location_prop: str = "location" # Fileset Catalog must set `location`catalog_provider: str = "hadoop"schema_name: str = "schema"@@ -109,10 +111,10 @@ class TestFilesetCatalog(IntegrationTestEnv):)catalog = self.gravitino_client.create_catalog(ident=self.catalog_ident,- type=CatalogDTO.Type.FILESET,+ type=Catalog.Type.FILESET,provider=self.catalog_provider,comment="",- properties={self.catalog_location_pcatarop: "/tmp/test1"},+ properties={self.catalog_location_prop: "/tmp/test1"},)catalog.as_schemas().create_schema(ident=self.schema_ident, comment="", properties={}diff --git a/clients/client-python/tests/integration/test_metalake.py b/clients/client-python/tests/integration/test_metalake.pyindex bde94a1b75..a814756c90 100644--- a/clients/client-python/tests/integration/test_metalake.py+++ b/clients/client-python/tests/integration/test_metalake.py@@ -6,12 +6,14 @@ This software is licensed under the Apache License version 2.import loggingfrom typing import Dict, List-from gravitino.client.gravitino_admin_client import GravitinoAdminClient-from gravitino.client.gravitino_metalake import GravitinoMetalake+from gravitino import (+ GravitinoAdminClient,+ GravitinoMetalake,+ MetalakeChange,+ NameIdentifier,+)from gravitino.dto.dto_converters import DTOConvertersfrom gravitino.dto.requests.metalake_updates_request import MetalakeUpdatesRequest-from gravitino.api.metalake_change import MetalakeChange-from gravitino.name_identifier import NameIdentifierfrom tests.integration.integration_test_env import IntegrationTestEnvlogger = logging.getLogger(__name__)diff --git a/clients/client-python/tests/integration/test_schema.py b/clients/client-python/tests/integration/test_schema.pyindex 244017f698..895bc30275 100644--- a/clients/client-python/tests/integration/test_schema.py+++ b/clients/client-python/tests/integration/test_schema.py@@ -7,12 +7,15 @@ import loggingfrom random import randintfrom typing import Dict, List-from gravitino.api.catalog import Catalog-from gravitino.api.schema import Schema-from gravitino.api.schema_change import SchemaChange-from gravitino.client.gravitino_admin_client import GravitinoAdminClient-from gravitino.client.gravitino_client import GravitinoClient-from gravitino.name_identifier import NameIdentifier+from gravitino import (+ NameIdentifier,+ GravitinoAdminClient,+ GravitinoClient,+ Catalog,+ SchemaChange,+ Schema,+)+from tests.integration.integration_test_env import IntegrationTestEnvlogger = logging.getLogger(__name__)diff --git a/clients/client-python/tests/test_gravitino_client.py b/clients/client-python/tests/test_gravitino_client.pyindex ad497b2ba7..0a2a7e2855 100644--- a/clients/client-python/tests/test_gravitino_client.py+++ b/clients/client-python/tests/test_gravitino_client.py@@ -5,7 +5,7 @@ This software is licensed under the Apache License version 2.import unittest-from gravitino import GravitinoClient, gravitino_metalake+from gravitino.gravitino_client import gravitino_metalake, GravitinoClientfrom .utils import services_fixturesdiff --git a/docs/assets/gravitino-python-client-introduction.png b/docs/assets/gravitino-python-client-introduction.pngnew file mode 100644index 0000000000..315ff847d6Binary files /dev/null and b/docs/assets/gravitino-python-client-introduction.png differdiff --git a/docs/how-to-use-python-client.md b/docs/how-to-use-python-client.mdnew file mode 100644index 0000000000..55705d5635--- /dev/null+++ b/docs/how-to-use-python-client.md@@ -0,0 +1,130 @@+---+title: "How to use Gravitino Python client"+slug: /how-to-use-gravitino-python-client+date: 2024-05-09+keyword: Gravitino Python client+license: Copyright 2024 Datastrato Pvt Ltd. This software is licensed under the Apache License version 2.+---+## Introduction++Gravitino is a high-performance, geo-distributed, and federated metadata lake.+It manages the metadata directly in different sources, types, and regions, also provides users+the unified metadata access for data and AI assets.++Gravitino Python client helps data scientists easily manage metadata using Python language.++++## Use Guidance++You can use Gravitino Python client library with Spark, PyTorch, Tensorflow, Ray and Python environment.++First of all, You must have a Gravitino server set up and run, You can refer document of+[How to install Gravitino](./how-to-install.md) to build Gravitino server from source code and+install it in your local.++### Gravitino Python client API++```shell+pip install gravitino+```++1. [Manage metalake using Gravitino Python API](./manage-metalake-using-gravitino.md)+2. [Manage fileset metadata using Gravitino Python API](./manage-fileset-metadata-using-gravitino.md)++### Gravitino Fileset Example++We offer a playground environment to help you quickly understand how to use Gravitino Python+client to manage non-tabular data on HDFS via Fileset in Gravitino. You can refer to the+document [How to use the playground#Launch AI components of playground](./how-to-use-the-playground.md#launch-ai-components-of-playground)+to launch a Gravitino server, HDFS and Jupyter notebook environment in you local Docker environment.++Waiting for the playground Docker environment to start, you can directly open+`http://localhost:8888/lab/tree/gravitino-fileset-sample.ipynb` in the browser and run the example.++The [gravitino-fileset-example](https://github.com/datastrato/gravitino-playground/blob/main/init/jupyter/gravitino-fileset-sample.ipynb)+contains the following code snippets:++1. Install HDFS Python client.+2. Create a HDFS client to connect HDFS and to do some test operations.+3. Install Gravitino Python client.+4. Initialize Gravitino admin client and create a Gravitino metalake.+5. Initialize Gravitino client and list metalakes.+6. Create a Gravitino `Catalog` and special `type` is `Catalog.Type.FILESET` and `provider` is+ [hadoop](./hadoop-catalog.md)+7. Create a Gravitino `Schema` with the `location` pointed to a HDFS path, and use `hdfs client` to+ check if the schema location is successfully created in HDFS.+8. Create a `Fileset` with `type` is [Fileset.Type.MANAGED](./manage-fileset-metadata-using-gravitino.md#fileset-operations),+ use `hdfs client` to check if the fileset location was successfully created in HDFS.+9. Drop this `Fileset.Type.MANAGED` type fileset and check if the fileset location was+ successfully deleted in HDFS.+10. Create a `Fileset` with `type` is [Fileset.Type.EXTERNAL](./manage-fileset-metadata-using-gravitino.md#fileset-operations)+ and `location` pointed to exist HDFS path+11. Drop this `Fileset.Type.EXTERNAL` type fileset and check if the fileset location was+ not deleted in HDFS.++## How to development Gravitino Python Client++You can ues any IDE to develop Gravitino Python Client. Directly open the client-python module project in the IDE.++### Prerequisites+++ Python 3.8+++ Refer to [How to build Gravitino](./how-to-build.md#prerequisites) to have necessary build+ environment ready for building.++### Build and testing++1. Clone the Gravitino project.++ ```shell+ git clone [email protected]:datastrato/gravitino.git+ ```++2. Build the Gravitino Python client module++ ```shell+ ./gradlew :clients:client-python:build+ ```++3. Run unit tests++ ```shell+ ./gradlew :clients:client-python:test -PskipITs+ ```++4. Run integration tests++ Because Python client connects to Gravitino Server to run integration tests,+ So it runs `./gradlew compileDistribution -x test` command automatically to compile the+ Gravitino project in the `distribution` directory. When you run integration tests via Gradle+ command or IDE, Gravitino integration test framework (`integration_test_env.py`)+ will start and stop Gravitino server automatically.++ ```shell+ ./gradlew :clients:client-python:test+ ```++5. Distribute the Gravitino Python client module++ ```shell+ ./gradlew :clients:client-python:distribution+ ```++6. Deploy the Gravitino Python client to https://pypi.org/project/gravitino/++ ```shell+ ./gradlew :clients:client-python:deploy+ ```++## Resources+++ Official website https://datastrato.ai/++ Project home on GitHub: https://github.com/datastrato/gravitino/++ Playground with Docker: https://github.com/datastrato/gravitino-playground++ User documentation: https://datastrato.ai/docs/++ Videos on Youtube: https://www.youtube.com/@Datastrato++ Twitter: https://twitter.com/datastrato++ Linkedin: https://www.linkedin.com/company/datastrato++ Slack Community: [https://join.slack.com/t/datastrato-community](https://join.slack.com/t/datastrato-community/shared_invite/zt-2a8vsjoch-cU_uUwHA_QU6Ab50thoq8w)++ Discourse Community: https://gravitino.discourse.group/diff --git a/docs/how-to-use-the-playground.md b/docs/how-to-use-the-playground.mdindex 9245928c7f..e096ea3fd0 100644--- a/docs/how-to-use-the-playground.md+++ b/docs/how-to-use-the-playground.md@@ -8,7 +8,7 @@ This software is licensed under the Apache License version 2."## Playground introduction-The playground is a complete Gravitino Docker runtime environment with `Hive`, `HDFS`, `Trino`, `MySQL`, `PostgreSQL`, and a `Gravitino` server.+The playground is a complete Gravitino Docker runtime environment with `Hive`, `HDFS`, `Trino`, `MySQL`, `PostgreSQL`, `Jupyter`, and a `Gravitino` server.Depending on your network and computer, startup time may take 3-5 minutes. Once the playground environment has started, you can open [http://localhost:8090](http://localhost:8090) in a browser to access the Gravitino Web UI.@@ -27,15 +27,77 @@ The playground runs a number of services. The TCP ports used may clash with exis| playground-mysql | 3306 || playground-postgresql | 5342 || playground-trino | 8080 |+| playground-jupyter | 8888 |## Start playground+### Launch all components of playground+```shellgit clone [email protected]:datastrato/gravitino-playground.gitcd gravitino-playground./launch-playground.sh```+### Launch big data components of playground++```shell+git clone [email protected]:datastrato/gravitino-playground.git+cd gravitino-playground+./launch-playground.sh bigdata+# equivalent to+./launch-playground.sh hive gravitino trino postgresql mysql spark+```++### Launch AI components of playground++```shell+git clone [email protected]:datastrato/gravitino-playground.git+cd gravitino-playground+./launch-playground.sh ai+# equivalent to+./launch-playground.sh hive gravitino mysql jupyter+```++### Launch special component or components of playground++```shell+git clone [email protected]:datastrato/gravitino-playground.git+cd gravitino-playground+./launch-playground.sh hive|gravitino|trino|postgresql|mysql|spark|jupyter+```++### Experiencing Gravitino Fileset with Jupyter++We provide a Fileset playground environment to help you quickly understand how to use Gravitino+Python client to manage non-tabular data on HDFS via fileset in Gravitino service.+You can refer document of [Launch AI components of playground](#launch-ai-components-of-playground)+to launch a Gravitino server, HDFS and Jupyter notebook environment in you local Docker environment.++Waiting for the playground Docker environment to start, you can directly open+`http://localhost:8888/lab/tree/gravitino-fileset-sample.ipynb` in the browser and run the example.++The [gravitino-fileset-example](https://github.com/datastrato/gravitino-playground/blob/main/init/jupyter/gravitino-fileset-sample.ipynb)+contains the following code snippets:++1. Install HDFS Python client.+2. Create a HDFS client to connect HDFS and to do some test operations.+3. Install Gravitino Python client.+4. Initialize Gravitino admin client and create a Gravitino metalake.+5. Initialize Gravitino client and list metalakes.+6. Create a Gravitino `Catalog` and special `type` is `Catalog.Type.FILESET` and `provider` is+ [hadoop](./hadoop-catalog.md)+7. Create a Gravitino `Schema` with the `location` pointed to a HDFS path, and use `hdfs client` to+ check if the schema location is successfully created in HDFS.+8. Create a `Fileset` with `type` is [Fileset.Type.MANAGED](./manage-fileset-metadata-using-gravitino.md#fileset-operations),+ use `hdfs client` to check if the fileset location was successfully created in HDFS.+9. Drop this `Fileset.Type.MANAGED` type fileset and check if the fileset location was+ successfully deleted in HDFS.+10. Create a `Fileset` with `type` is [Fileset.Type.EXTERNAL](./manage-fileset-metadata-using-gravitino.md#fileset-operations)+ and `location` pointed to exist HDFS path+11. Drop this `Fileset.Type.EXTERNAL` type fileset and check if the fileset location was+ not deleted in HDFS.+## Experiencing Gravitino with Trino SQL1. Log in to the Gravitino playground Trino Docker container using the following command:@@ -47,7 +109,7 @@ docker exec -it playground-trino bash2. Open the Trino CLI in the container.```shell-trino@d2bbfccc7432:/$ trino+trino@container_id:/$ trino```## Example@@ -115,7 +177,7 @@ ORDER BY location, SUM(total_amount) DESC;To know the employee's average performance rating and total sales, run this SQL:```SQL-SELECT e.employee_id, given_name, family_name, AVG(rating) AS average_rating, SUM(total_amount) AS total_sales+SELECT e.employee_id, given_name, family_name, AVG(rating) AS average_rating, SUM(total_amount) AS total_salesFROM catalog_postgres.hr.employees AS e,catalog_postgres.hr.employee_performance AS p,catalog_hive.sales.sales AS s@@ -146,7 +208,7 @@ docker exec -it playground-spark bash``````shell-spark@7a495f27b92e:/$ cd /opt/spark && /bin/bash bin/spark-sql+spark@container_id:/$ cd /opt/spark && /bin/bash bin/spark-sql``````SQL@@ -154,7 +216,7 @@ use catalog_iceberg;create database sales;use sales;create table customers (customer_id int, customer_name varchar(100), customer_email varchar(100));-describe extended customers;+describe extended customers;insert into customers (customer_id, customer_name, customer_email) values (11,'Rory Brown','[email protected]');insert into customers (customer_id, customer_name, customer_email) values (12,'Jerry Washington','[email protected]');```@@ -167,7 +229,7 @@ docker exec -it playground-trino bash``````shell-trino@d2bbfccc7432:/$ trino+trino@container_id:/$ trino``````SQLdiff --git a/docs/manage-fileset-metadata-using-gravitino.md b/docs/manage-fileset-metadata-using-gravitino.mdindex 3ed273c28a..49413e31e7 100644--- a/docs/manage-fileset-metadata-using-gravitino.md+++ b/docs/manage-fileset-metadata-using-gravitino.md@@ -38,7 +38,7 @@ For a fileset catalog, you must specify the catalog `type` as `FILESET` when creYou can create a catalog by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs`endpoint or just use the Gravitino Java client. The following is an example of creating a catalog:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -59,7 +59,7 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \```javaGravitinoClient gravitinoClient = GravitinoClient- .builder("http://127.0.0.1:8090")+ .builder("http://localhost:8090").withMetalake("metalake").build();@@ -78,6 +78,18 @@ Catalog catalog = gravitinoClient.createCatalog(// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")+catalog = gravitino_client.create_catalog(ident=NameIdentifier.of("metalake", "catalog"),+ type=Catalog.Type.FILESET,+ provider="hadoop",+ comment="This is a Hadoop fileset catalog",+ properties={"location": "/tmp/test1"})+```+</TabItem></Tabs>@@ -131,7 +143,7 @@ Users should create a metalake and a catalog before creating a schema.You can create a schema by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas`endpoint or just use the Gravitino Java client. The following is an example of creating a schema:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -150,7 +162,7 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \```javaGravitinoClient gravitinoClient = GravitinoClient- .builder("http://127.0.0.1:8090")+ .builder("http://localhost:8090").withMetalake("metalake").build();@@ -172,6 +184,18 @@ Schema schema = supportsSchemas.createSchema(// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")++catalog: Catalog = gravitino_client.load_catalog(ident=NameIdentifier.of("metalake", "catalog"))+catalog.as_schemas().create_schema(ident=NameIdentifier.of("metalake", "catalog", "schema"),+ comment="This is a schema",+ properties={"location": "/tmp/root/schema"})+```+</TabItem></Tabs>@@ -221,7 +245,7 @@ You can create a fileset by sending a `POST` request to the `/api/metalakes/{met/catalogs/{catalog_name}/schemas/{schema_name}/filesets` endpoint or just use the Gravitino Javaclient. The following is an example of creating a fileset:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -242,7 +266,7 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \```javaGravitinoClient gravitinoClient = GravitinoClient- .builder("http://127.0.0.1:8090")+ .builder("http://localhost:8090").withMetalake("metalake").build();@@ -262,6 +286,20 @@ filesetCatalog.createFileset();```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")++catalog: Catalog = gravitino_client.load_catalog(ident=NameIdentifier.of("metalake", "catalog"))+catalog.as_fileset_catalog().create_fileset(ident=NameIdentifier.of("metalake", "catalog", "schema", "example_fileset"),+ type=Fileset.Type.MANAGED,+ comment="This is an example fileset",+ storage_location="/tmp/root/schema/example_fileset",+ properties={"k1": "v1"})+```+</TabItem></Tabs>@@ -299,7 +337,7 @@ You can modify a fileset by sending a `PUT` request to the `/api/metalakes/{meta/catalogs/{catalog_name}/schemas/{schema_name}/filesets/{fileset_name}` endpoint or just use theGravitino Java client. The following is an example of modifying a fileset:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -333,6 +371,21 @@ Fileset f = filesetCatalog.alterFileset(NameIdentifier.of("metalake", "catalog",// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")++catalog: Catalog = gravitino_client.load_catalog(ident=NameIdentifier.of("metalake", "catalog"))+changes = (+ FilesetChange.remove_property("fileset_properties_key1"),+ FilesetChange.set_property("fileset_properties_key2", "fileset_propertie_new_value"),+)+fileset_new = catalog.as_fileset_catalog().alter_fileset(NameIdentifier.of("metalake", "catalog", "schema", "fileset"),+ *changes)+```+</TabItem></Tabs>@@ -351,7 +404,7 @@ You can remove a fileset by sending a `DELETE` request to the `/api/metalakes/{m/catalogs/{catalog_name}/schemas/{schema_name}/filesets/{fileset_name}` endpoint or by using theGravitino Java client. The following is an example of dropping a fileset:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -375,6 +428,16 @@ filesetCatalog.dropFileset(NameIdentifier.of("metalake", "catalog", "schema", "f// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")++catalog: Catalog = gravitino_client.load_catalog(ident=NameIdentifier.of("metalake", "catalog"))+catalog.as_fileset_catalog().drop_fileset(ident=NameIdentifier.of("metalake", "catalog", "schema", "fileset"))+```+</TabItem></Tabs>@@ -387,7 +450,7 @@ You can list all filesets in a schema by sending a `GET` request to the `/api/me{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/filesets` endpoint or by using theGravitino Java client. The following is an example of listing all the filesets in a schema:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -409,5 +472,15 @@ NameIdentifier[] identifiers =// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_client: GravitinoClient = GravitinoClient(uri="http://localhost:8090", metalake_name="metalake")++catalog: Catalog = gravitino_client.load_catalog(ident=NameIdentifier.of("metalake", "catalog"))+fileset_list: List[NameIdentifier] = catalog.as_fileset_catalog().list_filesets(namespace=Namespace.of_fileset("metalake", "catalog", "schema")))+```+</TabItem></Tabs>diff --git a/docs/manage-metalake-using-gravitino.md b/docs/manage-metalake-using-gravitino.mdindex 24699352f5..cbd2e24400 100644--- a/docs/manage-metalake-using-gravitino.md+++ b/docs/manage-metalake-using-gravitino.md@@ -25,7 +25,7 @@ Assuming Gravitino has just started, and the host and port is [http://localhost:You can create a metalake by sending a `POST` request to the `/api/metalakes` endpoint or just use the Gravitino Admin Java client.The following is an example of creating a metalake:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -39,7 +39,7 @@ http://localhost:8090/api/metalakes```javaGravitinoAdminClient gravitinoAdminClient = GravitinoAdminClient- .builder("http://127.0.0.1:8090")+ .builder("http://localhost:8090").build();GravitinoMetaLake newMetalake = gravitinoAdminClient.createMetalake(@@ -49,6 +49,16 @@ GravitinoMetaLake newMetalake = gravitinoAdminClient.createMetalake(// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_admin_client: GravitinoAdminClient = GravitinoAdminClient(uri="http://localhost:8090")+gravitino_admin_client.create_metalake(ident=NameIdentifier.of("metalake"),+ comment="This is a new metalake",+ properties={})+```+</TabItem></Tabs>@@ -56,7 +66,7 @@ GravitinoMetaLake newMetalake = gravitinoAdminClient.createMetalake(You can create a metalake by sending a `GET` request to the `/api/metalakes/{metalake_name}` endpoint or just use the Gravitino Java client. The following is an example of loading a metalake:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -74,6 +84,13 @@ GravitinoMetaLake loaded = gravitinoAdminClient.loadMetalake(// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_admin_client.load_metalake(NameIdentifier.of("metalake"))+```+</TabItem></Tabs>@@ -81,7 +98,7 @@ GravitinoMetaLake loaded = gravitinoAdminClient.loadMetalake(You can modify a metalake by sending a `PUT` request to the `/api/metalakes/{metalake_name}` endpoint or just use the Gravitino Java client. The following is an example of altering a metalake:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -113,6 +130,20 @@ GravitinoMetaLake renamed = gravitinoAdminClient.alterMetalake(// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+changes = (+ MetalakeChange.rename("metalake_new_name"),+ MetalakeChange.update_comment("metalake_new_comment"),+ MetalakeChange.remove_property("metalake_properties_key1"),+ MetalakeChange.set_property("metalake_properties_key2", "metalake_propertie_new_value"),+)++metalake = gravitino_admin_client.alter_metalake(NameIdentifier.of("metalake_name"), *changes)+```+</TabItem></Tabs>@@ -131,7 +162,7 @@ Currently, Gravitino supports the following changes to a metalake:You can remove a metalake by sending a `DELETE` request to the `/api/metalakes/{metalake_name}` endpoint or just use the Gravitino Java client. The following is an example of dropping a metalake:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -150,6 +181,13 @@ boolean success = gravitinoAdminClient.dropMetalake(// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+gravitino_admin_client.drop_metalake(NameIdentifier.of("metalake"))+```+</TabItem></Tabs>@@ -162,7 +200,7 @@ catalogs, schemas and tables under the metalake need to be removed before droppiYou can list metalakes by sending a `GET` request to the `/api/metalakes` endpoint or just use the Gravitino Java client. The following is an example of listing all metalake names:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -179,5 +217,12 @@ GravitinoMetaLake[] allMetalakes = gravitinoAdminClient.listMetalakes();// ...```+</TabItem>+<TabItem value="python" label="Python">++```python+metalake_list: List[GravitinoMetalake] = gravitino_admin_client.list_metalakes()+```+</TabItem></Tabs>diff --git a/docs/manage-relational-metadata-using-gravitino.md b/docs/manage-relational-metadata-using-gravitino.mdindex 1ae6a66ff2..78d81125ca 100644--- a/docs/manage-relational-metadata-using-gravitino.md+++ b/docs/manage-relational-metadata-using-gravitino.md@@ -172,7 +172,7 @@ Currently, Gravitino supports the following changes to a catalog:You can remove a catalog by sending a `DELETE` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}` endpoint or just use the Gravitino Java client. The following is an example of dropping a catalog:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -204,7 +204,7 @@ Dropping a catalog only removes metadata about the catalog, schemas, and tablesYou can list all catalogs under a metalake by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs` endpoint or just use the Gravitino Java client. The following is an example of listing all catalogs ina metalake:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -230,7 +230,7 @@ NameIdentifier[] catalogsIdents = gravitinoClient.listCatalogs(Namespace.ofCatalYou can list all catalogs' information under a metalake by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs?details=true` endpoint or just use the Gravitino Java client. The following is an example of listing all catalogs' information in a metalake:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -263,7 +263,7 @@ Users should create a metalake and a catalog before creating a schema.You can create a schema by sending a `POST` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas` endpoint or just use the Gravitino Java client. The following is an example of creating a schema:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -296,6 +296,17 @@ Schema schema = supportsSchemas.createSchema(// ...```+</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(ident=NameIdentifier.of("metalake", "hive_catalog"))+catalog.as_schemas().create_schema(ident=NameIdentifier.of("metalake", "hive_catalog", "schema"),+ comment="This is a schema",+ properties={})+```+</TabItem></Tabs>@@ -313,7 +324,7 @@ Currently, Gravitino supports the following schema property:You can create a schema by sending a `GET` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}` endpoint or just use the Gravitino Java client. The following is an example of loading a schema:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -334,6 +345,15 @@ Schema schema = supportsSchemas.loadSchema(NameIdentifier.of("metalake", "hive_c// ...```+</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(ident=NameIdentifier.of("metalake", "hive_catalog"))+schema: Schema = catalog.as_schemas().load_schema(ident=NameIdentifier.of("metalake", "hive_catalog", "schema"))+```+</TabItem></Tabs>@@ -341,7 +361,7 @@ Schema schema = supportsSchemas.loadSchema(NameIdentifier.of("metalake", "hive_cYou can change a schema by sending a `PUT` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}` endpoint or just use the Gravitino Java client. The following is an example of modifying a schema:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -376,6 +396,21 @@ Schema schema = supportsSchemas.alterSchema(NameIdentifier.of("metalake", "hive_// ...```+</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(ident=NameIdentifier.of("metalake", "hive_catalog"))++changes = (+ SchemaChange.remove_property("schema_properties_key1"),+ SchemaChange.set_property("schema_properties_key2", "schema_propertie_new_value"),+)+schema_new: Schema = catalog.as_schemas().alter_schema(NameIdentifier.of("metalake", "hive_catalog", "schema"),+ *changes)+```+</TabItem></Tabs>@@ -389,7 +424,7 @@ Currently, Gravitino supports the following changes to a schema:### Drop a schemaYou can remove a schema by sending a `DELETE` request to the `/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}` endpoint or just use the Gravitino Java client. The following is an example of dropping a schema:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -412,6 +447,16 @@ SupportsSchemas supportsSchemas = catalog.asSchemas();supportsSchemas.dropSchema(NameIdentifier.of("metalake", "hive_catalog", "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(ident=NameIdentifier.of("metalake", "hive_catalog"))++catalog.as_schemas().drop_schema(NameIdentifier.of("metalake", "hive_catalog", "schema"), cascade=True)+```+</TabItem></Tabs>@@ -424,7 +469,7 @@ You can alter all schemas under a catalog by sending a `GET` request to the `/apin a catalog:-<Tabs>+<Tabs groupId="language" queryString><TabItem value="shell" label="Shell">```shell@@ -444,6 +489,16 @@ SupportsSchemas supportsSchemas = catalog.asSchemas();NameIdentifier[] schemas = supportsSchemas.listSchemas(Namespace.ofSchema("metalake", "hive_catalog"));```+</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(ident=NameIdentifier.of("metalake", "hive_catalog"))++schema_list: List[NameIdentifier] = catalog.as_schemas().list_schemas(Namespace.of_schema("metalake", "hive_catalog"))+```+</TabItem></Tabs>