luoyuxia commented on code in PR #1847:
URL: https://github.com/apache/fluss/pull/1847#discussion_r2514037538
##########
fluss-server/src/test/java/org/apache/fluss/server/coordinator/LakeTableManagerITCase.java:
##########
@@ -103,9 +103,7 @@ void testCreateAndGetTable() throws Exception {
lakeTablePath,
lakeTableDescriptor, false))
.get())
.cause()
- .isInstanceOf(LakeTableAlreadyExistException.class)
- .hasMessage(
- "The table %s already exists in paimon catalog, please
first drop the table in paimon catalog or use a new table name.",
- lakeTablePath);
+ .isInstanceOf(TableAlreadyExistException.class)
+ .hasMessage("Table %s already exists.", lakeTablePath);
Review Comment:
I think still we need a clear exception to tell user the table exists in
which catalog and guide users how to handle the exception.
##########
fluss-server/src/main/java/org/apache/fluss/server/coordinator/MetadataManager.java:
##########
@@ -400,7 +399,6 @@ private void preAlterTableProperties(
TableDescriptor newDescriptor,
List<TableChange> tableChanges,
LakeCatalog lakeCatalog,
- DataLakeFormat dataLakeFormat,
Review Comment:
we can also remove `dataLakeFormat` in `alterTableProperties`
##########
fluss-server/src/main/java/org/apache/fluss/server/coordinator/CoordinatorService.java:
##########
@@ -294,13 +292,7 @@ public CompletableFuture<CreateTableResponse>
createTable(CreateTableRequest req
tableDescriptor,
new
DefaultLakeCatalogContext(currentSession().getPrincipal()));
} catch (TableAlreadyExistException e) {
- throw new LakeTableAlreadyExistException(
- String.format(
- "The table %s already exists in %s catalog,
please "
- + "first drop the table in %s catalog
or use a new table name.",
- tablePath,
- lakeCatalogContainer.getDataLakeFormat(),
- lakeCatalogContainer.getDataLakeFormat()));
+ throw new LakeTableAlreadyExistException(e.getMessage(), e);
Review Comment:
why change this?
##########
fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/PaimonLakeCatalog.java:
##########
@@ -120,7 +123,19 @@ private void createTable(Identifier tablePath, Schema
schema)
// not ignore if table exists
paimonCatalog.createTable(tablePath, schema, false);
} catch (Catalog.TableAlreadyExistException e) {
- throw new TableAlreadyExistException("Table " + tablePath + "
already exists.");
+ try {
+ Table table = paimonCatalog.getTable(tablePath);
+ FileStoreTable fileStoreTable = (FileStoreTable) table;
+
validatePaimonSchemaCapability(fileStoreTable.schema().toSchema(), schema);
+ } catch (Catalog.TableNotExistException tableNotExistException) {
+ throw new RuntimeException(
Review Comment:
nit:
add comment
`// shouldn't happen in normal cases`
##########
fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/utils/PaimonSchemaValidation.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.fluss.lake.paimon.utils;
+
+import org.apache.fluss.config.ConfigOptions;
+import org.apache.fluss.exception.TableAlreadyExistException;
+
+import org.apache.paimon.CoreOptions;
+import org.apache.paimon.schema.Schema;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static
org.apache.fluss.lake.paimon.utils.PaimonConversions.FLUSS_CONF_PREFIX;
+
+/** Validator of Paimon table schema. */
+public class PaimonSchemaValidation {
+
+ public static void validatePaimonSchemaCapability(Schema existingSchema,
Schema newSchema) {
Review Comment:
Can just be use `existingSchema.equals(newSchema)` with some adjust to
options?
Then, I think we can remove PaimonSchemaValidation class
--
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]