Мы can't
вставляем данные во временную таблицу, но мы можем имитировать c вставку с помощью union all
(или) union
(для удаления дубликатов).
Example:
#create temp view
spark.sql("""create or replace temporary view temp_view_t as select 1 as no, 'aaa' as str""")
spark.sql("select * from temp_view_t").show()
#+---+---+
#| no|str|
#+---+---+
#| 1|aaa|
#+---+---+
#union all with the new data
spark.sql("""create or replace temporary view temp_view_t as select * from temp_view_t union all select 2 as no, 'bbb' as str""")
spark.sql("select * from temp_view_t").show()
#+---+---+
#| no|str|
#+---+---+
#| 1|aaa|
#| 2|bbb|
#+---+---+
#to eliminate duplicates we can use union also.
spark.sql("""create or replace temporary view temp_view_t as select * from temp_view_t union select 1 as no, 'aaa' as str""")
spark.sql("select * from temp_view_t").show()
#+---+---+
#| no|str|
#+---+---+
#| 1|aaa|
#| 2|bbb|
#+---+---+