Merge pull request #21352 from taosdata/fix/TD-24218
fix: fix interp in nested query and fill value with string issue
This commit is contained in:
commit
d801aaa2e6
|
@ -271,15 +271,27 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
|
||||
if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) {
|
||||
float v = 0;
|
||||
if (!IS_VAR_DATA_TYPE(pVar->nType)) {
|
||||
GET_TYPED_DATA(v, float, pVar->nType, &pVar->i);
|
||||
} else {
|
||||
v = taosStr2Float(varDataVal(pVar->pz), NULL);
|
||||
}
|
||||
colDataSetVal(pDst, rows, (char*)&v, false);
|
||||
} else if (pDst->info.type == TSDB_DATA_TYPE_DOUBLE) {
|
||||
double v = 0;
|
||||
if (!IS_VAR_DATA_TYPE(pVar->nType)) {
|
||||
GET_TYPED_DATA(v, double, pVar->nType, &pVar->i);
|
||||
} else {
|
||||
v = taosStr2Double(varDataVal(pVar->pz), NULL);
|
||||
}
|
||||
colDataSetVal(pDst, rows, (char*)&v, false);
|
||||
} else if (IS_SIGNED_NUMERIC_TYPE(pDst->info.type)) {
|
||||
int64_t v = 0;
|
||||
if (!IS_VAR_DATA_TYPE(pVar->nType)) {
|
||||
GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i);
|
||||
} else {
|
||||
v = taosStr2int64(varDataVal(pVar->pz));
|
||||
}
|
||||
colDataSetVal(pDst, rows, (char*)&v, false);
|
||||
} else if (IS_BOOLEAN_TYPE(pDst->info.type)) {
|
||||
bool v = false;
|
||||
|
|
|
@ -1523,11 +1523,6 @@ static int32_t translateInterpFunc(STranslateContext* pCxt, SFunctionNode* pFunc
|
|||
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
|
||||
SNode* pTable = pSelect->pFromTable;
|
||||
|
||||
if ((NULL != pTable && QUERY_NODE_REAL_TABLE != nodeType(pTable))) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE,
|
||||
"%s is only supported in single table query", pFunc->functionName);
|
||||
}
|
||||
|
||||
if (pSelect->hasAggFuncs || pSelect->hasMultiRowsFunc || pSelect->hasIndefiniteRowsFunc) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ class TDTestCase:
|
|||
|
||||
tdLog.printNoPrefix("==========step2:insert data")
|
||||
|
||||
tdSql.execute(f"use db")
|
||||
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:05', 5, 5, 5, 5, 5.0, 5.0, true, 'varchar', 'nchar')")
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:10', 10, 10, 10, 10, 10.0, 10.0, true, 'varchar', 'nchar')")
|
||||
tdSql.execute(f"insert into {dbname}.{tbname} values ('2020-02-01 00:00:15', 15, 15, 15, 15, 15.0, 15.0, true, 'varchar', 'nchar')")
|
||||
|
@ -182,6 +184,35 @@ class TDTestCase:
|
|||
tdSql.checkData(2, 0, 1)
|
||||
tdSql.checkData(3, 0, 1)
|
||||
|
||||
## test fill value with string
|
||||
tdSql.query(f"select interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:16', '2020-02-01 00:00:19') every(1s) fill(value, 'abc')")
|
||||
tdSql.checkRows(4)
|
||||
tdSql.checkData(0, 0, 0)
|
||||
tdSql.checkData(1, 0, 0)
|
||||
tdSql.checkData(2, 0, 0)
|
||||
tdSql.checkData(3, 0, 0)
|
||||
|
||||
tdSql.query(f"select interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:16', '2020-02-01 00:00:19') every(1s) fill(value, '123')")
|
||||
tdSql.checkRows(4)
|
||||
tdSql.checkData(0, 0, 123)
|
||||
tdSql.checkData(1, 0, 123)
|
||||
tdSql.checkData(2, 0, 123)
|
||||
tdSql.checkData(3, 0, 123)
|
||||
|
||||
tdSql.query(f"select interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:16', '2020-02-01 00:00:19') every(1s) fill(value, '123.123')")
|
||||
tdSql.checkRows(4)
|
||||
tdSql.checkData(0, 0, 123)
|
||||
tdSql.checkData(1, 0, 123)
|
||||
tdSql.checkData(2, 0, 123)
|
||||
tdSql.checkData(3, 0, 123)
|
||||
|
||||
tdSql.query(f"select interp(c0) from {dbname}.{tbname} range('2020-02-01 00:00:16', '2020-02-01 00:00:19') every(1s) fill(value, '12abc')")
|
||||
tdSql.checkRows(4)
|
||||
tdSql.checkData(0, 0, 12)
|
||||
tdSql.checkData(1, 0, 12)
|
||||
tdSql.checkData(2, 0, 12)
|
||||
tdSql.checkData(3, 0, 12)
|
||||
|
||||
tdLog.printNoPrefix("==========step5:fill prev")
|
||||
|
||||
## {. . .}
|
||||
|
@ -2916,6 +2947,24 @@ class TDTestCase:
|
|||
tdLog.printNoPrefix("======step 14: test interp pseudo columns")
|
||||
tdSql.error(f"select _irowts, c6 from {dbname}.{tbname}")
|
||||
|
||||
tdLog.printNoPrefix("======step 15: test interp in nested query")
|
||||
tdSql.query(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{stbname}) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
tdSql.query(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{ctbname1}) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
|
||||
tdSql.error(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{stbname}) partition by tbname range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
tdSql.error(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{ctbname1}) partition by tbname range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
|
||||
tdSql.error(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{ctbname1} union select * from {dbname}.{ctbname2}) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
tdSql.error(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{ctbname1} union select * from {dbname}.{ctbname2} order by ts) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
|
||||
tdSql.error(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{ctbname1} union all select * from {dbname}.{ctbname2}) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
tdSql.error(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{ctbname1} union all select * from {dbname}.{ctbname2} order by ts) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
|
||||
tdSql.error(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{ctbname1} union all select * from {dbname}.{ctbname2}) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
tdSql.error(f"select _irowts, _isfilled, interp(c0) from (select * from {dbname}.{ctbname1} union all select * from {dbname}.{ctbname2} order by ts) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
|
||||
tdSql.query(f"select _irowts, _isfilled, interp(c0) from (select {ctbname1}.ts,{ctbname1}.c0 from {dbname}.{ctbname1}, {dbname}.{ctbname2} where {ctbname1}.ts = {ctbname2}.ts) range('2020-02-01 00:00:00', '2020-02-01 00:00:14') every(1s) fill(null)")
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
|
Loading…
Reference in New Issue