提交 905a0780 编写于 作者: S shenglian zhou

fix: fix errors of join test case

上级 27437d85
......@@ -556,6 +556,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x2660)
#define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661)
#define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662)
#define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
//planner
......
......@@ -61,16 +61,42 @@ static bool beforeHaving(ESqlClause clause) { return clause < SQL_CLAUSE_HAVING;
static bool afterHaving(ESqlClause clause) { return clause > SQL_CLAUSE_HAVING; }
static bool hasSameTableAlias(SArray* pTables) {
if (taosArrayGetSize(pTables) < 2) {
return false;
}
STableNode* pTable0 = taosArrayGetP(pTables, 0);
for (int32_t i = 1; i < taosArrayGetSize(pTables); ++i) {
STableNode* pTable = taosArrayGetP(pTables, i);
if (0 == strcmp(pTable0->tableAlias, pTable->tableAlias)) {
return true;
}
}
return false;
}
static int32_t addNamespace(STranslateContext* pCxt, void* pTable) {
size_t currTotalLevel = taosArrayGetSize(pCxt->pNsLevel);
if (currTotalLevel > pCxt->currLevel) {
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
taosArrayPush(pTables, &pTable);
if (hasSameTableAlias(pTables)) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf,
TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS,
"Not unique table/alias: '%s'",
((STableNode*)pTable)->tableAlias);
}
} else {
do {
SArray* pTables = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES);
if (pCxt->currLevel == currTotalLevel) {
taosArrayPush(pTables, &pTable);
if (hasSameTableAlias(pTables)) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf,
TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS,
"Not unique table/alias: '%s'",
((STableNode*)pTable)->tableAlias);
}
}
taosArrayPush(pCxt->pNsLevel, &pTables);
++currTotalLevel;
......
此差异已折叠。
......@@ -560,6 +560,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE, "Only support single
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SMA_INDEX, "Invalid sma index")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_SELECTED_EXPR, "Invalid SELECTed expression")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GET_META_ERROR, "Fail to get table info")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS, "Not unique table/alias")
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error")
//planner
......
......@@ -133,7 +133,7 @@
./test.sh -f tsim/parser/join_manyblocks.sim
# TD-18018 ./test.sh -f tsim/parser/join_multitables.sim
./test.sh -f tsim/parser/join_multivnode.sim
# TD-17707 ./test.sh -f tsim/parser/join.sim
./test.sh -f tsim/parser/join.sim
./test.sh -f tsim/parser/last_cache.sim
./test.sh -f tsim/parser/last_groupby.sim
./test.sh -f tsim/parser/lastrow.sim
......
......@@ -320,7 +320,7 @@ sql_error select count(join_tb1.c3), last(join_tb1.c3) from $tb1 , $tb2 where jo
sql_error select count(join_tb3.*) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true;
sql_error select first(join_tb1.*) from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 or join_tb0.c7 = true;
sql_error select join_tb3.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true;
sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts = join_tb0.c1;
sql select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.ts and join_tb1.ts = join_tb0.c1;
sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts = join_tb0.c1;
sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.c7 = join_tb0.c1;
sql_error select join_tb1.* from $tb1 , $tb2 where join_tb1.ts > join_tb0.ts;
......@@ -407,32 +407,32 @@ if $data00 != 396.000000000 then
endi
# first/last
sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by join_mt0.ts asc;
sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by _wstart asc;
$val = 100
if $rows != $val then
print $rows
return -1
endi
print $data00 $data01 $data02
$val = 10
if $data01 != $val then
if $data00 != $val then
return -1
endi
$val = 45.000000000
print $data02
if $data02 != $val then
print $data01
if $data01 != $val then
return -1
endi
$val = 0
if $data03 != 0 then
if $data02 != 0 then
return -1
endi
# order by first/last
sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by join_mt0.ts desc;
sql select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts and join_mt0.t1=1 interval(10a) order by _wstart desc;
$val = 100
if $rows != $val then
......@@ -453,13 +453,13 @@ print =================>"group by not supported"
#======================limit offset===================================
# tag values not int
sql_error select count(*) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t2=join_mt1.t2;
sql select count(*) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t2=join_mt1.t2;
# tag type not identical
sql_error select count(*) from join_mt0, join_mt1 where join_mt1.t2 = join_mt0.t1 and join_mt1.ts=join_mt0.ts;
sql select count(*) from join_mt0, join_mt1 where join_mt1.t2 = join_mt0.t1 and join_mt1.ts=join_mt0.ts;
# table/super table join
sql_error select count(join_mt0.c1) from join_mt0, join_tb1 where join_mt0.ts=join_tb1.ts
sql select count(join_mt0.c1) from join_mt0, join_tb1 where join_mt0.ts=join_tb1.ts
# multi-condition
......@@ -471,7 +471,7 @@ sql_error select count(join_mt0.c1), count(join_mt0.c2) from join_mt0, join_mt0
sql_error select sum(join_mt1.c2) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1;
# missing tag equals
sql_error select count(join_mt1.c3) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts;
sql select count(join_mt1.c3) from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts;
# tag values are identical error
sql create table m1(ts timestamp, k int) tags(a int);
......@@ -486,7 +486,7 @@ sql insert into tm2 using m1 tags(1) values(1000000, 1)(2000000, 2);
sql insert into um1 using m2 tags(1) values(1000001, 10)(2000000, 20);
sql insert into um2 using m2 tags(9) values(1000001, 10)(2000000, 20);
sql_error select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts;
sql select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts;
print ====> empty table/empty super-table join test, add for no result join test
sql create database ux1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册