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

fix bugs and add test case

上级 8f768263
...@@ -4979,8 +4979,9 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql ...@@ -4979,8 +4979,9 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
tSqlExpr *rexpr = NULL; tSqlExpr *rexpr = NULL;
if ((*pExpr)->tokenId == TK_NE && (pSchema->type != TSDB_DATA_TYPE_BINARY if ((*pExpr)->tokenId == TK_NE && (pSchema->type != TSDB_DATA_TYPE_BINARY
&& pSchema->type != TSDB_DATA_TYPE_NCHAR && pSchema->type != TSDB_DATA_TYPE_NCHAR
&& pSchema->type != TSDB_DATA_TYPE_BOOL)) { && pSchema->type != TSDB_DATA_TYPE_BOOL
handleNeOptr(&rexpr, *pExpr); //todo json check && pSchema->type != TSDB_DATA_TYPE_JSON)) {
handleNeOptr(&rexpr, *pExpr);
*pExpr = rexpr; *pExpr = rexpr;
} }
...@@ -9907,7 +9908,10 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS ...@@ -9907,7 +9908,10 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
// NOTE: binary|nchar data allows the >|< type filter // NOTE: binary|nchar data allows the >|< type filter
if ((*pExpr)->_node.optr != TSDB_RELATION_EQUAL && (*pExpr)->_node.optr != TSDB_RELATION_NOT_EQUAL) { if ((*pExpr)->_node.optr != TSDB_RELATION_EQUAL && (*pExpr)->_node.optr != TSDB_RELATION_NOT_EQUAL) {
if (pRight != NULL && pRight->nodeType == TSQL_NODE_VALUE) { if (pRight != NULL && pRight->nodeType == TSQL_NODE_VALUE) {
if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL && pLeft->pSchema->type == TSDB_DATA_TYPE_BOOL) { if (pLeft->_node.optr == TSDB_RELATION_ARROW){
pLeft = pLeft->_node.pLeft;
}
if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL && (pLeft->pSchema->type == TSDB_DATA_TYPE_BOOL || pLeft->pSchema->type == TSDB_DATA_TYPE_JSON)) {
return TSDB_CODE_TSC_INVALID_OPERATION; return TSDB_CODE_TSC_INVALID_OPERATION;
} }
} }
......
...@@ -62,15 +62,23 @@ filter_desc_compare_func gDescCompare [FLD_TYPE_MAX] = { ...@@ -62,15 +62,23 @@ filter_desc_compare_func gDescCompare [FLD_TYPE_MAX] = {
}; };
bool filterRangeCompGi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { bool filterRangeCompGi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
int32_t result = cfunc(maxv, minr);
if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false;
return cfunc(maxv, minr) >= 0; return cfunc(maxv, minr) >= 0;
} }
bool filterRangeCompGe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { bool filterRangeCompGe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
int32_t result = cfunc(maxv, minr);
if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false;
return cfunc(maxv, minr) > 0; return cfunc(maxv, minr) > 0;
} }
bool filterRangeCompLi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { bool filterRangeCompLi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
int32_t result = cfunc(minv, maxr);
if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false;
return cfunc(minv, maxr) <= 0; return cfunc(minv, maxr) <= 0;
} }
bool filterRangeCompLe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { bool filterRangeCompLe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
int32_t result = cfunc(minv, maxr);
if (result == TSDB_DATA_JSON_CAN_NOT_COMPARE) return false;
return cfunc(minv, maxr) < 0; return cfunc(minv, maxr) < 0;
} }
bool filterRangeCompii (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { bool filterRangeCompii (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
...@@ -2990,6 +2998,42 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows ...@@ -2990,6 +2998,42 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
return all; return all;
} }
static void doJsonCompare(SFilterComUnit *cunit, int8_t *result, void* colData){
if(cunit->optr == TSDB_RELATION_MATCH || cunit->optr == TSDB_RELATION_NMATCH){
uint8_t jsonType = *(char*)colData;
char* realData = colData + CHAR_BYTES;
if (jsonType != TSDB_DATA_TYPE_NCHAR){
*result = false;
}else{
char *newColData = calloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1);
int len = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), varDataVal(newColData));
varDataSetLen(newColData, len);
tVariant* val = cunit->valData;
char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0};
assert(val->nLen <= TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE);
memcpy(varDataVal(newValData), val->pz, val->nLen);
varDataSetLen(newValData, val->nLen);
*result = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, newValData);
tfree(newColData);
}
}else if(cunit->optr == TSDB_RELATION_LIKE){
uint8_t jsonType = *(char*)colData;
char* realData = colData + CHAR_BYTES;
if (jsonType != TSDB_DATA_TYPE_NCHAR){
*result = false;
}else{
tVariant* val = cunit->valData;
char* newValData = calloc(val->nLen + VARSTR_HEADER_SIZE, 1);
memcpy(varDataVal(newValData), val->pz, val->nLen);
varDataSetLen(newValData, val->nLen);
*result = filterDoCompare(gDataCompare[cunit->func], cunit->optr, realData, newValData);
tfree(newValData);
}
}else{
*result = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
}
}
bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols) { bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols) {
SFilterInfo *info = (SFilterInfo *)pinfo; SFilterInfo *info = (SFilterInfo *)pinfo;
bool all = true; bool all = true;
...@@ -3056,39 +3100,7 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat ...@@ -3056,39 +3100,7 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData); (*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData);
tfree(newColData); tfree(newColData);
}else if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_JSON){ }else if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_JSON){
if(info->cunits[uidx].optr == TSDB_RELATION_MATCH || info->cunits[uidx].optr == TSDB_RELATION_NMATCH){ doJsonCompare(&(info->cunits[uidx]), &(*p)[i], colData);
uint8_t jsonType = *(char*)colData;
char* realData = colData + CHAR_BYTES;
if (jsonType != TSDB_DATA_TYPE_NCHAR){
(*p)[i] = false;
}else{
char *newColData = calloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1);
int len = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), varDataVal(newColData));
varDataSetLen(newColData, len);
tVariant* val = info->cunits[uidx].valData;
char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0};
assert(val->nLen <= TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE);
memcpy(varDataVal(newValData), val->pz, val->nLen);
varDataSetLen(newValData, val->nLen);
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, newValData);
tfree(newColData);
}
}else if(info->cunits[uidx].optr == TSDB_RELATION_LIKE){
uint8_t jsonType = *(char*)colData;
char* realData = colData + CHAR_BYTES;
if (jsonType != TSDB_DATA_TYPE_NCHAR){
(*p)[i] = false;
}else{
tVariant* val = info->cunits[uidx].valData;
char* newValData = calloc(val->nLen + VARSTR_HEADER_SIZE, 1);
memcpy(varDataVal(newValData), val->pz, val->nLen);
varDataSetLen(newValData, val->nLen);
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, realData, newValData);
tfree(newValData);
}
}else{
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData);
}
}else{ }else{
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData); (*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData);
} }
...@@ -3101,7 +3113,6 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat ...@@ -3101,7 +3113,6 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
return all; return all;
} }
bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols) { bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols) {
SFilterInfo *info = (SFilterInfo *)pinfo; SFilterInfo *info = (SFilterInfo *)pinfo;
bool all = true; bool all = true;
...@@ -3146,39 +3157,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis * ...@@ -3146,39 +3157,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData); (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData);
tfree(newColData); tfree(newColData);
}else if(cunit->dataType == TSDB_DATA_TYPE_JSON){ }else if(cunit->dataType == TSDB_DATA_TYPE_JSON){
if(cunit->optr == TSDB_RELATION_MATCH || cunit->optr == TSDB_RELATION_NMATCH){ doJsonCompare(cunit, &(*p)[i], colData);
uint8_t jsonType = *(char*)colData;
char* realData = colData + CHAR_BYTES;
if (jsonType != TSDB_DATA_TYPE_NCHAR){
(*p)[i] = false;
}else{
char *newColData = calloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1);
int len = taosUcs4ToMbs(varDataVal(realData), varDataLen(realData), varDataVal(newColData));
varDataSetLen(newColData, len);
tVariant* val = cunit->valData;
char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0};
assert(val->nLen <= TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE);
memcpy(varDataVal(newValData), val->pz, val->nLen);
varDataSetLen(newValData, val->nLen);
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, newValData);
tfree(newColData);
}
}else if(cunit->optr == TSDB_RELATION_LIKE){
uint8_t jsonType = *(char*)colData;
char* realData = colData + CHAR_BYTES;
if (jsonType != TSDB_DATA_TYPE_NCHAR){
(*p)[i] = false;
}else{
tVariant* val = cunit->valData;
char* newValData = calloc(val->nLen + VARSTR_HEADER_SIZE, 1);
memcpy(varDataVal(newValData), val->pz, val->nLen);
varDataSetLen(newValData, val->nLen);
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, realData, newValData);
tfree(newValData);
}
}else{
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
}
}else{ }else{
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
} }
......
...@@ -4106,11 +4106,9 @@ static int32_t queryByJsonTag(STable* pTable, void* filterInfo, SArray* res){ ...@@ -4106,11 +4106,9 @@ static int32_t queryByJsonTag(STable* pTable, void* filterInfo, SArray* res){
} }
} }
} }
if(tabList == NULL || taosArrayGetSize(tabList) == 0){ if(tabList == NULL){
tsdbError("json key not exist, no candidate table"); tsdbError("json key not exist, no candidate table");
terrno = TSDB_CODE_TDB_NO_JSON_TAG_KEY; return TSDB_CODE_SUCCESS;
taosArrayDestroy(tabList);
return TSDB_CODE_TDB_NO_JSON_TAG_KEY;
} }
int32_t size = taosArrayGetSize(tabList); int32_t size = taosArrayGetSize(tabList);
int8_t *addToResult = NULL; int8_t *addToResult = NULL;
......
...@@ -146,6 +146,9 @@ class TDTestCase: ...@@ -146,6 +146,9 @@ class TDTestCase:
# test where with json tag # test where with json tag
tdSql.error("select * from jsons1_1 where jtag is not null") tdSql.error("select * from jsons1_1 where jtag is not null")
tdSql.error("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'")
tdSql.error("select * from jsons1 where jtag->'tag1'={}")
# where json value is string # where json value is string
tdSql.query("select * from jsons1 where jtag->'tag2'='beijing'") tdSql.query("select * from jsons1 where jtag->'tag2'='beijing'")
tdSql.checkRows(2) tdSql.checkRows(2)
...@@ -161,6 +164,19 @@ class TDTestCase: ...@@ -161,6 +164,19 @@ class TDTestCase:
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1'='收到货'") tdSql.query("select * from jsons1 where jtag->'tag1'='收到货'")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select * from jsons1 where jtag->'tag2'>'beijing'")
tdSql.checkRows(1)
tdSql.query("select * from jsons1 where jtag->'tag2'>='beijing'")
tdSql.checkRows(3)
tdSql.query("select * from jsons1 where jtag->'tag2'<'beijing'")
tdSql.checkRows(2)
tdSql.query("select * from jsons1 where jtag->'tag2'<='beijing'")
tdSql.checkRows(4)
tdSql.query("select * from jsons1 where jtag->'tag2'!='beijing'")
tdSql.checkRows(3)
tdSql.query("select * from jsons1 where jtag->'tag2'=''")
tdSql.checkRows(2)
# where json value is int # where json value is int
tdSql.query("select * from jsons1 where jtag->'tag1'=5") tdSql.query("select * from jsons1 where jtag->'tag1'=5")
tdSql.checkRows(1) tdSql.checkRows(1)
...@@ -169,12 +185,58 @@ class TDTestCase: ...@@ -169,12 +185,58 @@ class TDTestCase:
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1'<54") tdSql.query("select * from jsons1 where jtag->'tag1'<54")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query("select * from jsons1 where jtag->'tag1'<=11")
tdSql.checkRows(3)
tdSql.query("select * from jsons1 where jtag->'tag1'>4")
tdSql.checkRows(2)
tdSql.query("select * from jsons1 where jtag->'tag1'>=5")
tdSql.checkRows(2)
tdSql.query("select * from jsons1 where jtag->'tag1'!=5")
tdSql.checkRows(2)
tdSql.query("select * from jsons1 where jtag->'tag1'!=55")
tdSql.checkRows(3)
# where json value is double # where json value is double
tdSql.query("select * from jsons1 where jtag->'tag1'=1.232") tdSql.query("select * from jsons1 where jtag->'tag1'=1.232")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select * from jsons1 where jtag->'tag1'<1.232")
tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1'<=1.232")
tdSql.checkRows(1)
tdSql.query("select * from jsons1 where jtag->'tag1'>1.23")
tdSql.checkRows(3)
tdSql.query("select * from jsons1 where jtag->'tag1'>=1.232")
tdSql.checkRows(3)
tdSql.query("select * from jsons1 where jtag->'tag1'!=1.232")
tdSql.checkRows(2)
tdSql.query("select * from jsons1 where jtag->'tag1'!=3.232")
tdSql.checkRows(3)
tdSql.error("select * from jsons1 where jtag->'tag1'/0=3")
tdSql.error("select * from jsons1 where jtag->'tag1'/5=1")
# where json value is bool
tdSql.query("select * from jsons1 where jtag->'tag1'=true")
tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1'=false")
tdSql.checkRows(1)
tdSql.query("select * from jsons1 where jtag->'tag1'!=false")
tdSql.checkRows(0)
tdSql.error("select * from jsons1 where jtag->'tag1'>false")
# where json value is null # where json value is null
tdSql.query("select * from jsons1 where jtag->'tag1'=null") tdSql.query("select * from jsons1 where jtag->'tag1'=null") # only json suport =null. This synatx will change later.
tdSql.checkRows(1) tdSql.checkRows(1)
# where json is null
tdSql.query("select * from jsons1 where jtag is null")
tdSql.checkRows(1)
tdSql.query("select * from jsons1 where jtag is not null")
tdSql.checkRows(8)
# where json key is null
tdSql.query("select * from jsons1 where jtag->'tag_no_exist'=3")
tdSql.checkRows(0)
# where json value is not exist # where json value is not exist
tdSql.query("select * from jsons1 where jtag->'tag1' is null") tdSql.query("select * from jsons1 where jtag->'tag1' is null")
tdSql.checkData(0, 0, 'jsons1_9') tdSql.checkData(0, 0, 'jsons1_9')
...@@ -184,55 +246,42 @@ class TDTestCase: ...@@ -184,55 +246,42 @@ class TDTestCase:
tdSql.query("select * from jsons1 where jtag->'tag3' is not null") tdSql.query("select * from jsons1 where jtag->'tag3' is not null")
tdSql.checkRows(4) tdSql.checkRows(4)
# test ?
# test json tag in where condition with and/or/? tdSql.query("select * from jsons1 where jtag?'tag1'")
tdSql.query("select * from jsons1 where jtag->'location'!='beijing'") tdSql.checkRows(8)
tdSql.checkRows(1) tdSql.query("select * from jsons1 where jtag?'tag3'")
tdSql.checkRows(4)
tdSql.query("select jtag->'num' from jsons1 where jtag->'level'='l1'") tdSql.query("select * from jsons1 where jtag?'tag_no_exist'")
tdSql.checkData(0, 0, 34)
# test json number value
tdSql.query("select *,tbname from jsons1 where jtag->'class'>5 and jtag->'class'<9")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select *,tbname from jsons1 where jtag->'class'>5 and jtag->'class'<92") # test json tag in where condition with and/or
tdSql.checkRows(1) tdSql.query("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='beijing'")
# test where condition
tdSql.query("select * from jsons1 where jtag?'sex' or jtag?'num'")
tdSql.checkRows(3)
tdSql.query("select * from jsons1 where jtag?'sex' or jtag?'numww'")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select * from jsons1 where jtag->'tag1'=false or jtag->'tag2'='beijing'")
tdSql.query("select * from jsons1 where jtag?'sex' and jtag?'num'")
tdSql.checkRows(0)
tdSql.query("select jtag->'sex' from jsons1 where jtag?'sex' or jtag?'num'")
tdSql.checkRows(3)
tdSql.query("select *,tbname from jsons1 where jtag->'location'='beijing'")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'")
tdSql.query("select *,tbname from jsons1 where jtag->'num'=5 or jtag?'sex'") tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'")
tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35")
tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35")
tdSql.checkRows(0)
tdSql.query("select * from jsons1 where jtag->'tag1' is not null and jtag?'tag3'")
tdSql.checkRows(4)
tdSql.query("select * from jsons1 where jtag->'tag1'='femail' and jtag?'tag3'")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select *,tbname from jsons1 where jtag->'num'=5") # test with tbname/normal cloumn
tdSql.checkRows(1)
# test with tbname
tdSql.query("select * from jsons1 where tbname = 'jsons1_1'") tdSql.query("select * from jsons1 where tbname = 'jsons1_1'")
tdSql.checkRows(1) tdSql.checkRows(2)
tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag?'tag3'")
tdSql.query("select * from jsons1 where tbname = 'jsons1_1' or jtag?'num'") tdSql.checkRows(2)
tdSql.checkRows(3) tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag?'tag3' and dataint=3")
tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag?'num'")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select * from jsons1 where tbname = 'jsons1_1' and jtag?'tag3' and dataint=23")
tdSql.checkRows(1)
tdSql.query("select * from jsons1 where tbname = 'jsons1_1' or jtag->'num'=5")
tdSql.checkRows(2)
# test where condition like # test where condition like
tdSql.query("select *,tbname from jsons1 where jtag->'location' like 'bei%'") tdSql.query("select *,tbname from jsons1 where jtag->'location' like 'bei%'")
...@@ -298,11 +347,7 @@ class TDTestCase: ...@@ -298,11 +347,7 @@ class TDTestCase:
tdSql.query("select jtag from jsons1 where jtag->'k2'=true") tdSql.query("select jtag from jsons1 where jtag->'k2'=true")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select jtag from jsons1 where jtag is null")
tdSql.checkRows(4)
tdSql.query("select jtag from jsons1 where jtag is not null")
tdSql.checkRows(6)
tdSql.query("select * from jsons1 where jtag->'location' is not null") tdSql.query("select * from jsons1 where jtag->'location' is not null")
tdSql.checkRows(3) tdSql.checkRows(3)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册