[python] Render min/max_partition_stats in the $manifests system table#8842
Open
wombatu-kun wants to merge 2 commits into
Open
[python] Render min/max_partition_stats in the $manifests system table#8842wombatu-kun wants to merge 2 commits into
wombatu-kun wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Done 9df763e - FLOAT/DOUBLE now render via Java's Float/Double.toString format (uppercase E, no + sign, no zero-padded exponent; e.g. 1.0E7 / 1.0E-5). |
Contributor
|
The new floating-point format implementation does not fully match Java 8’s |
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
This closes a TODO in
pypaimon/table/system/manifests_table.py:So
$manifestsreturns NULL formin_partition_statsandmax_partition_statsin pypaimon while Java renders them, and inspecting which manifests cover which partitions gives nothing on the Python side. The data is already parsed:ManifestListManagerbuildsSimpleStatsfrom the manifest list, only the rendering was missing.This adds
cast_row_to_string, the helper the TODO asks for: a port ofRowToStringCastRuleand the per type*ToStringCastRulerules ofpaimon-common, with fields joined by", "inside braces, the literalnullfor a null field, and{}for an unpartitioned table. The types that need more thanstr()are boolean (lower case), binary (decoded as UTF-8), date, time, timestamp, float and double. Timestamps followDateTimeUtils.formatTimestamp, which separates date and time with a space and strips trailing zeros of the fraction down to the declared precision, sodatetime.isoformat()can not be used. Float and double follow Java'sFloat.toString/Double.toString: the shortest decimal that round trips (through float32 for float, so a float320.1widened to a Python float stays0.1rather than0.10000000149011612), laid out in Java's notation with an upper caseE, no+sign and no zero-padded exponent, so1e7renders as1.0E7and1e-5as1.0E-5rather than Python's1e+07/1e-05.One point for a maintainer opinion, deliberately not changed here: pypaimon renders the
partitioncolumn of$filesand$bucketsaspt=v/pt2=v2, while Java renders those two with the brace form and keepspt=vonly for$partitions. Aligning them would change values these tables already return, so it is out of scope for this PR.Tests
New
pypaimon/tests/row_to_string_test.pycovers the rendering per type, including a null field, an empty row, the timestamp fraction at precision 0/3/6, and the float/double forms checked against Java'sFloat/Double.toString(shortest float32 form, scientific notation like1.0E7/1.0E-5, signed zero and the non-finite valuesNaN/Infinity).pypaimon/tests/system/manifests_table_test.pyreplaces the assertions that pinned the NULL placeholder: an unpartitioned table now yields{}, and a table partitioned by INT and STRING yields{1, 2024-01-01}and{2, 2024-01-02}.Cross checked against Java on a single warehouse: a table written by pypaimon and partitioned by INT, STRING, DATE, BOOLEAN and DECIMAL renders identically on both sides.