rdblue commented on a change in pull request #1947:
URL: https://github.com/apache/iceberg/pull/1947#discussion_r559837388



##########
File path: 
spark3-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestMergeIntoTable.java
##########
@@ -0,0 +1,267 @@
+/*
+ * 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.extensions;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.TableProperties;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.spark.sql.Dataset;
+import org.apache.spark.sql.Row;
+import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.iceberg.TableProperties.DEFAULT_FILE_FORMAT;
+import static org.apache.iceberg.TableProperties.PARQUET_VECTORIZATION_ENABLED;
+
+public class TestMergeIntoTable extends SparkRowLevelOperationsTestBase {
+  private final String sourceName;
+  private final String targetName;
+
+  public TestMergeIntoTable(String catalogName, String implementation, 
Map<String, String> config,

Review comment:
       I don't think that there is a need to test this with both Hive and 
Hadoop catalogs or with all 3 formats, since the main thing that needs to be 
tested is conversion and Spark behavior. Also, this doesn't test partitioned 
tables at all. To fix those, I think this should customize parameters:
   
   ```java
     @Parameterized.Parameters(
         name = "catalogName = {0}, implementation = {1}, config = {2}, format 
= {3}, vectorized = {4}, partitioned = {5}")
     public static Object[][] parameters() {
       return new Object[][] {
           { "testhive", SparkCatalog.class.getName(),
               ImmutableMap.of(
                   "type", "hive",
                   "default-namespace", "default"
               ),
               "parquet",
               true,
               false
           },
           { "spark_catalog", SparkSessionCatalog.class.getName(),
               ImmutableMap.of(
                   "type", "hive",
                   "default-namespace", "default",
                   "clients", "1",
                   "parquet-enabled", "false",
                   "cache-enabled", "false" // Spark will delete tables using 
v1, leaving the cache out of sync
               ),
               "parquet",
               false,
               true
           }
       };
     }
   
     public TestMergeIntoTable(String catalogName, String implementation, 
Map<String, String> config,
                               String fileFormat, Boolean vectorized, Boolean 
partitioned) {
       super(catalogName, implementation, config, fileFormat, vectorized);
       this.partitioned = partitioned;
       this.sourceName = tableName("source");
       this.targetName = tableName("target");
     }
   ```
   
   I also added a `partitioned` boolean and moved all of the `createAndInit` 
calls into a `@Before`:
   
   ```java
     @Before
     public void createTables() {
       if (partitioned) {
         createAndInitPartitionedTargetTable(targetName);
       } else {
         createAndInitUnPartitionedTargetTable(targetName);
       }
       createAndInitSourceTable(sourceName);
     }
   ```
   
   With those changes, tests run faster and cover partitioned tables.




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to