This file contains 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
import org.apache.spark.sql.functions._ |
This file contains 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
val initial_df = Seq( | |
("x", 4, 1), | |
("x", 6, 2), | |
("z", 7, 3), | |
("a", 3, 4), | |
("z", 5, 2), | |
("x", 7, 3), | |
("x", 9, 7), | |
("z", 1, 8), | |
("z", 4, 9), |
This file contains 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
full_df.printSchema() |
This file contains 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
val arr_contains_df = df.withColumn("result", array_contains($"array_col2", 3)) | |
arr_contains_df.show() |
This file contains 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
val arr_distinct_df = df.withColumn("result", array_distinct($"array_col2")) | |
arr_distinct_df.show() |
This file contains 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
val arr_except_df = full_df.withColumn("result", array_except($"array_col1", $"array_col2")) | |
arr_except_df.show() |
This file contains 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
val arr_intersect_df = full_df | |
.withColumn("result", array_intersect($"array_col1", $"array_col2")) | |
arr_intersect_df.show() |
This file contains 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
val arr_join_df = df.withColumn("result", array_join($"array_col2", ",")) | |
arr_join_df.show() |
This file contains 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
val arr_max_df = df.withColumn("result", array_max($"array_col2")) | |
arr_max_df.show() |
This file contains 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
val arr_min_df = df.withColumn("result", array_min($"array_col2")) | |
arr_min_df.show() |
OlderNewer