-1

I have a hive table with schema

CREATE TABLE `temp_table`(
  `gpid` string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS TEXTFILE
LOCATION
  'wasbs://test@test.blob.core.windows.net/warehouse/test_data';

I am using airflow2 to add data into it. I need to override data each time job run so I tried using

INSERT OVERWRITE TABLE default.temp_table
select id from sometable

but I am getting issue

trino.exceptions.TrinoUserError: TrinoUserError(type=USER_ERROR, name=SYNTAX_ERROR, message="line 1:8: mismatched input 'OVERWRITE'. Expecting: 'INTO'", query_id=20210817_140454_00001_rbuac)

eshirvana
  • 23,227
  • 3
  • 22
  • 38
SHIVAM JINDAL
  • 2,844
  • 1
  • 17
  • 34

1 Answers1

3

From Trino Documentation:

By default, INSERT queries are not allowed to overwrite existing data. You can use the catalog session property insert_existing_partitions_behavior to allow overwrites. Prepend the name of the catalog using the Hive connector, for example hdfs, and set the property in the session before you run the insert query:

SET SESSION hdfs.insert_existing_partitions_behavior = 'OVERWRITE';
INSERT INTO hdfs.schema.table ...

The resulting behavior is equivalent to using INSERT OVERWRITE in Hive.

Insert overwrite operation is not supported by Trino when the table is stored on S3, encrypted HDFS or an external location. In such case deletebefore inserting.

leftjoin
  • 36,950
  • 8
  • 57
  • 116