in awswrangler/_data_types.py [0:0]
def athena2pandas(dtype: str, dtype_backend: str | None = None) -> str: # noqa: PLR0911
"""Athena to Pandas data types conversion."""
dtype = dtype.lower()
if dtype == "tinyint":
return "Int8" if dtype_backend != "pyarrow" else "int8[pyarrow]"
if dtype == "smallint":
return "Int16" if dtype_backend != "pyarrow" else "int16[pyarrow]"
if dtype in ("int", "integer"):
return "Int32" if dtype_backend != "pyarrow" else "int32[pyarrow]"
if dtype == "bigint":
return "Int64" if dtype_backend != "pyarrow" else "int64[pyarrow]"
if dtype in ("float", "real"):
return "float32" if dtype_backend != "pyarrow" else "double[pyarrow]"
if dtype == "double":
return "float64" if dtype_backend != "pyarrow" else "double[pyarrow]"
if dtype == "boolean":
return "boolean" if dtype_backend != "pyarrow" else "bool[pyarrow]"
if (dtype == "string") or dtype.startswith("char") or dtype.startswith("varchar"):
return "string" if dtype_backend != "pyarrow" else "string[pyarrow]"
if dtype in ("timestamp", "timestamp with time zone"):
return "datetime64" if dtype_backend != "pyarrow" else "timestamp[ns][pyarrow]"
if dtype == "date":
return "date" if dtype_backend != "pyarrow" else "date32[pyarrow]"
if dtype == "time":
# Pandas does not have a type for time of day, so we are returning a string.
# However, if the backend is pyarrow, we can return time32[ms]
return "string" if dtype_backend != "pyarrow" else "time32[ms][pyarrow]"
if dtype.startswith("decimal"):
return "decimal" if dtype_backend != "pyarrow" else "double[pyarrow]"
if dtype in ("binary", "varbinary"):
return "bytes" if dtype_backend != "pyarrow" else "binary[pyarrow]"
if any(dtype.startswith(t) for t in ["array", "row", "map", "struct", "json"]):
return "object"
if dtype == "geometry":
return "string"
raise exceptions.UnsupportedType(f"Unsupported Athena type: {dtype}")