Merge pull request #29634 from taosdata/fix/main/TS-5941

fix:[TS-5941] fix interpolate varchar/nchar data error
This commit is contained in:
Shengliang Guan 2025-01-22 15:24:25 +08:00 committed by GitHub
commit 0a42d32112
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 118 additions and 2 deletions

View File

@ -63,7 +63,7 @@ static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
pkey->isNull = false; pkey->isNull = false;
char* val = colDataGetData(pColInfoData, rowIndex); char* val = colDataGetData(pColInfoData, rowIndex);
if (IS_VAR_DATA_TYPE(pkey->type)) { if (IS_VAR_DATA_TYPE(pkey->type)) {
memcpy(pkey->pData, val, varDataLen(val)); memcpy(pkey->pData, val, varDataTLen(val));
} else { } else {
memcpy(pkey->pData, val, pkey->bytes); memcpy(pkey->pData, val, pkey->bytes);
} }
@ -87,7 +87,7 @@ static void doKeepNextRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
if (!IS_VAR_DATA_TYPE(pkey->type)) { if (!IS_VAR_DATA_TYPE(pkey->type)) {
memcpy(pkey->pData, val, pkey->bytes); memcpy(pkey->pData, val, pkey->bytes);
} else { } else {
memcpy(pkey->pData, val, varDataLen(val)); memcpy(pkey->pData, val, varDataTLen(val));
} }
} else { } else {
pkey->isNull = true; pkey->isNull = true;

View File

@ -1015,3 +1015,108 @@ taos> select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '
taos> select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-01-01 00:00:22' and '2020-01-01 00:00:30' range('2020-01-01 00:00:00', '2020-01-01 00:00:21') every(1s) fill(linear); taos> select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-01-01 00:00:22' and '2020-01-01 00:00:30' range('2020-01-01 00:00:00', '2020-01-01 00:00:21') every(1s) fill(linear);
taos> select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(prev);
_irowts | interp(c1) | t1 |
===========================================================================
2020-02-01 00:00:05.000 | 5 | testts5941 |
2020-02-01 00:00:06.000 | 5 | testts5941 |
2020-02-01 00:00:07.000 | 5 | testts5941 |
2020-02-01 00:00:08.000 | 5 | testts5941 |
2020-02-01 00:00:09.000 | 5 | testts5941 |
2020-02-01 00:00:10.000 | 10 | testts5941 |
2020-02-01 00:00:11.000 | 10 | testts5941 |
2020-02-01 00:00:12.000 | 10 | testts5941 |
2020-02-01 00:00:13.000 | 10 | testts5941 |
2020-02-01 00:00:14.000 | 10 | testts5941 |
2020-02-01 00:00:15.000 | 15 | testts5941 |
2020-02-01 00:00:16.000 | 15 | testts5941 |
2020-02-01 00:00:17.000 | 15 | testts5941 |
2020-02-01 00:00:18.000 | 15 | testts5941 |
2020-02-01 00:00:19.000 | 15 | testts5941 |
2020-02-01 00:00:20.000 | 15 | testts5941 |
taos> select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(next);
_irowts | interp(c1) | t1 |
===========================================================================
2020-02-01 00:00:00.000 | 5 | testts5941 |
2020-02-01 00:00:01.000 | 5 | testts5941 |
2020-02-01 00:00:02.000 | 5 | testts5941 |
2020-02-01 00:00:03.000 | 5 | testts5941 |
2020-02-01 00:00:04.000 | 5 | testts5941 |
2020-02-01 00:00:05.000 | 5 | testts5941 |
2020-02-01 00:00:06.000 | 10 | testts5941 |
2020-02-01 00:00:07.000 | 10 | testts5941 |
2020-02-01 00:00:08.000 | 10 | testts5941 |
2020-02-01 00:00:09.000 | 10 | testts5941 |
2020-02-01 00:00:10.000 | 10 | testts5941 |
2020-02-01 00:00:11.000 | 15 | testts5941 |
2020-02-01 00:00:12.000 | 15 | testts5941 |
2020-02-01 00:00:13.000 | 15 | testts5941 |
2020-02-01 00:00:14.000 | 15 | testts5941 |
2020-02-01 00:00:15.000 | 15 | testts5941 |
taos> select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(linear);
_irowts | interp(c1) | t1 |
===========================================================================
2020-02-01 00:00:05.000 | 5 | testts5941 |
2020-02-01 00:00:06.000 | 6 | testts5941 |
2020-02-01 00:00:07.000 | 7 | testts5941 |
2020-02-01 00:00:08.000 | 8 | testts5941 |
2020-02-01 00:00:09.000 | 9 | testts5941 |
2020-02-01 00:00:10.000 | 10 | testts5941 |
2020-02-01 00:00:11.000 | 11 | testts5941 |
2020-02-01 00:00:12.000 | 12 | testts5941 |
2020-02-01 00:00:13.000 | 13 | testts5941 |
2020-02-01 00:00:14.000 | 14 | testts5941 |
2020-02-01 00:00:15.000 | 15 | testts5941 |
taos> select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(null);
_irowts | interp(c1) | t1 |
===========================================================================
2020-02-01 00:00:00.000 | NULL | testts5941 |
2020-02-01 00:00:01.000 | NULL | testts5941 |
2020-02-01 00:00:02.000 | NULL | testts5941 |
2020-02-01 00:00:03.000 | NULL | testts5941 |
2020-02-01 00:00:04.000 | NULL | testts5941 |
2020-02-01 00:00:05.000 | 5 | testts5941 |
2020-02-01 00:00:06.000 | NULL | testts5941 |
2020-02-01 00:00:07.000 | NULL | testts5941 |
2020-02-01 00:00:08.000 | NULL | testts5941 |
2020-02-01 00:00:09.000 | NULL | testts5941 |
2020-02-01 00:00:10.000 | 10 | testts5941 |
2020-02-01 00:00:11.000 | NULL | testts5941 |
2020-02-01 00:00:12.000 | NULL | testts5941 |
2020-02-01 00:00:13.000 | NULL | testts5941 |
2020-02-01 00:00:14.000 | NULL | testts5941 |
2020-02-01 00:00:15.000 | 15 | testts5941 |
2020-02-01 00:00:16.000 | NULL | testts5941 |
2020-02-01 00:00:17.000 | NULL | testts5941 |
2020-02-01 00:00:18.000 | NULL | testts5941 |
2020-02-01 00:00:19.000 | NULL | testts5941 |
2020-02-01 00:00:20.000 | NULL | testts5941 |
taos> select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(value, 1);
_irowts | interp(c1) | t1 |
===========================================================================
2020-02-01 00:00:00.000 | 1 | testts5941 |
2020-02-01 00:00:01.000 | 1 | testts5941 |
2020-02-01 00:00:02.000 | 1 | testts5941 |
2020-02-01 00:00:03.000 | 1 | testts5941 |
2020-02-01 00:00:04.000 | 1 | testts5941 |
2020-02-01 00:00:05.000 | 5 | testts5941 |
2020-02-01 00:00:06.000 | 1 | testts5941 |
2020-02-01 00:00:07.000 | 1 | testts5941 |
2020-02-01 00:00:08.000 | 1 | testts5941 |
2020-02-01 00:00:09.000 | 1 | testts5941 |
2020-02-01 00:00:10.000 | 10 | testts5941 |
2020-02-01 00:00:11.000 | 1 | testts5941 |
2020-02-01 00:00:12.000 | 1 | testts5941 |
2020-02-01 00:00:13.000 | 1 | testts5941 |
2020-02-01 00:00:14.000 | 1 | testts5941 |
2020-02-01 00:00:15.000 | 15 | testts5941 |
2020-02-01 00:00:16.000 | 1 | testts5941 |
2020-02-01 00:00:17.000 | 1 | testts5941 |
2020-02-01 00:00:18.000 | 1 | testts5941 |
2020-02-01 00:00:19.000 | 1 | testts5941 |
2020-02-01 00:00:20.000 | 1 | testts5941 |

1 taos> select _irowts as irowts ,tbname as table_name, _isfilled as isfilled , interp(c1) as intp_c1 from test.td32727 partition by tbname range('2020-02-01 00:00:04', '2020-02-01 00:00:16') every(1s) fill (null) order by irowts;
1015 2020-02-01 00:00:08.000 | NULL | testts5941 |
1016 2020-02-01 00:00:09.000 | NULL | testts5941 |
1017 2020-02-01 00:00:10.000 | 10 | testts5941 |
1018 2020-02-01 00:00:11.000 | NULL | testts5941 |
1019 2020-02-01 00:00:12.000 | NULL | testts5941 |
1020 2020-02-01 00:00:13.000 | NULL | testts5941 |
1021 2020-02-01 00:00:14.000 | NULL | testts5941 |
1022 2020-02-01 00:00:15.000 | 15 | testts5941 |
1023 2020-02-01 00:00:16.000 | NULL | testts5941 |
1024 2020-02-01 00:00:17.000 | NULL | testts5941 |
1025 2020-02-01 00:00:18.000 | NULL | testts5941 |
1026 2020-02-01 00:00:19.000 | NULL | testts5941 |
1027 2020-02-01 00:00:20.000 | NULL | testts5941 |
1028 taos> select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(value, 1);
1029 _irowts | interp(c1) | t1 |
1030 ===========================================================================
1031 2020-02-01 00:00:00.000 | 1 | testts5941 |
1032 2020-02-01 00:00:01.000 | 1 | testts5941 |
1033 2020-02-01 00:00:02.000 | 1 | testts5941 |
1034 2020-02-01 00:00:03.000 | 1 | testts5941 |
1035 2020-02-01 00:00:04.000 | 1 | testts5941 |
1036 2020-02-01 00:00:05.000 | 5 | testts5941 |
1037 2020-02-01 00:00:06.000 | 1 | testts5941 |
1038 2020-02-01 00:00:07.000 | 1 | testts5941 |
1039 2020-02-01 00:00:08.000 | 1 | testts5941 |
1040 2020-02-01 00:00:09.000 | 1 | testts5941 |
1041 2020-02-01 00:00:10.000 | 10 | testts5941 |
1042 2020-02-01 00:00:11.000 | 1 | testts5941 |
1043 2020-02-01 00:00:12.000 | 1 | testts5941 |
1044 2020-02-01 00:00:13.000 | 1 | testts5941 |
1045 2020-02-01 00:00:14.000 | 1 | testts5941 |
1046 2020-02-01 00:00:15.000 | 15 | testts5941 |
1047 2020-02-01 00:00:16.000 | 1 | testts5941 |
1048 2020-02-01 00:00:17.000 | 1 | testts5941 |
1049 2020-02-01 00:00:18.000 | 1 | testts5941 |
1050 2020-02-01 00:00:19.000 | 1 | testts5941 |
1051 2020-02-01 00:00:20.000 | 1 | testts5941 |
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122

View File

@ -63,3 +63,8 @@ select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-0
select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-01-01 00:00:22' and '2020-01-01 00:00:30' range('2020-01-01 00:00:00', '2020-01-01 00:00:21') every(1s) fill(prev); select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-01-01 00:00:22' and '2020-01-01 00:00:30' range('2020-01-01 00:00:00', '2020-01-01 00:00:21') every(1s) fill(prev);
select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-01-01 00:00:22' and '2020-01-01 00:00:30' range('2020-01-01 00:00:00', '2020-01-01 00:00:21') every(1s) fill(next); select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-01-01 00:00:22' and '2020-01-01 00:00:30' range('2020-01-01 00:00:00', '2020-01-01 00:00:21') every(1s) fill(next);
select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-01-01 00:00:22' and '2020-01-01 00:00:30' range('2020-01-01 00:00:00', '2020-01-01 00:00:21') every(1s) fill(linear); select _irowts, _isfilled, interp(c1) from test.td32861 where ts between '2020-01-01 00:00:22' and '2020-01-01 00:00:30' range('2020-01-01 00:00:00', '2020-01-01 00:00:21') every(1s) fill(linear);
select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(prev);
select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(next);
select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(linear);
select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(null);
select _irowts, interp(c1), t1 from test.ts5941_child range('2020-02-01 00:00:00', '2020-02-01 00:00:20') every(1s) fill(value, 1);

View File

@ -40,6 +40,9 @@ class TDTestCase(TBase):
) )
tdSql.execute("create table if not exists test.td32861(ts timestamp, c1 int);") tdSql.execute("create table if not exists test.td32861(ts timestamp, c1 int);")
tdSql.execute("create stable if not exists test.ts5941(ts timestamp, c1 int, c2 int) tags (t1 varchar(30));")
tdSql.execute("create table if not exists test.ts5941_child using test.ts5941 tags ('testts5941');")
tdLog.printNoPrefix("==========step2:insert data") tdLog.printNoPrefix("==========step2:insert data")
tdSql.execute(f"insert into test.td32727 values ('2020-02-01 00:00:05', 5, 5, 5, 5, 5.0, 5.0, true, 'varchar', 'nchar', 5, 5, 5, 5)") tdSql.execute(f"insert into test.td32727 values ('2020-02-01 00:00:05', 5, 5, 5, 5, 5.0, 5.0, true, 'varchar', 'nchar', 5, 5, 5, 5)")
@ -56,6 +59,9 @@ class TDTestCase(TBase):
('2020-01-01 00:00:15', 15), ('2020-01-01 00:00:15', 15),
('2020-01-01 00:00:21', 21);""" ('2020-01-01 00:00:21', 21);"""
) )
tdSql.execute(f"insert into test.ts5941_child values ('2020-02-01 00:00:05', 5, 5)")
tdSql.execute(f"insert into test.ts5941_child values ('2020-02-01 00:00:10', 10, 10)")
tdSql.execute(f"insert into test.ts5941_child values ('2020-02-01 00:00:15', 15, 15)")
def test_normal_query_new(self, testCase): def test_normal_query_new(self, testCase):
# read sql from .sql file and execute # read sql from .sql file and execute