Amazon Athena: no viable alternative at input

萝らか妹 提交于 2019-12-18 12:06:01

问题


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:


This error generally occurs when the syntax of DDL has some silly errors.There are several answers that explain different errors based on there state.The simple solution to this problem is to patiently look into DDL and verify following points line by line:-

  1. Check for missing commas
  2. Unbalanced `(backtick operator)
  3. Incompatible datatype not supported by HIVE(HIVE DATA TYPES REFERENCE)
  4. Unbalanced comma
  5. Hypen in table name



回答4:


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.




回答5:


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




回答6:


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




回答7:


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




回答8:


My case: it was an external table and the location had a typo (hence didn't exist)

Couple of tips:

  • Click the "Format query" button so you can spot errors easily
  • Use the example at the bottom of the documentation - it works - and modify it with your parameters: https://docs.aws.amazon.com/athena/latest/ug/create-table.html


来源:https://stackoverflow.com/questions/40912086/amazon-athena-no-viable-alternative-at-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!