Merge pull request #21754 from taosdata/fix/TD-24832
fix: invalid system table primary key and distinct order by column issue
This commit is contained in:
commit
3bd5fbad0c
|
@ -884,6 +884,10 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef,
|
||||||
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
||||||
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
|
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
|
||||||
if (isInternalPrimaryKey(pCol)) {
|
if (isInternalPrimaryKey(pCol)) {
|
||||||
|
if (TSDB_SYSTEM_TABLE == pMeta->tableType) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pCol->colName);
|
||||||
|
}
|
||||||
|
|
||||||
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema, -1, pCol);
|
setColumnInfoBySchema((SRealTableNode*)pTable, pMeta->schema, -1, pCol);
|
||||||
*pFound = true;
|
*pFound = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -2255,7 +2259,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
|
||||||
if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc) {
|
if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc || (isDistinctOrderBy(pCxt) && pCxt->currClause == SQL_CLAUSE_ORDER_BY)) {
|
||||||
return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias);
|
return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias);
|
||||||
} else {
|
} else {
|
||||||
return rewriteColToSelectValFunc(pCxt, pNode);
|
return rewriteColToSelectValFunc(pCxt, pNode);
|
||||||
|
|
|
@ -31,10 +31,10 @@ class TDTestCase:
|
||||||
tdSql.query(f"select histogram(`columns`, 'user_input', '[1, 3, 5]', 0) from `information_schema`.`ins_tables`;")
|
tdSql.query(f"select histogram(`columns`, 'user_input', '[1, 3, 5]', 0) from `information_schema`.`ins_tables`;")
|
||||||
tdSql.query(f"select hyperloglog(`columns`) from `information_schema`.`ins_tables`;")
|
tdSql.query(f"select hyperloglog(`columns`) from `information_schema`.`ins_tables`;")
|
||||||
tdSql.query(f"select sample(`columns`, 3) from `information_schema`.`ins_tables`;")
|
tdSql.query(f"select sample(`columns`, 3) from `information_schema`.`ins_tables`;")
|
||||||
tdSql.query(f"select tail(`columns`, 3) from `information_schema`.`ins_tables`;")
|
|
||||||
tdSql.query(f"select unique(`columns`) from `information_schema`.`ins_tables`;")
|
|
||||||
tdSql.query(f"select mode(`columns`) from `information_schema`.`ins_tables`;")
|
tdSql.query(f"select mode(`columns`) from `information_schema`.`ins_tables`;")
|
||||||
|
|
||||||
|
tdSql.error(f"select unique(`columns`) from `information_schema`.`ins_tables`;")
|
||||||
|
tdSql.error(f"select tail(`columns`, 3) from `information_schema`.`ins_tables`;")
|
||||||
tdSql.error(f"select leastsquares(`columns`, 1, 1) from `information_schema`.`ins_tables`;")
|
tdSql.error(f"select leastsquares(`columns`, 1, 1) from `information_schema`.`ins_tables`;")
|
||||||
tdSql.error(f"select elapsed(`columns`) from `information_schema`.`ins_tables`;")
|
tdSql.error(f"select elapsed(`columns`) from `information_schema`.`ins_tables`;")
|
||||||
tdSql.error(f"select interp(`columns`) from `information_schema`.`ins_tables` range(0, 1) every(1s) fill(null);")
|
tdSql.error(f"select interp(`columns`) from `information_schema`.`ins_tables` range(0, 1) every(1s) fill(null);")
|
||||||
|
|
Loading…
Reference in New Issue