Skip to content

Commit

Permalink
fix: Add pyarrow date64/time64('ns') to the list of supported Arrow d…
Browse files Browse the repository at this point in the history
…ata types in the Python client (deephaven#6048)

related to deephaven#6044

The DH server is now able to convert between Arrow date64/time64 and
Java LocalDate/LocalTime. The Python client needs to include the mapping
of these two types when building Arrow schema for uploading Arrow data
to the server.
  • Loading branch information
jmao-denver authored Sep 25, 2024
1 parent 6982984 commit 33d955e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions py/client/pydeephaven/_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
pa.time32('s'): '',
pa.time32('ms'): '',
pa.time64('us'): '',
pa.time64('ns'): '',
pa.time64('ns'): 'java.time.LocalTime',
pa.timestamp('s'): '',
pa.timestamp('ms'): '',
pa.timestamp('us'): '',
pa.timestamp('ns'): 'java.time.Instant',
pa.date32(): '',
pa.date64(): '',
pa.date64(): 'java.time.LocalDate',
pa.duration('s'): '',
pa.duration('ms'): '',
pa.duration('us'): '',
Expand Down
17 changes: 14 additions & 3 deletions py/client/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def test_import_table_long_csv(self):
df = pa_table2.to_pandas()
self.assertEquals(1000, len(df.index))

@unittest.skip("GH ticket filed #941.")
def test_import_table_time64(self):
pa_array = pa.array([1, 2], type=pa.time64('ns'))
pa_record_batch = pa.RecordBatch.from_arrays([pa_array], names=['f1'])
Expand Down Expand Up @@ -187,8 +186,8 @@ def test_import_table_strings(self):
self.assertEqual(0, len(exception_list))

@unittest.skip("GH ticket filed #941.")
def test_import_table_dates(self):
types = [pa.date32(), pa.date64()]
def test_import_table_date32(self):
types = [pa.date32()]
exception_list = []
for t in types:
pa_array = pa.array([1245, 123456], type=t)
Expand All @@ -203,6 +202,18 @@ def test_import_table_dates(self):

self.assertEqual(0, len(exception_list))

def test_import_table_date64(self):
from datetime import datetime
pa_date1 = pa.scalar(datetime(2012, 1, 1), type=pa.date64())
pa_date2 = pa.scalar(datetime(2022, 11, 11), type=pa.date64())
pa_array = pa.array([pa_date1, pa_date2], type=pa.date64())

pa_record_batch = pa.RecordBatch.from_arrays([pa_array], names=['f1'])
pa_table = pa.Table.from_batches([pa_record_batch])
new_table = self.session.import_table(pa_table)
pa_table2 = new_table.to_arrow()
self.assertEqual(pa_table, pa_table2)

def test_input_table(self):
pa_types = [
pa.bool_(),
Expand Down

0 comments on commit 33d955e

Please sign in to comment.