0

I'm creating the table the following way:

spark.sql("CREATE TABLE IF NOT EXISTS table USING DELTA AS SELECT * FROM origin")

But i get this error:

Exception in thread "main" org.apache.spark.SparkException: Table implementation does not support writes: table

Vincent Doba
  • 4,343
  • 3
  • 22
  • 42
NachoAG
  • 3
  • 6

1 Answers1

0

You get this SparkException error because this way to create a delta-lake table using a SQL request as input data is not implemented.

If you want to create a delta-lake table and insert data in the same time, you should use DataFrameWriter API, as explained in databricks documentation:

spark.sql("SELECT * FROM origin")
  .write
  .format("delta")
  .save("/path/to/where/you/want/to/save/your/data")
Vincent Doba
  • 4,343
  • 3
  • 22
  • 42
  • Thanks for your answer, I was really confused by this other documentation (https://spark.apache.org/docs/latest/sql-ref-syntax-ddl-create-table-hiveformat.html) but your solution seems to work :) – NachoAG Sep 01 '21 at 08:10