codope commented on code in PR #8618:
URL: https://github.com/apache/hudi/pull/8618#discussion_r1196802185


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieBaseRelation.scala:
##########
@@ -483,9 +483,17 @@ abstract class HoodieBaseRelation(val sqlContext: 
SQLContext,
       if (extractPartitionValuesFromPartitionPath) {
         val tablePathWithoutScheme = 
CachingPath.getPathWithoutSchemeAndAuthority(metaClient.getBasePathV2)
         val partitionPathWithoutScheme = 
CachingPath.getPathWithoutSchemeAndAuthority(file.getPath.getParent)
-        val relativePath = new 
URI(tablePathWithoutScheme.toString).relativize(new 
URI(partitionPathWithoutScheme.toString)).toString
+        var relativePath = new 
URI(tablePathWithoutScheme.toString).relativize(new 
URI(partitionPathWithoutScheme.toString)).toString
         val hiveStylePartitioningEnabled = 
tableConfig.getHiveStylePartitioningEnable.toBoolean
         if (hiveStylePartitioningEnabled) {
+          val nEqualsSign = StringUtils.countMatches(relativePath, "=")
+          lazy val nSlashes = StringUtils.countMatches(relativePath,"/")
+          if (nEqualsSign == 1 && nSlashes > 0){
+            relativePath = relativePath.replace("/", "%2F")
+          } else if (nEqualsSign > 1 && nEqualsSign < nSlashes) {
+            relativePath = 
HoodieSparkUtils.splitHiveSlashPartitions(relativePath.
+              split("/"), nEqualsSign, "%2F", hive = true).mkString("/")

Review Comment:
   What if there are characters other than `=`?



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/bootstrap/translator/DecodedBootstrapPartitionPathTranslator.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.bootstrap.translator;
+
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.common.util.PartitionPathEncodeUtils;
+
+/**
+ * URI decodes the partition path
+ *
+ */
+public class DecodedBootstrapPartitionPathTranslator extends 
BootstrapPartitionPathTranslator {
+  public DecodedBootstrapPartitionPathTranslator(TypedProperties properties) {
+    super(properties);

Review Comment:
   Do we need `properties`?



##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/hudi/HoodieSparkUtils.scala:
##########
@@ -272,4 +278,27 @@ object HoodieSparkUtils extends SparkAdapterSupport with 
SparkVersionsSupport wi
       validatePartitionValues = shouldValidatePartitionCols
     ).toSeq(partitionSchema)
   }
+
+  def splitHiveSlashPartitions(partitionFragments: Array[String], nPartitions: 
Int, sep: String, hive: Boolean): Array[String] = {

Review Comment:
   preferably move it to an appropriate util in hudi-common. There is nothin 
spark specific in this method.



##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieBaseRelation.scala:
##########
@@ -483,9 +483,17 @@ abstract class HoodieBaseRelation(val sqlContext: 
SQLContext,
       if (extractPartitionValuesFromPartitionPath) {
         val tablePathWithoutScheme = 
CachingPath.getPathWithoutSchemeAndAuthority(metaClient.getBasePathV2)
         val partitionPathWithoutScheme = 
CachingPath.getPathWithoutSchemeAndAuthority(file.getPath.getParent)
-        val relativePath = new 
URI(tablePathWithoutScheme.toString).relativize(new 
URI(partitionPathWithoutScheme.toString)).toString
+        var relativePath = new 
URI(tablePathWithoutScheme.toString).relativize(new 
URI(partitionPathWithoutScheme.toString)).toString
         val hiveStylePartitioningEnabled = 
tableConfig.getHiveStylePartitioningEnable.toBoolean
         if (hiveStylePartitioningEnabled) {
+          val nEqualsSign = StringUtils.countMatches(relativePath, "=")
+          lazy val nSlashes = StringUtils.countMatches(relativePath,"/")
+          if (nEqualsSign == 1 && nSlashes > 0){

Review Comment:
   Why do we need this logic? It looks pretty hacky. I want to understand the 
purpose and see if there is a better solution.
   Also, it would be better to extract this logic to `PartitionPathEncodeUtils` 
and write a UT for this.



##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieBaseRelation.scala:
##########
@@ -238,7 +238,7 @@ abstract class HoodieBaseRelation(val sqlContext: 
SQLContext,
       case HoodieFileFormat.PARQUET =>
         // We're delegating to Spark to append partition values to every row 
only in cases
         // when these corresponding partition-values are not persisted w/in 
the data file itself
-        val parquetFileFormat = 
sparkAdapter.createHoodieParquetFileFormat(shouldExtractPartitionValuesFromPartitionPath).get
+        val parquetFileFormat = 
sparkAdapter.createHoodieParquetFileFormat(shouldExtractPartitionValuesFromPartitionPath,
 decodeFilePath = true).get

Review Comment:
   Can you confirm when this argument `decodeFilePath` was not present, the 
default behavior was to decode the path? Let;s ensure that the default behavior 
does not change.



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