提交 855c7da9 编写于 作者: A Alex Duan

[TS-207]<fix>(query):doCompare fixed

上级 37bda43b
......@@ -750,7 +750,8 @@ int32_t jsonCompareUnit(const char* f1, const char* f2, bool* canReturn){
}
}
int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
int32_t
doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
if (type == TSDB_DATA_TYPE_JSON){
bool canReturn = true;
int32_t result = jsonCompareUnit(f1, f2, &canReturn);
......@@ -771,33 +772,8 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2));
case TSDB_DATA_TYPE_UINT: DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2));
case TSDB_DATA_TYPE_UBIGINT: DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2));
case TSDB_DATA_TYPE_NCHAR:{
tstr* t1 = (tstr*) f1;
tstr* t2 = (tstr*) f2;
if (t1->len != t2->len) {
return t1->len > t2->len? 1:-1;
}
int32_t ret = memcmp((wchar_t*) t1, (wchar_t*) t2, t2->len);
if (ret == 0) {
return ret;
}
return (ret < 0) ? -1 : 1;
}
default: { // todo refactor
tstr* t1 = (tstr*) f1;
tstr* t2 = (tstr*) f2;
if (t1->len != t2->len) {
return t1->len > t2->len? 1:-1;
} else {
int32_t ret = strncmp(t1->data, t2->data, t1->len);
if (ret == 0) {
return 0;
} else {
return ret < 0? -1:1;
}
}
}
case TSDB_DATA_TYPE_NCHAR: return compareLenPrefixedWStr(f1, f2);
default: // BINARY AND NULL AND SO ON
return compareLenPrefixedStr(f1, f2);
}
}
......@@ -117,15 +117,15 @@ class TDTestCase:
tdSql.execute('insert into D002 values("2021-11-17 20:31:31", 1, 3276, true, NULL, 3.32322, 4.982392323, "你好吗", "sdf", 333)')
tdSql.query('select mode(num) from d002 group by dbinary')
tdSql.checkRows(2)
tdSql.checkData(0, 0, 3276)
tdSql.checkData(1, 0, None)
tdSql.checkData(1, 0, 3276)
tdSql.checkData(0, 0, None)
tdSql.query('select mode(dfloat) from d002 group by dbinary')
tdSql.checkRows(2)
tdSql.checkData(0, 0, None)
tdSql.checkData(1, 0, None)
tdSql.query('select mode(dchar) from d002 group by dbinary')
tdSql.checkRows(2)
tdSql.checkData(0, 0, "你好吗")
tdSql.checkData(1, 0, "试试")
tdSql.checkData(1, 0, "你好吗")
tdSql.checkData(0, 0, "试试")
tdSql.query('select mode(dchar) from smode group by dchar')
tdSql.checkRows(4)
tdSql.query('select mode(dbool) from smode group by dchar')
......
......@@ -116,10 +116,10 @@ class TDTestCase:
#group by column
tdSql.query('select tail(dtiny,2) from tail2 group by dnchar')
tdSql.checkRows(5)
tdSql.checkData(0, 0, "2021-10-15 00:31:33")
tdSql.checkData(0, 1, 23)
tdSql.checkData(2, 0, "2021-12-24 00:31:34")
tdSql.checkData(2, 1, None)
tdSql.checkData(2, 0, "2021-10-15 00:31:33")
tdSql.checkData(2, 1, 23)
tdSql.checkData(1, 0, "2021-12-24 00:31:34")
tdSql.checkData(1, 1, None)
tdSql.checkData(4, 0, "2022-01-01 08:00:07")
tdSql.checkData(4, 1, 25)
tdSql.query('select tail(dtiny,2,1) from tail2 group by dnchar')
......@@ -130,7 +130,7 @@ class TDTestCase:
tdSql.checkData(0, 1, 123)
tdSql.checkData(2, 0, "2021-10-17 00:31:31")
tdSql.checkData(2, 1, 253)
tdSql.checkData(4, 0, "2022-01-01 08:00:07")
tdSql.checkData(6, 0, "2022-01-01 08:00:07")
tdSql.checkData(6, 1, 25)
tdSql.query('select tail(dtiny,2,1) from stail group by dnchar')
tdSql.checkRows(5)
......
......@@ -303,11 +303,11 @@ class TDTestCase:
tdSql.checkRows(10)
# > for binary type on tag
tdSql.query("select * from st where tagcol3 > '表'")
tdSql.query("select * from st where tagcol3 < '表'")
tdSql.checkRows(10)
# >= for binary type on tag
tdSql.query("select * from st where tagcol3 >= '表'")
tdSql.query("select * from st where tagcol3 <= '表'")
tdSql.checkRows(10)
# = for binary type on tag
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册