Repository navigation
[python] Encode format table partition paths like Java - #11018
Draft
plusplusjiajia wants to merge 1 commit into
Draft
plusplusjiajia wants to merge 1 commit into
plusplusjiajia wants to merge 1 commit into
Conversation
plusplusjiajia
force-pushed
the
fix/python-format-table-partition-paths
branch
3 times, most recently
from
November 8, 2026 14:16
921404e to
03a0223
Compare
plusplusjiajia
force-pushed
the
fix/python-format-table-partition-paths
branch
6 times, most recently
from
November 15, 2026 12:50
25b8f03 to
3cbe56f
Compare
2 tasks done
plusplusjiajia
force-pushed
the
fix/python-format-table-partition-paths
branch
2 times, most recently
from
November 15, 2026 13:54
2eb8da5 to
fd97991
Compare
plusplusjiajia
force-pushed
the
fix/python-format-table-partition-paths
branch
2 times, most recently
from
November 16, 2026 01:39
f89466a to
5c9e1ae
Compare
Contributor
|
Thanks for looking into #11164. I tested a three-row Parquet format table using the JDK 11 and JDK 21 directory names for the same FLOAT value. A full scan reads all three rows on master. On |
plusplusjiajia
force-pushed
the
fix/python-format-table-partition-paths
branch
11 times, most recently
from
November 24, 2026 09:26
ed165c8 to
2842b36
Compare
This was referenced Nov 24, 2026
PyPaimon's format table writer stopped the partition path at the first
null value, did not escape keys or values, and formatted some values
with Python's str(), so for example a value 'a/b' created two directory
levels and a null value put the file at a shorter path. Java readers
read such files with wrong partition values, and PyPaimon read Java
paths without unescaping them.
As in Java FormatTableFileWriter and PartitionPathUtils, the writer now
formats values like Java's partition computer, escapes keys and values,
writes null values as the default partition name, and rejects values
that a value-only layout would hide. As in Java FormatTableWrite,
partition columns are left out of the data files. CSV and JSON files
of a table whose columns are all partition columns keep them, since a
file without columns loses its rows, and the other formats refuse such
a table. Those files store null for a blank value, which names the
default partition, so a read returns what a partition filter finds.
The reader unescapes keys and values, reads the default partition name as null and skips
directories that are not partition directories, as Java does; older
files that contain partition columns still read their own values.
Equality partition filters now compare typed values, so they match the
new directory names, and partition columns read with the table's types
whether or not a file contains them. A static overwrite compares
directory names, so a spec such as 'true', '1.0' or the default
partition name clears the partition written for True, 1.00 or a null or
blank value, NaN clears the NaN partition, and 0.0 does not clear -0.0.
A static overwrite or partition filter whose value does not convert to
the partition type, such as a DECIMAL overflow, is refused instead of
selecting the null partition.
The value formatting is shared with the path factory of normal tables.
Since the files leave the partition columns out, a read takes the
partition values from the directory names, as filters and overwrites
do for every table. The writer refuses a value whose name reads back
as another value, such as non-UTF-8 BINARY, a local time in a DST
overlap, or a value equal to the default partition name, which names
the null partition; a static overwrite value is checked the same way,
since it would select the other value's directory, and a typed static
value takes the partition type's form, as rows do, so Decimal('1.0')
selects the directory 1.00 of a DECIMAL(4, 2) partition. The writer checks
every partition of the input before an overwrite deletes any file, so
a rejected value does not clear the partitions that precede it.
A row whose only column in a CSV file is null is an empty line, so CSV
reads keep empty lines unless csv.skip-empty-lines is set, as Java
does. CSV null handling is otherwise unchanged; a null STRING still
reads back as an empty string, as before, until the CSV writer and
reader share Java's null representation. CSV and JSON files infer
their column types, so a column of only nulls infers the null type;
their data columns are read with the declared types, which lets such
files be read together with the others.
Tables written by earlier PyPaimon versions keep working. Those
versions named directories with str() of the values, without escaping,
stopped the path at the first null value and kept the partition
columns in the files, so a file that has partition columns carries its
own values. Reads take those values; a directory that only an earlier
version writes, such as pt=a=b for 'a=b', is read, though Java skips
it. A partition filter matches a directory by its escaped or its
earlier unescaped name, keeps the rows of files with partition columns
by their own values, and also reads the files that earlier versions
left above the partition depth for null values. An overwrite deletes
only the partition's files: in the partition's directory, files
without partition columns and, when the name was escaped and so may be
an earlier name of another value, such as pt=a%3Ab for 'a%3Ab', files
whose partition columns hold only the partition's values; and at the
earlier version's path of the partition, such as pt=True, files whose
partition columns hold only its values. Subdirectories, such as the
earlier pt=x/y, are left alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plusplusjiajia
force-pushed
the
fix/python-format-table-partition-paths
branch
from
November 27, 2026 11:00
2842b36 to
3fed644
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
PyPaimon's format table did not name partition directories as Java does: values were not escaped (
x/ybecame two levels), null cut the path short instead of using__DEFAULT_PARTITION__, some values were formatted withstr(), and escaped directories were read without unescaping.As in Java
PartitionPathUtils,FormatTableFileWriterandFormatTableWrite:overwrite({'pt': 'true'})clears the partition ofTrue, and0.0does not clear-0.0. A value that does not convert to the partition type is refused instead of selecting the null partition.Compatibility
str()and kept partition columns in the files, need no migration: reads, filters and overwrites still find their files. Earlier TEXT files keep no partition columns, so an earlier TEXT directory with an escape, such aspt=a%3Ab, reads as'a:b', as in Java.2.68873286E11and2.6887329E11([Bug] [python] FLOAT and DOUBLE partition names differ between PyPaimon and Java on JDK 8/11/17 #11164), and Java 11 rejects the Java 19+ name. PyPaimon reads both as one partition and, as before, writes the exact value, which every Java reads. A Java filter on0.1does not findpt=0.10000000149011612.#11007 (CSV nulls) depends on this PR and is merged after it. #11008 also changes
file_store_path_factory.py; #11173 fixes the Java side of value-only default partition names.Tests
format_write_execution_test.py: escaped, null and value-only paths, typed filters and overwrites, refused values, CSV and TEXT files, tables written by earlier versions, and FLOAT names of both JDKs.a b,x/yand null partitions against a DLF catalog, and every client read every table back with the same rows.JavaPyE2ETest#testReadPythonFloatFormatTablereads FLOAT partitions written by PyPaimon with Java.rest_format_table_test.py,cli_table_test.py,filesystem_catalog_test.pyandnative_commit_partition_spec_test.pypass. flake8 is clean.