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

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

上级 e01c569e
......@@ -89,7 +89,10 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) {
STR_WITH_MAXSIZE_TO_VARSTR(dst, type, pField->bytes);
int32_t bytes = pSchema[i].bytes;
if (pSchema[i].type == TSDB_DATA_TYPE_BINARY || pSchema[i].type == TSDB_DATA_TYPE_NCHAR) {
if (pSchema[i].type == TSDB_DATA_TYPE_BINARY || (pSchema[i].type == TSDB_DATA_TYPE_JSON && JSON_TYPE_BINARY)){
bytes -= VARSTR_HEADER_SIZE;
}
else if(pSchema[i].type == TSDB_DATA_TYPE_NCHAR || (pSchema[i].type == TSDB_DATA_TYPE_JSON && JSON_TYPE_NCHAR)) {
bytes -= VARSTR_HEADER_SIZE;
if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) {
......
......@@ -5325,7 +5325,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
char tagVal[TSDB_MAX_TAGS_LEN] = {0};
int32_t outLen = 0;
if (JSON_TYPE_BINARY){
strncpy(tagVal, item->string, strlen(item->string));
strncpy(varDataVal(tagVal), item->string, strlen(item->string));
outLen = strlen(item->string);
}else if(JSON_TYPE_NCHAR){
if (!taosMbsToUcs4(item->string, strlen(item->string), varDataVal(tagVal), TSDB_MAX_TAGS_LEN - VARSTR_HEADER_SIZE, &outLen)) {
......@@ -5344,7 +5344,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
*tagVal = jsonType2DbType(0, item->type); // type
char* tagData = POINTER_SHIFT(tagVal,CHAR_BYTES);
if (JSON_TYPE_BINARY){
strncpy(tagVal, item->valuestring, strlen(item->valuestring));
strncpy(varDataVal(tagData), item->valuestring, strlen(item->valuestring));
outLen = strlen(item->valuestring);
}else if(JSON_TYPE_NCHAR) {
if (!taosMbsToUcs4(item->valuestring, strlen(item->valuestring), varDataVal(tagData),
......
......@@ -7181,7 +7181,6 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
type = pExprInfo[j].base.resType;
bytes = pExprInfo[j].base.resBytes;
char* tagJsonElementData = NULL;
dst = pColInfo->pData + count * pExprInfo[j].base.resBytes;
if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
data = tsdbGetTableName(item->pTable);
......@@ -7189,7 +7188,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
if(type == TSDB_DATA_TYPE_JSON){
data = tsdbGetTableTagVal(item->pTable, pExprInfo[j].base.colInfo.colId, type, bytes);
if(pExprInfo[j].base.numOfParams > 0){ // tag-> operation
tagJsonElementData = calloc(bytes, 1);
char* tagJsonElementData = calloc(bytes, 1);
findTagValue(item->pTable, pExprInfo[j].base.param[0].pz, pExprInfo[j].base.param[0].nLen, tagJsonElementData, bytes);
*dst = SELECT_ELEMENT_JSON_TAG; // select tag->element
dst++;
......
......@@ -281,8 +281,8 @@ void taosArrayClear(SArray* pArray) {
void* taosArrayDestroy(SArray* pArray) {
if (pArray) {
free(pArray->pData);
free(pArray);
tfree(pArray->pData);
tfree(pArray);
}
return NULL;
......
......@@ -142,6 +142,18 @@ class TDTestCase:
tdSql.query("select *,tbname from db_json_tag_test.jsons1 where (jtag->'location' like 'bei%' or jtag->'num'=34) and jtag->'class'=55")
tdSql.checkRows(0)
# test where condition in
tdSql.query("select * from db_json_tag_test.jsons1 where jtag->'location' in ('beijing')")
tdSql.checkRows(2)
tdSql.query("select * from db_json_tag_test.jsons1 where jtag->'num' in (5,34)")
tdSql.checkRows(2)
tdSql.error("select * from db_json_tag_test.jsons1 where jtag->'num' in ('5',34)")
tdSql.query("select * from db_json_tag_test.jsons1 where jtag->'location' in ('shanghai') and jtag->'class'=55")
tdSql.checkRows(1)
def stop(self):
tdSql.close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册