Feature/sangshuduo/td 4752 python support ns (#6534)
* [TD-4752]<feature>: python connector support nanosecond. * [TD-4752]<feature>: support nanosecond in test framework. return integer for nanosecond in connector since python does not support nanosecond yet.
This commit is contained in:
parent
b364ae65f3
commit
945354280c
|
@ -15,7 +15,7 @@ def _convert_microsecond_to_datetime(micro):
|
|||
|
||||
|
||||
def _convert_nanosecond_to_datetime(nanosec):
|
||||
return datetime.datetime.fromtimestamp(nanosec / 1000000000.0)
|
||||
return nanosec
|
||||
|
||||
|
||||
def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN):
|
||||
|
|
|
@ -18,6 +18,7 @@ import datetime
|
|||
import inspect
|
||||
import psutil
|
||||
import shutil
|
||||
import pandas as pd
|
||||
from util.log import *
|
||||
|
||||
|
||||
|
@ -136,7 +137,14 @@ class TDSql:
|
|||
def checkData(self, row, col, data):
|
||||
self.checkRowCol(row, col)
|
||||
if self.queryResult[row][col] != data:
|
||||
if self.cursor.istype(col, "TIMESTAMP") and self.queryResult[row][col] == datetime.datetime.fromisoformat(data):
|
||||
if self.cursor.istype(col, "TIMESTAMP"):
|
||||
# suppose user want to check nanosecond timestamp if a longer data passed
|
||||
if (len(data) >= 28):
|
||||
if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data):
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
else:
|
||||
if self.queryResult[row][col] == datetime.datetime.fromisoformat(data):
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue