Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a update query in spark sql temp tables

I am trying the below code but it is throwing some random error that I am unable to understand:

df.registerTempTable("Temp_table")

spark.sql("Update Temp_table set column_a='1'")
like image 566
Rahul Avatar asked Oct 31 '25 19:10

Rahul


1 Answers

Currently spark sql does not support UPDATE statments. The workaround is to use create a delta lake / iceberg table using your spark dataframe and execute you sql query directly on this table.

For iceberg implementation refer to : https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-format-iceberg.html

like image 57
Francisco Rodrigues Avatar answered Nov 04 '25 16:11

Francisco Rodrigues