diff --git a/source/libs/executor/src/timesliceoperator.c b/source/libs/executor/src/timesliceoperator.c index 2698b0bfd951a701d4364d5c0312f256136cfdc1..4348bce1b8f4af05916429003b1a6ee1194acd8f 100644 --- a/source/libs/executor/src/timesliceoperator.c +++ b/source/libs/executor/src/timesliceoperator.c @@ -271,15 +271,27 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) { float v = 0; - GET_TYPED_DATA(v, float, pVar->nType, &pVar->i); + 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; - GET_TYPED_DATA(v, double, pVar->nType, &pVar->i); + 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; - GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); + 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; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 285102beeb209608401d65641bfefe18bfbca039..2a586a44a2ad7863ed5bbb08159a33ae48eba71e 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -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); } diff --git a/tests/system-test/2-query/interp.py b/tests/system-test/2-query/interp.py index cdbfa0de84ad51dbbbf5e9146ce43797cf13e5b8..6630713f73389f4fabe2f6542f3c89c7da982638 100644 --- a/tests/system-test/2-query/interp.py +++ b/tests/system-test/2-query/interp.py @@ -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")