提交 fa89ad47 编写于 作者: D dapan1121

add test case

上级 e5e8f6d7
......@@ -35,12 +35,12 @@ extern "C" {
#define UTIL_TABLE_IS_CHILD_TABLE(metaInfo) \
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_CHILD_TABLE))
#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo) \
(!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo)))
#define UTIL_TABLE_IS_TMP_TABLE(metaInfo) \
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_TEMP_TABLE))
#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo) \
(!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo) || UTIL_TABLE_IS_TMP_TABLE(metaInfo)))
#define UTIL_GET_VGROUPMAP(pSql) \
(pSql->pTscObj->pClusterInfo->vgroupMap)
......
......@@ -6193,6 +6193,27 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
return invalidOperationMsg(pMsgBuf, msg11);
}
if (tscIsProjectionQuery(pQueryInfo)) {
bool found = false;
for (int32_t i = 0; i < tscNumOfExprs(pQueryInfo); ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
if (pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.colInfo.colId == pSchema[index.columnIndex].colId) {
found = true;
break;
}
}
if (!found) {
int32_t numOfCols = (int32_t)tscNumOfFields(pQueryInfo);
tscAddFuncInSelectClause(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL, getNewResColId(pCmd));
SInternalField* pSupInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, numOfCols);
pSupInfo->visible = false;
pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY;
}
}
tVariantListItem* pItem = taosArrayGet(pSqlNode->pSortOrder, 0);
pQueryInfo->order.order = pItem->sortOrder;
pQueryInfo->order.orderColId = pSchema[index.columnIndex].colId;
......
......@@ -100,6 +100,7 @@ sql insert into tba1 values ('2021-11-11 09:00:29',true, 0,0,0,0,0,0,"000","0000
run general/compute/cast_query1.sim
run general/compute/cast_query2.sim
run general/compute/cast_query3.sim
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
......@@ -218,6 +218,8 @@ sql_error select cast(c2+c3 as binary(6)) from stb1 group by c1;
sql_error select cast(c2+c3 as binary(6)) from stb1 group by tbname;
sql_error select cast(c2+c3 as binary(6)) from tb1 order by c2;
sql_error select cast(c8 as bigint),cast(c9 as bigint(12)) from tbn;
sql_error select cast(ts as binary(10)) from (select avg(c2) as a from stb1 interval(1s));
sql_error select cast(a as timestamp) from (select cast(c2 as binary(2)) as a from tb1);
print "test constant"
......
......@@ -946,3 +946,320 @@ sql select cast(cast(cast(cast(ts as bigint) as binary(5)) as bigint)+cast(cast(
if $rows != 0 then
return -1
endi
sql select cast(a as bigint) from (select avg(c2) as a from stb1 interval(1s));
if $rows != 7 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 2 then
return -1
endi
if $data20 != 2 then
return -1
endi
if $data30 != 4 then
return -1
endi
if $data40 != 4 then
return -1
endi
if $data50 != 66 then
return -1
endi
if $data60 != -60 then
return -1
endi
sql select cast(c2 as binary(10)) from (select * from stb1);
if $rows != 14 then
return -1
endi
sql select cast(a as binary(10)) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));
if $rows != 10 then
return -1
endi
if $data00 != 1.000000 then
return -1
endi
if $data10 != 2.000000 then
return -1
endi
if $data20 != 2.500000 then
return -1
endi
if $data30 != 4.000000 then
return -1
endi
if $data40 != 4.500000 then
return -1
endi
if $data50 != 66.500000 then
return -1
endi
if $data60 != -60.000000 then
return -1
endi
if $data70 != NULL then
return -1
endi
if $data80 != NULL then
return -1
endi
if $data90 != NULL then
return -1
endi
sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;
if $rows != 10 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 2 then
return -1
endi
if $data20 != 2 then
return -1
endi
if $data30 != 4 then
return -1
endi
if $data40 != 4 then
return -1
endi
if $data50 != 66 then
return -1
endi
if $data60 != -60 then
return -1
endi
if $data70 != NULL then
return -1
endi
if $data80 != NULL then
return -1
endi
if $data90 != NULL then
return -1
endi
sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;
if $rows != 10 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != -60 then
return -1
endi
if $data40 != 66 then
return -1
endi
if $data50 != 4 then
return -1
endi
if $data60 != 4 then
return -1
endi
if $data70 != 2 then
return -1
endi
if $data80 != 2 then
return -1
endi
if $data90 != 1 then
return -1
endi
sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;
if $rows != 10 then
return -1
endi
if $data00 != NULL then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != 66 then
return -1
endi
if $data40 != 4 then
return -1
endi
if $data50 != 4 then
return -1
endi
if $data60 != 2 then
return -1
endi
if $data70 != 2 then
return -1
endi
if $data80 != 1 then
return -1
endi
if $data90 != -60 then
return -1
endi
sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;
if $rows != 10 then
return -1
endi
if $data00 != -60 then
return -1
endi
if $data10 != 1 then
return -1
endi
if $data20 != 2 then
return -1
endi
if $data30 != 2 then
return -1
endi
if $data40 != 4 then
return -1
endi
if $data50 != 4 then
return -1
endi
if $data60 != 66 then
return -1
endi
if $data70 != NULL then
return -1
endi
if $data80 != NULL then
return -1
endi
if $data90 != NULL then
return -1
endi
sql select cast(a as bigint) from (select cast(c2 as binary(2)) as a from tb1);
if $rows != 7 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != 2 then
return -1
endi
if $data30 != NULL then
return -1
endi
if $data40 != 4 then
return -1
endi
if $data50 != 12 then
return -1
endi
if $data60 != -1 then
return -1
endi
sql select cast(tb1.c3 as binary(10)),cast(tb2.c3 as binary(10)) from tb1,tb2 where tb1.ts=tb2.ts;
if $rows != 7 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data21 != 3 then
return -1
endi
if $data30 != 3 then
return -1
endi
if $data31 != 4 then
return -1
endi
if $data40 != 4 then
return -1
endi
if $data41 != 5 then
return -1
endi
if $data50 != 32767 then
return -1
endi
if $data51 != 6 then
return -1
endi
if $data60 != -32767 then
return -1
endi
if $data61 != 7 then
return -1
endi
sql select cast(c3 as binary(10)) from tb1 union all select cast(c3 as binary(10)) from tb2;
if $rows != 14 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != 3 then
return -1
endi
if $data40 != 4 then
return -1
endi
if $data50 != 32767 then
return -1
endi
if $data60 != -32767 then
return -1
endi
if $data70 != 1 then
return -1
endi
if $data80 != 2 then
return -1
endi
if $data90 != 3 then
return -1
endi
\ No newline at end of file
sleep 100
sql connect
sql use db;
sql select cast(stb1.c4 as binary(10)),cast(stba.c5 as binary(10)) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;
if $rows != 7 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data01 != 1 then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data20 != 2 then
return -1
endi
if $data21 != 3 then
return -1
endi
if $data30 != NULL then
return -1
endi
if $data31 != 4 then
return -1
endi
if $data40 != 4 then
return -1
endi
if $data41 != 5 then
return -1
endi
if $data50 != 2147483647 then
return -1
endi
if $data51 != 6 then
return -1
endi
if $data60 != -214748364 then
return -1
endi
if $data61 != 7 then
return -1
endi
sql select cast(c4 as binary(10)) as a from stb1 union all select cast(c5 as binary(10)) as a from stba;
if $rows != 44 then
return -1
endi
sql select cast(c2 as bigint) from stba;
if $rows != 30 then
return -1
endi
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册