Skip to content

Commit fd9f24a

Browse files
committed
Fix Athena read with ctas_approach=False and chunksize=True #458
1 parent 1d6da61 commit fd9f24a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

awswrangler/athena/_read.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import datetime
55
import logging
66
import re
7+
import sys
78
import uuid
89
from typing import Any, Dict, Iterator, List, Match, NamedTuple, Optional, Union
910

@@ -699,6 +700,7 @@ def read_sql_query(
699700
"(https://github.com/awslabs/aws-data-wrangler/blob/master/"
700701
"tutorials/006%20-%20Amazon%20Athena.ipynb)"
701702
)
703+
chunksize = sys.maxsize if ctas_approach is False and chunksize is True else chunksize
702704
session: boto3.Session = _utils.ensure_session(session=boto3_session)
703705

704706
cache_info: _CacheInfo = _check_for_cached_results(

tests/test_athena.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,3 +804,9 @@ def test_athena_ctas_data_source(glue_database):
804804
sql = "SELECT nan() AS nan, infinity() as inf, -infinity() as inf_n, 1.2 as regular"
805805
with pytest.raises(wr.exceptions.InvalidArgumentCombination):
806806
wr.athena.read_sql_query(sql, glue_database, True, data_source="foo")
807+
808+
809+
def test_chunked_ctas_false(glue_database):
810+
sql = "SELECT 1 AS foo, 2 AS boo"
811+
df_iter = wr.athena.read_sql_query(sql, database=glue_database, ctas_approach=False, chunksize=True)
812+
assert len(list(df_iter)) == 1

0 commit comments

Comments
 (0)