Search code examples
sqlhiveprestotrinohive-partitions

Insert into static hive partition using Presto


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)


Solution

  • 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 
    ...