codope commented on code in PR #9761: URL: https://github.com/apache/hudi/pull/9761#discussion_r1367634339
########## hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieMultiFileFormatRelation.scala: ########## @@ -0,0 +1,232 @@ +/* + * 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 + +import org.apache.hadoop.conf.Configuration +import org.apache.hadoop.fs.Path +import org.apache.hudi.HoodieBaseRelation.projectReader +import org.apache.hudi.HoodieConversionUtils.toScalaOption +import org.apache.hudi.HoodieMultiFileFormatRelation.{createPartitionedFile, inferFileFormat} +import org.apache.hudi.common.fs.FSUtils +import org.apache.hudi.common.model.{FileSlice, HoodieFileFormat, HoodieLogFile} +import org.apache.hudi.common.table.HoodieTableMetaClient +import org.apache.spark.rdd.RDD +import org.apache.spark.sql.SQLContext +import org.apache.spark.sql.catalyst.InternalRow +import org.apache.spark.sql.catalyst.expressions.Expression +import org.apache.spark.sql.execution.datasources.{FilePartition, PartitionedFile} +import org.apache.spark.sql.sources.Filter +import org.apache.spark.sql.types.StructType + +import scala.jdk.CollectionConverters.asScalaIteratorConverter + +/** + * Base split for all Hoodie multi-file format relations. + */ +case class HoodieMultiFileFormatSplit(baseFile: Option[PartitionedFile], + logFiles: List[HoodieLogFile]) extends HoodieFileSplit + +/** + * Base relation to handle table with multiple base file formats. + */ +abstract class BaseHoodieMultiFileFormatRelation(override val sqlContext: SQLContext, + override val metaClient: HoodieTableMetaClient, Review Comment: Yes, we are using the file extension to figure out the base file format. However, the usual `BaseFileOnlyRelation` converts to `HadoopFsRelation`, which cannot be done for multiple file formats because the file format is not known at the time creating the relation. It is only known when we the relation is collecting file splits. Hence, a separate relation to handle multiple file formats. I will add this in scaladoc of the class. Plus, I think a separate relation keeps the code clean and more maintainable. -- 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]
