fix: ignore NULL tag

This commit is contained in:
kailixu 2023-12-04 20:08:46 +08:00
parent 210a304cc1
commit 08be3d790c
8 changed files with 31 additions and 2 deletions

View File

@ -700,7 +700,8 @@ static int32_t parseBoundTagsClause(SInsertParseContext* pCxt, SVnodeModifyOpStm
static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, SSchema* pTagSchema, SToken* pToken, static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, SSchema* pTagSchema, SToken* pToken,
SArray* pTagName, SArray* pTagVals, STag** pTag) { SArray* pTagName, SArray* pTagVals, STag** pTag) {
if (!isNullValue(pTagSchema->type, pToken)) { bool isNull = isNullValue(pTagSchema->type, pToken);
if (!isNull) {
taosArrayPush(pTagName, pTagSchema->name); taosArrayPush(pTagName, pTagSchema->name);
} }
@ -709,13 +710,15 @@ static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStm
return buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", pToken->z); return buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", pToken->z);
} }
if (isNullValue(pTagSchema->type, pToken)) { if (isNull) {
return tTagNew(pTagVals, 1, true, pTag); return tTagNew(pTagVals, 1, true, pTag);
} else { } else {
return parseJsontoTagData(pToken->z, pTagVals, pTag, &pCxt->msg); return parseJsontoTagData(pToken->z, pTagVals, pTag, &pCxt->msg);
} }
} }
if (isNull) return 0;
STagVal val = {0}; STagVal val = {0};
int32_t code = int32_t code =
parseTagToken(ppSql, pToken, pTagSchema, pStmt->pTableMeta->tableInfo.precision, &val, &pCxt->msg); parseTagToken(ppSql, pToken, pTagSchema, pStmt->pTableMeta->tableInfo.precision, &val, &pCxt->msg);

View File

@ -17,6 +17,7 @@ sql create table mt_bigint (ts timestamp, c bigint) tags (tagname bigint)
## case 00: static create table for test tag values ## case 00: static create table for test tag values
sql create table st_bigint_0 using mt_bigint tags (NULL) sql create table st_bigint_0 using mt_bigint tags (NULL)
sql show create table st_bigint_0
sql show tags from st_bigint_0 sql show tags from st_bigint_0
if $data05 != NULL then if $data05 != NULL then
return -1 return -1
@ -173,6 +174,7 @@ endi
## case 02: dynamic create table for test tag values ## case 02: dynamic create table for test tag values
sql insert into st_bigint_16 using mt_bigint tags (NULL) values (now, NULL) sql insert into st_bigint_16 using mt_bigint tags (NULL) values (now, NULL)
sql show create table st_bigint_16
sql show tags from st_bigint_16 sql show tags from st_bigint_16
if $data05 != NULL then if $data05 != NULL then
return -1 return -1

View File

@ -17,6 +17,7 @@ sql create table mt_bool (ts timestamp, c bool) tags (tagname bool)
## case 00: static create table for test tag values ## case 00: static create table for test tag values
sql create table st_bool_0 using mt_bool tags (NULL) sql create table st_bool_0 using mt_bool tags (NULL)
sql show create table st_bool_0
sql show tags from st_bool_0 sql show tags from st_bool_0
if $data05 != NULL then if $data05 != NULL then
print ==1== expect: NULL, actually: $data05 print ==1== expect: NULL, actually: $data05
@ -291,6 +292,7 @@ endi
## case 02: dynamic create table for test tag values ## case 02: dynamic create table for test tag values
sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL) sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL)
sql show create table st_bool_16
sql show tags from st_bool_16 sql show tags from st_bool_16
if $data05 != NULL then if $data05 != NULL then
print ==33== expect: NULL, actually: $data00 print ==33== expect: NULL, actually: $data00

View File

@ -17,6 +17,7 @@ sql create table mt_float (ts timestamp, c float) tags (tagname float)
## case 00: static create table for test tag values ## case 00: static create table for test tag values
sql create table st_float_0 using mt_float tags (NULL) sql create table st_float_0 using mt_float tags (NULL)
sql show create table st_float_0
sql show tags from st_float_0 sql show tags from st_float_0
if $data05 != NULL then if $data05 != NULL then
return -1 return -1
@ -299,6 +300,7 @@ endi
## case 02: dynamic create table for test tag values ## case 02: dynamic create table for test tag values
sql insert into st_float_16 using mt_float tags (NULL) values (now, NULL) sql insert into st_float_16 using mt_float tags (NULL) values (now, NULL)
sql show create table st_float_16
sql show tags from st_float_16 sql show tags from st_float_16
if $data05 != NULL then if $data05 != NULL then
return -1 return -1

View File

@ -17,6 +17,7 @@ sql create table mt_int (ts timestamp, c int) tags (tagname int)
## case 00: static create table for test tag values ## case 00: static create table for test tag values
sql create table st_int_0 using mt_int tags (NULL) sql create table st_int_0 using mt_int tags (NULL)
sql show create table st_int_0
sql show tags from st_int_0 sql show tags from st_int_0
if $data05 != NULL then if $data05 != NULL then
return -1 return -1
@ -27,6 +28,18 @@ if $data05 != NULL then
return -1 return -1
endi endi
sql insert into mt_int(tbname,tagname,ts,c) values("st_int_00",NULL,now,1) values("st_int_01", NULL, now,2)
sql show create table st_int_00
sql show create table st_int_01
sql show tags from st_int_00
if $data05 != NULL then
return -1
endi
sql show tags from st_int_01
if $data05 != NULL then
return -1
endi
sql_error create table st_int_2 using mt_int tags ('NULL') sql_error create table st_int_2 using mt_int tags ('NULL')
sql_error create table st_int_3 using mt_int tags ('NULL') sql_error create table st_int_3 using mt_int tags ('NULL')
sql_error create table st_int_4 using mt_int tags ("NULL") sql_error create table st_int_4 using mt_int tags ("NULL")
@ -172,6 +185,7 @@ endi
## case 02: dynamic create table for test tag values ## case 02: dynamic create table for test tag values
sql insert into st_int_16 using mt_int tags (NULL) values (now, NULL) sql insert into st_int_16 using mt_int tags (NULL) values (now, NULL)
sql show create table st_int_16
sql show tags from st_int_16 sql show tags from st_int_16
if $data05 != NULL then if $data05 != NULL then
return -1 return -1

View File

@ -20,6 +20,7 @@ sql create table mt_smallint (ts timestamp, c smallint) tags (tagname smallint)
## case 00: static create table for test tag values ## case 00: static create table for test tag values
sql create table st_smallint_0 using mt_smallint tags (NULL) sql create table st_smallint_0 using mt_smallint tags (NULL)
sql show create table st_smallint_0
sql show tags from st_smallint_0 sql show tags from st_smallint_0
if $data05 != NULL then if $data05 != NULL then
return -1 return -1
@ -175,6 +176,7 @@ endi
## case 02: dynamic create table for test tag values ## case 02: dynamic create table for test tag values
sql insert into st_smallint_16 using mt_smallint tags (NULL) values (now, NULL) sql insert into st_smallint_16 using mt_smallint tags (NULL) values (now, NULL)
sql show create table st_smallint_16
sql show tags from st_smallint_16 sql show tags from st_smallint_16
if $data05 != NULL then if $data05 != NULL then
return -1 return -1

View File

@ -17,6 +17,7 @@ sql create table mt_tinyint (ts timestamp, c tinyint) tags (tagname tinyint)
## case 00: static create table for test tag values ## case 00: static create table for test tag values
sql create table st_tinyint_0 using mt_tinyint tags (NULL) sql create table st_tinyint_0 using mt_tinyint tags (NULL)
sql show create table st_tinyint_0
sql show tags from st_tinyint_0 sql show tags from st_tinyint_0
if $data05 != NULL then if $data05 != NULL then
print expect NULL, actually: $data05 print expect NULL, actually: $data05
@ -173,6 +174,7 @@ endi
## case 02: dynamic create table for test tag values ## case 02: dynamic create table for test tag values
sql insert into st_tinyint_16 using mt_tinyint tags (NULL) values (now, NULL) sql insert into st_tinyint_16 using mt_tinyint tags (NULL) values (now, NULL)
sql show create table st_tinyint_16
sql show tags from st_tinyint_16 sql show tags from st_tinyint_16
if $data05 != NULL then if $data05 != NULL then
return -1 return -1

View File

@ -13,6 +13,7 @@ sql use $db
#### case 0: field NULL, or 'NULL' #### case 0: field NULL, or 'NULL'
sql create table mt1 (ts timestamp, col1 int, col2 bigint, col3 float, col4 double, col5 binary(8), col6 bool, col7 smallint, col8 tinyint, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag4 bigint, tag5 bool, tag6 float) sql create table mt1 (ts timestamp, col1 int, col2 bigint, col3 float, col4 double, col5 binary(8), col6 bool, col7 smallint, col8 tinyint, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag4 bigint, tag5 bool, tag6 float)
sql create table st1 using mt1 tags (NULL, 'NULL', 100, 1000, 'false', 9.123) sql create table st1 using mt1 tags (NULL, 'NULL', 100, 1000, 'false', 9.123)
sql show create table st1
sql insert into st1 values ('2019-01-01 09:00:00.000', 123, -123, 3.0, 4.0, 'binary', true, 1000, 121, 'nchar') sql insert into st1 values ('2019-01-01 09:00:00.000', 123, -123, 3.0, 4.0, 'binary', true, 1000, 121, 'nchar')
sql insert into st1 values ('2019-01-01 09:00:01.000', '456', '456', '3.33', '4.444', 'binary', 'true', '1001', '122', 'nchar') sql insert into st1 values ('2019-01-01 09:00:01.000', '456', '456', '3.33', '4.444', 'binary', 'true', '1001', '122', 'nchar')
sql insert into st1 values ('2019-01-01 09:00:02.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) sql insert into st1 values ('2019-01-01 09:00:02.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
@ -117,6 +118,7 @@ if $rows != 0 then
endi endi
sql create table st3 using mt2 tags (NULL, 'ABC', 103, 'FALSE') sql create table st3 using mt2 tags (NULL, 'ABC', 103, 'FALSE')
sql show create table st3
sql insert into st3 (ts, col1) values(now, 1) sql insert into st3 (ts, col1) values(now, 1)
sql select tag1, tag2, tag3, tag5 from st3 sql select tag1, tag2, tag3, tag5 from st3
if $rows != 1 then if $rows != 1 then