Merge pull request #26415 from taosdata/feat/3.0/TS-5131
feat:[TS-5131] Support parse alias table name with backquote.
This commit is contained in:
commit
2dbedaf88b
|
@ -139,7 +139,7 @@ SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataTy
|
|||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
||||
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
||||
SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias);
|
||||
SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const SToken* pTableAlias);
|
||||
SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, SToken* pTableAlias);
|
||||
SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, EJoinSubType stype, SNode* pLeft, SNode* pRight,
|
||||
SNode* pJoinCond);
|
||||
SNode* createViewNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pViewName);
|
||||
|
|
|
@ -949,8 +949,11 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTa
|
|||
return (SNode*)realTable;
|
||||
}
|
||||
|
||||
SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const SToken* pTableAlias) {
|
||||
SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, SToken* pTableAlias) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
if (!checkTableName(pCxt, pTableAlias)) {
|
||||
return NULL;
|
||||
}
|
||||
STempTableNode* tempTable = (STempTableNode*)nodesMakeNode(QUERY_NODE_TEMP_TABLE);
|
||||
CHECK_OUT_OF_MEM(tempTable);
|
||||
tempTable->pSubquery = pSubquery;
|
||||
|
|
|
@ -26,6 +26,8 @@ class TDTestCase:
|
|||
self.dbname = 'db'
|
||||
self.setsql = TDSetSql()
|
||||
self.stbname = 'stb'
|
||||
self.ntbname1 = 'ntb1'
|
||||
self.ntbname2 = 'ntb2'
|
||||
self.streamname = 'stm'
|
||||
self.streamtb = 'stm_stb'
|
||||
def topic_name_check(self):
|
||||
|
@ -75,10 +77,32 @@ class TDTestCase:
|
|||
tdSql.execute(f'drop stream `{self.streamname}`')
|
||||
tdSql.execute(f'drop database {self.dbname}')
|
||||
|
||||
def table_name_check(self):
|
||||
tdSql.execute(f'create database if not exists {self.dbname} wal_retention_period 3600')
|
||||
tdSql.execute(f'use {self.dbname}')
|
||||
tdSql.execute(f'create table {self.ntbname1} (ts timestamp,c0 int,c1 int)')
|
||||
tdSql.execute(f'create table {self.ntbname2} (ts timestamp,c0 int,c1 int)')
|
||||
tdSql.execute(f'insert into {self.ntbname1} values(now(),1,1)')
|
||||
tdSql.execute(f'insert into {self.ntbname2} values(now(),2,2)')
|
||||
tdSql.query(f'select `{self.ntbname1}`.`c0`, `{self.ntbname1}`.`c1` from `{self.ntbname1}`')
|
||||
tdSql.checkEqual(tdSql.queryResult[0][0], 1)
|
||||
tdSql.query(f'select `{self.ntbname1}`.`c0`, `{self.ntbname1}`.`c1` from `{self.dbname}`.`{self.ntbname1}`')
|
||||
tdSql.checkEqual(tdSql.queryResult[0][0], 1)
|
||||
tdSql.query(f'select `{self.ntbname1}`.`c0` from `{self.ntbname2}` `{self.ntbname1}`')
|
||||
tdSql.checkEqual(tdSql.queryResult[0][0], 2)
|
||||
tdSql.query(f'select `{self.ntbname1}`.`c0` from (select * from `{self.ntbname2}`) `{self.ntbname1}`')
|
||||
tdSql.checkEqual(tdSql.queryResult[0][0], 2)
|
||||
# select `t1`.`col1`, `col2`, `col3` from (select ts `col1`, 123 `col2`, c0 + c1 as `col3` from t2) `t1`;
|
||||
tdSql.query(f'select `{self.ntbname1}`.`col1`, `col2`, `col3` from (select ts `col1`, 123 `col2`, c0 + c1 as `col3` from {self.ntbname2}) `{self.ntbname1}`')
|
||||
tdSql.checkEqual(tdSql.queryResult[0][1], 123)
|
||||
tdSql.checkEqual(tdSql.queryResult[0][2], 4)
|
||||
|
||||
tdSql.execute(f'drop database {self.dbname}')
|
||||
def run(self):
|
||||
self.topic_name_check()
|
||||
self.db_name_check()
|
||||
self.stream_name_check()
|
||||
self.table_name_check()
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
|
Loading…
Reference in New Issue