Amazon Athena: no viable alternative at input

后端 未结 12 1578
-上瘾入骨i
-上瘾入骨i 2020-12-14 05:15

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

no viable alternative at input

相关标签:
12条回答
  • 2020-12-14 06:03

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

    0 讨论(0)
  • 2020-12-14 06:06

    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
    0 讨论(0)
  • 2020-12-14 06:08

    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.

    0 讨论(0)
  • 2020-12-14 06:08

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

    0 讨论(0)
  • 2020-12-14 06:13

    This happened to me due to having comments in the query.

    I realized this was a possibility when I tried the "Format Query" button and it turned the entire thing into almost 1 line, mostly commented out. My guess is that the query parser runs this formatter before sending the query to Athena.

    Removed the comments, ran the query, and an angel got its wings!

    0 讨论(0)
  • Slashes. Mine was slashes. I had the DDL from Athena, saved as a python string.

    WITH SERDEPROPERTIES ( 
      'escapeChar'='\\', 
      'quoteChar'='\"',
      'separatorChar'=',')  
    

    was changed to

    WITH SERDEPROPERTIES ( 
      'escapeChar'='\', 
      'quoteChar'='"',
      'separatorChar'=',')
    

    And everything fell apart.

    Had to make it:

    WITH SERDEPROPERTIES (
      'escapeChar'='\\\\', 
      'quoteChar'='\\\"',
      'separatorChar'=',')
    
    0 讨论(0)
提交回复
热议问题