By using AWS re:Post, you agree to the AWS re:Post Terms of Use

ATHENA time data type support

0

Hi, I have a column with value in the format of HH:MM:SS so according to the documentation: https://docs.aws.amazon.com/athena/latest/ug/data-types-timestamps.html i should use time column however, i found only timestamp is supported, and if i use time, i would get syntax error. could this be supported soon? thanks

asked 24 days ago58 views
1 Answer
1
Accepted Answer

I apologize for the confusion, but there seems to be a misunderstanding regarding the TIME data type support in Amazon Athena. Let me clarify the situation for you.

Athena does indeed support the TIME data type, but there's a distinction between how it's used in DDL (Data Definition Language) statements and DML (Data Manipulation Language) queries.

For DDL statements like CREATE TABLE, Athena uses Apache Hive data type names. In this context, the TIME data type is not available.

However, for DML queries like SELECT, CTAS (Create Table As Select), and INSERT INTO, Athena uses Trino data type names. In these DML operations, the TIME data type is supported.

Specifically, for a column with values in the format HH:MM:SS, you can use the TIME data type in your DML queries. Athena expects the corresponding column or property of the data to be a string in the ISO format HH:MM:SS, or a built-in time type like those for Parquet or ORC.

If you're encountering a syntax error when using TIME, it's possible that you're trying to use it in a DDL statement where it's not supported. In such cases, you might need to use a different data type like STRING or VARCHAR for the column definition, and then cast it to TIME in your queries.

For example, you could define the column as VARCHAR in your CREATE TABLE statement, and then use CAST(column_name AS TIME) in your SELECT queries.

It's worth noting that Athena also supports TIME with specific precision (e.g., TIME(3)) and TIME WITH TIME ZONE for more advanced time-based operations in DML queries.

If you continue to experience issues, you may want to double-check your query syntax or consult the latest Athena documentation, as features and supported data types can evolve over time.
Sources
Supported column data types - Amazon Athena
Work with timestamp data - Amazon Athena
Data types in Amazon Athena - Amazon Athena

profile picture
answered 24 days ago
profile picture
EXPERT
reviewed 22 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions