Commit cb434d5
[SPARK-59507][SQL] Parse interval fractional seconds without building a padded string
`IntervalUtils.parseNanos` right-padded the fractional-second digits to 9 characters with a
string concatenation and a substring before parsing:
(nanos + "000000000").substring(0, maxNanosLen)
That allocated two throwaway strings per call purely to zero-pad ahead of an integer parse.
Since the fractional part is guaranteed to be 1-9 ASCII digits by the interval grammar,
parse it directly and scale by the corresponding power of ten instead. The result is
identical -- the parsed value stays in [0, 999999999], so the range check and error
behavior are unchanged -- and no intermediate string is allocated.
Co-authored-by: Isaac <no-reply@databricks.com>1 parent 93d4016 commit cb434d5
1 file changed
Lines changed: 10 additions & 4 deletions
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
543 | 548 | | |
544 | 549 | | |
545 | 550 | | |
546 | 551 | | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
551 | 557 | | |
552 | 558 | | |
553 | 559 | | |
| |||
0 commit comments