RussellSpitzer commented on code in PR #17940: URL: https://github.com/apache/iceberg/pull/17940#discussion_r3928380826
########## docs/docs/rest-catalog.md: ########## @@ -0,0 +1,228 @@ +--- +title: "REST Catalog" +--- +<!-- + - 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. + --> + +# Iceberg REST Catalog + +The REST catalog is a client for any catalog service that implements the +[Iceberg REST Catalog API specification](../../rest-catalog-spec.md). Instead of +requiring a catalog-specific client in every engine and language, the catalog +logic lives behind an HTTP API, and a single client implementation works with +any compliant server. + +This page describes how to configure the REST catalog client and the protocol +features it supports. For the protocol definition itself, see the +[spec page](../../rest-catalog-spec.md). To try the protocol locally, the +community publishes the +[`apache/iceberg-rest-fixture`](https://hub.docker.com/r/apache/iceberg-rest-fixture) +Docker image, which serves the REST API backed by an in-memory catalog; see its +[README](https://github.com/apache/iceberg/blob/main/docker/iceberg-rest-fixture/README.md) +for how to run and configure it, or the +[Spark quickstart](../../spark-quickstart.md). + +## Configuring a REST catalog + +A REST catalog needs at minimum a `uri` pointing at the server. Most +deployments also configure authentication; see +[REST auth properties](catalog-properties.md#auth-properties) for the +supported mechanisms (Basic, OAuth2, SigV4, and Google). The full list of +client properties is in +[REST catalog properties](catalog-properties.md#rest-catalog-properties). + +### Java + +```java +import java.util.HashMap; +import java.util.Map; +import org.apache.iceberg.CatalogProperties; +import org.apache.iceberg.rest.RESTCatalog; + +Map<String, String> properties = new HashMap<>(); +properties.put(CatalogProperties.URI, "https://catalog-service/api/catalog"); + +RESTCatalog catalog = new RESTCatalog(); +catalog.initialize("prod", properties); +``` + +Engines that load catalogs through `CatalogUtil.buildIcebergCatalog` select the +REST catalog with `type=rest`. + +### Spark + +```ini +spark.sql.catalog.prod = org.apache.iceberg.spark.SparkCatalog +spark.sql.catalog.prod.type = rest +spark.sql.catalog.prod.uri = https://catalog-service/api/catalog +``` + +See [Spark catalog configuration](spark-configuration.md#catalog-configuration) +for details. + +### Flink + +```sql +CREATE CATALOG prod WITH ( + 'type'='iceberg', + 'catalog-type'='rest', + 'uri'='https://catalog-service/api/catalog' +); +``` + +See the [Flink catalog documentation](flink.md#rest-catalog) for details. + +## Endpoint discovery and server-provided configuration + +On initialization, the client calls the server's configuration route +(`GET /v1/config`, passing the configured `warehouse` as a query parameter if +one is set). The response can adjust the client's configuration in three ways: + +- **`defaults`**: properties the server suggests; the client's own + configuration takes precedence over them. +- **`overrides`**: properties the server requires; they take precedence over + the client's configuration. A common override is `prefix`, which the client + inserts into all subsequent request paths (`/v1/{prefix}/namespaces/...`) + so that one server can host multiple catalogs. +- **`endpoints`**: the list of API endpoints the server supports. The client + only uses features whose endpoints are advertised, so a server that does not + implement, for example, view or scan-planning endpoints simply causes those + features to be unavailable rather than producing failed requests. + +If the server omits the `endpoints` field entirely, the client assumes a +default set of namespace and table endpoints. For older servers that support +views but predate endpoint discovery, set `view-endpoints-supported=true` +(see [REST catalog properties](catalog-properties.md#rest-catalog-properties)). + +## Multi-table transactions + +The REST protocol can commit changes to multiple tables in one atomic +operation (`POST /v1/{prefix}/transactions/commit`). Each participating table +contributes its update requirements and metadata updates; the server validates +all requirements and applies all updates atomically, so either every table +commit succeeds or none does. + +In Java, this is exposed as `RESTCatalog.commitTransaction`: + +```java +import org.apache.iceberg.catalog.TableCommit; + +// derive requirements and updates from each table's base and updated metadata +TableCommit commit1 = TableCommit.create(identifier1, baseMetadata1, updatedMetadata1); +TableCommit commit2 = TableCommit.create(identifier2, baseMetadata2, updatedMetadata2); + +catalog.commitTransaction(commit1, commit2); +``` + +This requires server support for the transactions endpoint. + +## Storage access delegation Review Comment: I feel like a lot of the following are also pretty much user opaque features. A general user won't know these things are happening so I'm not sure how important it is for them to be in this doc. I think we should focus on things they need to know or would have to configure themselves. Most of these (like storage access delegation) are not options the end user has any choice about. Most of those probably fit somewhere else in the docs as a technical reference but I think a lot of it is just transpositions from the spec -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
