Commit ce94cb3
[SPARK-53552][SQL] Optimize substr SQL function
### What changes were proposed in this pull request?
In substringSQL() functions, if pos > 0 then we don't need to calculate numChars().
<img width="1846" height="388" alt="企业微信截图_96d4fc98-bce1-4b43-937c-68ca3c21e54c" src="https://github.com/user-attachments/assets/504eceee-83eb-45aa-91ab-b9c657993861" />
### Why are the changes needed?
SQL function substr performance improvement.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Exists UT
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #52308 from wankunde/substr.
Authored-by: WanKun <wankun@bilibili.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>1 parent 9bd844b commit ce94cb3
File tree
1 file changed
+8
-5
lines changed- common/unsafe/src/main/java/org/apache/spark/unsafe/types
1 file changed
+8
-5
lines changedLines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
645 | | - | |
646 | | - | |
647 | | - | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
648 | 652 | | |
649 | 653 | | |
650 | 654 | | |
| |||
663 | 667 | | |
664 | 668 | | |
665 | 669 | | |
666 | | - | |
667 | 670 | | |
668 | | - | |
| 671 | + | |
669 | 672 | | |
670 | 673 | | |
671 | 674 | | |
| |||
0 commit comments