This is an automated email from the ASF dual-hosted git repository.
Gabriel39 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 6403a7fa9f7 [fix](iceberg) Preserve floating-point partition precision
(#70613)
6403a7fa9f7 is described below
commit 6403a7fa9f7944d0eb6451303dffda3db870c812
Author: daidai <[email protected]>
AuthorDate: Mon Nov 23 11:07:12 2026 +0800
[fix](iceberg) Preserve floating-point partition precision (#70613)
### Background
The Iceberg writer serializes partition values as strings for writer
grouping, partition paths, and FE commit metadata. The FE parses these
strings using each partition field's declared type before building
Iceberg PartitionData.
### What problem does this PR solve?
Issue Number: None
Related PR: #64315 (special-value handling), #65609 (round-trip
floating-point formatting)
PR Type: Bugfix
Problem Summary:
Finite FLOAT and DOUBLE identity partition values were serialized with
std::to_string, which retains only six digits after the decimal point.
For example, DOUBLE values 1.0000001 and 1.0000002 both became 1.000000,
producing incorrect partition metadata and potentially merging distinct
partitions into one writer. Subsequent partition filtering can silently
omit matching rows.
Use the existing fmt shortest-round-trip formatting for finite partition
values while preserving the current NaN and infinity spellings. This
fixes the shared serialization used by writer keys, paths, and commit
values. Previously written incorrect metadata is not repaired by this
change.
### Details
- **Frequency:** Triggered by dynamic FLOAT/DOUBLE identity partition
values that cannot round-trip through fixed six-decimal formatting; no
concurrency is required.
- **Root cause:** floating_point_partition_value_to_string used
std::to_string for finite values, losing precision before writer
grouping and FE partition parsing.
- **Why existing tests missed it:** Existing partition serialization
tests cover NaN and infinities, without finite precision or signed-zero
bit comparisons.
- **Fix:** Use fmt::format with the original FLOAT/DOUBLE type. Add
actual transform unit tests for adjacent values, small values, finite
extrema, subnormals, signed zeros, commit/human-string consistency, and
distinct partition strings.
- **Other paths and branches:** Dynamic writer keys, partition paths,
and commit values share this helper. No FE parser or Thrift changes are
needed. Full static partition fields use a separate precomputed-value
path. Apache branch-4.2 at 0a24ed86fb8da943e43facf653b5a3016470177a has
the identical affected production file and should receive this fix and
tests; the complete patch applies cleanly, and no additional
prerequisite picks are needed.
- **Behavior change:** New writes preserve the original finite
floating-point partition values. NaN/infinity handling is unchanged.
Existing files with incorrect partition metadata still require separate
recovery.
### Testing
- Passed clang-format v16, build-support/check-format.sh,
build-support/check-build-hygiene.sh, and git diff --check.
- Independently compiled helpers extracted from the baseline and
modified production source, then parsed their output using Java
Float.parseFloat/Double.parseDouble. The original implementation lost
finite-value precision in 10,006 FLOAT and 10,208 DOUBLE samples; the
modified implementation had zero round-trip failures across 40,034
samples, including special values and signed zeros.
- The typed fast_float parser used by the new unit tests also preserved
all 39,923 finite samples. These isolated experiments do not execute the
full Doris transform, writer, or commit path.
- Added PartitionTransformersTest.test_float_partition_value_round_trip
and test_double_partition_value_round_trip. Full BE UT was not run: this
worktree has no existing BE build, approximately 4.5 GB of free disk
space remains, and run-be-ut.sh builds the complete BE test binary even
with a GTest filter.
- No end-to-end Iceberg SQL regression or clang-tidy run: an isolated
built cluster and BE compilation database are not available. No
regression golden files were handwritten.
- Verified that the production fix and unit-test patch apply cleanly to
the current branch-4.2 files.
### Notes for Reviewers
This remains a draft until the full BE tests and external Iceberg SQL
checks are completed. Suggested unit-test command: ./run-be-ut.sh --run
--filter='PartitionTransformersTest.*' -j 1. The SQL check should write
DOUBLE partitions 1.0000001 and 1.0000002, verify distinct accurate
typed partitions in the files metadata, and expect equality/range counts
of 1, 1, and 2. Recommend picking this PR to branch-4.2 after merge.
### Release note
Fix precision loss when writing finite FLOAT/DOUBLE Iceberg identity
partition values, preventing incorrect partition metadata and missing
rows during partition filtering for newly written data.
### Check List (For Author)
- Test:
- [ ] Regression test
- [ ] Unit Test (added; full BE test binary not built locally)
- [x] Manual test (isolated serialization/parser experiments and
formatting/hygiene checks described above)
- Behavior changed: Yes (see Details)
- Does this need documentation: No
- Pre-submission status: Partially verified: full BE UT, end-to-end
Iceberg SQL regression, and clang-tidy remain pending; keep as Draft.
### AI Disclosure
- Tool: Codex
- Generated: Code, unit tests, validation probes, and this description.
- Human review: Pending.
---
.../sink/writer/iceberg/partition_transformers.cpp | 5 ++-
.../writer/iceberg/partition_transformers_test.cpp | 48 ++++++++++++++++++++++
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/be/src/exec/sink/writer/iceberg/partition_transformers.cpp
b/be/src/exec/sink/writer/iceberg/partition_transformers.cpp
index d1f141792cc..b976eec6821 100644
--- a/be/src/exec/sink/writer/iceberg/partition_transformers.cpp
+++ b/be/src/exec/sink/writer/iceberg/partition_transformers.cpp
@@ -17,6 +17,8 @@
#include "exec/sink/writer/iceberg/partition_transformers.h"
+#include <fmt/format.h>
+
#include <any>
#include <cmath>
@@ -35,7 +37,8 @@ std::string floating_point_partition_value_to_string(T value)
{
if (std::isinf(value)) {
return value > 0 ? "Infinity" : "-Infinity";
}
- return std::to_string(value);
+ // Distinct partitions such as 1.0000001 and 1.0000002 must round-trip
without rounding.
+ return fmt::format("{}", value);
}
} // namespace
diff --git a/be/test/exec/sink/writer/iceberg/partition_transformers_test.cpp
b/be/test/exec/sink/writer/iceberg/partition_transformers_test.cpp
index 673e41dac64..3481010d592 100644
--- a/be/test/exec/sink/writer/iceberg/partition_transformers_test.cpp
+++ b/be/test/exec/sink/writer/iceberg/partition_transformers_test.cpp
@@ -17,9 +17,14 @@
#include "exec/sink/writer/iceberg/partition_transformers.h"
+#include <fast_float/fast_float.h>
#include <gtest/gtest.h>
+#include <bit>
+#include <cmath>
#include <limits>
+#include <system_error>
+#include <type_traits>
#include "core/data_type/data_type_date_or_datetime_v2.h"
#include "core/data_type/data_type_timestamp_ns.h"
@@ -34,6 +39,41 @@ class PartitionTransformersTest : public testing::Test {
public:
PartitionTransformersTest() = default;
virtual ~PartitionTransformersTest() = default;
+
+ template <typename T>
+ void check_floating_point_partition_round_trip(PrimitiveType
primitive_type) {
+ auto type =
DataTypeFactory::instance().create_data_type(primitive_type, false);
+ IdentityPartitionColumnTransform transform(type);
+ const std::vector<T> values = {T(1.0000001),
+ T(1.0000002),
+ std::nextafter(T(1), T(2)),
+ T(-1.0000001),
+ T(1e-8),
+ T(-1e-8),
+ std::numeric_limits<T>::min(),
+ -std::numeric_limits<T>::min(),
+ std::numeric_limits<T>::max(),
+ -std::numeric_limits<T>::max(),
+ std::numeric_limits<T>::denorm_min(),
+ -std::numeric_limits<T>::denorm_min(),
+ T(0.0),
+ T(-0.0)};
+ using Bits = std::conditional_t<sizeof(T) == sizeof(UInt32), UInt32,
UInt64>;
+ for (T value : values) {
+ const auto serialized = transform.get_partition_value(type, value);
+ SCOPED_TRACE(serialized);
+ T parsed;
+ const auto result = fast_float::from_chars(
+ serialized.data(), serialized.data() + serialized.size(),
parsed);
+ ASSERT_EQ(std::errc {}, result.ec);
+ ASSERT_EQ(serialized.data() + serialized.size(), result.ptr);
+ EXPECT_EQ(std::bit_cast<Bits>(value), std::bit_cast<Bits>(parsed));
+ EXPECT_EQ(serialized, transform.to_human_string(type, value));
+ }
+
+ EXPECT_NE(transform.to_human_string(type, T(1.0000001)),
+ transform.to_human_string(type, T(1.0000002)));
+ }
};
TEST_F(PartitionTransformersTest, human_hour_floors_negative_ordinals) {
@@ -301,6 +341,14 @@ TEST_F(PartitionTransformersTest,
test_string_truncate_transform) {
}
}
+TEST_F(PartitionTransformersTest, test_float_partition_value_round_trip) {
+ check_floating_point_partition_round_trip<Float32>(TYPE_FLOAT);
+}
+
+TEST_F(PartitionTransformersTest, test_double_partition_value_round_trip) {
+ check_floating_point_partition_round_trip<Float64>(TYPE_DOUBLE);
+}
+
TEST_F(PartitionTransformersTest, test_floating_point_special_partition_value)
{
auto float_type =
DataTypeFactory::instance().create_data_type(PrimitiveType::TYPE_FLOAT, false);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]