diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 2774d9e2fabd11a3fcb45d650dc696518d504501..4c0bb1ae52b6938ffdef465112ade6ef3e3e93af 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -1725,6 +1725,9 @@ void castConvert(int16_t inputType, int16_t inputBytes, char *input, int16_t Out tfree(newColData); } else { GET_TYPED_DATA(*(int64_t *)output, int64_t, inputType, input); + if (*(int64_t *)output == TSDB_DATA_BIGINT_NULL) { + SET_TYPED_DATA(output, OutputType, INT64_MAX); + } } break; case TSDB_DATA_TYPE_UBIGINT: @@ -1755,6 +1758,9 @@ void castConvert(int16_t inputType, int16_t inputBytes, char *input, int16_t Out } else { GET_TYPED_DATA(*(int64_t *)output, int64_t, inputType, input); } + if (*(int64_t *)output == TSDB_DATA_BIGINT_NULL) { + SET_TYPED_DATA(output, OutputType, INT64_MAX); + } break; case TSDB_DATA_TYPE_BINARY: if (inputType == TSDB_DATA_TYPE_BOOL) { diff --git a/tests/script/general/compute/cast_query1.sim b/tests/script/general/compute/cast_query1.sim index de0722bcd8c3911d94b4558c302c22bbc607defd..8e560025b8ac2c7e0141bd2f97a0c541ca4a94d5 100644 --- a/tests/script/general/compute/cast_query1.sim +++ b/tests/script/general/compute/cast_query1.sim @@ -1158,10 +1158,10 @@ endi if $data40 != 4 then return -1 endi -if $data50 != NULL then +if $data50 != 9223372036854775807 then return -1 endi -if $data60 != NULL then +if $data60 != 9223372036854775807 then return -1 endi sql select cast(c6 as binary(60)) from tb1; @@ -1233,10 +1233,11 @@ endi if $data40 != @70-01-01 08:00:00.004@ then return -1 endi -if $data50 != NULL then +print $data50 +if $data50 != @94-08-17 15:12:55.807@ then return -1 endi -if $data60 != NULL then +if $data60 != @94-08-17 15:12:55.807@ then return -1 endi sql select cast(c6 as nchar(50)) from tb1; @@ -1331,10 +1332,10 @@ endi if $data40 != 4 then return -1 endi -if $data50 != NULL then +if $data50 != 9223372036854775807 then return -1 endi -if $data60 != NULL then +if $data60 != 9223372036854775807 then return -1 endi sql select cast(c7 as binary(400)) from tb1; @@ -1406,10 +1407,10 @@ endi if $data40 != @70-01-01 08:00:00.004@ then return -1 endi -if $data50 != NULL then +if $data50 != @94-08-17 15:12:55.807@ then return -1 endi -if $data60 != NULL then +if $data60 != @94-08-17 15:12:55.807@ then return -1 endi sql select cast(c7 as nchar(500)) from tb1;