doris icon indicating copy to clipboard operation
doris copied to clipboard

[feature-wip](array-type) add the array_join function

Open carlvinhust2012 opened this issue 2 years ago • 4 comments

Proposed changes

Issue Number: close #10052

  1. this pr is used to add the array_join function.
  2. the usage is as below:
mysql> set enable_array_type=true;
mysql> set enable_vectorized_engine=true;

mysql> select k1, k2, array_join(k1, '_', 'null') from array_test order by k1;
+------+-----------------------------+------------------------------------+
| k1   | k2                          | array_join(`k2`, '_', 'null')      |
+------+-----------------------------+------------------------------------+
|  1   | [1, 2, 3, 4, 5]             | 1_2_3_4_5                          |
|  2   | [6, 7, 8]                   | 6_7_8                              |
|  3   | []                          |                                    |
|  4   | NULL                        | NULL                               |
|  5   | [1, 2, 3, 4, 5, 4, 3, 2, 1] | 1_2_3_4_5_4_3_2_1                  |
|  6   | [1, 2, 3, NULL]             | 1_2_3_null                         |
|  7   | [4, 5, 6, NULL, NULL]       | 4_5_6_null_null                    |
+------+-----------------------------+------------------------------------+

mysql> select k1, k2, array_join(k2, '_', 'null') from array_test01 order by k1;
+------+-----------------------------------+------------------------------------+
| k1   | k2                                | array_join(`k2`, '_', 'null')      |
+------+-----------------------------------+------------------------------------+
|  1   | ['a', 'b', 'c', 'd']              | a_b_c_d                            |
|  2   | ['e', 'f', 'g', 'h']              | e_f_g_h                            |
|  3   | [NULL, 'a', NULL, 'b', NULL, 'c'] | null_a_null_b_null_c               |
|  4   | ['d', 'e', NULL, ' ']             | d_e_null_                          |
|  5   | [' ', NULL, 'f', 'g']             |  _null_f_g                         |
+------+-----------------------------------+------------------------------------+

Problem summary

Describe your changes.

Checklist(Required)

  1. Does it affect the original behavior:
    • [ ] Yes
    • [x] No
    • [ ] I don't know
  2. Has unit tests been added:
    • [ ] Yes
    • [x] No
    • [ ] No Need
  3. Has document been added or modified:
    • [x] Yes
    • [ ] No
    • [ ] No Need
  4. Does it need to update dependencies:
    • [ ] Yes
    • [x] No
  5. Are there any changes that cannot be rolled back:
    • [ ] Yes (If Yes, please explain WHY)
    • [x] No

Further comments

If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...

carlvinhust2012 avatar Aug 01 '22 15:08 carlvinhust2012

the function is a agg function. we should use group_concat to do the work. like sum avg max

HappenLee avatar Aug 04 '22 08:08 HappenLee

the function is a agg function. we should use group_concat to do the work. like sum avg max -->We consider the compatibility with the hdfs ecosystem and follow the spark syntax. https://spark.apache.org/docs/latest/sql-ref-functions-builtin.html

carlvinhust2012 avatar Aug 05 '22 02:08 carlvinhust2012

PR approved by at least one committer and no changes requested.

github-actions[bot] avatar Aug 10 '22 11:08 github-actions[bot]

PR approved by anyone and no changes requested.

github-actions[bot] avatar Aug 10 '22 11:08 github-actions[bot]

LGTM

cambyzju avatar Aug 12 '22 14:08 cambyzju