You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "jacktengg (via GitHub)" <gi...@apache.org> on 2026/10/13 02:03:11 UTC
[PR] [fix](be) Fix CONV results for negative string inputs [doris]
jacktengg opened a new pull request, #68984:
URL: https://github.com/apache/doris/pull/68984
[fix](be) Fix CONV results for negative string inputs
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary: CONV('-10', 10, 10) returned 18446744073709551615 while
CONV(-10, 10, 10) returned 18446744073709551606. Converting the string to
signed output with CONV('-10', 10, -10) or CONV('-10', 2, -10) likewise
returned -1 instead of -10 or -2.
The base-aware string parser added one to UINT64_MAX when it encountered
a negative sign, wrapping the unsigned magnitude limit to zero and
incorrectly reporting overflow. Expand the negative magnitude limit only
for signed integer types, using unsigned arithmetic; keep the full
unsigned magnitude limit when parsing negative strings as uint64_t.
Negative destination bases continue to select signed output, and allowed
base magnitudes remain [2, 36]. Add unsigned parser boundary tests and CONV
coverage for negative string and integer inputs, signed and unsigned
output, 64-bit limits and overflow, NULLs, all TINYINT base values, all
eight constant/column argument combinations, and constant folding.
Generate the regression output through the standard regression script.
The reported six-expression query now returns
18446744073709551606, 18446744073709551606, -10, -10, -2, -2.
### Release note
Fix incorrect CONV results for negative string inputs, including signed
output selected by a negative destination base.
### Check List (For Author)
- Test:
- ASAN BE build: ./build.sh --be -j32
- Unit Test: ./run-be-ut.sh --run --filter='MathFunctionTest.conv*:StringToIntWithBase.*' -j32 (10 tests passed)
- Regression test: ./run-regression-test.sh --run -d query_p0/sql_functions/math_functions -s test_conv_negative_base_range -forceGenOut
- Regression test: ./run-regression-test.sh --run -d query_p0/sql_functions/math_functions -s test_conv,test_conv_negative_base_range (2 suites passed)
- Manual test: verified the reported six-expression SQL on the rebuilt worktree cluster
- clang-format 16, clang-tidy on changed lines, build hygiene, and git diff checks passed
- Behavior changed: Yes, correct negative string conversion results while preserving existing negative base support
- Does this need documentation: No, this is a bug fix with existing base semantics preserved
### 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 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "jacktengg (via GitHub)" <gi...@apache.org>.
jacktengg commented on code in PR #68984:
URL: https://github.com/apache/doris/pull/68984#discussion_r4254421072
##########
be/src/util/string_parser.hpp:
##########
@@ -611,7 +612,9 @@ T StringParser::string_to_int_internal(const char* __restrict s, int64_t len, in
switch (*s) {
case '-':
negative = true;
- max_val = StringParser::numeric_limits<T>(false) + 1;
+ // Only signed types have an extra value in their negative range.
+ // Keep the unsigned magnitude limit unchanged to avoid wrapping it to zero.
+ max_val += std::numeric_limits<T>::is_signed;
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "jacktengg (via GitHub)" <gi...@apache.org>.
jacktengg commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6137784012
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "jacktengg (via GitHub)" <gi...@apache.org>.
jacktengg commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6136525232
/review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6141226209
<details>
<summary>TPC-DS: <b>Total hot run time: 151856 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 28c1eee2ca8d3c80946e5467f07075510a8034cf, data reload: false
query5 4308 591 448 448
query6 432 207 189 189
query7 4800 459 228 228
query8 317 192 167 167
query9 8764 3960 3935 3935
query10 466 304 247 247
query11 5948 3395 3172 3172
query12 149 92 81 81
query13 1241 428 308 308
query14 6550 4789 4477 4477
query14_1 4254 4253 4166 4166
query15 205 204 177 177
query16 949 434 419 419
query17 848 662 536 536
query18 2423 421 317 317
query19 204 167 134 134
query20 82 81 81 81
query21 213 133 109 109
query22 12918 13003 12776 12776
query23 13115 12455 12232 12232
query23_1 12166 12215 12116 12116
query24 7094 821 498 498
query24_1 485 472 472 472
query25 530 427 363 363
query26 1254 254 142 142
query27 2757 441 272 272
query28 4615 1967 1941 1941
query29 1576 580 433 433
query30 294 217 176 176
query31 895 771 655 655
query32 136 88 89 88
query33 501 289 231 231
query34 901 861 516 516
query35 754 764 641 641
query36 841 825 753 753
query37 125 105 90 90
query38 1782 1754 1707 1707
query39 705 687 676 676
query39_1 674 666 643 643
query40 214 118 95 95
query41 81 69 61 61
query42 84 83 84 83
query43 368 367 322 322
query44 1302 696 699 696
query45 179 191 163 163
query46 850 951 566 566
query47 2931 2862 2938 2862
query48 287 304 219 219
query49 562 393 289 289
query50 679 281 209 209
query51 10567 10820 10575 10575
query52 80 78 69 69
query53 183 215 157 157
query54 240 196 179 179
query55 76 69 63 63
query56 223 214 205 205
query57 1614 1573 1542 1542
query58 275 256 251 251
query59 2355 2402 2136 2136
query60 275 237 220 220
query61 148 143 145 143
query62 389 336 284 284
query63 193 157 173 157
query64 2750 936 821 821
query65 3410 3370 3339 3339
query66 1756 409 304 304
query67 20278 20279 20125 20125
query68 2933 997 616 616
query69 386 299 246 246
query70 923 848 814 814
query71 286 238 209 209
query72 2768 2618 2223 2223
query73 509 523 297 297
query74 4585 4452 4298 4298
query75 2329 2319 1944 1944
query76 2275 1024 619 619
query77 359 402 295 295
query78 8968 8961 8468 8468
query79 840 886 514 514
query80 485 422 339 339
query81 516 327 281 281
query82 217 130 115 115
query83 268 195 178 178
query84 297 125 100 100
query85 767 433 361 361
query86 288 227 224 224
query87 2018 1970 1808 1808
query88 3577 2692 2660 2660
query89 324 298 254 254
query90 2119 181 174 174
query91 156 147 121 121
query92 97 85 88 85
query93 985 990 581 581
query94 446 339 288 288
query95 584 342 320 320
query96 653 530 231 231
query97 2534 2451 2316 2316
query98 151 148 145 145
query99 767 764 655 655
Total cold run time: 232702 ms
Total hot run time: 151856 ms
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6143523032
PR approved by at least one committer and no changes requested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6136511962
Thank you for your contribution to Apache Doris.
Don't know what should be done next? See [How to process your PR](https://doris.apache.org/community/how-to-contribute/review-and-ci).
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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6141302322
<details>
<summary>ClickBench: <b>Total hot run time: 24.52 s</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 28c1eee2ca8d3c80946e5467f07075510a8034cf, data reload: false
query1 0.01 0.01 0.00
query2 0.09 0.06 0.05
query3 0.26 0.12 0.12
query4 1.62 0.13 0.12
query5 0.27 0.22 0.24
query6 1.17 0.69 0.68
query7 0.03 0.01 0.01
query8 0.05 0.04 0.03
query9 0.42 0.35 0.35
query10 0.61 0.58 0.58
query11 0.21 0.14 0.14
query12 0.18 0.14 0.14
query13 0.49 0.50 0.48
query14 0.98 0.98 0.97
query15 0.64 0.61 0.61
query16 0.33 0.34 0.34
query17 1.12 1.11 1.12
query18 0.23 0.20 0.20
query19 2.10 2.05 1.99
query20 0.02 0.01 0.01
query21 15.48 0.27 0.14
query22 4.38 0.05 0.05
query23 16.27 0.34 0.12
query24 3.14 0.57 0.38
query25 0.12 0.05 0.06
query26 1.05 0.26 0.16
query27 0.04 0.04 0.04
query28 1.48 0.62 0.40
query29 12.51 4.15 3.28
query30 0.28 0.13 0.16
query31 2.77 0.59 0.34
query32 3.22 0.61 0.51
query33 3.12 3.23 3.20
query34 15.67 4.04 3.43
query35 3.34 3.35 3.34
query36 0.56 0.48 0.46
query37 0.09 0.06 0.06
query38 0.05 0.04 0.04
query39 0.04 0.03 0.03
query40 0.17 0.14 0.13
query41 0.09 0.03 0.03
query42 0.03 0.02 0.03
query43 0.04 0.03 0.03
Total cold run time: 94.77 s
Total hot run time: 24.52 s
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "jacktengg (via GitHub)" <gi...@apache.org>.
jacktengg commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6137582176
/review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6141071889
<details>
<summary>TPC-H: <b>Total hot run time: 28732 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 28c1eee2ca8d3c80946e5467f07075510a8034cf, data reload: false
------ Round 1 ----------------------------------
============================================
q1 17579 5690 5519 5519
q2 2104 327 259 259
q3 10234 1404 833 833
q4 4680 475 358 358
q5 7435 793 535 535
q6 190 187 158 158
q7 774 795 602 602
q8 9240 1392 1096 1096
q9 5704 4452 4440 4440
q10 6816 1290 1037 1037
q11 432 257 243 243
q12 630 400 292 292
q13 18080 3299 2367 2367
q14 271 266 237 237
q15 q16 735 722 647 647
q17 1175 746 580 580
q18 6937 6201 6170 6170
q19 1095 959 586 586
q20 378 331 225 225
q21 4772 2273 2413 2273
q22 361 325 275 275
Total cold run time: 99622 ms
Total hot run time: 28732 ms
----- Round 2, with runtime_filter_mode=off -----
============================================
q1 6183 6134 6118 6118
q2 670 548 525 525
q3 5250 5427 4944 4944
q4 2023 2164 1560 1560
q5 5336 5198 5844 5198
q6 247 194 155 155
q7 2288 2095 1934 1934
q8 3193 2760 2807 2760
q9 8325 8322 8340 8322
q10 3801 3717 3389 3389
q11 651 458 418 418
q12 699 773 520 520
q13 2991 3274 2557 2557
q14 315 302 300 300
q15 q16 697 753 664 664
q17 8413 7490 7567 7490
q18 13138 12244 12974 12244
q19 937 785 787 785
q20 2175 2138 1925 1925
q21 5726 4666 4779 4666
q22 488 466 402 402
Total cold run time: 73546 ms
Total hot run time: 66876 ms
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #68984:
URL: https://github.com/apache/doris/pull/68984#discussion_r4254097132
##########
be/src/util/string_parser.hpp:
##########
@@ -611,7 +612,9 @@ T StringParser::string_to_int_internal(const char* __restrict s, int64_t len, in
switch (*s) {
case '-':
negative = true;
- max_val = StringParser::numeric_limits<T>(false) + 1;
+ // Only signed types have an extra value in their negative range.
+ // Keep the unsigned magnitude limit unchanged to avoid wrapping it to zero.
+ max_val += std::numeric_limits<T>::is_signed;
Review Comment:
[P2] Preserve negative-source prefix conversions
`CONV('-121', -2, -10)` (and `CONV('-1a1', -10, -10)`) changes from `'-1'` to `NULL`, although `_check_oob` still accepts these source-base magnitudes. With `T=uint64_t`, the raw negative `base` becomes a huge unsigned divisor: the new `UINT64_MAX` limit makes `max_div_base=1`, so the second digit triggers `PARSE_OVERFLOW`. Its negative saturation value is now `1`, which `ConvStringImpl` rejects as nonnegative before `handle_parse_result`. Both inputs have a valid `-1` prefix, matching the existing out-of-base-digit truncation behavior, so this loses a previously correct result. Please handle the negative source radix correctly before applying this unsigned overflow check and add these prefix cases; the new source-base range test only uses `-10`, `0`, and `10` and misses them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6138582311
<details>
<summary>TPC-H: <b>Total hot run time: 29338 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 28c1eee2ca8d3c80946e5467f07075510a8034cf, data reload: false
------ Round 1 ----------------------------------
============================================
q1 17590 5660 5587 5587
q2 2088 307 247 247
q3 10266 1443 847 847
q4 4683 484 347 347
q5 7448 805 547 547
q6 194 192 159 159
q7 795 819 603 603
q8 9255 1382 1099 1099
q9 5774 4524 4471 4471
q10 6819 1305 1036 1036
q11 451 259 243 243
q12 636 418 289 289
q13 18056 3082 2428 2428
q14 281 275 245 245
q15 q16 738 736 679 679
q17 1200 752 585 585
q18 7080 6266 6219 6219
q19 1127 978 617 617
q20 386 338 238 238
q21 5757 2554 2629 2554
q22 399 345 298 298
Total cold run time: 101023 ms
Total hot run time: 29338 ms
----- Round 2, with runtime_filter_mode=off -----
============================================
q1 6730 6788 6862 6788
q2 758 606 571 571
q3 5707 5737 5345 5345
q4 2103 2209 1578 1578
q5 5756 5656 5831 5656
q6 267 192 143 143
q7 2244 2050 1819 1819
q8 3158 2904 2793 2793
q9 8185 8211 8169 8169
q10 3720 3646 3273 3273
q11 603 407 376 376
q12 667 707 499 499
q13 2776 3093 2394 2394
q14 286 290 266 266
q15 q16 672 692 618 618
q17 7894 7129 6943 6943
q18 13191 12309 13114 12309
q19 933 792 797 792
q20 2201 2177 1949 1949
q21 5893 4786 4844 4786
q22 497 468 408 408
Total cold run time: 74241 ms
Total hot run time: 67475 ms
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "jacktengg (via GitHub)" <gi...@apache.org>.
jacktengg merged PR #68984:
URL: https://github.com/apache/doris/pull/68984
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](be) Fix CONV results for negative string inputs [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #68984:
URL: https://github.com/apache/doris/pull/68984#issuecomment-6143522394
PR approved by anyone and no changes requested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org