From 29fe1d24a4b04ec237097b16dc674b327830fd24 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sat, 23 Jul 2022 17:20:08 +0800 Subject: [PATCH 1/4] fix(query): fix sclrewrite function&operator type/bytes TD-17682 --- source/libs/scalar/src/scalar.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 14406a26ed..cfeac04bbd 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -735,15 +735,13 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { res->translate = true; + res->node.resType.type = output.columnData->info.type; + res->node.resType.bytes = output.columnData->info.bytes; + res->node.resType.scale = output.columnData->info.scale; + res->node.resType.precision = output.columnData->info.precision; if (colDataIsNull_s(output.columnData, 0)) { res->isNull = true; - //res->node.resType.type = TSDB_DATA_TYPE_NULL; - //res->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; } else { - res->node.resType.type = output.columnData->info.type; - res->node.resType.bytes = output.columnData->info.bytes; - res->node.resType.scale = output.columnData->info.scale; - res->node.resType.precision = output.columnData->info.precision; int32_t type = output.columnData->info.type; if (type == TSDB_DATA_TYPE_JSON){ int32_t len = getJsonValueLen(output.columnData->pData); @@ -826,16 +824,11 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { res->translate = true; + res->node.resType = node->node.resType; if (colDataIsNull_s(output.columnData, 0)) { - if(node->node.resType.type != TSDB_DATA_TYPE_JSON){ - res->node.resType.type = TSDB_DATA_TYPE_NULL; - res->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; - }else{ - res->node.resType = node->node.resType; - res->isNull = true; - } - } else { + res->isNull = true; res->node.resType = node->node.resType; + } else { int32_t type = output.columnData->info.type; if (IS_VAR_DATA_TYPE(type)) { // todo refactor res->datum.p = output.columnData->pData; From 2ff07c8f1e6107fed345accb88337b354ed3ad85 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sat, 23 Jul 2022 18:15:39 +0800 Subject: [PATCH 2/4] restore sclRewriteOperator logic --- source/libs/scalar/src/scalar.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index cfeac04bbd..955c8c074a 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -824,10 +824,14 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { res->translate = true; - res->node.resType = node->node.resType; if (colDataIsNull_s(output.columnData, 0)) { - res->isNull = true; - res->node.resType = node->node.resType; + if(node->node.resType.type != TSDB_DATA_TYPE_JSON){ + res->node.resType.type = TSDB_DATA_TYPE_NULL; + res->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; + } else { + res->isNull = true; + res->node.resType = node->node.resType; + } } else { int32_t type = output.columnData->info.type; if (IS_VAR_DATA_TYPE(type)) { // todo refactor From 2416411eaf88faa8e33b5242d9715701f3fcb1dc Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sat, 23 Jul 2022 19:21:08 +0800 Subject: [PATCH 3/4] Revert "restore sclRewriteOperator logic" This reverts commit 2ff07c8f1e6107fed345accb88337b354ed3ad85. --- source/libs/scalar/src/scalar.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 955c8c074a..cfeac04bbd 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -824,14 +824,10 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { res->translate = true; + res->node.resType = node->node.resType; if (colDataIsNull_s(output.columnData, 0)) { - if(node->node.resType.type != TSDB_DATA_TYPE_JSON){ - res->node.resType.type = TSDB_DATA_TYPE_NULL; - res->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; - } else { - res->isNull = true; - res->node.resType = node->node.resType; - } + res->isNull = true; + res->node.resType = node->node.resType; } else { int32_t type = output.columnData->info.type; if (IS_VAR_DATA_TYPE(type)) { // todo refactor From 738e1803a8c425e93e94aeee270a2647ec19a8f3 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sat, 23 Jul 2022 19:24:24 +0800 Subject: [PATCH 4/4] fix test case --- tests/script/tsim/query/scalarNull.sim | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/script/tsim/query/scalarNull.sim b/tests/script/tsim/query/scalarNull.sim index ae4b2a9624..1b437747ce 100644 --- a/tests/script/tsim/query/scalarNull.sim +++ b/tests/script/tsim/query/scalarNull.sim @@ -89,10 +89,4 @@ endi #TODO: MOVE IT TO NORMAL CASE sql_error select * from tb1 where not (null); -sql select sum(1/0) from tb1; -if $rows != 1 then - return -1 -endi - - system sh/exec.sh -n dnode1 -s stop -x SIGINT