Open jmao-denver opened 1 year ago
from datetime import datetime
from typing import List, Any
import numpy as np
import pandas as pd
import pyarrow as pa
from deephaven import arrow as dharrow, dtypes, new_table, time_table
def verify_type_conversion(self, pa_types: List[pa.DataType], pa_data: List[Any]):
fields = [pa.field(f"f{i}", ty) for i, ty in enumerate(pa_types)]
schema = pa.schema(fields)
pa_table = pa.table(pa_data, schema=schema)
dh_table = dharrow.to_table(pa_table)
arrow_table = dharrow.to_arrow(dh_table)
print(pa_table.equals(arrow_table))
pa_types = [
pa.time64('ns'),
pa.date32(),
pa.timestamp('ns', tz='Europe/Paris'),
]
pa_data = [
pa.array([1_000_001, 1_000_002]),
pa.array([datetime(2022, 12, 7), datetime(2022, 12, 30)]),
pa.array([pd.Timestamp('2017-01-01T12:01:01', tz='UTC'),
pd.Timestamp('2017-01-01T11:01:01', tz='Europe/Paris')]),
]
verify_type_conversion(pa_types=pa_types, pa_data=pa_data)
This should work in the WebUI's Python console with the PR #3216 checked out.
Should support timestamp
with and without a timezone specified.
These problems were discovered in testing the new arrow module in Python on the supposedly supported Arrow data types. 'timestamp' round-trip doesn't work if it starts from Arrow with a tz other than UTC.
Also the following Arrow types appear to be reasonable to support