Skip to content

Commit c0340dc

Browse files
committed
feat: [TS-6100] Parse create stream sql: Fix out col / tag wrong length
1 parent bcd3ee9 commit c0340dc

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

source/libs/parser/src/parTranslater.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13494,13 +13494,13 @@ static int32_t createStreamReqBuildOutTable(STranslateContext* pCxt, SCreateStre
1349413494

1349513495
PAR_ERR_JRET(checkTableSchemaImpl(pCxt, pStmt->pTags, pStmt->pCols, NULL));
1349613496
if (pReq->outTblType == TSDB_SUPER_TABLE) {
13497-
PAR_ERR_JRET(streamTagDefNodeToField(pStmt->pTags, &pReq->outTags, true));
13497+
PAR_ERR_JRET(streamTagDefNodeToField(pStmt->pTags, &pReq->outTags, false)); // tag bytes has been calculated in createStreamReqSetDefaultTag
1349813498
PAR_ERR_JRET(createStreamReqBuildStreamTagExprStr(pCxt, pStmt->pTags, ((SStreamTriggerNode*)pStmt->pTrigger)->pPartitionList, pTriggerSlotHash, (char**)&pReq->tagValueExpr));
1349913499
} else {
1350013500
PAR_ERR_JRET(getTableVgId(pCxt, pStmt->targetDbName, pStmt->targetTabName, &pReq->outTblVgId));
1350113501
}
1350213502

13503-
PAR_ERR_JRET(columnDefNodeToField(pStmt->pCols, &pReq->outCols, true, false));
13503+
PAR_ERR_JRET(columnDefNodeToField(pStmt->pCols, &pReq->outCols, false, false));
1350413504
PAR_ERR_JRET(createStreamReqBuildOutSubtable(pCxt, pStmt->streamDbName, pStmt->streamName, pStmt->pSubtable, pTriggerSlotHash, ((SStreamTriggerNode*)pStmt->pTrigger)->pPartitionList, (char**)&pReq->subTblNameExpr));
1350513505

1350613506
return code;
@@ -13703,7 +13703,15 @@ static int32_t createStreamReqSetDefaultTag(STranslateContext* pCxt, SCreateStre
1370313703
SNode* pNode = NULL;
1370413704
SStreamTagDefNode* pTagDef = NULL;
1370513705

13706-
if (pStmt->pTags || !pTriggerPartition) {
13706+
if (!pTriggerPartition) {
13707+
return code;
13708+
}
13709+
13710+
if (pStmt->pTags) {
13711+
FOREACH(pNode, pStmt->pTags) {
13712+
SStreamTagDefNode *pDef = (SStreamTagDefNode*)pNode;
13713+
pDef->dataType.bytes = calcTypeBytes(pDef->dataType);
13714+
}
1370713715
return code;
1370813716
}
1370913717

test/cases/13-StreamProcessing/20-UseCase/test_three_gorges_phase1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def test_stream_usecase_3gorges_1(self):
141141
["tw", "TIMESTAMP", 8, ""],
142142
["alarmdate", "TIMESTAMP", 8, ""],
143143
["alarmstatus", "DOUBLE", 8, ""],
144-
["tag_tbname", "VARCHAR", 272, "TAG"],
144+
["tag_tbname", "VARCHAR", 270, "TAG"],
145145
],
146146
)
147147

test/cases/13-StreamProcessing/31-OldTsimCases/test_oldcase_check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def checkStreamSTable(self):
4848
tdSql.execute(f"create table t2 using st tags(2, 2, 2);")
4949

5050
tdSql.execute(
51-
f"create stable result.streamt0(ts timestamp, a bigint, b int) tags(tag_tbname varchar(272), ta int, tb int, tc int);"
51+
f"create stable result.streamt0(ts timestamp, a bigint, b int) tags(tag_tbname varchar(270), ta int, tb int, tc int);"
5252
)
5353
tdSql.execute(
54-
"create stream streams0 interval(10s) sliding(10s) from st partition by tbname, ta, tb, tc options(MAX_DELAY(1s)) into result.streamt0 tags(tag_tbname varchar(272) as %%1, ta int as %%2, tb int as %%3, tc int as %%4) as select _twstart ts, count(*) a, max(a) b from %%tbname;"
54+
"create stream streams0 interval(10s) sliding(10s) from st partition by tbname, ta, tb, tc options(MAX_DELAY(1s)) into result.streamt0 tags(tag_tbname varchar(270) as %%1, ta int as %%2, tb int as %%3, tc int as %%4) as select _twstart ts, count(*) a, max(a) b from %%tbname;"
5555
)
5656
tdStream.checkStreamStatus()
5757

test/cases/13-StreamProcessing/31-OldTsimCases/test_oldcase_check_bug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_stream_oldcase_check(self):
4444
tdSql.execute(f"create table t2 using st tags(2, 2, 2);")
4545

4646
tdSql.execute(
47-
"create stream streams0 interval(10s) sliding(10s) from st partition by tbname, ta, tb, tc options(MAX_DELAY(1s)) into result.streamt0 tags(tag_tbname varchar(272) as %%1, ta int as %%2, tb int as %%3, tc int as %%4) as select _twstart, count(*) c1, max(a) c2 from %%tbname;"
47+
"create stream streams0 interval(10s) sliding(10s) from st partition by tbname, ta, tb, tc options(MAX_DELAY(1s)) into result.streamt0 tags(tag_tbname varchar(270) as %%1, ta int as %%2, tb int as %%3, tc int as %%4) as select _twstart, count(*) c1, max(a) c2 from %%tbname;"
4848
)
4949
tdStream.checkStreamStatus()
5050

test/cases/13-StreamProcessing/31-OldTsimCases/test_oldcase_concat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def udTableAndCol0(self):
110110
["a", "TIMESTAMP", 8, ""],
111111
["b", "BIGINT", 8, ""],
112112
["c", "INT", 4, ""],
113-
["tag_tbname", "VARCHAR", 272, "TAG"],
113+
["tag_tbname", "VARCHAR", 270, "TAG"],
114114
],
115115
)
116116

@@ -179,7 +179,7 @@ def udTableAndCol0(self):
179179
["a", "TIMESTAMP", 8, ""],
180180
["b", "BIGINT", 8, ""],
181181
["c", "INT", 4, ""],
182-
["tag_tbname", "VARCHAR", 272, "TAG"],
182+
["tag_tbname", "VARCHAR", 270, "TAG"],
183183
],
184184
)
185185

@@ -473,7 +473,7 @@ def udTableAndTag1(self):
473473
tdLog.info("===== table name")
474474

475475
tdSql.execute("create database result vgroups 1;")
476-
tdSql.execute("create database test vgroups 4;")
476+
tdSql.execute("create database test vgroups 1;")
477477
tdSql.execute("use test;")
478478

479479
tdSql.execute(

test/cases/13-StreamProcessing/99-Others/test_dev_basic1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def udTableAndCol0(self):
270270
["a", "TIMESTAMP", 8, ""],
271271
["b", "BIGINT", 8, ""],
272272
["c", "INT", 4, ""],
273-
["tag_tbname", "VARCHAR", 272, "TAG"],
273+
["tag_tbname", "VARCHAR", 270, "TAG"],
274274
],
275275
)
276276

@@ -339,7 +339,7 @@ def udTableAndCol0(self):
339339
["a", "TIMESTAMP", 8, ""],
340340
["b", "BIGINT", 8, ""],
341341
["c", "INT", 4, ""],
342-
["tag_tbname", "VARCHAR", 272, "TAG"],
342+
["tag_tbname", "VARCHAR", 270, "TAG"],
343343
],
344344
)
345345

test/cases/13-StreamProcessing/99-Others/test_dev_basic3.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ def check2(self):
201201
["tw", "BIGINT", 8, ""],
202202
["tg", "BIGINT", 8, ""],
203203
["tl", "TIMESTAMP", 8, ""],
204-
["tb", "VARCHAR", 272, ""],
204+
["tb", "VARCHAR", 270, ""],
205205
["c1", "BIGINT", 8, ""],
206206
["c2", "DOUBLE", 8, ""],
207-
["tag_tbname", "VARCHAR", 272, "TAG"],
207+
["tag_tbname", "VARCHAR", 270, "TAG"],
208208
],
209209
)
210210
tdSql.checkResultsByFunc(
@@ -233,12 +233,12 @@ def check6(self):
233233
tbname="r6",
234234
schema=[
235235
["ts", "TIMESTAMP", 8, ""],
236-
["tb", "VARCHAR", 272, ""],
237-
["%%1", "VARCHAR", 272, ""],
236+
["tb", "VARCHAR", 270, ""],
237+
["%%1", "VARCHAR", 270, ""],
238238
["v1", "BIGINT", 8, ""],
239239
["v2", "DOUBLE", 8, ""],
240240
["v3", "INT", 4, ""],
241241
["v4", "INT", 4, ""],
242-
["tag_tbname", "VARCHAR", 272, "TAG"],
242+
["tag_tbname", "VARCHAR", 270, "TAG"],
243243
],
244244
)

test/cases/13-StreamProcessing/99-Others/test_dev_basic6.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ def check6(self):
131131
tbname="r6",
132132
schema=[
133133
["ts", "TIMESTAMP", 8, ""],
134-
["tb", "VARCHAR", 272, ""],
135-
["%%1", "VARCHAR", 272, ""],
134+
["tb", "VARCHAR", 270, ""],
135+
["%%1", "VARCHAR", 270, ""],
136136
["v1", "BIGINT", 8, ""],
137137
["v2", "DOUBLE", 8, ""],
138138
["v3", "INT", 4, ""],
139139
["v4", "INT", 4, ""],
140-
["tag_tbname", "VARCHAR", 272, "TAG"],
140+
["tag_tbname", "VARCHAR", 270, "TAG"],
141141
],
142142
)

0 commit comments

Comments
 (0)