Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Generate the nested array using the function "array_repeat".
val arr_repeat_df = df.withColumn("repeat", array_repeat($"array_col2", 2))
// flatten the nested array.
val arr_flat_df = arr_repeat_df
.withColumn("result", flatten($"repeat")).select("repeat", "result")
.select("repeat", "result")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment