This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ad7aa7b21 [hive] Decode escaped input paths before planning splits 
(#11362)
2ad7aa7b21 is described below

commit 2ad7aa7b21d288a56f20364d415ee520542ad073
Author: YueZhang <[email protected]>
AuthorDate: Mon Nov 23 02:38:45 2026 -0500

    [hive] Decode escaped input paths before planning splits (#11362)
---
 .../paimon/hive/utils/HiveSplitGenerator.java      |  4 +-
 .../apache/paimon/hive/HiveSplitGeneratorTest.java | 57 ++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git 
a/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/utils/HiveSplitGenerator.java
 
b/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/utils/HiveSplitGenerator.java
index 04d5aec799..c3d7780469 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/utils/HiveSplitGenerator.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/main/java/org/apache/paimon/hive/utils/HiveSplitGenerator.java
@@ -38,6 +38,7 @@ import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.mapred.InputSplit;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -139,7 +140,8 @@ public class HiveSplitGenerator {
             FileStoreTable table, JobConf jobConf, String locations) {
         List<String> belonging = new ArrayList<>();
         String foreign = null;
-        for (String location : locations.split(",")) {
+        for (String escapedLocation : StringUtils.split(locations)) {
+            String location = StringUtils.unEscapeString(escapedLocation);
             // Hive create dummy file for empty table or partition. If this 
location doesn't
             // belong to this table, nothing to do.
             if (location.startsWith(table.location().toString())) {
diff --git 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveSplitGeneratorTest.java
 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveSplitGeneratorTest.java
index 7c6e56aaba..ced783d06b 100644
--- 
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveSplitGeneratorTest.java
+++ 
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveSplitGeneratorTest.java
@@ -24,12 +24,15 @@ import org.apache.paimon.data.BinaryRow;
 import org.apache.paimon.data.BinaryRowWriter;
 import org.apache.paimon.data.BinaryString;
 import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
 import org.apache.paimon.fs.FileIO;
 import org.apache.paimon.fs.Path;
+import org.apache.paimon.hive.mapred.PaimonInputSplit;
 import org.apache.paimon.hive.utils.HiveSplitGenerator;
 import org.apache.paimon.io.DataFileMeta;
 import org.apache.paimon.manifest.FileSource;
 import org.apache.paimon.options.Options;
+import org.apache.paimon.reader.RecordReaderIterator;
 import org.apache.paimon.schema.FileSystemSchemaManager;
 import org.apache.paimon.schema.SchemaManager;
 import org.apache.paimon.schema.TableSchema;
@@ -181,6 +184,60 @@ public class HiveSplitGeneratorTest {
         assertThat(splits).hasSize(1);
     }
 
+    @Test
+    public void testGenerateSplitsForCommaPartitionValue() throws Exception {
+        Options options = new Options();
+        options.set(CoreOptions.FILE_FORMAT, CoreOptions.FILE_FORMAT_AVRO);
+        options.set(CoreOptions.BUCKET, -1);
+        TableSchema schema =
+                new TableSchema(
+                        0,
+                        SCHEMA_FIELDS,
+                        2,
+                        Collections.singletonList("pt"),
+                        Collections.emptyList(),
+                        options.toMap(),
+                        "");
+        FileStoreTable table = createFileStoreTable(schema);
+        BatchWriteBuilder writeBuilder = table.newBatchWriteBuilder();
+        try (BatchTableWrite write = writeBuilder.newWrite();
+                BatchTableCommit commit = writeBuilder.newCommit()) {
+            write.write(
+                    GenericRow.of(1, BinaryString.fromString("a"), 
BinaryString.fromString("a,b")));
+            write.write(
+                    GenericRow.of(
+                            2, BinaryString.fromString("b"), 
BinaryString.fromString("plain")));
+            commit.commit(write.prepareCommit());
+        }
+        org.apache.hadoop.fs.Path commaPath = new 
org.apache.hadoop.fs.Path(tablePath + "/pt=a,b");
+        org.apache.hadoop.fs.Path plainPath =
+                new org.apache.hadoop.fs.Path(tablePath + "/pt=plain");
+        assertThat(fileIO.exists(new Path(commaPath.toString()))).isTrue();
+
+        JobConf jobConf = new JobConf();
+        org.apache.hadoop.mapred.FileInputFormat.setInputPaths(jobConf, 
commaPath, plainPath);
+        assertThat(jobConf.get(FileInputFormat.INPUT_DIR)).contains("\\,");
+        
assertThat(org.apache.hadoop.mapred.FileInputFormat.getInputPaths(jobConf))
+                .containsExactly(commaPath, plainPath);
+        InputSplit[] splits = HiveSplitGenerator.generateSplits(table, 
jobConf, 1);
+        assertThat(splits).hasSize(2);
+        assertThat(Arrays.stream(splits).map(split -> ((PaimonInputSplit) 
split).getPath()))
+                .containsExactlyInAnyOrder(commaPath, plainPath);
+        List<Integer> ids = new ArrayList<>();
+        for (InputSplit split : splits) {
+            try (RecordReaderIterator<InternalRow> reader =
+                    new RecordReaderIterator<>(
+                            table.newReadBuilder()
+                                    .newRead()
+                                    .createReader(((PaimonInputSplit) 
split).split()))) {
+                while (reader.hasNext()) {
+                    ids.add(reader.next().getInt(0));
+                }
+            }
+        }
+        assertThat(ids).containsExactlyInAnyOrder(1, 2);
+    }
+
     @Test
     public void testForeignLocation() throws Exception {
         FileStoreTable table = createPartitionedTableWithTwoPartitions();

Reply via email to