jerryshao commented on code in PR #11280: URL: https://github.com/apache/gravitino/pull/11280#discussion_r3536159867
########## design-docs/spark-rest-catalog-registration.md: ########## @@ -0,0 +1,315 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +# Design: Spark REST Catalog Automatic Registration + +## Problem + +Spark users can already connect to Gravitino with a small amount of configuration: + +```text +spark.plugins=org.apache.gravitino.spark.connector.plugin.GravitinoSparkPlugin +spark.sql.gravitino.uri=http://127.0.0.1:8090 +spark.sql.gravitino.metalake=test +``` + +However, when users want Spark to access Iceberg or Lance through their REST protocols, they still +need to hand-write Spark catalog configuration for each catalog: + +```text +spark.sql.catalog.iceberg_prod=org.apache.iceberg.spark.SparkCatalog +spark.sql.catalog.iceberg_prod.type=rest +spark.sql.catalog.iceberg_prod.uri=http://127.0.0.1:9001/iceberg/ +spark.sql.catalog.iceberg_prod.warehouse=iceberg_prod + +spark.sql.catalog.lance_vectors=org.lance.spark.LanceNamespaceSparkCatalog +spark.sql.catalog.lance_vectors.impl=rest +spark.sql.catalog.lance_vectors.uri=http://127.0.0.1:9101/lance +spark.sql.catalog.lance_vectors.parent=lance_vectors +``` + +This duplicates information already managed by Gravitino and forces users to update Spark +configuration whenever Gravitino catalogs change. + +## Goal + +The Gravitino Spark connector should register Spark REST catalogs automatically for supported +Gravitino catalogs. The user-facing goal is simple: Gravitino remains the catalog inventory, and +Spark derives the Iceberg/Lance REST catalog configuration from that inventory. + +V1 scope is Spark only. + +Non-goals in V1: + +1. Do not introduce a generic access-mode framework. +2. Do not introduce a dedicated Lance catalog provider. +3. Do not change the Gravitino REST API contract. + +## Supported Catalogs + +This design supports the following Gravitino catalog providers in V1: + +| Gravitino catalog provider | Extra catalog constraints | Default Spark registration | REST catalog registration | +|----------------------------|------------------------------|-------------------------------------------|-------------------------------------------------------------------| +| `lakehouse-iceberg` | None | Existing Gravitino Spark catalog behavior | Enabled only when `spark.sql.gravitino.iceberg.enableRestAccess=true` | +| `lakehouse-generic` | Catalog-level `format=lance` | Existing behavior | Enabled only when `spark.sql.gravitino.lance.enableRestAccess=true` | +| Other providers | None | Existing behavior | Not supported in V1 | + +For `lakehouse-generic + format=lance`, `format=lance` is interpreted as a catalog-level marker only +for Lance REST catalog registration. This does not change the existing behavior of other generic +catalogs. When the marker is present, the catalog is treated as a Lance catalog, and tables under +this catalog must be Lance tables. Generic catalogs without catalog-level `format=lance` are ignored +by Lance REST catalog registration. Because there is no Lance Gravitino Spark catalog in V1, Lance +only supports REST catalog registration. + +## Spark Configuration + +Iceberg REST catalog registration is disabled by default to preserve existing Gravitino Spark +connector behavior. Users enable it with: + +```text +spark.sql.gravitino.iceberg.enableRestAccess=true +``` + +Lance REST catalog registration is disabled by default because registration needs to load Lance +Spark catalog and extension classes, and users may not have the Lance Spark runtime on the +classpath. Users explicitly enable Lance REST access with: + +```text +spark.sql.gravitino.lance.enableRestAccess=true +``` + +When Lance REST access is enabled, the Spark connector registers REST catalogs for +`lakehouse-generic + format=lance` catalogs. + +Optional REST service URI overrides: + +| Configuration | Default | +|---------------|---------| +| `spark.sql.gravitino.iceberg.restUri` | Inferred from `spark.sql.gravitino.uri` | +| `spark.sql.gravitino.lance.restUri` | Inferred from `spark.sql.gravitino.uri` | + +The Iceberg switch applies to all Gravitino Iceberg catalogs visible to the Spark connector in V1. +Per-catalog REST registration override is future work. + +## Registration Precedence + +For each Spark catalog name, the connector should register exactly one Spark catalog implementation. +When `spark.sql.gravitino.iceberg.enableRestAccess=true`, REST catalog registration replaces the +existing Gravitino Spark catalog registration for matching `lakehouse-iceberg` catalogs and keeps the +same Spark catalog name. Review Comment: What if users already have exsting catalog configurations in the Spark conf. And then, they update the conf to enable this feature, who takes precedence? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
