Skip to content

Commit a4c9815

Browse files
authored
Merge pull request #36 from awslabs/read-athena-tz
Add support for timestamp with time zone for read from Athena
2 parents 8c15804 + 4b39295 commit a4c9815

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

awswrangler/athena.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def get_query_columns_metadata(self, query_execution_id):
2525
def get_query_dtype(self, query_execution_id):
2626
cols_metadata = self.get_query_columns_metadata(
2727
query_execution_id=query_execution_id)
28+
logger.debug(f"cols_metadata: {cols_metadata}")
2829
dtype = {}
2930
parse_timestamps = []
3031
parse_dates = []

awswrangler/data_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def athena2pandas(dtype):
1818
return "bool"
1919
elif dtype in ["string", "char", "varchar"]:
2020
return "str"
21-
elif dtype == "timestamp":
21+
elif dtype in ["timestamp", "timestamp with time zone"]:
2222
return "datetime64"
2323
elif dtype == "date":
2424
return "date"

testing/test_awswrangler/test_pandas.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,3 +742,14 @@ def test_to_parquet_with_cast_null(
742742
sleep(2)
743743
assert len(dataframe.index) == len(dataframe2.index)
744744
assert len(list(dataframe.columns)) == len(list(dataframe2.columns))
745+
746+
747+
def test_read_sql_athena_with_time_zone(session, bucket, database):
748+
dataframe = session.pandas.read_sql_athena(
749+
sql=
750+
"select current_timestamp as value, typeof(current_timestamp) as type",
751+
database=database)
752+
assert len(dataframe.index) == 1
753+
assert len(dataframe.columns) == 2
754+
assert dataframe["type"][0] == "timestamp with time zone"
755+
assert dataframe["value"][0].year == datetime.utcnow().year

0 commit comments

Comments
 (0)