branch-2.1: [feat](function) SUBSTRING_INDEX function delimiter supports dynamic #50149#50303
Merged
yiguolei merged 1 commit intobranch-2.1from Apr 23, 2025
Merged
Conversation
…50149) ### What problem does this PR solve? Problem Summary: sql ``` SELECT t1.no ,t1.sub_str ,t1.str ,substring_index(t1.str, t1.sub_str, -1) ,t2.rst2 FROM ( SELECT 1 AS no, 'BBB' AS sub_str, 'AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06' AS str UNION ALL SELECT 2 AS no, 'ccc' AS sub_str, 'zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06' AS str UNION ALL SELECT 3 AS no, 'DDD' AS sub_str, 'AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06' AS str UNION ALL SELECT 4 AS no, 'DDD' AS sub_str, 'sgr_01|wsc_02|CCC_03|DDD_04|rfv_05|rgb_06' AS str UNION ALL SELECT 5 AS no, 'eee' AS sub_str, 'cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06' AS str UNION ALL SELECT 6 AS no, 'A_01' AS sub_str, 'AAA_01|dsd_02|ert_03|bgt_04|fgh_05|hyb_06' AS str ) t1 LEFT JOIN ( SELECT 1 AS no, 'BBB' AS sub_str, substring_index('AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06', 'BBB', -1) AS rst2 UNION ALL SELECT 2 AS no, 'ccc' AS sub_str, substring_index('zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06', 'ccc', -1) AS rst2 UNION ALL SELECT 3 AS no, 'DDD' AS sub_str, substring_index('AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06', 'DDD', -1) AS rst2 UNION ALL SELECT 4 AS no, 'DDD' AS sub_str, substring_index('sgr_01|wsc_02|CCC_03|DDD_04|rfv_05|rgb_06', 'DDD', -1) AS rst2 UNION ALL SELECT 5 AS no, 'eee' AS sub_str, substring_index('cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06', 'eee', -1) AS rst2 UNION ALL SELECT 6 AS no, 'A_01' AS sub_str, substring_index('AAA_01|dsd_02|ert_03|bgt_04|fgh_05|hyb_06', 'A_01', -1) AS rst2 ) t2 ON t1.no = t2.no AND t1.sub_str = t2.sub_str ORDER BY t1.no; ``` previous results for doris: ``` -- master function except for the first argument, other parameter must be a constant -- 2.1 +------+---------+-------------------------------------------+-------------------------------------------------+-------------------------------------------+ | no | sub_str | str | substring_index(`t1`.`str`, `t1`.`sub_str`, -1) | rst2 | +------+---------+-------------------------------------------+-------------------------------------------------+-------------------------------------------+ | 1 | BBB | AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06 | _02|CCC_03|DDD_04|EEE_05|FFF_06 | _02|CCC_03|DDD_04|EEE_05|FFF_06 | | 2 | ccc | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | | 3 | DDD | AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06 | _02|CCC_03|DDD_04|EEE_05|FFF_06 | _04|EEE_05|FFF_06 | | 4 | DDD | sgr_01|wsc_02|CCC_03|DDD_04|rfv_05|rgb_06 | sgr_01|wsc_02|CCC_03|DDD_04|rfv_05|rgb_06 | _04|rfv_05|rgb_06 | | 5 | eee | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | | 6 | A_01 | AAA_01|dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | AAA_01|dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | |dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | +------+---------+-------------------------------------------+-------------------------------------------------+-------------------------------------------+ ``` mysql result: ``` +----+---------+-------------------------------------------+-------------------------------------------+-------------------------------------------+ | no | sub_str | str | substring_index(t1.str, t1.sub_str, -1) | rst2 | +----+---------+-------------------------------------------+-------------------------------------------+-------------------------------------------+ | 1 | BBB | AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06 | _02|CCC_03|DDD_04|EEE_05|FFF_06 | _02|CCC_03|DDD_04|EEE_05|FFF_06 | | 2 | ccc | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | | 3 | DDD | AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06 | _04|EEE_05|FFF_06 | _04|EEE_05|FFF_06 | | 4 | DDD | sgr_01|wsc_02|CCC_03|DDD_04|rfv_05|rgb_06 | _04|rfv_05|rgb_06 | _04|rfv_05|rgb_06 | | 5 | eee | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | | 6 | A_01 | AAA_01|dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | |dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | |dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | +----+---------+-------------------------------------------+-------------------------------------------+-------------------------------------------+ ``` current doris results: ``` +------+---------+-------------------------------------------+-------------------------------------------+-------------------------------------------+ | no | sub_str | str | substring_index(t1.str, t1.sub_str, -1) | rst2 | +------+---------+-------------------------------------------+-------------------------------------------+-------------------------------------------+ | 1 | BBB | AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06 | _02|CCC_03|DDD_04|EEE_05|FFF_06 | _02|CCC_03|DDD_04|EEE_05|FFF_06 | | 2 | ccc | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | zyz_01|zyz_02|CCC_03|qwe_04|qwe_05|qwe_06 | | 3 | DDD | AAA_01|BBB_02|CCC_03|DDD_04|EEE_05|FFF_06 | _04|EEE_05|FFF_06 | _04|EEE_05|FFF_06 | | 4 | DDD | sgr_01|wsc_02|CCC_03|DDD_04|rfv_05|rgb_06 | _04|rfv_05|rgb_06 | _04|rfv_05|rgb_06 | | 5 | eee | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | cdr_01|vfr_02|dfc_03|DDD_04|EEE_05|FFF_06 | | 6 | A_01 | AAA_01|dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | |dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | |dsd_02|ert_03|bgt_04|fgh_05|hyb_06 | +------+---------+-------------------------------------------+-------------------------------------------+-------------------------------------------+ ``` now consistent with mysql behavior.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
Contributor
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
Contributor
BE Regression P0 && UT Coverage ReportIncrement line coverage Increment coverage report
|
Member
|
run feut |
Contributor
BE Regression P0 && UT Coverage ReportIncrement line coverage Increment coverage report
|
yiguolei
approved these changes
Apr 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #50149