Merge pull request #23807 from taosdata/FIX/TS-4258
Fix bug [4258]: add process ignore/no timezone for timetruncate unit …
This commit is contained in:
commit
e7fbe0279f
|
@ -1457,13 +1457,29 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
||||||
}
|
}
|
||||||
case 604800000: { /* 1w */
|
case 604800000: { /* 1w */
|
||||||
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
timeVal = timeVal / 1000 / 604800 * 604800 * 1000;
|
if (ignoreTz) {
|
||||||
|
timeVal = timeVal - (timeVal + offsetFromTz(timezone, 1000)) % (((int64_t)604800) * 1000);
|
||||||
|
} else {
|
||||||
|
timeVal = timeVal / 1000 / 604800 * 604800 * 1000;
|
||||||
|
}
|
||||||
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
timeVal = timeVal / 1000000 / 604800 * 604800 * 1000000;
|
if (ignoreTz) {
|
||||||
|
timeVal = timeVal - (timeVal + offsetFromTz(timezone, 1000000)) % (((int64_t)604800) * 1000000);
|
||||||
|
} else {
|
||||||
|
timeVal = timeVal / 1000000 / 604800 * 604800 * 1000000;
|
||||||
|
}
|
||||||
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
timeVal = timeVal / 1000000000 / 604800 * 604800 * 1000000000;
|
if (ignoreTz) {
|
||||||
|
timeVal = timeVal - (timeVal + offsetFromTz(timezone, 1000000000)) % (((int64_t)604800) * 1000000000);
|
||||||
|
} else {
|
||||||
|
timeVal = timeVal / 1000000000 / 604800 * 604800 * 1000000000;
|
||||||
|
}
|
||||||
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
timeVal = timeVal * factor / factor / 604800 * 604800 * factor;
|
if (ignoreTz) {
|
||||||
|
timeVal = timeVal - (timeVal + offsetFromTz(timezone, 1)) % (((int64_t)604800L) * factor);
|
||||||
|
} else {
|
||||||
|
timeVal = timeVal * factor / factor / 604800 * 604800 * factor;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
colDataSetNULL(pOutput->columnData, i);
|
colDataSetNULL(pOutput->columnData, i);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -58,7 +58,11 @@ class TDTestCase:
|
||||||
elif unit.lower() == '1w':
|
elif unit.lower() == '1w':
|
||||||
for i in range(len(self.ts_str)):
|
for i in range(len(self.ts_str)):
|
||||||
ts_result = self.get_time.get_ms_timestamp(str(tdSql.queryResult[i][0]))
|
ts_result = self.get_time.get_ms_timestamp(str(tdSql.queryResult[i][0]))
|
||||||
tdSql.checkEqual(ts_result,int(date_time[i]/1000/60/60/24/7)*7*24*60*60*1000)
|
if ignore_tz == 0:
|
||||||
|
tdSql.checkEqual(ts_result,int(date_time[i]/1000/60/60/24/7)*7*24*60*60*1000)
|
||||||
|
else:
|
||||||
|
# assuming the client timezone is UTC+0800
|
||||||
|
tdSql.checkEqual(ts_result,int(date_time[i] - (date_time[i] + 8 * 3600 * 1000) % (86400 * 7 * 1000)))
|
||||||
|
|
||||||
def check_us_timestamp(self,unit,date_time, ignore_tz):
|
def check_us_timestamp(self,unit,date_time, ignore_tz):
|
||||||
if unit.lower() == '1u':
|
if unit.lower() == '1u':
|
||||||
|
@ -92,7 +96,11 @@ class TDTestCase:
|
||||||
elif unit.lower() == '1w':
|
elif unit.lower() == '1w':
|
||||||
for i in range(len(self.ts_str)):
|
for i in range(len(self.ts_str)):
|
||||||
ts_result = self.get_time.get_us_timestamp(str(tdSql.queryResult[i][0]))
|
ts_result = self.get_time.get_us_timestamp(str(tdSql.queryResult[i][0]))
|
||||||
tdSql.checkEqual(ts_result,int(date_time[i]/1000/1000/60/60/24/7)*7*24*60*60*1000*1000)
|
if ignore_tz == 0:
|
||||||
|
tdSql.checkEqual(ts_result,int(date_time[i]/1000/1000/60/60/24/7)*7*24*60*60*1000*1000)
|
||||||
|
else:
|
||||||
|
# assuming the client timezone is UTC+0800
|
||||||
|
tdSql.checkEqual(ts_result,int(date_time[i] - (date_time[i] + 8 * 3600 * 1000000) % (86400 * 7 * 1000000)))
|
||||||
|
|
||||||
def check_ns_timestamp(self,unit,date_time, ignore_tz):
|
def check_ns_timestamp(self,unit,date_time, ignore_tz):
|
||||||
if unit.lower() == '1b':
|
if unit.lower() == '1b':
|
||||||
|
@ -130,7 +138,11 @@ class TDTestCase:
|
||||||
elif unit.lower() == '1w':
|
elif unit.lower() == '1w':
|
||||||
for i in range(len(self.ts_str)):
|
for i in range(len(self.ts_str)):
|
||||||
if self.rest_tag != 'rest':
|
if self.rest_tag != 'rest':
|
||||||
tdSql.checkEqual(tdSql.queryResult[i][0],int(date_time[i]*1000/1000/1000/1000/1000/60/60/24/7)*7*24*60*60*1000*1000*1000)
|
if ignore_tz == 0:
|
||||||
|
tdSql.checkEqual(tdSql.queryResult[i][0],int(date_time[i]*1000/1000/1000/1000/1000/60/60/24/7)*7*24*60*60*1000*1000*1000)
|
||||||
|
else:
|
||||||
|
# assuming the client timezone is UTC+0800
|
||||||
|
tdSql.checkEqual(tdSql.queryResult[i][0],int(date_time[i] - (date_time[i] + 8 * 3600 * 1000000000) % (86400 * 7 * 1000000000)))
|
||||||
|
|
||||||
def check_tb_type(self,unit,tb_type,ignore_tz):
|
def check_tb_type(self,unit,tb_type,ignore_tz):
|
||||||
if tb_type.lower() == 'ntb':
|
if tb_type.lower() == 'ntb':
|
||||||
|
|
Loading…
Reference in New Issue