Skip to content

Commit c32a62f

Browse files
committedMar 6, 2023
PHOENIX-4664 Time Python driver tests failing
1 parent 76dc256 commit c32a62f

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed
 

‎python-phoenixdb/phoenixdb/tests/test_types.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ def test_boolean(self):
142142
self.assertEqual(cursor.description[1].type_code, phoenixdb.BOOLEAN)
143143
self.assertEqual(cursor.fetchall(), [[1, True], [2, False], [3, None], [4, True], [5, False], [6, None]])
144144

145-
@unittest.skip("https://issues.apache.org/jira/browse/PHOENIX-4664")
146145
def test_time(self):
147146
self.createTable("phoenixdb_test_tbl1", "CREATE TABLE {table} (id integer primary key, val time)")
148147
with self.conn.cursor() as cursor:
@@ -172,7 +171,6 @@ def test_time_full(self):
172171
[2, datetime.datetime(2015, 7, 12, 13, 1, 2, 123000)],
173172
])
174173

175-
@unittest.skip("https://issues.apache.org/jira/browse/PHOENIX-4664")
176174
def test_date(self):
177175
self.createTable("phoenixdb_test_tbl1", "CREATE TABLE {table} (id integer primary key, val date)")
178176
with self.conn.cursor() as cursor:
@@ -194,8 +192,8 @@ def test_date_full(self):
194192
cursor.execute("UPSERT INTO phoenixdb_test_tbl1 VALUES (2, ?)", [datetime.datetime(2015, 7, 12, 13, 1, 2, 123000)])
195193
cursor.execute("SELECT id, val FROM phoenixdb_test_tbl1 ORDER BY id")
196194
self.assertEqual(cursor.fetchall(), [
197-
[1, datetime.datetime(2015, 7, 12, 13, 1, 2, 123000)],
198-
[2, datetime.datetime(2015, 7, 12, 13, 1, 2, 123000)],
195+
[1, datetime.datetime(2015, 7, 12)],
196+
[2, datetime.datetime(2015, 7, 12)],
199197
])
200198

201199
def test_date_null(self):
@@ -209,7 +207,6 @@ def test_date_null(self):
209207
[2, None],
210208
])
211209

212-
@unittest.skip("https://issues.apache.org/jira/browse/PHOENIX-4664")
213210
def test_timestamp(self):
214211
self.createTable("phoenixdb_test_tbl1", "CREATE TABLE {table} (id integer primary key, val timestamp)")
215212
with self.conn.cursor() as cursor:

‎python-phoenixdb/phoenixdb/types.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,11 @@ def date_to_java_sql_date(d):
8484

8585

8686
def datetime_from_java_sql_timestamp(n):
87-
return datetime.datetime(1970, 1, 1) + datetime.timedelta(milliseconds=n)
87+
return datetime.datetime.utcfromtimestamp(n/1000.0)
8888

8989

9090
def datetime_to_java_sql_timestamp(d):
91-
td = d - datetime.datetime(1970, 1, 1)
92-
return td.microseconds // 1000 + (td.seconds + td.days * 24 * 3600) * 1000
91+
return int(d.replace(tzinfo=datetime.timezone.utc).timestamp()*1000)
9392

9493

9594
# FIXME This doesn't seem to be used anywhere in the code

0 commit comments

Comments
 (0)