[td-4231]<enhance>: report error if only tags of the table are retrieved in the select clause when the filter condition only includes normal columns.
This commit is contained in:
parent
c824330bb5
commit
80fc12ea79
|
@ -7119,6 +7119,7 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i
|
||||||
const char* msg6 = "too many tables in from clause";
|
const char* msg6 = "too many tables in from clause";
|
||||||
const char* msg7 = "invalid table alias name";
|
const char* msg7 = "invalid table alias name";
|
||||||
const char* msg8 = "alias name too long";
|
const char* msg8 = "alias name too long";
|
||||||
|
const char* msg9 = "only tag query not compatible with normal column filter";
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -7288,6 +7289,16 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i
|
||||||
if (hasUnsupportFunctionsForSTableQuery(pCmd, pQueryInfo)) {
|
if (hasUnsupportFunctionsForSTableQuery(pCmd, pQueryInfo)) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(tscQueryTags(pQueryInfo)) {
|
||||||
|
int32_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
||||||
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumn* pCols = taosArrayGetP(pQueryInfo->colList, i);
|
||||||
|
if (pCols->numOfFilters > 0) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseSessionClause(pCmd, pQueryInfo, pQuerySqlNode) != TSDB_CODE_SUCCESS) {
|
if (parseSessionClause(pCmd, pQueryInfo, pQuerySqlNode) != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -847,10 +847,16 @@ sql_error select tbname, t1 from select_tags_mt0 interval(1y);
|
||||||
#valid sql: select first(c1), last(c2), count(*) from select_tags_mt0 group by tbname, t1;
|
#valid sql: select first(c1), last(c2), count(*) from select_tags_mt0 group by tbname, t1;
|
||||||
#valid sql: select first(c1), tbname, t1 from select_tags_mt0 group by t2;
|
#valid sql: select first(c1), tbname, t1 from select_tags_mt0 group by t2;
|
||||||
|
|
||||||
|
print ==================================>TD-4231
|
||||||
|
sql_error select t1,tbname from select_tags_mt0 where c1<0
|
||||||
|
sql_error select t1,tbname from select_tags_mt0 where c1<0 and tbname in ('select_tags_tb12')
|
||||||
|
|
||||||
|
sql select tbname from select_tags_mt0 where tbname in ('select_tags_tb12');
|
||||||
|
|
||||||
sql_error select first(c1), last(c2), t1 from select_tags_mt0 group by tbname;
|
sql_error select first(c1), last(c2), t1 from select_tags_mt0 group by tbname;
|
||||||
sql_error select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname;
|
sql_error select first(c1), last(c2), tbname, t2 from select_tags_mt0 group by tbname;
|
||||||
sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname;
|
sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group by tbname;
|
||||||
# this sql is valid: select first(c1), t2 from select_tags_mt0 group by tbname;
|
#valid sql: select first(c1), t2 from select_tags_mt0 group by tbname;
|
||||||
|
|
||||||
#sql select first(ts), tbname from select_tags_mt0 group by tbname;
|
#sql select first(ts), tbname from select_tags_mt0 group by tbname;
|
||||||
#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
|
#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
|
||||||
|
|
Loading…
Reference in New Issue