fix: case issues

This commit is contained in:
dapan1121 2024-03-22 15:15:07 +08:00
parent e6caf6fd43
commit 84d0eb5fc0
8 changed files with 64 additions and 32 deletions

View File

@ -230,8 +230,8 @@ int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow,
int32_t len = pColumnInfoData->info.bytes;
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
len = varDataTLen(pData);
if (pColumnInfoData->varmeta.allocLen < (numOfRows + currentRow) * len) {
int32_t code = colDataReserve(pColumnInfoData, (numOfRows + currentRow) * len);
if (pColumnInfoData->varmeta.allocLen < (numOfRows * len + pColumnInfoData->varmeta.length)) {
int32_t code = colDataReserve(pColumnInfoData, (numOfRows * len + pColumnInfoData->varmeta.length));
if (code != TSDB_CODE_SUCCESS) {
return code;
}

View File

@ -5375,6 +5375,23 @@ static EDealRes appendTsForImplicitTsFuncImpl(SNode* pNode, void* pContext) {
STranslateContext* pCxt = pContext;
if (isImplicitTsFunc(pNode)) {
SFunctionNode* pFunc = (SFunctionNode*)pNode;
if (!isSelectStmt(pCxt->pCurrStmt)) {
pCxt->errCode = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
"%s function must be used in select statements", pFunc->functionName);
return DEAL_RES_ERROR;
}
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
if ((NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
!isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) &&
!isTimeLineAlignedQuery(pCxt->pCurrStmt)) ||
(NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) &&
(TIME_LINE_GLOBAL != pSelect->timeLineResMode && TIME_LINE_MULTI != pSelect->timeLineResMode))) {
pCxt->errCode = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
"%s function requires valid time series input", pFunc->functionName);
return DEAL_RES_ERROR;
}
SNode* pPrimaryKey = NULL;
SSHashObj* pTableAlias = NULL;
nodesWalkExprs(pFunc->pParameterList, collectTableAlias, &pTableAlias);
@ -5538,6 +5555,9 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
if (TSDB_CODE_SUCCESS == code) {
code = checkIsEmptyResult(pCxt, pSelect);
}
if (TSDB_CODE_SUCCESS == code) {
code = appendTsForImplicitTsFunc(pCxt, pSelect);
}
if (TSDB_CODE_SUCCESS == code) {
resetSelectFuncNumWithoutDup(pSelect);
code = checkAggColCoexist(pCxt, pSelect);
@ -5551,9 +5571,6 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
if (TSDB_CODE_SUCCESS == code) {
code = translateInterp(pCxt, pSelect);
}
if (TSDB_CODE_SUCCESS == code) {
code = appendTsForImplicitTsFunc(pCxt, pSelect);
}
if (TSDB_CODE_SUCCESS == code) {
code = replaceOrderByAliasForSelect(pCxt, pSelect);
}

View File

@ -7,6 +7,16 @@ if $rows != 64 then
endi
#inner join + non join
sql_error select tail(col1, 1) from (select b.col1 from sta a join sta b on a.ts = b.ts and a.t1 = b.t1 and a.t1 > 0) c;
sql_error select tail(col1, 1) from (select b.col1 from sta a join sta b on a.ts = b.ts and a.t1 = b.t1 and a.t1 > 0 order by b.ts) c;
sql select tail(col1, 1) from (select b.col1, a.ts from sta a join sta b on a.ts = b.ts and a.t1 = b.t1 and a.t1 > 0 order by b.ts) c;
if $rows != 1 then
return -1
endi
if $data00 != 7 then
return -1
endi
sql_error select a.*,b.* from (select * from sta partition by tbname) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts;
sql_error select a.t1 from (select * from sta partition by tbname order by col1) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts;
sql select a.t1 from (select * from sta partition by tbname order by ts) a join (select * from sta partition by tbname order by ts) b on a.ts = b.ts;

View File

@ -12,6 +12,8 @@ endi
sql_error select diff(a.col1) c1 from sta a join sta b on a.ts = b.ts and a.t1 = b.t1;
sql_error select csum(b.col1) from sta a join sta b on a.ts = b.ts and a.t1 = b.t1;
sql_error select tail(b.col1, 1) from sta a join sta b on a.ts = b.ts and a.t1 = b.t1;
sql_error select tail(b.col1, 1) from sta a join sta b on a.ts = b.ts and a.t1 = b.t1 and a.t1 > 0;
sql select count(a.col1) c1 from sta a join sta b on a.ts = b.ts and a.t1 = b.t1 interval(1s);
if $rows != 6 then

View File

@ -407,7 +407,7 @@ 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 _wstart asc;
sql select count(join_mt0.c1), sum(join_mt1.c2) 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
@ -426,13 +426,8 @@ if $data01 != $val then
return -1
endi
$val = 0
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 _wstart desc;
sql select count(join_mt0.c1), sum(join_mt1.c2) 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

View File

@ -423,16 +423,8 @@ class TDTestCase:
self.calc_select_in_not_support_ts_j = ['apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' ,
'apercentile(t1.q_int_null,20)' , 'apercentile(t1.q_bigint_null,20)' ,'apercentile(t1.q_smallint_null,20)' ,'apercentile(t1.q_tinyint_null,20)' ,'apercentile(t1.q_float_null,20)' ,'apercentile(t1.q_double_null,20)' ,
'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' ,
'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' ,
'last_row(t1.q_int_null)' , 'last_row(t1.q_bigint_null)' , 'last_row(t1.q_smallint_null)' , 'last_row(t1.q_tinyint_null)' , 'last_row(t1.q_float_null)' ,
'last_row(t1.q_double_null)' , 'last_row(t1.q_bool_null)' ,'last_row(t1.q_binary_null)' ,'last_row(t1.q_nchar_null)' ,'last_row(t1.q_ts_null)' ,
'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' ,
'apercentile(t2.q_int_null,20)' , 'apercentile(t2.q_bigint_null,20)' ,'apercentile(t2.q_smallint_null,20)' ,'apercentile(t2.q_tinyint_null,20)' ,'apercentile(t2.q_float_null,20)' ,'apercentile(t2.q_double_null,20)' ,
'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' ,
'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)',
'last_row(t2.q_int_null)' , 'last_row(t2.q_bigint_null)' , 'last_row(t2.q_smallint_null)' , 'last_row(t2.q_tinyint_null)' , 'last_row(t2.q_float_null)' ,
'last_row(t2.q_double_null)' , 'last_row(t2.q_bool_null)' ,'last_row(t2.q_binary_null)' ,'last_row(t2.q_nchar_null)' ,'last_row(t2.q_ts_null)']
'apercentile(t2.q_int_null,20)' , 'apercentile(t2.q_bigint_null,20)' ,'apercentile(t2.q_smallint_null,20)' ,'apercentile(t2.q_tinyint_null,20)' ,'apercentile(t2.q_float_null,20)' ,'apercentile(t2.q_double_null,20)' ]
self.calc_select_in_j = ['min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' ,
'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' ,
@ -5213,8 +5205,7 @@ class TDTestCase:
for i in range(self.fornum):
sql = "select * from ( select "
sql += "%s as calc16_1 " % random.choice(self.calc_calculate_groupbytbname_j)
sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and "
sql += "%s " % random.choice(self.t_join_where)
sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts "
sql += "limit 2 ) "
sql += "%s " % random.choice(self.limit1_where)
tdLog.info(sql)
@ -5588,9 +5579,7 @@ class TDTestCase:
sql += ") "
tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
self.cur1.execute(sql)
self.explain_sql(sql)
tdSql.error(sql)
tdSql.query("select 18-7 from stable_1;")
for i in range(self.fornum):

View File

@ -1239,8 +1239,7 @@ class TDTestCase:
tdLog.info(sql)
tdSql.query(sql)
self.explain_sql(sql)
elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \
or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) :
elif (mathlist == ['SAMPLE']) or (mathlist == ['HISTOGRAM']) or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['MODE']) :
sql = "select /*+ para_tables_sort() */ %s as asct1 " % math_fun_join_2
sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
sql += "%s " % random.choice(self.t_join_where)
@ -1250,6 +1249,15 @@ class TDTestCase:
tdLog.info(sql)
tdSql.query(sql)
self.explain_sql(sql)
elif (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['MAVG']) or (mathlist == ['UNIQUE']) or (mathlist == ['statecount','stateduration']) :
sql = "select /*+ para_tables_sort() */ %s as asct1 " % math_fun_join_2
sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
sql += "%s " % random.choice(self.t_join_where)
sql += "and %s " % random.choice(self.t_u_where)
sql += "and %s " % random.choice(self.t_u_or_where)
sql += "%s " % random.choice(self.limit1_where)
tdLog.info(sql)
tdSql.error(sql)
tdSql.query("select /*+ para_tables_sort() */1-10 as math_nest from stable_1 limit 1;")
for i in range(self.fornum):
@ -3025,8 +3033,7 @@ class TDTestCase:
sql += "%s " % random.choice(self.limit1_where)
sql += ") ;"
tdLog.info(sql)
tdSql.query(sql)
self.explain_sql(sql)
tdSql.error(sql)
tdSql.query("select /*+ para_tables_sort() */1-10 as time_nest from stable_1 limit 1;")

View File

@ -1385,8 +1385,7 @@ class TDTestCase:
tdSql.query(sql)
self.cur1.execute(sql)
self.explain_sql(sql)
elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \
or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) :
elif (mathlist == ['SAMPLE']) or (mathlist == ['HISTOGRAM']) or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['MODE']) :
sql = "select /*+ para_tables_sort() */ count(asct1) from ( select /*+ para_tables_sort() */ "
sql += "%s as asct1 " % math_fun_join_2
sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
@ -1400,6 +1399,19 @@ class TDTestCase:
tdSql.query(sql)
self.cur1.execute(sql)
self.explain_sql(sql)
elif (mathlist == ['MAVG']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \
or (mathlist == ['UNIQUE']) or (mathlist == ['statecount','stateduration']) :
sql = "select /*+ para_tables_sort() */ count(asct1) from ( select /*+ para_tables_sort() */ "
sql += "%s as asct1 " % math_fun_join_2
sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and "
sql += "%s " % random.choice(self.t_join_where)
sql += "and %s " % random.choice(self.t_u_where)
sql += "and %s " % random.choice(self.t_u_or_where)
sql += "%s " % random.choice(self.limit1_where)
sql += ") ;"
tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
self.restartDnodes()
tdSql.query("select /*+ para_tables_sort() */1-10 as math_nest from stable_1 limit 1;")