deniskuzZ commented on code in PR #6685:
URL: https://github.com/apache/hive/pull/6685#discussion_r4468522561


##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergMerge.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.mr.hive;
+
+import java.util.List;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.mr.TestHelper;
+import org.apache.iceberg.mr.hive.test.utils.HiveIcebergTestUtils;
+import org.apache.iceberg.relocated.com.google.common.base.Throwables;
+import org.apache.iceberg.types.Types;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.types.Types.NestedField.optional;
+
+/**
+ * Tests Merge Related SQL features.
+ */
+public class TestHiveIcebergMerge extends 
HiveIcebergStorageHandlerWithEngineBase {
+
+  static final Schema SCHEMA = new Schema(
+      optional(1, "a", Types.IntegerType.get()),
+      optional(2, "b", Types.IntegerType.get(), "This is first name")
+  );
+
+  static final List<Record> TGT_RECORDS = 
TestHelper.RecordsBuilder.newInstance(SCHEMA)
+      .add(0, 1)
+      .add(9, 9)
+      .build();
+
+  @Test
+  public void testMergeIntoOnClauseColumnsNoAssignedTables() {
+    testTables.createTable(shell, "tgt", SCHEMA,
+        PartitionSpec.unpartitioned(), fileFormat, TGT_RECORDS, formatVersion);
+    shell.executeStatement("alter table default.tgt set 
tblproperties('write.merge.mode'='copy-on-write')");
+    shell.executeStatement("drop table if exists default.src");
+    shell.executeStatement("create table default.src (a int, b int) stored as 
orc");
+    shell.executeStatement("use default");
+    String sql = "MERGE INTO tgt using src on a= src.a when matched then 
update set b=10";
+    try {
+      shell.executeStatement(sql);
+      Assert.assertFalse(true); // place we should not touch

Review Comment:
   The AssertionError from assertFalse(true) is caught by the catch (Throwable) 
below. The test still fails, but on the instanceof SemanticException check, 
with a misleading message. Please use Assert.assertThrows(...) (JUnit 4.13.2 is 
available) and assert on the root cause.
   
   Since this is a parse-time check, a .q file under 
iceberg-handler/src/test/queries/negative would be cheaper than running the 
parameterized HiveIcebergStorageHandlerWithEngineBase matrix. Please also cover 
an unqualified source-only column on COW, and that MOR behavior is unchanged.



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


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

Reply via email to