Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awswrangler/_data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def athena2pyarrow(dtype: str, df_type: str | None = None) -> pa.DataType: # no
return pa.timestamp(unit="ns")
if dtype == "date":
return pa.date32()
if dtype in ("binary" or "varbinary"):
if dtype in ("binary", "varbinary"):
return pa.binary()
if dtype.startswith("decimal") is True:
precision, scale = dtype.replace("decimal(", "").replace(")", "").split(sep=",")
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/test_data_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pyarrow as pa
import pytest

from awswrangler._data_types import athena2pandas, athena2pyarrow
from awswrangler.exceptions import UnsupportedType


@pytest.mark.parametrize(
"dtype,expected",
[
("binary", pa.binary()),
("varbinary", pa.binary()),
("BINARY", pa.binary()),
("VARBINARY", pa.binary()),
],
)
def test_athena2pyarrow_binary_types(dtype, expected):
assert athena2pyarrow(dtype) == expected


@pytest.mark.parametrize("dtype", ["i", "n", "ary", "bin"])
def test_athena2pyarrow_rejects_binary_substrings(dtype):
with pytest.raises(UnsupportedType, match=f"Unsupported Athena type: {dtype}"):
athena2pyarrow(dtype)


@pytest.mark.parametrize("dtype", ["binary", "varbinary"])
def test_athena2pandas_binary_types(dtype):
assert athena2pandas(dtype) == "bytes"