nsivabalan commented on code in PR #8885:
URL: https://github.com/apache/hudi/pull/8885#discussion_r1224997915


##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/spark/sql/execution/datasources/HoodieSparkPartitionedFileUtils.scala:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.spark.sql.execution.datasources
+
+import org.apache.hadoop.fs.Path
+import org.apache.spark.sql.catalyst.InternalRow
+
+/**
+ * Utils on Spark [[PartitionedFile]] to adapt to type changes.
+ * Before Spark 3.4.0,
+ * ```
+ * case class PartitionedFile(
+ *   partitionValues: InternalRow,
+ *   filePath: String,
+ *   start: Long,
+ *   @transient locations: Array[String] = Array.empty)
+ * ```,
+ * Since Spark 3.4.0, the filePath is switch to [[SparkPath]] for type safety:
+ * ```
+ * case class PartitionedFile(
+ *   partitionValues: InternalRow,
+ *   filePath: SparkPath,
+ *   start: Long,
+ *   length: Long,
+ *   @transient locations: Array[String] = Array.empty,
+ *   modificationTime: Long = 0L,
+ *   fileSize: Long = 0L)
+ * ```
+ */
+trait HoodieSparkPartitionedFileUtils extends Serializable {
+  /**
+   * Gets the Hadoop [[Path]] instance from Spark [[PartitionedFile]] instance.
+   *
+   * @param partitionedFile Spark [[PartitionedFile]] instance.
+   * @return Hadoop [[Path]] instance.
+   */
+  def getPathFromPartitionedFile(partitionedFile: PartitionedFile): Path

Review Comment:
   may I know why do we need two methods, one to fetch string version and 
another to fetch Path. we can return string and the caller can construct the 
Path if need be? 



##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/BaseFileOnlyRelation.scala:
##########
@@ -66,17 +66,21 @@ case class BaseFileOnlyRelation(override val sqlContext: 
SQLContext,
   // NOTE: This override has to mirror semantic of whenever this Relation is 
converted into [[HadoopFsRelation]],
   //       which is currently done for all cases, except when Schema Evolution 
is enabled
   override protected val shouldExtractPartitionValuesFromPartitionPath: 
Boolean =
-    internalSchemaOpt.isEmpty
+  internalSchemaOpt.isEmpty
 
   override lazy val mandatoryFields: Seq[String] = Seq.empty
 
+  // Before Spark 3.4.0: PartitioningAwareFileIndex.BASE_PATH_PARAM
+  // Since Spark 3.4.0: FileIndexOptions.BASE_PATH_PARAM
+  val BASE_PATH_PARAM = "basePath"
+
   override def updatePrunedDataSchema(prunedSchema: StructType): Relation =
     this.copy(prunedDataSchema = Some(prunedSchema))
 
   override def imbueConfigs(sqlContext: SQLContext): Unit = {
     super.imbueConfigs(sqlContext)
     // TODO Issue with setting this to true in spark 332
-    if (!HoodieSparkUtils.gteqSpark3_3_2) {
+    if (HoodieSparkUtils.gteqSpark3_4 || !HoodieSparkUtils.gteqSpark3_3_2) {

Review Comment:
   should we introduce "HoodieSparkUtils.ltSpark3_3_2" instead of 
"!HoodieSparkUtils.gteqSpark3_3_2"



##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieBaseRelation.scala:
##########
@@ -733,8 +734,8 @@ object HoodieBaseRelation extends SparkAdapterSupport {
 
     partitionedFile => {
       val hadoopConf = hadoopConfBroadcast.value.get()
-      val reader = new HoodieAvroHFileReader(hadoopConf, new 
Path(partitionedFile.filePath),
-        new CacheConfig(hadoopConf))
+      val filePath = 
sparkAdapter.getSparkPartitionedFileUtils.getPathFromPartitionedFile(partitionedFile)

Review Comment:
   sg



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

Reply via email to