zhangyue19921010 commented on code in PR #13365: URL: https://github.com/apache/hudi/pull/13365#discussion_r2138134779
########## hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/clustering/run/strategy/SparkStreamCopyClusteringExecutionStrategy.java: ########## @@ -0,0 +1,148 @@ +/* + * 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.client.clustering.run.strategy; + +import org.apache.hudi.avro.model.HoodieClusteringPlan; +import org.apache.hudi.client.WriteStatus; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.SerializableSchema; +import org.apache.hudi.common.data.HoodieData; +import org.apache.hudi.common.engine.HoodieEngineContext; +import org.apache.hudi.common.engine.TaskContextSupplier; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.ClusteringGroupInfo; +import org.apache.hudi.common.model.HoodieFileGroupId; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.config.HoodieWriteConfig; +import org.apache.hudi.data.HoodieJavaRDD; +import org.apache.hudi.io.HoodieCreateRewriteHandle; +import org.apache.hudi.io.SingleFileHandleRewriteFactory; +import org.apache.hudi.storage.StoragePath; +import org.apache.hudi.table.HoodieTable; +import org.apache.hudi.table.action.HoodieWriteMetadata; + +import org.apache.avro.Schema; +import org.apache.spark.api.java.JavaRDD; +import org.apache.spark.api.java.JavaSparkContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +import static org.apache.hudi.common.model.HoodieTableType.COPY_ON_WRITE; + +/** + * Clustering strategy to submit single spark jobs using streaming copy + * PAY ATTENTION!!! + * IN THIS STRATEGY + * 1. Only support clustering for cow table. + * 2. Sort function is not supported yet. + * 3. Each clustering group only has one task to write. + */ +public class SparkStreamCopyClusteringExecutionStrategy<T> extends SparkSortAndSizeExecutionStrategy<T> { Review Comment: After careful consideration, I believe we still need to extend the SparkSortAndSizeExecutionStrategy method. The reasons are as follows: Currently, due to the need to maintain compatibility with various existing data types (e.g., legacy array types), we require a pre-check named supportBinaryStreamCopy. In cases where streaming copy cannot be used, we need to automatically fall back to SparkSortAndSizeExecutionStrategy to avoid task failures while remaining transparent to users. Regarding the sorting issue, it is true that the new strategy only supports file-level sorting and cannot achieve record-level sorting. -- 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]
