pvary commented on code in PR #14435: URL: https://github.com/apache/iceberg/pull/14435#discussion_r2665229996
########## spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/actions/TestSparkParquetFileMergeRunner.java: ########## @@ -0,0 +1,223 @@ +/* + * 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.actions; + +import static org.apache.iceberg.types.Types.NestedField.optional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.util.Collections; +import java.util.Set; +import org.apache.hadoop.conf.Configuration; +import org.apache.iceberg.DataFile; +import org.apache.iceberg.DeleteFile; +import org.apache.iceberg.FileFormat; +import org.apache.iceberg.FileScanTask; +import org.apache.iceberg.Schema; +import org.apache.iceberg.Table; +import org.apache.iceberg.actions.RewriteFileGroup; +import org.apache.iceberg.hadoop.HadoopTables; +import org.apache.iceberg.relocated.com.google.common.collect.Lists; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.apache.iceberg.spark.TestBase; +import org.apache.iceberg.types.Types; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +public class TestSparkParquetFileMergeRunner extends TestBase { + + private static final HadoopTables TABLES = new HadoopTables(new Configuration()); + private static final Schema SCHEMA = + new Schema( + optional(1, "c1", Types.IntegerType.get()), + optional(2, "c2", Types.StringType.get()), + optional(3, "c3", Types.StringType.get())); + + @TempDir private File tableDir; + private String tableLocation; + + @BeforeEach + public void setupTableLocation() { + this.tableLocation = tableDir.toURI().toString(); + } + + @Test + public void testDescriptionReturnsParquetMerge() { + Table table = TABLES.create(SCHEMA, tableLocation); + SparkParquetFileMergeRunner runner = new SparkParquetFileMergeRunner(spark, table); + + assertThat(runner.description()).isEqualTo("PARQUET-MERGE"); + } + + @Test + public void testInheritsFromSparkBinPackFileRewriteRunner() { + Table table = TABLES.create(SCHEMA, tableLocation); + SparkParquetFileMergeRunner runner = new SparkParquetFileMergeRunner(spark, table); + + // Verify inheritance + assertThat(runner).isInstanceOf(SparkBinPackFileRewriteRunner.class); + } + + @Test + public void testValidOptionsInheritedFromParent() { + Table table = TABLES.create(SCHEMA, tableLocation); + SparkParquetFileMergeRunner runner = new SparkParquetFileMergeRunner(spark, table); + + // Should inherit validOptions from parent + Set<String> validOptions = runner.validOptions(); + assertThat(validOptions).isNotNull(); + } + + @Test + public void testInitMethodInheritedFromParent() { + Table table = TABLES.create(SCHEMA, tableLocation); + SparkParquetFileMergeRunner runner = new SparkParquetFileMergeRunner(spark, table); + + // Should not throw exception when init is called + runner.init(Collections.emptyMap()); + } Review Comment: Do we need these tests? Do we have similar tests for other Runners? -- 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]
