Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[function] array_flatten #19819

Open
wangsimo0 opened this issue Mar 20, 2023 · 7 comments
Open

[function] array_flatten #19819

wangsimo0 opened this issue Mar 20, 2023 · 7 comments
Assignees

Comments

@wangsimo0
Copy link
Contributor

wangsimo0 commented Mar 20, 2023

need a function to flatten one layer of nested arrays.

description

Flattens an array(array(T)) to an array(T) by concatenating the contained arrays.

syntax

array_flatten(expr)

in which, expr is an nested array.

examples

SELECT array_flatten([[1, 2], [1, 4]]);
 [1,2,1,4]

select array_flatten([[[1],[2]],[[3],[4]]]);
 [[1], [2], [3], [4]] 

@chenlong1993
Copy link

I want try it

@wangxiaobaidu11
Copy link
Contributor

I want to take it

@kateshaowanjou
Copy link
Contributor

I want try it

Sorry I missed your message.😂 Can you take another one maybe? We appreciate your willingness to contribute to the community! ❤️

@wangsimo0 wangsimo0 added the good first issue Good for newcomers label May 12, 2023
@DionysusG
Copy link

@kateshaowanjou Can you assign this task to me? Also, can @wangsimo0 provide more design guides on the functions?
I am concerned with the following issues:

  1. What is the scenario in which we shall use the function? Wheteher we can make a recursive function?
  2. What do you mean by array? STL array? Or do you have your array implementation?
  3. How shall we decide the size of the flattened array? Decide in advance? Use a dynamic array to flatten the array in the first place?

@wangsimo0
Copy link
Contributor Author

Hi @DionysusG , thanks a lot!
I just modified the function's design. I think flatten one layer is more reasonable like snowflake and trino. and this will help us in trino's compatibility too. so it won't be a recursive function and I think it will make more sense and easier to implement. what do you think?

reference:
https://trino.io/docs/current/functions/array.html?highlight=flatten#flatten
https://docs.snowflake.com/en/sql-reference/functions/array_flatten

@sergeyshaykhullin
Copy link

Any workaround to flatten arrays in 3.1.x?

@sfwang218
Copy link
Contributor

sfwang218 commented May 27, 2024

@kateshaowanjou Excuse me, Has this issue been resolved? If not, can you assign it to me?

Sure, already did! If you have any questions, you are welcome to discuss with us. If you prefer to use wechat, here's the link:https://853921.ma3you.cn/articles/b12e90J/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants