dataengref errors

Home / Hive / Query compilation

Hive: ParseException: cannot recognize input near

org.apache.hadoop.hive.ql.parse.ParseExceptionFAILED: ParseException line 1:7 cannot recognize input near 'date' ',' 'amount' in select clause

The parser hit tokens it did not expect. The three tokens quoted after "near" show where parsing stopped; the mistake is at or just before them. Reserved words used as identifiers and syntax from other SQL dialects are the common causes.

Causes · Fixes · Source

Common causes

  1. A reserved keyword such as date, timestamp, user or order is used as a column or table name without backticks.How to confirm: One of the quoted tokens is a keyword used as a name.
  2. Syntax from another dialect, for example TOP n, a trailing comma before FROM, or a missing alias on a subquery in FROM.How to confirm: The quoted tokens sit right after the construct that Hive does not support.

How to fix it

Quote reserved words with backticks.

SELECT `date`, `user` FROM events;

Rewrite unsupported constructs: use LIMIT instead of TOP, remove trailing commas, and alias every subquery in FROM.

Where the message comes from

Message template in the source: cannot recognize input near

References

Related errors

Last checked: