Edamame Edamame - 21 days ago 5
SQL Question

Impala query: Exception: Syntax error caused by cast function

I have the following Impala query

select session_id, max(cast(milli_ts) as integer), min(cast(milli_ts) as integer)from my_table group by session_id


But got the following errors:

HiveServer2Error: AnalysisException: Syntax error in line 10:
...sion_id, max(cast(milli_ts) as integer), min(cast(mill...
^
Encountered: )
Expected: AND, AS, BETWEEN, DIV, ILIKE, IN, IREGEXP, IS, LIKE, NOT, OR, REGEXP, RLIKE

CAUSED BY: Exception: Syntax error


Any idea what I missed? Thanks!

Answer

The correct syntax for CAST is as following:

cast(milli_ts as integer)