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

TD-6129<feature> add tag?'key' in where logic

上级 2b419e64
......@@ -1117,7 +1117,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
char tmp[128]= {0};
sprintf(tmp, "tag value is too small, can not contain encoded json tag:%d|%d", kvRowLen(row), pTagSchema[spd.boundedColumns[0]].bytes);
tscDestroyBoundColumnInfo(&spd);
return tscSQLSyntaxErrMsg(pInsertParam->msg, tmp, NULL);
return tscInvalidOperationMsg(pInsertParam->msg, tmp, NULL);
}
}
tscDestroyBoundColumnInfo(&spd);
......
......@@ -4453,6 +4453,7 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_
const char* msg1 = "regular expression string should be less than %d characters";
const char* msg2 = "illegal column type for match/nmatch";
const char* msg3 = "invalid regular expression";
const char* msg4 = "json column type must encode by binary for match/nmatch";
tSqlExpr* pLeft = pExpr->pLeft;
tSqlExpr* pRight = pExpr->pRight;
......@@ -4471,7 +4472,7 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_
}
if(pLeft->tokenId == TK_ARROW && pSchema[index].type == TSDB_DATA_TYPE_JSON && !JSON_TYPE_BINARY){
return invalidOperationMsg(msgBuf, msg2);
return invalidOperationMsg(msgBuf, msg4);
}
if (!(pRight->type == SQL_NODE_VALUE && pRight->value.nType == TSDB_DATA_TYPE_BINARY)) {
......
......@@ -290,6 +290,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E) //"System error")
#define TSDB_CODE_QRY_JSON_KEY_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x070F) //"json tag key not exist")
#define TSDB_CODE_QRY_JSON_KEY_TYPE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0710) //"json tag key type not match")
#define TSDB_CODE_QRY_JSON_KEY_NOT_STR_ERROR TAOS_DEF_ERROR_CODE(0, 0x0711) //"json tag key must be string in match/nmatch")
// grant
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) //"License expired")
......
......@@ -3213,6 +3213,9 @@ int filterJsonTypeConvert(SFilterInfo* info) {
SFilterField *colLeft = FILTER_UNIT_LEFT_FIELD(info, &info->units[i]);
info->units[i].compare.type = FILTER_GET_COL_FIELD_TYPE(colLeft);
if((info->units[i].compare.optr == TSDB_RELATION_MATCH || info->units[i].compare.optr == TSDB_RELATION_NMATCH)
&& info->units[i].compare.type != TSDB_DATA_TYPE_BINARY)
return TSDB_CODE_QRY_JSON_KEY_NOT_STR_ERROR;
// SFilterField *colRight = FILTER_UNIT_RIGHT_FIELD(info, &info->units[i]);
// tVariant* var = colRight->desc;
// if(!tVariantTypeMatch(var, info->units[i].compare.type))
......
......@@ -296,6 +296,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_TIME_CONDITION, "One valid time range
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_SYS_ERROR, "System error")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JSON_KEY_NOT_EXIST, "json tag key not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JSON_KEY_TYPE_ERROR, "json tag key type not match")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JSON_KEY_NOT_STR_ERROR, "json tag key must be string in match/nmatch")
// grant
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, "License expired")
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, "DNode creation limited by licence")
......
......@@ -154,7 +154,15 @@ class TDTestCase:
tdSql.query("select * from db_json_tag_test.jsons1 where jtag->'location' in ('shanghai') and jtag->'class'=55")
tdSql.checkRows(1)
# test where condition match
tdSql.query("select * from db_json_tag_test.jsons1 where jtag->'location' match 'jin$'")
tdSql.checkRows(0)
tdSql.query("select * from db_json_tag_test.jsons1 where jtag->'location' match 'jin'")
tdSql.checkRows(2)
tdSql.error("select * from db_json_tag_test.jsons1 where jtag->'num' match '5'")
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册