Skip to content

[fix](be) Preserve decimal precision in format_round - #68397

Merged
jacktengg merged 1 commit into
apache:masterfrom
jacktengg:DORIS-28927
Sep 24, 2026
Merged

jacktengg merged 1 commit into
apache:masterfrom
jacktengg:DORIS-28927

Conversation

@jacktengg

Copy link
Copy Markdown
Contributor

Issue Number: None

Related PR: None

Problem Summary: format_round(CAST('1.44' AS DECIMAL(38, 2)), 20) returns 1.00000000000000000044 instead of 1.44000000000000000000. The decimal formatter uses a 32-bit power-of-ten helper to expand the fraction and narrows the fraction to int when rounding and rendering it. This also corrupts existing high-scale fractions. The DECIMALV2 caller additionally discards all but three fractional digits.

Round with full-width integer arithmetic and append trailing zeroes in the output buffer instead of scaling the fraction. Pass the complete DECIMALV2 fraction. Cover decimal widths, constant and column arguments, NULLs, negative values, rounding carries, and the 1024-place boundary. Regenerate the two existing incorrect format_round expectations and verify money_format retains exact two-place rounding.

Fix incorrect format_round results for high-precision decimals and preserve all fractional digits of DECIMALV2 inputs before rounding.

  • Test:
    • ASAN BE build via ./build.sh --be -j48
    • Unit Test: 7 tests passed via ./run-be-ut.sh --run --filter='FormatRoundTest.:function_money_format_test.' -j48
    • Regression test: test_format_round, test_format_round_decimal, and test_money_format passed
    • Manual test: original SQL reproduced before the fix and returned exact decimal results after it; 59 generated SQL output rows checked against Python Decimal ROUND_HALF_UP
    • clang-format v16 and build hygiene passed
    • clang-tidy attempted; blocked by the pre-existing unmatched NOLINTEND in be/src/core/types.h:576
  • Behavior changed: Yes, decimal formatting preserves the correct value and requested fractional digits
  • Does this need documentation: No

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

Issue Number: None

Related PR: None

Problem Summary: format_round(CAST('1.44' AS DECIMAL(38, 2)), 20)
returns 1.00000000000000000044 instead of 1.44000000000000000000.
The decimal formatter uses a 32-bit power-of-ten helper to expand the
fraction and narrows the fraction to int when rounding and rendering it.
This also corrupts existing high-scale fractions. The DECIMALV2 caller
additionally discards all but three fractional digits.

Round with full-width integer arithmetic and append trailing zeroes in
the output buffer instead of scaling the fraction. Pass the complete
DECIMALV2 fraction. Cover decimal widths, constant and column arguments,
NULLs, negative values, rounding carries, and the 1024-place boundary.
Regenerate the two existing incorrect format_round expectations and
verify money_format retains exact two-place rounding.

Fix incorrect format_round results for high-precision decimals and
preserve all fractional digits of DECIMALV2 inputs before rounding.

- Test:
    - ASAN BE build via ./build.sh --be -j48
    - Unit Test: 7 tests passed via ./run-be-ut.sh --run --filter='FormatRoundTest.*:function_money_format_test.*' -j48
    - Regression test: test_format_round, test_format_round_decimal, and test_money_format passed
    - Manual test: original SQL reproduced before the fix and returned exact decimal results after it; 59 generated SQL output rows checked against Python Decimal ROUND_HALF_UP
    - clang-format v16 and build hygiene passed
    - clang-tidy attempted; blocked by the pre-existing unmatched NOLINTEND in be/src/core/types.h:576
- Behavior changed: Yes, decimal formatting preserves the correct value and requested fractional digits
- Does this need documentation: No
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@jacktengg

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: one material correctness gap remains in the advertised DecimalV2 path; see the inline comment.

Critical checkpoint conclusions:

  • Goal and scope: the full-width rounding/right-padding rewrite is focused and correct for integers plus Decimal32/64/128V3/256, but the stated DecimalV2 precision fix is not implemented.
  • Concurrency, lifecycle, and configuration: this is stateless row-local formatting with no new threads, locks, static lifecycle, or configuration item. The existing Decimal256 and DecimalV2 gates were traced.
  • Compatibility and parallel paths: no protocol, symbol, serialization, or storage-format change is introduced. FE/BE dispatch is consistent for the covered types; the registered DecimalV2 parallel path remains lossy.
  • Errors, transactions, and data correctness: every execution path validates places in [0,1024] and propagates failure. There is no transaction, persistence, or data-write path, but DecimalV2 can still return an incorrect displayed value.
  • Performance and memory: work is output-proportional, integer buffers are sufficient through Decimal256, and no untracked long-lived ownership is added.
  • Tests and results: the new BE test is auto-discovered and the DecimalV3/Decimal256 unit/regression expectations are consistent with half-up rounding, including const/column, NULL, sign, carry, extrema, and 1024-place cases. No changed test exercises TYPE_DECIMALV2, which is the missing path.

Review completion: the main scan plus two normal/risk-focused convergence rounds covered all seven changed files and relevant call chains. Round 2 returned NO_NEW_VALUABLE_FINDINGS, every candidate was accepted, dismissed with evidence, or deduplicated, and no additional user focus was supplied. Validation here was static-only because this review environment prohibited builds/tests; the author-reported ASAN build, unit tests, and regression tests were not independently executed.

@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28023 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 0646aeec375f66e7336d406f3a539dc9777277e8, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17624	3870	3859	3859
q2	2166	360	310	310
q3	10115	1375	840	840
q4	4687	479	351	351
q5	7505	840	561	561
q6	185	173	135	135
q7	735	833	589	589
q8	9315	1511	1500	1500
q9	5450	4203	4177	4177
q10	6827	1342	1016	1016
q11	436	269	235	235
q12	631	410	294	294
q13	18031	2642	2021	2021
q14	263	261	232	232
q15	q16	737	732	676	676
q17	1681	1166	983	983
q18	6541	5620	5549	5549
q19	1207	1304	1133	1133
q20	474	391	262	262
q21	5108	3212	2996	2996
q22	459	358	304	304
Total cold run time: 100177 ms
Total hot run time: 28023 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4593	4717	4466	4466
q2	764	573	536	536
q3	4759	5323	4604	4604
q4	2254	2342	1456	1456
q5	4492	4390	4627	4390
q6	233	180	126	126
q7	1826	1743	1512	1512
q8	2317	2064	2034	2034
q9	7356	7234	7205	7205
q10	3724	3624	3065	3065
q11	528	369	335	335
q12	721	707	513	513
q13	2277	2652	2009	2009
q14	266	273	256	256
q15	q16	671	687	605	605
q17	7232	6716	6675	6675
q18	11851	11104	11778	11104
q19	1060	1015	1032	1015
q20	2204	2187	1920	1920
q21	5038	4137	4288	4137
q22	515	456	387	387
Total cold run time: 64681 ms
Total hot run time: 58350 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 152601 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 0646aeec375f66e7336d406f3a539dc9777277e8, data reload: false

query5	4327	590	466	466
query6	426	209	185	185
query7	4810	538	309	309
query8	322	174	161	161
query9	8794	4042	3994	3994
query10	457	305	246	246
query11	5803	3535	3222	3222
query12	149	90	87	87
query13	1248	571	418	418
query14	6502	4506	4255	4255
query14_1	3983	3990	4019	3990
query15	196	193	174	174
query16	968	447	431	431
query17	874	638	533	533
query18	2427	452	324	324
query19	191	171	132	132
query20	86	79	77	77
query21	221	133	113	113
query22	13003	13053	12860	12860
query23	13909	13014	12414	12414
query23_1	12538	12600	12544	12544
query24	7171	1123	653	653
query24_1	741	700	708	700
query25	537	413	350	350
query26	1260	316	159	159
query27	2700	580	333	333
query28	4566	1976	1978	1976
query29	1640	722	536	536
query30	294	212	185	185
query31	910	763	664	664
query32	151	105	101	101
query33	523	326	258	258
query34	1222	1158	630	630
query35	735	762	645	645
query36	783	797	726	726
query37	151	116	99	99
query38	1837	1762	1673	1673
query39	699	673	636	636
query39_1	617	654	649	649
query40	228	128	102	102
query41	76	70	71	70
query42	105	97	94	94
query43	333	348	307	307
query44	1357	729	729	729
query45	187	177	164	164
query46	1090	1187	778	778
query47	1505	1502	1400	1400
query48	378	403	308	308
query49	595	414	309	309
query50	954	348	265	265
query51	10255	10496	10102	10102
query52	92	92	78	78
query53	246	259	187	187
query54	263	222	204	204
query55	85	77	73	73
query56	252	243	238	238
query57	1498	1542	1288	1288
query58	294	272	269	269
query59	2042	2091	1886	1886
query60	283	257	238	238
query61	186	175	175	175
query62	403	330	276	276
query63	217	180	186	180
query64	2938	1162	786	786
query65	3539	3439	3440	3439
query66	1856	418	307	307
query67	20180	19956	19886	19886
query68	3261	1501	882	882
query69	409	301	249	249
query70	943	797	818	797
query71	293	225	214	214
query72	2706	2235	2314	2235
query73	850	788	439	439
query74	4612	4510	4299	4299
query75	2305	2282	1930	1930
query76	2368	1091	743	743
query77	365	393	302	302
query78	9006	9056	8465	8465
query79	1361	1202	770	770
query80	900	463	360	360
query81	596	322	282	282
query82	647	169	127	127
query83	289	227	203	203
query84	312	149	116	116
query85	1011	460	376	376
query86	377	239	230	230
query87	1994	1947	1834	1834
query88	3619	2755	2704	2704
query89	362	285	256	256
query90	1716	182	176	176
query91	175	154	123	123
query92	105	80	88	80
query93	1629	1447	874	874
query94	610	351	317	317
query95	658	372	435	372
query96	1105	769	351	351
query97	2473	2451	2309	2309
query98	167	151	145	145
query99	733	722	624	624
Total cold run time: 236821 ms
Total hot run time: 152601 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.09 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 0646aeec375f66e7336d406f3a539dc9777277e8, data reload: false

query1	0.00	0.00	0.00
query2	0.09	0.05	0.05
query3	0.26	0.14	0.14
query4	1.61	0.15	0.14
query5	0.25	0.22	0.21
query6	1.16	0.93	0.96
query7	0.04	0.01	0.00
query8	0.05	0.04	0.04
query9	0.38	0.33	0.35
query10	0.55	0.55	0.56
query11	0.20	0.14	0.15
query12	0.20	0.15	0.14
query13	0.47	0.46	0.47
query14	0.95	0.98	0.93
query15	0.61	0.57	0.58
query16	0.31	0.33	0.32
query17	1.09	1.08	1.11
query18	0.23	0.19	0.20
query19	2.05	1.97	2.00
query20	0.02	0.01	0.01
query21	15.44	0.19	0.14
query22	4.99	0.05	0.06
query23	16.14	0.31	0.12
query24	2.96	0.42	0.31
query25	0.11	0.05	0.04
query26	0.73	0.21	0.17
query27	0.03	0.04	0.04
query28	3.53	0.82	0.37
query29	12.57	4.09	3.22
query30	0.29	0.16	0.16
query31	2.78	0.57	0.31
query32	3.21	0.59	0.49
query33	3.16	3.18	3.22
query34	15.48	3.92	3.28
query35	3.22	3.27	3.26
query36	0.55	0.42	0.43
query37	0.10	0.06	0.06
query38	0.04	0.04	0.03
query39	0.04	0.04	0.03
query40	0.17	0.14	0.13
query41	0.08	0.03	0.02
query42	0.03	0.03	0.03
query43	0.05	0.03	0.03
Total cold run time: 96.22 s
Total hot run time: 24.09 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 78.57% (33/42) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.92% (29751/46541)
Line Coverage 48.58% (309965/638044)
Region Coverage 44.09% (249833/566667)
Branch Coverage 45.68% (116194/254378)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 88.10% (37/42) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.27% (34374/45067)
Line Coverage 61.16% (385763/630768)
Region Coverage 57.57% (324899/564382)
Branch Coverage 58.40% (148098/253591)

@jacktengg
jacktengg merged commit b515db2 into apache:master Sep 24, 2026
39 checks passed
morningman added a commit that referenced this pull request Sep 28, 2026
### What problem does this PR solve?

Issue Number: N/A

Problem Summary:

**Context.** `run-be-ut.sh` is the only entry point for the BE unit
tests, and on macOS it is also the only way to run them: the `BE UT
(macOS)` workflow runs `build.sh --be`, which configures with
`-DMAKE_TEST=OFF`, so nothing under `be/test` is compiled there (the
workflow says so in its own comment at
`.github/workflows/be-ut-mac.yml:123`). On a clean worktree the script
therefore fails twice before a single test executes, and then stops
seven more times while compiling `be/test`.

**1. The problem, and what it cost**

*The script never initializes two of the submodules it needs.*
`run-be-ut.sh` initializes three submodules (`contrib/datasketches-cpp`,
`contrib/apache-orc`, `contrib/clucene`); `build.sh` initializes five,
and the two it adds — `contrib/faiss` and `contrib/openblas` — are
required before a single file is compiled. `be/CMakeLists.txt:1038` adds
`be/src/storage/index/ann` unconditionally, and that directory's
`cmake-protect/CMakeLists.txt:48,66` calls `add_subdirectory()` on both.
On a fresh clone or a new git worktree the configure step therefore ends
with

CMake Error at src/storage/index/ann/cmake-protect/CMakeLists.txt:48
(add_subdirectory):
The source directory .../contrib/openblas does not contain a
CMakeLists.txt file.
CMake Error at src/storage/index/ann/cmake-protect/CMakeLists.txt:66
(add_subdirectory):
The source directory .../contrib/faiss does not contain a CMakeLists.txt
file.

Running `build.sh` once first hides it, which is why it goes unnoticed.

*Seven `be/test` translation units do not compile on macOS.* The Linux
BE UT build is green for all seven. `run-be-ut.sh` invokes ninja without
`-k`, so the developer fixes one file, waits out another full compile,
and meets the next one — seven round trips, each of them tens of
minutes, for a task whose whole point is to run a test.

| # | TU | Error | Root cause |
|---|---|---|---|
| 1 | `exprs/function/function_map_inner_product_test.cpp` |
`'faiss/impl/platform_macros.h' file not found` | The `APPLE` branch of
`be/test/CMakeLists.txt:170` links `vector_search_test` as
`-Wl,-force_load,$<TARGET_FILE:vector_search_test>`: a file path, which
carries no usage requirements. Every other platform links
`-Wl,--whole-archive vector_search_test`, which is a target in the link
list and does propagate them. |
| 2 | `exprs/function/function_format_round_test.cpp` | `ambiguous
conversion for functional-style cast from 'long' to 'Decimal64'` (11
sites) | `Decimal64` is `Decimal<int64_t>`, so on Darwin the constructor
parameter is `long long` while these literals are `long`; every integral
and floating constructor is then an equally ranked conversion away. |
| 3 | `storage/index/snii/bench/bkd_native_vs_clucene_bench_test.cpp` |
six `-Werror,-Wformat` | `uint64_t` is `unsigned long long` on Darwin
and `unsigned long` on Linux, so `%lu` / `%ld` is right on one and wrong
on the other. |
| 4 | `storage/index/snii/bench/snii_vs_v3_benchmark_test.cpp` | `no
member named 'posix_fadvise'`, `mincore` argument type | `posix_fadvise`
/ `POSIX_FADV_DONTNEED` do not exist on Darwin; `mincore(2)` takes
`char*` there and `unsigned char*` on Linux. |
| 5 | `storage/index/snii/bkd/bkd_corruption_test.cpp` | `deduced
conflicting types ('size_type' vs 'uint64_t')` | An initializer list
mixing `payload.size()` (size_t) with `uint64_t` literals. |
| 6 | `storage/index/snii/writer/spimi_locality_bench_test.cpp` | libc++
`no matching function for call to object of type 'key_equal'` | The
transparent equality functor defines one argument order only. libc++
calls `key_equal` as `(key, lookup key)`, libstdc++ as `(lookup key,
key)`. |
| 7 | `storage/segment/hierarchical_data_iterator_test.cpp` | three `no
matching function for call to 'min'` | `kRows` is `size_t` and
`current_ordinal` is `ordinal_t` (`uint64_t`), which are distinct types
on Darwin, so `std::min` cannot deduce a common type. |

None of the seven is related to a local change; a clean master
reproduces all of them. #2 arrived on 2026-09-24 with #68397 (`[fix](be)
Preserve decimal precision in format_round`, by TengJianPing), which is
the commit that added `function_format_round_test.cpp` — after the last
full macOS sweep. So this class of breakage is still being produced:
"green on Linux, red on macOS" is invisible to every CI job we have, and
the two obstacles above make the one manual path that would find it
expensive enough that nobody walks it.

**2. What this PR does, and why it helps**

- `run-be-ut.sh`: the `update_submodule` list gains `contrib/openblas`
and `contrib/faiss`, with the same archive URLs `build.sh:941` already
uses, plus a comment that the list has to stay in sync with `build.sh`.
- `be/test/CMakeLists.txt`: the `APPLE` branch links `ann_index` in
addition to the `force_load` flag. `ann_index` is the target that
exports the faiss include directories `PUBLIC`, so the APPLE link line
now feeds the same compile and link inputs as every other platform,
instead of being a macOS special case.
- Six test files: the smallest change that removes the platform
difference, each spelled the way the file's neighbours already spell it
— `PRIu64` / `PRId64` (`core/decimal12.h`, `util/histogram.cpp`),
`int64_t(...)` around the literals (`storage/key_coder_test.cpp:392`,
`runtime/jsonb_document_test.cpp:433`), `#if
defined(POSIX_FADV_DONTNEED)` around the call.

Linux behaviour is unchanged: every edit is either inside an
`APPLE`-only path or a strictly more portable spelling of the same
value. On macOS `run-be-ut.sh` becomes a usable test line for the first
time.

One cost worth naming: because the APPLE link line now propagates
include directories, the compile command of every `be/test` TU changes
once, so the first macOS build after this lands rebuilds `be/test`
(about 1230 TUs). Later builds are incremental again.

**Branch pick.** #68397 was never picked to `branch-4.1`, so
`function_format_round_test.cpp` does not exist there. Of the seven
files, only `storage/segment/hierarchical_data_iterator_test.cpp` exists
on `branch-4.1`, with the same three `std::min(*rows, ROWS -
current_ordinal)` sites and the same types (`ROWS` is `size_t`,
`ordinal_t` is `uint64_t`), so it fails to compile on macOS there too;
that branch also has no `APPLE` `force_load` branch in
`be/test/CMakeLists.txt`, so the faiss part is master-only. If 4.1 is
meant to run BE UT on macOS, the pick is that one file's hunk.

**3. The classes, and how they call each other**

- `run-be-ut.sh` (changed): `update_submodule()` calls `git submodule
update --init --recursive <path>` and falls back to the branch tarball;
the two added lines are identical in shape to the three that were
already there.
- `be/test/CMakeLists.txt` (changed): the `APPLE` branch of the
`doris_be_test` link step.
- `be/src/storage/index/ann/cmake-protect/CMakeLists.txt` (unchanged,
the reason the submodules are mandatory): `add_subdirectory()` on
`contrib/openblas` and `contrib/faiss`, reached unconditionally from
`be/CMakeLists.txt:1038`.
- `ann_index` (unchanged target in `be/src/storage/index/ann`): links
`faiss` `PUBLIC`, so its `INTERFACE_INCLUDE_DIRECTORIES` carry the faiss
include path.
- `vector_search_test` (unchanged target in
`be/test/storage/index/ann`): links `ann_index` `PUBLIC`; on APPLE it
reaches `doris_be_test` as forced-in objects rather than as a target.
- The seven test TUs: unchanged in behaviour, three of them compiled in
a portable spelling.

```
run-be-ut.sh
  |- update_submodule contrib/{datasketches-cpp, apache-orc, clucene}   [already there]
  '- update_submodule contrib/{openblas, faiss}                        [added here]
        '- git submodule update --init --recursive

be/CMakeLists.txt:1038  add_subdirectory(be/src/storage/index/ann)
  '- storage/index/ann/CMakeLists.txt:18  add_subdirectory(cmake-protect)
        '- cmake-protect/CMakeLists.txt:48,66  add_subdirectory(contrib/{openblas, faiss})
              '- target faiss --(PUBLIC)--> target ann_index --(PUBLIC)--> vector_search_test
                                                                              |
be/test/CMakeLists.txt:170  if (APPLE)                                        |
  |- before: -Wl,-force_load,<path to libvector_search_test.a>  -- propagates nothing
  '- after:  the same flag + ann_index                          -- propagates the faiss include dirs
                                                                              |
                                        function_map_inner_product_test.cpp <--'
                                        (and every other be/test TU, which now
                                         compiles with the same inputs as on Linux)

be/test/CMakeLists.txt  add_executable(doris_be_test ${UT_FILES})   <- the other six TUs, no link involvement
```
github-actions Bot pushed a commit that referenced this pull request Nov 8, 2026
Issue Number: None

Related PR: None

Problem Summary: format_round(CAST('1.44' AS DECIMAL(38, 2)), 20)
returns 1.00000000000000000044 instead of 1.44000000000000000000. The
decimal formatter uses a 32-bit power-of-ten helper to expand the
fraction and narrows the fraction to int when rounding and rendering it.
This also corrupts existing high-scale fractions. The DECIMALV2 caller
additionally discards all but three fractional digits.

Round with full-width integer arithmetic and append trailing zeroes in
the output buffer instead of scaling the fraction. Pass the complete
DECIMALV2 fraction. Cover decimal widths, constant and column arguments,
NULLs, negative values, rounding carries, and the 1024-place boundary.
Regenerate the two existing incorrect format_round expectations and
verify money_format retains exact two-place rounding.

Fix incorrect format_round results for high-precision decimals and
preserve all fractional digits of DECIMALV2 inputs before rounding.

- Test:
    - ASAN BE build via ./build.sh --be -j48
- Unit Test: 7 tests passed via ./run-be-ut.sh --run
--filter='FormatRoundTest.*:function_money_format_test.*' -j48
- Regression test: test_format_round, test_format_round_decimal, and
test_money_format passed
- Manual test: original SQL reproduced before the fix and returned exact
decimal results after it; 59 generated SQL output rows checked against
Python Decimal ROUND_HALF_UP
    - clang-format v16 and build hygiene passed
- clang-tidy attempted; blocked by the pre-existing unmatched NOLINTEND
in be/src/core/types.h:576
- Behavior changed: Yes, decimal formatting preserves the correct value
and requested fractional digits
- Does this need documentation: No

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [ ] Regression test
    - [ ] Unit Test
    - [ ] Manual test (add detailed scripts or steps below)
    - [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
        - [ ] Previous test can cover this change.
        - [ ] No code files have been changed.
        - [ ] Other reason <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants