kbendick commented on a change in pull request #4348: URL: https://github.com/apache/iceberg/pull/4348#discussion_r828529195
########## File path: core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java ########## @@ -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. + */ + +package org.apache.iceberg.rest; + +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; +import org.apache.iceberg.BaseTable; +import org.apache.iceberg.BaseTransaction; +import org.apache.iceberg.PartitionSpec; +import org.apache.iceberg.Schema; +import org.apache.iceberg.SortOrder; +import org.apache.iceberg.Table; +import org.apache.iceberg.TableMetadata; +import org.apache.iceberg.TableOperations; +import org.apache.iceberg.Transaction; +import org.apache.iceberg.catalog.Catalog; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.catalog.SupportsNamespaces; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.exceptions.AlreadyExistsException; +import org.apache.iceberg.exceptions.CommitFailedException; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.collect.Maps; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.apache.iceberg.rest.requests.CreateNamespaceRequest; +import org.apache.iceberg.rest.requests.CreateTableRequest; +import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest; +import org.apache.iceberg.rest.requests.UpdateTableRequest; +import org.apache.iceberg.rest.responses.CreateNamespaceResponse; +import org.apache.iceberg.rest.responses.DropNamespaceResponse; +import org.apache.iceberg.rest.responses.DropTableResponse; +import org.apache.iceberg.rest.responses.GetNamespaceResponse; +import org.apache.iceberg.rest.responses.ListNamespacesResponse; +import org.apache.iceberg.rest.responses.ListTablesResponse; +import org.apache.iceberg.rest.responses.LoadTableResponse; +import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse; +import org.apache.iceberg.util.Tasks; + +import static org.apache.iceberg.TableProperties.COMMIT_MAX_RETRY_WAIT_MS_DEFAULT; +import static org.apache.iceberg.TableProperties.COMMIT_MIN_RETRY_WAIT_MS_DEFAULT; +import static org.apache.iceberg.TableProperties.COMMIT_NUM_RETRIES_DEFAULT; +import static org.apache.iceberg.TableProperties.COMMIT_TOTAL_RETRY_TIME_MS_DEFAULT; + +public class CatalogHandlers { + private static final Schema EMPTY_SCHEMA = new Schema(); + + private CatalogHandlers() { + } + + static class UnprocessableEntityException extends RuntimeException { Review comment: Currently, this exception (and HTTP 422 in general) is only used for conflicting namespace property updates. Though I don't disagree agree that some internal JavaDocs would be beneficial. I can grab some links to the spec that we might be able to pull from like [this usage of this exception](https://github.com/apache/iceberg/blob/dcbd5f694908781c07937f495690a4ae16886c61/open-api/rest-catalog-open-api.yaml#L302-L310). The Mozilla docs would also be helpful, as this is HTTP 422 [`Unprocessable Entity`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422). But the specific occurrence we have at present that is represented here is in the mentioned namespace update scenario. Per the spec, [this is the example](https://github.com/apache/iceberg/blob/dcbd5f694908781c07937f495690a4ae16886c61/open-api/rest-catalog-open-api.yaml#L1714-L1724) for this specific error (we can update the example's phrasing to match what's here as I prefer the usage in this PR for this one - but they can åbe consolidated generally speaking). ``` "error": { "message": "The request cannot be processed as there is a key present multiple times", "type": "UnprocessableEntityException", "code": 422 } ``` -- 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]
