提交 ccbf0fdb 编写于 作者: wmmhello's avatar wmmhello

enable different value type of the same key in json

上级 de52faff
......@@ -756,9 +756,15 @@ int32_t tagValCompar(const void* p1, const void* p2) {
}else if(!f1IsJsonNull && f2IsJsonNull) {
return 1;
}
if(*t1->tag != *t2->tag) {
if(*t1->tag != *t2->tag && !(IS_NUMERIC_TYPE(*t1->tag) && IS_NUMERIC_TYPE(*t2->tag))) {
return 1;
}
if(*t1->tag == TSDB_DATA_TYPE_BIGINT && *t2->tag == TSDB_DATA_TYPE_DOUBLE){
DEFAULT_DOUBLE_COMP(GET_INT64_VAL(t1->tag + CHAR_BYTES), GET_DOUBLE_VAL(t2->tag + CHAR_BYTES));
}else if(*t1->tag == TSDB_DATA_TYPE_DOUBLE && *t2->tag == TSDB_DATA_TYPE_BIGINT){
DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(t1->tag + CHAR_BYTES), GET_INT64_VAL(t2->tag + CHAR_BYTES));
}
__compar_fn_t func = getComparFunc(t1->tag[0], 0);
return func(t1->tag + CHAR_BYTES, t2->tag + CHAR_BYTES);
}
......
......@@ -386,9 +386,15 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
}else if(!f1IsJsonNull && f2IsJsonNull) {
return 1;
}
if(*f1 != *f2) {
if(*f1 != *f2 && !(IS_NUMERIC_TYPE(*f1) && IS_NUMERIC_TYPE(*f2))) {
return 1;
}
if(*f1 == TSDB_DATA_TYPE_BIGINT && *f2 == TSDB_DATA_TYPE_DOUBLE){
DEFAULT_DOUBLE_COMP(GET_INT64_VAL(f1 + CHAR_BYTES), GET_DOUBLE_VAL(f2 + CHAR_BYTES));
}else if(*f1 == TSDB_DATA_TYPE_DOUBLE && *f2 == TSDB_DATA_TYPE_BIGINT){
DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1 + CHAR_BYTES), GET_INT64_VAL(f2 + CHAR_BYTES));
}
type = *f1;
f1 += CHAR_BYTES;
f2 += CHAR_BYTES;
......
......@@ -220,9 +220,6 @@ int32_t compareLenPrefixedWStrDesc(const void* pLeft, const void* pRight) {
}
int32_t compareJsonVal(const void *pLeft, const void *pRight) {
if(*(char*)pLeft == TSDB_DATA_TYPE_BINARY){ // json null
return -1;
}
const tVariant* right = pRight;
if(right->nType != *(char*)pLeft && !(IS_NUMERIC_TYPE(right->nType) && IS_NUMERIC_TYPE(*(char*)pLeft)))
return TSDB_DATA_JSON_CAN_NOT_COMPARE;
......@@ -244,8 +241,10 @@ int32_t compareJsonVal(const void *pLeft, const void *pRight) {
return ret;
}
return (ret < 0) ? -1 : 1;
}else if(type == TSDB_DATA_TYPE_BINARY) { //json null
return 0;
}else{
assert(0);
assert(0);
}
}
......@@ -636,9 +635,14 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
}else if(!f1IsJsonNull && f2IsJsonNull) {
return 1;
}
if(*f1 != *f2) {
if(*f1 != *f2 && !(IS_NUMERIC_TYPE(*f1) && IS_NUMERIC_TYPE(*f2))) {
return 1;
}
if(*f1 == TSDB_DATA_TYPE_BIGINT && *f2 == TSDB_DATA_TYPE_DOUBLE){
DEFAULT_DOUBLE_COMP(GET_INT64_VAL(f1 + CHAR_BYTES), GET_DOUBLE_VAL(f2 + CHAR_BYTES));
}else if(*f1 == TSDB_DATA_TYPE_DOUBLE && *f2 == TSDB_DATA_TYPE_BIGINT){
DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1 + CHAR_BYTES), GET_INT64_VAL(f2 + CHAR_BYTES));
}
type = *f1;
f1 += CHAR_BYTES;
f2 += CHAR_BYTES;
......
......@@ -167,6 +167,8 @@ class TDTestCase:
tdSql.checkData(0, 1, 2)
tdSql.query("select * from jsons1 where jtag->'tag1'=10")
tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1'<54")
tdSql.checkRows(3)
# where json value is double
tdSql.query("select * from jsons1 where jtag->'tag1'=1.232")
tdSql.checkRows(1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册