Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/libs/parser/src/parTranslater.c
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ static int32_t findAndSetTempTableColumn(STranslateContext* pCxt, SColumnNode**
SExprNode* pFoundExpr = NULL;
FOREACH(pNode, pProjectList) {
SExprNode* pExpr = (SExprNode*)pNode;
if (0 == strcmp(pCol->colName, pExpr->aliasName)) {
if (0 == strcmp(pCol->colName, pExpr->userAlias)) {
if (*pFound) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AMBIGUOUS_COLUMN, pCol->colName);
}
Expand Down
13 changes: 13 additions & 0 deletions tests/system-test/2-query/cols_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,19 @@ def subquery_test(self):
tdSql.query(f'select count(1), cols(last(c0),c0) from (select * from test.d0)')
tdSql.query(f'select count(1), cols(last(c0),c0) from (select *, tbname from test.meters) group by tbname')

tdSql.query(f'select last(mts) from (select max(c0) as mc0, cols(max(c0), ts) as mts from test.meters group by tbname)')
tdSql.checkRows(1)
tdSql.checkCols(1)
tdSql.checkData(0, 0, 1734574929004)
tdSql.query(f'select max(mc0) as max_c0, cols(max(mc0), mts) max_ts from (select max(c0) as mc0, cols(max(c0), ts) as mts from test.meters group by tbname)')
tdSql.checkRows(1)
tdSql.checkCols(2)
tdSql.checkData(0, 0, 4)
tdSql.checkData(0, 1, 1734574929004)

tdSql.error(f'select last(ts) from (select max(c0) as mc0, cols(max(c0), ts) as mts from test.meters group by tbname)')
tdSql.error(f'select max(mc0) as max_c0, cols(max(mc0), ts) max_ts from (select max(c0) as mc0, cols(max(c0), ts) as mts from test.meters group by tbname)')

tdLog.info("subquery_test: orderby_test from meters")
self.orderby_test("test.meters", "c0", False)
tdLog.info("subquery_test: orderby_test from (select *, tbname from meters)")
Expand Down
Loading