Re: How to explode array columns of a dataframe having the same length

2023-02-19 Thread 404
sql: select inline(arrays_zip(col1, col2, col3)) as (c1, c2, c3) from t1 Replied Message | From | Enrico Minack | | Date | 02/16/2023 16:06 | | To | , sam smith | | Subject | Re: How to explode array columns of a dataframe having the same length | You have to take each row and

Re: How to explode array columns of a dataframe having the same length

2023-02-16 Thread Vikas Kumar
I think these 4 steps should help: Use zip Explode Withcolumn (getelement of array) Drop the array column Thanks On Thu, Feb 16, 2023, 2:18 PM sam smith wrote: > @Enrico Minack I used arrays_zip to merge values > into one row, and then used toJSON() to export the data. > @Bjørn explode_oute

Re: How to explode array columns of a dataframe having the same length

2023-02-16 Thread sam smith
@Enrico Minack I used arrays_zip to merge values into one row, and then used toJSON() to export the data. @Bjørn explode_outer didn't yield the expected results. Thanks anyway. Le jeu. 16 févr. 2023 à 09:06, Enrico Minack a écrit : > You have to take each row and zip the lists, each element of

Re: How to explode array columns of a dataframe having the same length

2023-02-16 Thread Bjørn Jørgensen
Use explode_outer() when rows have null values. tor. 16. feb. 2023 kl. 16:48 skrev Navneet : > I am not expert, may be try if this works: > In order to achieve the desired output using the explode() method in > Java, you can create a User-Defined Function (UDF) that zips the lists > in each row a

Re: How to explode array columns of a dataframe having the same length

2023-02-16 Thread Navneet
I am not expert, may be try if this works: In order to achieve the desired output using the explode() method in Java, you can create a User-Defined Function (UDF) that zips the lists in each row and returns the resulting list. Here's an example implementation: typescript Copy code import org.apach

Re: How to explode array columns of a dataframe having the same length

2023-02-16 Thread Enrico Minack
You have to take each row and zip the lists, each element of the result becomes one new row. So turn write a method that turns   Row(List("A","B","null"), List("C","D","null"), List("E","null","null")) into   List(List("A","C","E"), List("B","D","null"), List("null","null","null")) and use flatm

How to explode array columns of a dataframe having the same length

2023-02-14 Thread sam smith
Hello guys, I have the following dataframe: *col1* *col2* *col3* ["A","B","null"] ["C","D","null"] ["E","null","null"] I want to explode it to the following dataframe: *col1* *col2* *col3* "A" "C" "E" "B" "D" "null" "null" "null" "null" How to do that (preferably in Java) using