merge: from 3.3.6 to main branch (#32389)
* enh: grant support for data source ORC (#32378) * fix: wrong col_id in ins_columns (#32358) * test: remove un checked case (#32388) * fix(parser): subquery use last_row can't found the colname (#32353) * add col_id info in ins_columns * fix: test case --------- Co-authored-by: Kaili Xu <klxu@taosdata.com> Co-authored-by: Tony Zhang <34825804+Tony2h@users.noreply.github.com> Co-authored-by: hongzhenliu <wluckyjob@gmail.com> Co-authored-by: Tony Zhang <tonyzhang@taosdata.com>
This commit is contained in:
parent
74a1397134
commit
fe1658b79c
|
@ -249,6 +249,7 @@ static const SSysDbTableSchema userColsSchema[] = {
|
|||
{.name = "col_scale", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "col_nullable", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "col_source", .bytes = TSDB_COL_FNAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
|
||||
{.name = "col_id", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userVctbColsSchema[] = {
|
||||
|
|
|
@ -3546,9 +3546,12 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock *p, const SSysTableMeta *p
|
|||
varDataSetLen(colTypeStr, colTypeLen);
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfoData, numOfRows, (char *)colTypeStr, false), &lino, _OVER);
|
||||
|
||||
// col length
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfoData, numOfRows, (const char *)&pm->schema[j].bytes, false), &lino, _OVER);
|
||||
for (int32_t k = 6; k <= 9; ++k) {
|
||||
|
||||
// col precision, col scale, col nullable, col source
|
||||
for (int32_t k = 6; k <= 10; ++k) {
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, k);
|
||||
colDataSetNULL(pColInfoData, numOfRows);
|
||||
}
|
||||
|
@ -3711,13 +3714,21 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
varDataSetLen(colTypeStr, colTypeLen);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (char *)colTypeStr, false), pStb, &lino, _OVER);
|
||||
|
||||
// col length
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->pColumns[i].bytes, false), pStb,
|
||||
&lino, _OVER);
|
||||
while (cols < pShow->numOfColumns) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
||||
// col precision, col scale, col nullable, col source
|
||||
for (int32_t j = 6; j <= 9; ++j) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, j);
|
||||
colDataSetNULL(pColInfo, numOfRows);
|
||||
}
|
||||
|
||||
// col id
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, 10);
|
||||
RETRIEVE_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->pColumns[i].colId, false), pStb,
|
||||
&lino, _OVER);
|
||||
numOfRows++;
|
||||
}
|
||||
|
||||
|
|
|
@ -1492,11 +1492,13 @@ static int32_t sysTableUserColsFillOneTableCols(const SSysTableScanInfo* pInfo,
|
|||
code = colDataSetVal(pColInfoData, numOfRows, (char*)colTypeStr, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
// col length
|
||||
pColInfoData = taosArrayGet(dataBlock->pDataBlock, 5);
|
||||
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
||||
code = colDataSetVal(pColInfoData, numOfRows, (const char*)&schemaRow->pSchema[i].bytes, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
// col precision, col scale, col nullable
|
||||
for (int32_t j = 6; j <= 8; ++j) {
|
||||
pColInfoData = taosArrayGet(dataBlock->pDataBlock, j);
|
||||
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
||||
|
@ -1521,6 +1523,13 @@ static int32_t sysTableUserColsFillOneTableCols(const SSysTableScanInfo* pInfo,
|
|||
code = colDataSetVal(pColInfoData, numOfRows, (char*)refColName, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
// col id
|
||||
pColInfoData = taosArrayGet(dataBlock->pDataBlock, 10);
|
||||
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
|
||||
code = colDataSetVal(pColInfoData, numOfRows, (const char*)&schemaRow->pSchema[i].colId, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
++numOfRows;
|
||||
}
|
||||
|
||||
|
|
|
@ -3250,6 +3250,8 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu
|
|||
}
|
||||
}
|
||||
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias && !pFunc->node.asParam) {
|
||||
tstrncpy(pFunc->node.aliasName, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->aliasName,
|
||||
TSDB_COL_NAME_LEN);
|
||||
tstrncpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias,
|
||||
TSDB_COL_NAME_LEN);
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ taos> select table_name, db_name, columns, stable_name, type from information_sc
|
|||
vtb_virtual_ntb8 | test_vtable_meta | 20 | NULL | VIRTUAL_NORMAL_TABLE |
|
||||
vtb_virtual_ntb9 | test_vtable_meta | 20 | NULL | VIRTUAL_NORMAL_TABLE |
|
||||
|
||||
taos> select * from information_schema.ins_columns where table_type = 'VIRTUAL_NORMAL_TABLE' or table_type = 'VIRTUAL_CHILD_TABLE' order by table_name, col_name, table_type
|
||||
taos> select table_name, db_name, table_type, col_name, col_type, col_length, col_precision, col_scale, col_nullable, col_source from information_schema.ins_columns where table_type = 'VIRTUAL_NORMAL_TABLE' or table_type = 'VIRTUAL_CHILD_TABLE' order by table_name, col_name, table_type
|
||||
table_name | db_name | table_type | col_name | col_type | col_length | col_precision | col_scale | col_nullable | col_source |
|
||||
==========================================================================================================================================================================================================================================================
|
||||
vtb_virtual_ctb0 | test_vtable_meta | VIRTUAL_CHILD_TABLE | bigint_col | BIGINT | 8 | NULL | NULL | NULL | NULL |
|
||||
|
|
|
@ -13,4 +13,4 @@ describe test_vtable_meta.vtb_virtual_ctb0;
|
|||
describe test_vtable_meta.vtb_virtual_ntb0;
|
||||
select stable_name, db_name, columns, `tags`, isvirtual from information_schema.ins_stables where isvirtual = true order by stable_name;
|
||||
select table_name, db_name, columns, stable_name, type from information_schema.ins_tables where type = 'VIRTUAL_NORMAL_TABLE' or type = 'VIRTUAL_CHILD_TABLE' order by table_name;
|
||||
select * from information_schema.ins_columns where table_type = 'VIRTUAL_NORMAL_TABLE' or table_type = 'VIRTUAL_CHILD_TABLE' order by table_name, col_name, table_type;
|
||||
select table_name, db_name, table_type, col_name, col_type, col_length, col_precision, col_scale, col_nullable, col_source from information_schema.ins_columns where table_type = 'VIRTUAL_NORMAL_TABLE' or table_type = 'VIRTUAL_CHILD_TABLE' order by table_name, col_name, table_type;
|
|
@ -0,0 +1,46 @@
|
|||
from new_test_framework.utils import tdLog, tdSql, sc, clusterComCheck
|
||||
|
||||
class TestLastRow:
|
||||
|
||||
def setup_class(cls):
|
||||
tdLog.debug(f"start to execute {__file__}")
|
||||
|
||||
def test_last_row(self):
|
||||
"""Last Row Sub Query Test
|
||||
|
||||
1.Create db
|
||||
2.Create supper table and sub table
|
||||
3.Insert data into sub table
|
||||
4.Query last row from sub table as a sub query, it should return the last row data
|
||||
|
||||
Catalog:
|
||||
- Query
|
||||
|
||||
Since: v3.0.0.0
|
||||
|
||||
Labels: common,ci
|
||||
|
||||
Jira: TS-6365
|
||||
|
||||
History:
|
||||
- 2025-7-29 Ethan liu adds test for a sub query use last row
|
||||
|
||||
"""
|
||||
|
||||
tdLog.info(f"========== start sub query test")
|
||||
tdSql.execute(f"drop database if exists test_sub_query")
|
||||
tdSql.execute(f"create database test_sub_query")
|
||||
tdSql.execute(f"use test_sub_query")
|
||||
|
||||
# create super table and sub table
|
||||
tdSql.execute(f"create table super_t (ts timestamp, flag int) tags (t1 VARCHAR(10))")
|
||||
tdSql.execute(f"create table sub_t0 using super_t tags('t1')")
|
||||
|
||||
tdSql.execute(f"insert into sub_t0 values (now, 0)")
|
||||
|
||||
tdSql.execute(f"alter local 'keepColumnName' '1'")
|
||||
|
||||
tdSql.execute(f"select flag from (select last_row(flag) from sub_t0) as t")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdLog.info(f"end sub query test successfully")
|
|
@ -34,7 +34,7 @@ class TestOdbc:
|
|||
tdSql.checkData(5, 4, 8)
|
||||
|
||||
tdSql.query("desc information_schema.ins_columns")
|
||||
tdSql.checkRows(10)
|
||||
tdSql.checkRows(11)
|
||||
tdSql.checkData(0, 0, "table_name")
|
||||
tdSql.checkData(5, 0, "col_length")
|
||||
tdSql.checkData(1, 2, 64)
|
||||
|
|
|
@ -340,6 +340,7 @@
|
|||
## 08-SubQuery
|
||||
,,y,.,./ci/pytest.sh pytest cases/07-DataQuerying/08-SubQuery/test_nestquery.py
|
||||
,,y,.,./ci/pytest.sh pytest cases/07-DataQuerying/08-SubQuery/test_timeline.py
|
||||
,,y,.,./ci/pytest.sh pytest cases/07-DataQuerying/08-SubQuery/test_last_row.py
|
||||
## 09-SelectList
|
||||
,,y,.,./ci/pytest.sh pytest cases/07-DataQuerying/09-SelectList/test_column_1.py
|
||||
,,y,.,./ci/pytest.sh pytest cases/07-DataQuerying/09-SelectList/test_column_7.py
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue