Skip to content

Commit 9521731

Browse files
authored
Merge pull request #41 from awslabs/improve-exception-info
Improving exception info
2 parents e32a147 + 24b542f commit 9521731

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

awswrangler/glue.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from awswrangler import data_types
66
from awswrangler.athena import Athena
7-
from awswrangler.exceptions import UnsupportedFileFormat, InvalidSerDe, ApiError
7+
from awswrangler.exceptions import UnsupportedFileFormat, InvalidSerDe, ApiError, UnsupportedType
88

99
logger = logging.getLogger(__name__)
1010

@@ -192,7 +192,10 @@ def _build_schema(dataframe,
192192
else:
193193
schema_built.append((name, cast_columns[name]))
194194
else:
195-
athena_type = data_types.pyarrow2athena(dtype)
195+
try:
196+
athena_type = data_types.pyarrow2athena(dtype)
197+
except UnsupportedType:
198+
raise UnsupportedType(f"Unsupported Pyarrow type for column {name}: {dtype}")
196199
if name in partition_cols:
197200
partition_cols_types[name] = athena_type
198201
else:

testing/test_awswrangler/test_pandas.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy
1010

1111
from awswrangler import Session, Pandas
12-
from awswrangler.exceptions import LineTerminatorNotFound, EmptyDataframe, InvalidSerDe
12+
from awswrangler.exceptions import LineTerminatorNotFound, EmptyDataframe, InvalidSerDe, UnsupportedType
1313

1414
logging.basicConfig(
1515
level=logging.INFO,
@@ -864,3 +864,21 @@ def test_to_parquet_duplicated_columns(
864864
assert len(list(dataframe.columns)) == len(list(dataframe2.columns))
865865
assert dataframe2.columns[0] == "a"
866866
assert dataframe2.columns[1] == "c"
867+
868+
869+
def test_to_parquet_with_pyarrow_null_type(
870+
session,
871+
bucket,
872+
database,
873+
):
874+
dataframe = pandas.DataFrame({
875+
"a": [1, 2, 3],
876+
"b": [4, 5, 6],
877+
"col_null": [None, None, None],
878+
"c": [7, 8, 9],
879+
})
880+
with pytest.raises(UnsupportedType):
881+
assert session.pandas.to_parquet(dataframe=dataframe,
882+
database=database,
883+
path=f"s3://{bucket}/test/",
884+
mode="overwrite")

0 commit comments

Comments
 (0)