You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/06/25 01:42:27 UTC

[GitHub] [iceberg] karuppayya opened a new pull request #2736: Add schema validation before table import

karuppayya opened a new pull request #2736:
URL: https://github.com/apache/iceberg/pull/2736


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] flyrain commented on a change in pull request #2736: Add schema validation before table import

Posted by GitBox <gi...@apache.org>.
flyrain commented on a change in pull request #2736:
URL: https://github.com/apache/iceberg/pull/2736#discussion_r664949558



##########
File path: spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java
##########
@@ -437,6 +442,11 @@ private static void importUnpartitionedSparkTable(SparkSession spark, TableIdent
     }
   }
 
+  static boolean validateSchema(StructType srcSchema, Schema tgtSchema) {

Review comment:
       Is it more suitable to put into `SparkSchemaUtil`?

##########
File path: spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java
##########
@@ -370,6 +372,9 @@ public static void importSparkTable(SparkSession spark, TableIdentifier sourceTa
     }
 
     try {
+      CatalogTable sourceCatalogTable = catalog.getTableMetadata(sourceTableIdent);
+      Preconditions.checkArgument(validateSchema(sourceCatalogTable.schema(), targetTable.schema()),
+          "The schemas of source table and target table dont match");

Review comment:
       dont -> don't

##########
File path: spark/src/test/java/org/apache/iceberg/spark/TestSparkTableUtil.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.spark;
+
+import java.util.List;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.apache.iceberg.types.Types;
+import org.apache.spark.sql.types.DataTypes;
+import org.apache.spark.sql.types.Metadata;
+import org.apache.spark.sql.types.StructField;
+import org.apache.spark.sql.types.StructField$;
+import org.apache.spark.sql.types.StructType;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.types.Types.NestedField.optional;
+
+public class TestSparkTableUtil {

Review comment:
       Some test cases are more suitable for the method `SparkSchemaUtil.convert` since the method `validateSchema` didn't do a lot except invoking `SparkSchemaUtil.convert()` and `StructType.equals()`.  




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] karuppayya commented on pull request #2736: Add schema validation before table import

Posted by GitBox <gi...@apache.org>.
karuppayya commented on pull request #2736:
URL: https://github.com/apache/iceberg/pull/2736#issuecomment-889482340


   This PR requires more changes, closing it for now. 


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] karuppayya commented on pull request #2736: Add schema validation before table import

Posted by GitBox <gi...@apache.org>.
karuppayya commented on pull request #2736:
URL: https://github.com/apache/iceberg/pull/2736#issuecomment-868126185


   cc: @RussellSpitzer @aokolnychyi @flyrain @kbendick 


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] karuppayya closed pull request #2736: Add schema validation before table import

Posted by GitBox <gi...@apache.org>.
karuppayya closed pull request #2736:
URL: https://github.com/apache/iceberg/pull/2736


   


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] kbendick commented on a change in pull request #2736: Add schema validation before table import

Posted by GitBox <gi...@apache.org>.
kbendick commented on a change in pull request #2736:
URL: https://github.com/apache/iceberg/pull/2736#discussion_r670897796



##########
File path: spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java
##########
@@ -437,6 +442,11 @@ private static void importUnpartitionedSparkTable(SparkSession spark, TableIdent
     }
   }
 
+  static boolean validateSchema(StructType srcSchema, Schema tgtSchema) {
+    StructType convertSchem = SparkSchemaUtil.convert(tgtSchema);

Review comment:
       Nit: `convertSchema` - missing last `a` in variable name.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org