Skip to content

Commit

Permalink
Fix mypy error
Browse files Browse the repository at this point in the history
  • Loading branch information
eliabrio committed Sep 5, 2024
1 parent b159e3f commit ea43b45
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions awswrangler/_data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import numpy as np
import pandas as pd
import pyarrow as pa
import pyarrow.parquet

from awswrangler import _arrow, exceptions
from awswrangler._distributed import engine
Expand Down Expand Up @@ -306,7 +305,7 @@ def _split_map(s: str) -> list[str]:
return parts


def athena2pyarrow(dtype: str, df_type: str = None) -> pa.DataType: # noqa: PLR0911,PLR0912
def athena2pyarrow(dtype: str, df_type: str | None = None) -> pa.DataType: # noqa: PLR0911,PLR0912
"""Athena to PyArrow data types conversion."""
dtype = dtype.strip()
if dtype.startswith(("array", "struct", "map")):
Expand All @@ -329,18 +328,16 @@ def athena2pyarrow(dtype: str, df_type: str = None) -> pa.DataType: # noqa: PLR
if (dtype in ("string", "uuid")) or dtype.startswith("char") or dtype.startswith("varchar"):
return pa.string()
if dtype == "timestamp":
if df_type:
match df_type:
case "datetime64[s]":
return pa.timestamp(unit="s")
case "datetime64[ms]":
return pa.timestamp(unit="ms")
case "datetime64[us]":
return pa.timestamp(unit="us")
case "datetime64[ns]":
return pa.timestamp(unit="ns")
case _:
return pa.timestamp(unit="ns")
if df_type == "datetime64[ns]":
return pa.timestamp(unit="ns")
elif df_type == "datetime64[us]":
return pa.timestamp(unit="us")
elif df_type == "datetime64[ms]":
return pa.timestamp(unit="ms")
elif df_type == "datetime64[s]":
return pa.timestamp(unit="s")
else:
return pa.timestamp(unit="ns")
if dtype == "date":
return pa.date32()
if dtype in ("binary" or "varbinary"):
Expand Down

0 comments on commit ea43b45

Please sign in to comment.