[TD-6317]<fix> forbidden distinct with order by
This commit is contained in:
parent
7dcf682872
commit
1351b57036
|
@ -5787,11 +5787,6 @@ static void setDefaultOrderInfo(SQueryInfo* pQueryInfo) {
|
||||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||||
pQueryInfo->groupbyExpr.orderType = TSDB_ORDER_ASC;
|
pQueryInfo->groupbyExpr.orderType = TSDB_ORDER_ASC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQueryInfo->distinct) {
|
|
||||||
pQueryInfo->order.order = TSDB_ORDER_ASC;
|
|
||||||
pQueryInfo->order.orderColId = PRIMARYKEY_TIMESTAMP_COL_INDEX;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, SSchema* pSchema) {
|
int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, SSchema* pSchema) {
|
||||||
|
@ -5805,14 +5800,13 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
|
||||||
const char* msg7 = "only primary timestamp/column in groupby clause allowed as order column";
|
const char* msg7 = "only primary timestamp/column in groupby clause allowed as order column";
|
||||||
const char* msg8 = "only column in groupby clause allowed as order column";
|
const char* msg8 = "only column in groupby clause allowed as order column";
|
||||||
const char* msg9 = "orderby column must projected in subquery";
|
const char* msg9 = "orderby column must projected in subquery";
|
||||||
|
const char* msg10 = "not support distinct mixed with order by";
|
||||||
|
|
||||||
setDefaultOrderInfo(pQueryInfo);
|
setDefaultOrderInfo(pQueryInfo);
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
if (pSqlNode->pSortOrder == NULL) {
|
||||||
if (pQueryInfo->distinct || pSqlNode->pSortOrder == NULL) {
|
return TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_SUCCESS;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
char* pMsgBuf = tscGetErrorMsgPayload(pCmd);
|
char* pMsgBuf = tscGetErrorMsgPayload(pCmd);
|
||||||
SArray* pSortOrder = pSqlNode->pSortOrder;
|
SArray* pSortOrder = pSqlNode->pSortOrder;
|
||||||
|
|
||||||
|
@ -5832,6 +5826,9 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
|
||||||
return invalidOperationMsg(pMsgBuf, msg2);
|
return invalidOperationMsg(pMsgBuf, msg2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (size > 0 && pQueryInfo->distinct) {
|
||||||
|
return invalidOperationMsg(pMsgBuf, msg10);
|
||||||
|
}
|
||||||
|
|
||||||
// handle the first part of order by
|
// handle the first part of order by
|
||||||
tVariant* pVar = taosArrayGet(pSortOrder, 0);
|
tVariant* pVar = taosArrayGet(pSortOrder, 0);
|
||||||
|
|
Loading…
Reference in New Issue