opti:modify bytes for numbers and string
This commit is contained in:
parent
b5b698a76c
commit
d5876b0457
|
@ -3314,17 +3314,13 @@ static int32_t selectCommonType(SDataType* commonType, const SDataType* newType)
|
||||||
commonType->bytes = TMAX(commonType->bytes, newType->bytes);
|
commonType->bytes = TMAX(commonType->bytes, newType->bytes);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
if (resultType == commonType->type){
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
if(resultType == newType->type) {
|
|
||||||
*commonType = *newType;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), TYPE_BYTES[resultType]);
|
commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), TYPE_BYTES[resultType]);
|
||||||
if(resultType == TSDB_DATA_TYPE_VARCHAR && (IS_FLOAT_TYPE(commonType->type) || IS_FLOAT_TYPE(newType->type))) {
|
if((resultType == TSDB_DATA_TYPE_VARCHAR || resultType == TSDB_DATA_TYPE_NCHAR) && (
|
||||||
commonType->bytes += TYPE_BYTES[TSDB_DATA_TYPE_DOUBLE];
|
(IS_FLOAT_TYPE(commonType->type) || IS_FLOAT_TYPE(newType->type)) ||
|
||||||
}
|
(IS_NUMERIC_TYPE(commonType->type) || IS_NUMERIC_TYPE(newType->type))))
|
||||||
|
{
|
||||||
|
commonType->bytes = TMAX(commonType->bytes, 32);
|
||||||
|
}
|
||||||
commonType->type = resultType;
|
commonType->type = resultType;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -1033,21 +1033,21 @@ int8_t gConvertTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = {
|
||||||
int8_t gDisplyTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = {
|
int8_t gDisplyTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX] = {
|
||||||
/*NULL BOOL TINY SMAL INT BIGI FLOA DOUB VARC TIME NCHA UTINY USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/
|
/*NULL BOOL TINY SMAL INT BIGI FLOA DOUB VARC TIME NCHA UTINY USMA UINT UBIG JSON VARB DECI BLOB MEDB GEOM*/
|
||||||
/*NULL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, 8,
|
/*NULL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, 8,
|
||||||
/*BOOL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 5, 10, 11, 12, 13, 14, 8, -1, -1, -1, -1, 8,
|
/*BOOL*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 5, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1,
|
||||||
/*TINY*/ 0, 0, 2, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, 8, -1, -1, -1, -1, 8,
|
/*TINY*/ 0, 0, 2, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, -1, -1, -1, -1, -1, -1,
|
||||||
/*SMAL*/ 0, 0, 0, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, 8, -1, -1, -1, -1, 8,
|
/*SMAL*/ 0, 0, 0, 3, 4, 5, 8, 8, 8, 5, 10, 3, 4, 5, 8, -1, -1, -1, -1, -1, -1,
|
||||||
/*INT */ 0, 0, 0, 0, 4, 5, 8, 8, 8, 5, 10, 4, 4, 5, 8, 8, -1, -1, -1, -1, 8,
|
/*INT */ 0, 0, 0, 0, 4, 5, 8, 8, 8, 5, 10, 4, 4, 5, 8, -1, -1, -1, -1, -1, -1,
|
||||||
/*BIGI*/ 0, 0, 0, 0, 0, 5, 8, 8, 8, 5, 10, 5, 5, 5, 8, 8, -1, -1, -1, -1, 8,
|
/*BIGI*/ 0, 0, 0, 0, 0, 5, 8, 8, 8, 5, 10, 5, 5, 5, 8, -1, -1, -1, -1, -1, -1,
|
||||||
/*FLOA*/ 0, 0, 0, 0, 0, 0, 6, 7, 8, 8, 10, 8, 8, 8, 8, 8, -1, -1, -1, -1, 8,
|
/*FLOA*/ 0, 0, 0, 0, 0, 0, 6, 7, 8, 8, 10, 8, 8, 8, 8, -1, -1, -1, -1, -1, -1,
|
||||||
/*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 10, 8, 8, 8, 8, 8, -1, -1, -1, -1, 8,
|
/*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 10, 8, 8, 8, 8, -1, -1, -1, -1, -1, -1,
|
||||||
/*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 10, 8, 8, 8, 8, 8, -1, -1, -1, -1, 8,
|
/*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 10, 8, 8, 8, 8, -1, -1, -1, -1, -1, -1,
|
||||||
/*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 5, 5, 5, 8, 8, -1, -1, -1, -1, 8,
|
/*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 5, 5, 5, 8, -1, -1, -1, -1, -1, -1,
|
||||||
/*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, -1, -1, -1, -1, 10,
|
/*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, -1, -1, -1, -1, -1, -1,
|
||||||
/*UTINY*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, 8, -1, -1, -1, -1, 8,
|
/*UTINY*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1,
|
||||||
/*USMA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0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1,
|
||||||
|
|
|
@ -838,7 +838,7 @@ endi
|
||||||
if $data20 != 11 then
|
if $data20 != 11 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data30 != 1664176504 then
|
if $data30 != 1664176504000 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -1130,36 +1130,32 @@ if $data00 != varchar_val then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select case when ts > '2022-01-01 00:00:00' then c_varchar else c_geometry end as result from t_test;
|
sql select case when 1 then 1234567890987654 else 'abcertyuiojhgfddhjgfcvbn' end;
|
||||||
if $data00 != varchar_val then
|
if $data00 != 1234567890987654 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select case when ts > '2022-01-01 00:00:00' then c_bool else c_geometry end as result from t_test;
|
sql select case when 0 then 1234567890987654 else 'abcertyuiojhgfddhjgfcvbn' end;
|
||||||
if $data00 != true then
|
if $data00 != abcertyuiojhgfddhjgfcvbn then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select case when 0 then tag_id else c_geometry end as result from t_test;
|
sql select case when 0 then 1234567890987654 else c_nchar end from t_test;
|
||||||
if $data00 != 16842773 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql select case when 0 then tag_id else c_nchar end as result from t_test;
|
|
||||||
if $data00 != 涛思数据 then
|
if $data00 != 涛思数据 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select case when 0 then tag_id else c_int end as result from t_test;
|
sql select case when 1 then 1234567890987654 else c_nchar end from t_test;
|
||||||
if $data00 != 123 then
|
if $data00 != 1234567890987654 then
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql select case when 0 then tag_id else c_float end as result from t_test;
|
|
||||||
if $data00 != 123.449997 then
|
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql_error select case when ts > '2022-01-01 00:00:00' then c_varchar else c_geometry end as result from t_test;
|
||||||
|
sql_error select case when ts > '2022-01-01 00:00:00' then c_bool else c_geometry end as result from t_test;
|
||||||
|
sql_error select case when 0 then tag_id else c_geometry end as result from t_test;
|
||||||
|
sql_error select case when 0 then tag_id else c_nchar end as result from t_test;
|
||||||
|
sql_error select case when 0 then tag_id else c_int end as result from t_test;
|
||||||
|
sql_error select case when 0 then tag_id else c_float end as result from t_test;
|
||||||
sql_error select case when c_double > 100 then c_varbinary else c_geometry end as result from t_test;
|
sql_error select case when c_double > 100 then c_varbinary else c_geometry end as result from t_test;
|
||||||
sql_error select case when c_bool then c_double else c_varbinary end as result from t_test;
|
sql_error select case when c_bool then c_double else c_varbinary end as result from t_test;
|
||||||
sql_error select case when c_bool then c_varbinary else c_varchar end as result from t_test;
|
sql_error select case when c_bool then c_varbinary else c_varchar end as result from t_test;
|
||||||
|
|
Loading…
Reference in New Issue