Add pyarrow date and timestamp type conversion from pydantic (#576)

This commit is contained in:
Prashanth Rao
2023-10-16 22:42:24 -04:00
committed by Weston Pace
parent f4ac47e1b5
commit d38e3d496f
2 changed files with 28 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ import inspect
import sys
import types
from abc import ABC, abstractmethod
from datetime import date, datetime
from typing import Any, Callable, Dict, Generator, List, Type, Union, _GenericAlias
import numpy as np
@@ -159,6 +160,10 @@ def _py_type_to_arrow_type(py_type: Type[Any]) -> pa.DataType:
return pa.bool_()
elif py_type == bytes:
return pa.binary()
elif py_type == date:
return pa.date32()
elif py_type == datetime:
return pa.timestamp("us")
raise TypeError(
f"Converting Pydantic type to Arrow Type: unsupported type {py_type}"
)