COPY INTO command is not working in command line terminal

81 views Asked by At

I want to incrementally load data into a delta table. However, my "COPY INTO" command is not working in spark sql prompt of command line terminal.

enter image description here

The same command is working in databricks.

enter image description here

Please let me know does this command only works in databricks environment.

1

There are 1 answers

4
Alex Ott On

The COPY INTO is a SQL statement specific to Databricks (docs), you can't use it with the open source Spark. But basically it's just a simplification of the following streaming code:

df = spark.readStream.format("parquet").load(input_path)
df = df.select(....) # optionally transform the input data
df.writeStream.format("delta")\ 
  .trigger(availableNow=True) \
  .option("checkpointLocation", "some location") \
  .start(output_path)