Spark SQL: How to append new row to dataframe table (from another table)

前端 未结 2 995
予麋鹿
予麋鹿 2020-12-28 21:16

I am using Spark SQL with dataframes. I have an input dataframe, and I would like to append (or insert) its rows to a larger dataframe that has more columns. How would I do

2条回答
  •  一生所求
    2020-12-28 21:57

    Spark DataFrames are immutable so it is not possible to append / insert rows. Instead you can just add missing columns and use UNION ALL:

    output.unionAll(input.select($"*", lit(""), current_timestamp.cast("long")))
    

提交回复
热议问题