yuqi1129 commented on code in PR #10637: URL: https://github.com/apache/gravitino/pull/10637#discussion_r3050393382
########## lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/CommonUtil.java: ########## @@ -0,0 +1,36 @@ +/* + * 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.gravitino.lance.common.ops.gravitino; + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** Utility methods used by Gravitino Lance namespace operations. */ +class CommonUtil { + + private CommonUtil() {} + + static String formatCurrentStackTrace() { Review Comment: What is the method used for? Can `Throwables.getStackTraceAsString()` meet your needs? ########## lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceNameSpaceOperations.java: ########## @@ -52,20 +42,43 @@ import org.apache.gravitino.Schema; import org.apache.gravitino.SchemaChange; import org.apache.gravitino.client.GravitinoClient; -import org.apache.gravitino.exceptions.CatalogAlreadyExistsException; import org.apache.gravitino.exceptions.CatalogInUseException; import org.apache.gravitino.exceptions.NoSuchCatalogException; import org.apache.gravitino.exceptions.NoSuchSchemaException; import org.apache.gravitino.exceptions.NonEmptyCatalogException; import org.apache.gravitino.exceptions.NonEmptySchemaException; -import org.apache.gravitino.exceptions.SchemaAlreadyExistsException; import org.apache.gravitino.lance.common.ops.LanceNamespaceOperations; +import org.lance.namespace.errors.InvalidInputException; +import org.lance.namespace.errors.LanceNamespaceException; +import org.lance.namespace.errors.NamespaceAlreadyExistsException; +import org.lance.namespace.errors.NamespaceNotFoundException; +import org.lance.namespace.model.CreateNamespaceResponse; +import org.lance.namespace.model.DescribeNamespaceResponse; +import org.lance.namespace.model.DropNamespaceResponse; +import org.lance.namespace.model.ListNamespacesResponse; +import org.lance.namespace.model.ListTablesResponse; public class GravitinoLanceNameSpaceOperations implements LanceNamespaceOperations { private final GravitinoLanceNamespaceWrapper namespaceWrapper; private final GravitinoClient client; + private enum CreateMode { Review Comment: Why do we need to add those three enums? Can't we use enums in the Lance API? ########## lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/LanceTableOperations.java: ########## @@ -69,6 +67,7 @@ CreateTableResponse createTable( * @param tableProperties the properties of the table * @return the response of the create table operation */ + @SuppressWarnings("deprecation") CreateEmptyTableResponse createEmptyTable( Review Comment: I recalled that `createEmptyTable` has been replaced with `declareTable`, so will you plan to support it? ########## lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceNameSpaceOperations.java: ########## @@ -414,6 +407,60 @@ private <T> T[] buildChanges( return Stream.concat(setPropertiesStream, removePropertiesStream).toArray(arrayCreator); } + private static CreateMode parseCreateMode(String instance, String mode) { Review Comment: This one seems to be duplicated with `normalizeCreateMode`. Can you try to optimize it? ########## lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceTableOperations.java: ########## @@ -138,19 +141,26 @@ public Response createTable( @Produces("application/json") @Timed(name = "create-empty-table." + MetricNames.HTTP_PROCESS_DURATION, absolute = true) @ResponseMetered(name = "create-empty-table", absolute = true) + @SuppressWarnings("deprecation") public Response createEmptyTable( @PathParam("id") String tableId, @QueryParam("delimiter") @DefaultValue(NAMESPACE_DELIMITER_DEFAULT) String delimiter, - CreateEmptyTableRequest request, + Map<String, Object> requestBody, Review Comment: Why is the value type of `requestBody` `Object`? ########## lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/JsonArrowSchemaConverter.java: ########## @@ -0,0 +1,167 @@ +/* + * 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.gravitino.lance.common.ops.gravitino; + +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; +import org.apache.arrow.vector.types.FloatingPointPrecision; +import org.apache.arrow.vector.types.pojo.ArrowType; +import org.apache.arrow.vector.types.pojo.Field; +import org.apache.arrow.vector.types.pojo.Schema; +import org.lance.namespace.model.JsonArrowDataType; +import org.lance.namespace.model.JsonArrowField; +import org.lance.namespace.model.JsonArrowSchema; + +/** Converts Arrow schema to Lance Namespace JsonArrowSchema model. */ +class JsonArrowSchemaConverter { Review Comment: Is this class directly copied from Lance repo? ########## docs/lance-rest-service.md: ########## @@ -273,16 +273,16 @@ curl -X POST http://localhost:9101/lance/v1/table/lance_catalog%24schema%24table -d '{ "id": ["lance_catalog", "schema", "table01"], "location": "/tmp/lance_catalog/schema/table01", - "mode": "CREATE" + "mode": "create" }' # Create a new empty table curl -X POST http://localhost:9101/lance/v1/table/lance_catalog%24schema%24table02/create-empty \ -H 'Content-Type: application/json' \ + -H "x-lance-table-properties: {\"description\":\"This is table02\"}" \ Review Comment: Is the header `x-lance-table-properties` optional or required? -- 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]
