nastra commented on code in PR #12706:
URL: https://github.com/apache/iceberg/pull/12706#discussion_r2026334400


##########
spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestReplaceWhere.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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 static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
+import org.apache.spark.sql.AnalysisException;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.TestTemplate;
+
+public class TestReplaceWhere extends ExtensionsTestBase {
+
+  @AfterEach
+  public void cleanup() {
+    sql("DROP TABLE IF EXISTS %s", tableName);
+  }
+
+  @TestTemplate
+  public void testCaseSensitivity() {
+
+    sql("CREATE TABLE %s (id INT, dep STRING) USING iceberg PARTITIONED BY 
(dep)", tableName);
+    sql("INSERT INTO %s (id, dep) VALUES (1, 'hr')", tableName);
+    sql("INSERT INTO %s (id, dep) VALUES (2, 'support')", tableName);
+
+    sql("SET spark.sql.caseSensitive = false");
+    sql("INSERT INTO %s REPLACE WHERE DEP = 'hr' VALUES (3, 'hr')", tableName);
+    ImmutableList<Object[]> expectedRows =
+        ImmutableList.of(
+            row(2, "support"), row(3, "hr") // insert
+            );
+    assertEquals(

Review Comment:
   this can be simplified to 
   ```
   @TestTemplate
     public void testReplaceWhereCaseSensitivity() {
       sql("CREATE TABLE %s (id INT, dep STRING) USING iceberg PARTITIONED BY 
(dep)", tableName);
       sql("INSERT INTO %s (id, dep) VALUES (1, 'hr')", tableName);
       sql("INSERT INTO %s (id, dep) VALUES (2, 'support')", tableName);
   
       sql("SET spark.sql.caseSensitive = false");
       sql("INSERT INTO %s REPLACE WHERE DEP = 'hr' VALUES (2, 'hr')", 
tableName);
       assertThat(sql("SELECT ID, DEP FROM %s ORDER BY ID", tableName))
           .containsExactly(row(2, "hr"), row(3, "support"));
   
       sql("SET spark.sql.caseSensitive = true");
       String errorMsg = "A column or function parameter with name `DEP` cannot 
be resolved";
       assertThatThrownBy(
               () -> sql("INSERT INTO %s REPLACE WHERE DEP = 'hr' VALUES (2, 
'hr')", tableName))
           .isInstanceOf(AnalysisException.class)
           .hasMessageContaining(errorMsg);
       assertThatThrownBy(() -> sql("SELECT DEP FROM %s ORDER BY ID", 
tableName))
           .isInstanceOf(AnalysisException.class)
           .hasMessageContaining(errorMsg);
   
       sql("INSERT INTO %s REPLACE WHERE dep = 'hr' VALUES (2, 'hr')", 
tableName);
       assertThat(sql("SELECT id, dep FROM %s ORDER BY id", tableName))
           .containsExactly(row(2, "hr"), row(3, "support"));
     }
   ```



-- 
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-unsubscr...@iceberg.apache.org

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


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

Reply via email to