From 812ad38010576ca6db080064b6b6cfce41fa59da Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 7 Jan 2025 08:44:14 +0800 Subject: [PATCH] fix: alias not keep in view issue --- source/libs/nodes/src/nodesCloneFuncs.c | 3 +++ tests/script/tsim/view/query_view.sim | 25 +++++++++++++++++++++++++ tests/script/tsim/view/view.sim | 16 ++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 22f6dc7418..6d245ebd61 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -102,6 +102,9 @@ static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { COPY_OBJECT_FIELD(resType, sizeof(SDataType)); COPY_CHAR_ARRAY_FIELD(aliasName); COPY_CHAR_ARRAY_FIELD(userAlias); + COPY_SCALAR_FIELD(asAlias); + COPY_SCALAR_FIELD(asParam); + COPY_SCALAR_FIELD(asPosition); COPY_SCALAR_FIELD(projIdx); return TSDB_CODE_SUCCESS; } diff --git a/tests/script/tsim/view/query_view.sim b/tests/script/tsim/view/query_view.sim index 38ec71208e..21fe0a7cab 100644 --- a/tests/script/tsim/view/query_view.sim +++ b/tests/script/tsim/view/query_view.sim @@ -236,3 +236,28 @@ sql drop view view6; sql drop view view7; sql drop view view8; +sql use testb; +sql create view viewx1 as select ts, t from (select last(ts) as ts, last(f) as f, t from st3 partition by t order by ts desc); +sql create view viewx2 as select ts, t from (select last(dt) as ts, last(f) as f, t from st3 partition by t order by ts desc); +sql create view viewx3 as select ts1, t from (select last(ts) as ts1, last(f) as f, t from st3 partition by t order by ts1 desc); +sql create view viewx4 as select f, t from (select last(ts) as f, last(g) as g, t from st3 partition by t order by f desc); +sql select * from viewx1; +if $rows != 4 then + return -1 +endi +sql select * from viewx2; +if $rows != 4 then + return -1 +endi +sql select * from viewx3; +if $rows != 4 then + return -1 +endi +sql select * from viewx4; +if $rows != 4 then + return -1 +endi +sql drop view viewx1; +sql drop view viewx2; +sql drop view viewx3; +sql drop view viewx4; diff --git a/tests/script/tsim/view/view.sim b/tests/script/tsim/view/view.sim index 6b4372fe8c..6c79c2a800 100644 --- a/tests/script/tsim/view/view.sim +++ b/tests/script/tsim/view/view.sim @@ -40,6 +40,12 @@ sql insert into ctb22 using st2 tags(2) values('2023-10-16 09:10:12', 110222, 11 sql insert into ctb23 using st2 tags(3) values('2023-10-16 09:10:13', 110223, 1102230); sql insert into ctb24 using st2 tags(4) values('2023-10-16 09:10:14', 110224, 1102240); +sql create table st3(dt timestamp, ts timestamp, f int, g int) tags (t int); +sql insert into ctb31 using st3 tags(1) values('2023-10-16 09:10:11', 0, 110221, 1102210); +sql insert into ctb32 using st3 tags(2) values('2023-10-16 09:10:12', 1, 110222, 1102220); +sql insert into ctb33 using st3 tags(3) values('2023-10-16 09:10:13', 2, 110223, 1102230); +sql insert into ctb34 using st3 tags(4) values('2023-10-16 09:10:14', 3, 110224, 1102240); + run tsim/view/privilege_basic_view.sim run tsim/view/privilege_nested_view.sim run tsim/view/create_drop_view.sim @@ -63,4 +69,14 @@ run tsim/view/stream_view.sim run tsim/view/show_desc_view.sim run tsim/view/same_name_tb_view.sim +sql alter local 'keepColumnName' '1' +run tsim/view/privilege_basic_view.sim +run tsim/view/privilege_nested_view.sim +run tsim/view/create_drop_view.sim +run tsim/view/query_view.sim +run tsim/view/insert_view.sim +run tsim/view/stream_view.sim +run tsim/view/show_desc_view.sim +run tsim/view/same_name_tb_view.sim + system sh/exec.sh -n dnode1 -s stop -x SIGINT