Search code examples
sqlamazon-web-serviceshiveamazon-emr

Error while inserting into: no viable alternative at input 'with'


I'm getting the error

org.apache.spark.sql.catalyst.parser.ParseException: No viable alternative at input 'with' to insert in a table.

while executing the following insert query:

INSERT INTO users partition(date)
WITH existentes AS (SELECT COUNT(1) AS name FROM users WHERE date=20160303)

I would appreciate any help.


Solution

  • Try changing the order:

    WITH existentes AS (SELECT COUNT(1) AS name FROM users WHERE date=20160303)
    INSERT INTO users partition(date)