rdblue commented on code in PR #10678:
URL: https://github.com/apache/iceberg/pull/10678#discussion_r1723721641


##########
core/src/test/java/org/apache/iceberg/TestPartitionSpecBuilderCaseSensitivity.java:
##########
@@ -0,0 +1,993 @@
+/*
+ * 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;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+import static org.assertj.core.api.Assertions.assertThat;
+import static 
org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.iceberg.types.Types;
+import org.apache.iceberg.types.Types.NestedField;
+import org.apache.iceberg.types.Types.StructType;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+public class TestPartitionSpecBuilderCaseSensitivity {
+
+  private static final int V2_FORMAT_VERSION = 2;
+  private static final Schema SCHEMA_CASE_INSENSITIVE =
+      new Schema(
+          required(1, "id", Types.IntegerType.get()),
+          required(2, "data", Types.StringType.get()),
+          required(3, "category", Types.StringType.get()),
+          required(4, "order_date", Types.DateType.get()),
+          required(5, "order_time", Types.TimestampType.withoutZone()),
+          required(6, "ship_date", Types.DateType.get()),
+          required(7, "ship_time", Types.TimestampType.withoutZone()));
+
+  private static final Schema SCHEMA_CASE_SENSITIVE =
+      new Schema(
+          required(1, "id", Types.IntegerType.get()),
+          required(2, "data", Types.StringType.get()),
+          required(3, "DATA", Types.StringType.get()),
+          required(4, "order_date", Types.DateType.get()),
+          required(5, "ORDER_DATE", Types.DateType.get()),
+          required(6, "order_time", Types.TimestampType.withoutZone()),
+          required(7, "ORDER_TIME", Types.TimestampType.withoutZone()));
+
+  @TempDir private Path temp;
+  private File tableDir = null;
+
+  @BeforeEach
+  public void setupTableDir() throws IOException {
+    this.tableDir = Files.createTempDirectory(temp, "junit").toFile();
+  }
+
+  @AfterEach
+  public void cleanupTables() {
+    TestTables.clearTables();
+  }
+
+  @Test
+  public void testPartitionTypeWithColumnNamesThatDifferOnlyInLetterCase() {
+    Schema schema =
+        new Schema(
+            required(1, "id", Types.IntegerType.get()),
+            required(2, "data", Types.StringType.get()),
+            required(3, "DATA", Types.StringType.get()),
+            required(4, "order_date", Types.DateType.get()));
+    PartitionSpec spec = 
PartitionSpec.builderFor(schema).identity("data").identity("DATA").build();
+    TestTables.TestTable table =
+        TestTables.create(tableDir, "test", schema, spec, V2_FORMAT_VERSION);
+
+    StructType expectedType =
+        StructType.of(
+            NestedField.optional(1000, "data", Types.StringType.get()),
+            NestedField.optional(1001, "DATA", Types.StringType.get()));
+    StructType actualType = Partitioning.partitionType(table);
+    assertThat(actualType).isEqualTo(expectedType);
+  }
+
+  @Test
+  public void testPartitionTypeWithIdentityTargetName() {
+    PartitionSpec spec =
+        PartitionSpec.builderFor(SCHEMA_CASE_INSENSITIVE).identity("data", 
"partition1").build();
+    TestTables.TestTable table =
+        TestTables.create(tableDir, "test", SCHEMA_CASE_INSENSITIVE, spec, 
V2_FORMAT_VERSION);
+
+    StructType expectedType =
+        StructType.of(NestedField.optional(1000, "partition1", 
Types.StringType.get()));
+    StructType actualType = Partitioning.partitionType(table);
+    assertThat(actualType).isEqualTo(expectedType);

Review Comment:
   @sl255051, what's the purpose of this test? It just tests the default 
behavior with one field and no conflicts?



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