Amazon Athena: no viable alternative at input

2019-03-23 09:00发布

问题:

While creating a table in Athena; it gives me following exception:

no viable alternative at input

回答1:

hyphens are not allowed in table name.. ( though wizard allows it ) .. Just remove hyphen and it works like a charm



回答2:

Unfortunately, at the moment the syntax validation error messages are not very descriptive in Athena, this error may mean "almost" any possible syntax errors on the create table statement.

Although this is annoying at the moment you will need to check if the syntax follows the Create table documentation

Some examples are:

  • Backticks not in place (as already pointed out)
  • Missing/extra commas (remember that the last column doesn't need the comma after column definition
  • Missing spaces
  • More ..


回答3:

In my case, it was an extra comma in PARTITIONED BY section,



回答4:

In my case, I was missing the singlequotes for the S3 URL



回答5:

In my case, it was because of a trailing comma after the last column in the table. For example:

CREATE EXTERNAL TABLE IF NOT EXISTS my_table (
  one STRING,
  two STRING,
) LOCATION 's3://my-bucket/some/path';

After I removed the comma at the end of two STRING, it worked fine.



回答6:

In my case, it was that one of the table column names was enclosed in single quotes, as per the AWS documentation :( ('bucket')