yihua commented on code in PR #10718:
URL: https://github.com/apache/hudi/pull/10718#discussion_r1508535072
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieCompactor.java:
##########
@@ -271,9 +262,9 @@ private int doCompact(JavaSparkContext jsc) throws
Exception {
}
}
- private Option<String> doSchedule(JavaSparkContext jsc) {
+ private Option<String> doSchedule(JavaSparkContext jsc) throws Exception {
try (SparkRDDWriteClient client =
- UtilHelpers.createHoodieClient(jsc, cfg.basePath, "",
cfg.parallelism, Option.of(cfg.strategyClassName), props)) {
+ UtilHelpers.createHoodieClient(jsc, cfg.basePath, getSchema(),
cfg.parallelism, Option.of(cfg.strategyClassName), props)) {
Review Comment:
As discussed offline, a test implementation of `HoodieAvroWriteSupport`
needs to be added, that does schema parsing to reproduce the failure. This is
related to the custom write support as a Hudi extension in XTable:
https://github.com/apache/incubator-xtable/blob/main/hudi-support/extensions/README.md.
##########
hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieCompactor.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.hudi.utilities;
+
+import org.apache.hudi.common.model.HoodieAvroPayload;
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.testutils.HoodieTestUtils;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.utilities.testutils.UtilitiesTestBase;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.mockito.Mockito;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Properties;
+
+import static
org.apache.hudi.common.testutils.HoodieTestDataGenerator.TRIP_EXAMPLE_SCHEMA;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class TestHoodieCompactor extends UtilitiesTestBase {
+ @TempDir
+ protected static java.nio.file.Path sharedTempDir;
+ protected static Configuration hadoopConf =
HoodieTestUtils.getDefaultHadoopConf();
+ private final FileSystem fs;
+ private final JavaSparkContext jsc;
+ private String base;
+ private String schemaFile;
+
+ public TestHoodieCompactor() throws IOException {
+ fs = FileSystem.getLocal(hadoopConf);
+ jsc = UtilHelpers.buildSparkContext(TestHoodieCompactor.class + "-hoodie",
"local[4]");
+ basePath = sharedTempDir.toUri().toString();
+ }
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ base = basePath + "base";
+ schemaFile = basePath + "schema.avro";
+
+ HoodieWriteConfig writeConfig = getWriteConfig(base);
+ Properties metaClientProps = HoodieTableMetaClient.withPropertyBuilder()
+ .setTableType(HoodieTableType.MERGE_ON_READ)
+ .setPayloadClass(HoodieAvroPayload.class)
+ .fromProperties(writeConfig.getProps())
+ .build();
+ HoodieTableMetaClient.initTableAndGetMetaClient(
+ jsc.hadoopConfiguration(), base, metaClientProps);
+ }
+
+ public static HoodieWriteConfig getWriteConfig(String basePath) {
+ return HoodieWriteConfig.newBuilder()
+ .forTable("compactor_test_table")
+ .withPath(basePath)
+ .withSchema(TRIP_EXAMPLE_SCHEMA)
+ .build();
+ }
+
+ public static void writeSchema(FileSystem fs, String path, String schema)
throws IOException {
Review Comment:
Got it. Then create a new util method `writeStringToFile` in `FileIOUtils`
with different arguments and use it here?
--
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]