Insert into static hive partition using Presto
Asked Answered
B

1

7

Suppose I want to INSERT INTO a static hive partition, can I do that with Presto?

The PARTITION keyword is only for hive.

INSERT INTO TABLE Employee PARTITION (department='HR') 

Caused by: com.facebook.presto.sql.parser.ParsingException: line 1:44: mismatched input 'PARTITION'. Expecting: '(', at com.facebook.presto.sql.parser.ErrorHandler.syntaxError(ErrorHandler.java:109)

Boscage answered 20/5, 2020 at 22:39 Comment(0)
C
5

In Presto you do not need PARTITION(department='HR').

INSERT INTO Employee (name, department)
VALUES  ('John', 'HR');

or

INSERT INTO Employee (name, department)
select 
      name, 
      'HR' 
from 
...
Concelebrate answered 21/5, 2020 at 5:58 Comment(2)
INSERT INTO is good enough. TABLE clause is not neededReefer
This works, everybody. Make sure to use single quotes in presto, I just spent several minutes trying to figure out what didn't work, turns out presto didn't like double quotes.Jellify

© 2022 - 2024 — McMap. All rights reserved.