Merge pull request #14855 from taosdata/feature/3.0_debug_wxy

feat: support pseudo columns such as _qstart, _qend and _qduration
This commit is contained in:
Xiaoyu Wang 2022-07-14 10:09:32 +08:00 committed by GitHub
commit bc1251e0cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 2778 additions and 2640 deletions

View File

@ -98,10 +98,10 @@ int32_t create_stream() {
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/ /*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/ /*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/ /*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
pRes = taos_query( pRes =
pConn, taos_query(pConn,
"create stream stream1 trigger max_delay 10s into outstb as select _wstartts, sum(k) from st1 partition " "create stream stream1 trigger max_delay 10s into outstb as select _wstart, sum(k) from st1 partition "
"by tbname session(ts, 10s) "); "by tbname session(ts, 10s) ");
if (taos_errno(pRes) != 0) { if (taos_errno(pRes) != 0) {
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes)); printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
return -1; return -1;

View File

@ -213,63 +213,64 @@
#define TK_NK_ARROW 195 #define TK_NK_ARROW 195
#define TK_ROWTS 196 #define TK_ROWTS 196
#define TK_TBNAME 197 #define TK_TBNAME 197
#define TK_QSTARTTS 198 #define TK_QSTART 198
#define TK_QENDTS 199 #define TK_QEND 199
#define TK_WSTARTTS 200 #define TK_QDURATION 200
#define TK_WENDTS 201 #define TK_WSTART 201
#define TK_WDURATION 202 #define TK_WEND 202
#define TK_CAST 203 #define TK_WDURATION 203
#define TK_NOW 204 #define TK_CAST 204
#define TK_TODAY 205 #define TK_NOW 205
#define TK_TIMEZONE 206 #define TK_TODAY 206
#define TK_CLIENT_VERSION 207 #define TK_TIMEZONE 207
#define TK_SERVER_VERSION 208 #define TK_CLIENT_VERSION 208
#define TK_SERVER_STATUS 209 #define TK_SERVER_VERSION 209
#define TK_CURRENT_USER 210 #define TK_SERVER_STATUS 210
#define TK_COUNT 211 #define TK_CURRENT_USER 211
#define TK_LAST_ROW 212 #define TK_COUNT 212
#define TK_BETWEEN 213 #define TK_LAST_ROW 213
#define TK_IS 214 #define TK_BETWEEN 214
#define TK_NK_LT 215 #define TK_IS 215
#define TK_NK_GT 216 #define TK_NK_LT 216
#define TK_NK_LE 217 #define TK_NK_GT 217
#define TK_NK_GE 218 #define TK_NK_LE 218
#define TK_NK_NE 219 #define TK_NK_GE 219
#define TK_MATCH 220 #define TK_NK_NE 220
#define TK_NMATCH 221 #define TK_MATCH 221
#define TK_CONTAINS 222 #define TK_NMATCH 222
#define TK_JOIN 223 #define TK_CONTAINS 223
#define TK_INNER 224 #define TK_JOIN 224
#define TK_SELECT 225 #define TK_INNER 225
#define TK_DISTINCT 226 #define TK_SELECT 226
#define TK_WHERE 227 #define TK_DISTINCT 227
#define TK_PARTITION 228 #define TK_WHERE 228
#define TK_BY 229 #define TK_PARTITION 229
#define TK_SESSION 230 #define TK_BY 230
#define TK_STATE_WINDOW 231 #define TK_SESSION 231
#define TK_SLIDING 232 #define TK_STATE_WINDOW 232
#define TK_FILL 233 #define TK_SLIDING 233
#define TK_VALUE 234 #define TK_FILL 234
#define TK_NONE 235 #define TK_VALUE 235
#define TK_PREV 236 #define TK_NONE 236
#define TK_LINEAR 237 #define TK_PREV 237
#define TK_NEXT 238 #define TK_LINEAR 238
#define TK_HAVING 239 #define TK_NEXT 239
#define TK_RANGE 240 #define TK_HAVING 240
#define TK_EVERY 241 #define TK_RANGE 241
#define TK_ORDER 242 #define TK_EVERY 242
#define TK_SLIMIT 243 #define TK_ORDER 243
#define TK_SOFFSET 244 #define TK_SLIMIT 244
#define TK_LIMIT 245 #define TK_SOFFSET 245
#define TK_OFFSET 246 #define TK_LIMIT 246
#define TK_ASC 247 #define TK_OFFSET 247
#define TK_NULLS 248 #define TK_ASC 248
#define TK_ID 249 #define TK_NULLS 249
#define TK_NK_BITNOT 250 #define TK_ID 250
#define TK_VALUES 251 #define TK_NK_BITNOT 251
#define TK_IMPORT 252 #define TK_VALUES 252
#define TK_NK_SEMI 253 #define TK_IMPORT 253
#define TK_FILE 254 #define TK_NK_SEMI 254
#define TK_FILE 255
#define TK_NK_SPACE 300 #define TK_NK_SPACE 300
#define TK_NK_COMMENT 301 #define TK_NK_COMMENT 301

View File

@ -34,7 +34,7 @@ typedef enum EFunctionType {
FUNCTION_TYPE_ELAPSED, FUNCTION_TYPE_ELAPSED,
FUNCTION_TYPE_IRATE, FUNCTION_TYPE_IRATE,
FUNCTION_TYPE_LAST_ROW, FUNCTION_TYPE_LAST_ROW,
FUNCTION_TYPE_LAST_ROWT, //TODO: removed FUNCTION_TYPE_LAST_ROWT, // TODO: removed
FUNCTION_TYPE_MAX, FUNCTION_TYPE_MAX,
FUNCTION_TYPE_MIN, FUNCTION_TYPE_MIN,
FUNCTION_TYPE_MODE, FUNCTION_TYPE_MODE,
@ -114,10 +114,11 @@ typedef enum EFunctionType {
// pseudo column function // pseudo column function
FUNCTION_TYPE_ROWTS = 3500, FUNCTION_TYPE_ROWTS = 3500,
FUNCTION_TYPE_TBNAME, FUNCTION_TYPE_TBNAME,
FUNCTION_TYPE_QSTARTTS, FUNCTION_TYPE_QSTART,
FUNCTION_TYPE_QENDTS, FUNCTION_TYPE_QEND,
FUNCTION_TYPE_WSTARTTS, FUNCTION_TYPE_QDURATION,
FUNCTION_TYPE_WENDTS, FUNCTION_TYPE_WSTART,
FUNCTION_TYPE_WEND,
FUNCTION_TYPE_WDURATION, FUNCTION_TYPE_WDURATION,
// internal function // internal function
@ -197,6 +198,7 @@ bool fmIsInterpFunc(int32_t funcId);
bool fmIsLastRowFunc(int32_t funcId); bool fmIsLastRowFunc(int32_t funcId);
bool fmIsSystemInfoFunc(int32_t funcId); bool fmIsSystemInfoFunc(int32_t funcId);
bool fmIsImplicitTsFunc(int32_t funcId); bool fmIsImplicitTsFunc(int32_t funcId);
bool fmIsClientPseudoColumnFunc(int32_t funcId);
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc);

View File

@ -228,7 +228,7 @@ typedef struct SFillNode {
ENodeType type; // QUERY_NODE_FILL ENodeType type; // QUERY_NODE_FILL
EFillMode mode; EFillMode mode;
SNode* pValues; // SNodeListNode SNode* pValues; // SNodeListNode
SNode* pWStartTs; // _wstartts pseudo column SNode* pWStartTs; // _wstart pseudo column
STimeWindow timeRange; STimeWindow timeRange;
} SFillNode; } SFillNode;
@ -248,6 +248,7 @@ typedef struct SSelectStmt {
SNodeList* pOrderByList; // SOrderByExprNode SNodeList* pOrderByList; // SOrderByExprNode
SLimitNode* pLimit; SLimitNode* pLimit;
SLimitNode* pSlimit; SLimitNode* pSlimit;
STimeWindow timeRange;
char stmtName[TSDB_TABLE_NAME_LEN]; char stmtName[TSDB_TABLE_NAME_LEN];
uint8_t precision; uint8_t precision;
int32_t selectFuncNum; int32_t selectFuncNum;

View File

@ -1483,8 +1483,8 @@ int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosi
} else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) { } else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
// do nothing, todo refactor // do nothing, todo refactor
} else { } else {
// expand the result into multiple rows. E.g., _wstartts, top(k, 20) // expand the result into multiple rows. E.g., _wstart, top(k, 20)
// the _wstartts needs to copy to 20 following rows, since the results of top-k expands to 20 different rows. // the _wstart needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId); SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo); char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
for (int32_t k = 0; k < pRow->numOfRows; ++k) { for (int32_t k = 0; k < pRow->numOfRows; ++k) {
@ -1555,8 +1555,8 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprI
} else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) { } else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
// do nothing, todo refactor // do nothing, todo refactor
} else { } else {
// expand the result into multiple rows. E.g., _wstartts, top(k, 20) // expand the result into multiple rows. E.g., _wstart, top(k, 20)
// the _wstartts needs to copy to 20 following rows, since the results of top-k expands to 20 different rows. // the _wstart needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId); SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo); char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
if (pCtx[j].increase) { if (pCtx[j].increase) {

View File

@ -1600,7 +1600,7 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
} }
void increaseTs(SqlFunctionCtx* pCtx) { void increaseTs(SqlFunctionCtx* pCtx) {
if (pCtx[0].pExpr->pExpr->_function.pFunctNode->funcType == FUNCTION_TYPE_WSTARTTS) { if (pCtx[0].pExpr->pExpr->_function.pFunctNode->funcType == FUNCTION_TYPE_WSTART) {
pCtx[0].increase = true; pCtx[0].increase = true;
} }
} }

View File

@ -47,6 +47,7 @@ extern "C" {
#define FUNC_MGT_FORBID_WINDOW_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(18) #define FUNC_MGT_FORBID_WINDOW_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(18)
#define FUNC_MGT_FORBID_GROUP_BY_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(19) #define FUNC_MGT_FORBID_GROUP_BY_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(19)
#define FUNC_MGT_SYSTEM_INFO_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(20) #define FUNC_MGT_SYSTEM_INFO_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(20)
#define FUNC_MGT_CLIENT_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(21)
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)

View File

@ -2784,28 +2784,38 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.finalizeFunc = NULL .finalizeFunc = NULL
}, },
{ {
.name = "_qstartts", .name = "_qstart",
.type = FUNCTION_TYPE_QSTARTTS, .type = FUNCTION_TYPE_QSTART,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_CLIENT_PC_FUNC,
.translateFunc = translateTimePseudoColumn, .translateFunc = translateTimePseudoColumn,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = qStartTsFunction, .sprocessFunc = NULL,
.finalizeFunc = NULL .finalizeFunc = NULL
}, },
{ {
.name = "_qendts", .name = "_qend",
.type = FUNCTION_TYPE_QENDTS, .type = FUNCTION_TYPE_QEND,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_CLIENT_PC_FUNC,
.translateFunc = translateTimePseudoColumn, .translateFunc = translateTimePseudoColumn,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = qEndTsFunction, .sprocessFunc = NULL,
.finalizeFunc = NULL .finalizeFunc = NULL
}, },
{ {
.name = "_wstartts", .name = "_qduration",
.type = FUNCTION_TYPE_WSTARTTS, .type = FUNCTION_TYPE_QDURATION,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_CLIENT_PC_FUNC,
.translateFunc = translateWduration,
.getEnvFunc = NULL,
.initFunc = NULL,
.sprocessFunc = NULL,
.finalizeFunc = NULL
},
{
.name = "_wstart",
.type = FUNCTION_TYPE_WSTART,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
.translateFunc = translateTimePseudoColumn, .translateFunc = translateTimePseudoColumn,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,
@ -2814,8 +2824,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.finalizeFunc = NULL .finalizeFunc = NULL
}, },
{ {
.name = "_wendts", .name = "_wend",
.type = FUNCTION_TYPE_WENDTS, .type = FUNCTION_TYPE_WEND,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
.translateFunc = translateTimePseudoColumn, .translateFunc = translateTimePseudoColumn,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,

View File

@ -183,6 +183,8 @@ bool fmIsSystemInfoFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId,
bool fmIsImplicitTsFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_IMPLICIT_TS_FUNC); } bool fmIsImplicitTsFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_IMPLICIT_TS_FUNC); }
bool fmIsClientPseudoColumnFunc(int32_t funcId) { return isSpecificClassifyFunc(funcId, FUNC_MGT_CLIENT_PC_FUNC); }
bool fmIsInterpFunc(int32_t funcId) { bool fmIsInterpFunc(int32_t funcId) {
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
return false; return false;
@ -227,8 +229,8 @@ bool fmIsInvertible(int32_t funcId) {
case FUNCTION_TYPE_SUM: case FUNCTION_TYPE_SUM:
case FUNCTION_TYPE_STDDEV: case FUNCTION_TYPE_STDDEV:
case FUNCTION_TYPE_AVG: case FUNCTION_TYPE_AVG:
case FUNCTION_TYPE_WSTARTTS: case FUNCTION_TYPE_WSTART:
case FUNCTION_TYPE_WENDTS: case FUNCTION_TYPE_WEND:
case FUNCTION_TYPE_WDURATION: case FUNCTION_TYPE_WDURATION:
res = true; res = true;
break; break;

View File

@ -127,6 +127,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
COPY_SCALAR_FIELD(isDuration); COPY_SCALAR_FIELD(isDuration);
COPY_SCALAR_FIELD(translate); COPY_SCALAR_FIELD(translate);
COPY_SCALAR_FIELD(notReserved); COPY_SCALAR_FIELD(notReserved);
COPY_SCALAR_FIELD(isNull);
COPY_SCALAR_FIELD(placeholderNo); COPY_SCALAR_FIELD(placeholderNo);
COPY_SCALAR_FIELD(typeData); COPY_SCALAR_FIELD(typeData);
COPY_SCALAR_FIELD(unit); COPY_SCALAR_FIELD(unit);

View File

@ -2712,6 +2712,7 @@ static const char* jkValueLiteral = "Literal";
static const char* jkValueDuration = "Duration"; static const char* jkValueDuration = "Duration";
static const char* jkValueTranslate = "Translate"; static const char* jkValueTranslate = "Translate";
static const char* jkValueNotReserved = "NotReserved"; static const char* jkValueNotReserved = "NotReserved";
static const char* jkValueIsNull = "IsNull";
static const char* jkValueDatum = "Datum"; static const char* jkValueDatum = "Datum";
static int32_t datumToJson(const void* pObj, SJson* pJson) { static int32_t datumToJson(const void* pObj, SJson* pJson) {
@ -2798,6 +2799,9 @@ static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddBoolToObject(pJson, jkValueNotReserved, pNode->notReserved); code = tjsonAddBoolToObject(pJson, jkValueNotReserved, pNode->notReserved);
} }
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddBoolToObject(pJson, jkValueIsNull, pNode->isNull);
}
if (TSDB_CODE_SUCCESS == code && pNode->translate) { if (TSDB_CODE_SUCCESS == code && pNode->translate) {
code = datumToJson(pNode, pJson); code = datumToJson(pNode, pJson);
} }
@ -2945,6 +2949,9 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBoolValue(pJson, jkValueNotReserved, &pNode->notReserved); code = tjsonGetBoolValue(pJson, jkValueNotReserved, &pNode->notReserved);
} }
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBoolValue(pJson, jkValueIsNull, &pNode->isNull);
}
if (TSDB_CODE_SUCCESS == code && pNode->translate) { if (TSDB_CODE_SUCCESS == code && pNode->translate) {
code = jsonToDatum(pJson, pNode); code = jsonToDatum(pJson, pNode);
} }

View File

@ -956,7 +956,6 @@ void nodesDestroyNode(SNode* pNode) {
} }
case QUERY_NODE_PHYSICAL_SUBPLAN: { case QUERY_NODE_PHYSICAL_SUBPLAN: {
SSubplan* pSubplan = (SSubplan*)pNode; SSubplan* pSubplan = (SSubplan*)pNode;
// nodesDestroyList(pSubplan->pChildren);
nodesClearList(pSubplan->pChildren); nodesClearList(pSubplan->pChildren);
nodesDestroyNode((SNode*)pSubplan->pNode); nodesDestroyNode((SNode*)pSubplan->pNode);
nodesDestroyNode((SNode*)pSubplan->pDataSink); nodesDestroyNode((SNode*)pSubplan->pDataSink);
@ -965,25 +964,9 @@ void nodesDestroyNode(SNode* pNode) {
nodesClearList(pSubplan->pParents); nodesClearList(pSubplan->pParents);
break; break;
} }
case QUERY_NODE_PHYSICAL_PLAN: { case QUERY_NODE_PHYSICAL_PLAN:
SQueryPlan* pPlan = (SQueryPlan*)pNode; nodesDestroyList(((SQueryPlan*)pNode)->pSubplans);
if (NULL != pPlan->pSubplans) {
// only need to destroy the top-level subplans, because they will recurse to all the subplans below
bool first = true;
SNode* pElement = NULL;
FOREACH(pElement, pPlan->pSubplans) {
if (first) {
// first = false;
nodesDestroyNode(pElement);
} else {
nodesClearList(((SNodeListNode*)pElement)->pNodeList);
taosMemoryFreeClear(pElement);
}
}
nodesClearList(pPlan->pSubplans);
}
break; break;
}
default: default:
break; break;
} }
@ -1709,6 +1692,11 @@ int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
} }
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal) { void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
if (pNode->isNull) {
pVal->nType = TSDB_DATA_TYPE_NULL;
pVal->nLen = tDataTypes[TSDB_DATA_TYPE_NULL].bytes;
return;
}
pVal->nType = pNode->node.resType.type; pVal->nType = pNode->node.resType.type;
pVal->nLen = pNode->node.resType.bytes; pVal->nLen = pNode->node.resType.bytes;
switch (pNode->node.resType.type) { switch (pNode->node.resType.type) {
@ -1789,7 +1777,7 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext; SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext;
if (QUERY_NODE_COLUMN == nodeType(pNode)) { if (QUERY_NODE_COLUMN == nodeType(pNode)) {
SColumnNode* pCol = (SColumnNode*)pNode; SColumnNode* pCol = (SColumnNode*)pNode;
if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId) { if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId && TSDB_SYSTEM_TABLE != pCol->tableType) {
pCxt->hasPrimaryKey = true; pCxt->hasPrimaryKey = true;
} else if (pCol->hasIndex) { } else if (pCol->hasIndex) {
pCxt->hasTagIndexCol = true; pCxt->hasTagIndexCol = true;

View File

@ -520,7 +520,9 @@ cmd ::= DELETE FROM full_table_name(A) where_clause_opt(B).
cmd ::= query_expression(A). { pCxt->pRootNode = A; } cmd ::= query_expression(A). { pCxt->pRootNode = A; }
/************************************************ insert **************************************************************/ /************************************************ insert **************************************************************/
cmd ::= INSERT INTO full_table_name(A) specific_cols_opt(B) query_expression(C). { pCxt->pRootNode = createInsertStmt(pCxt, A, B, C); } cmd ::= INSERT INTO full_table_name(A)
NK_LP col_name_list(B) NK_RP query_expression(C). { pCxt->pRootNode = createInsertStmt(pCxt, A, B, C); }
cmd ::= INSERT INTO full_table_name(A) query_expression(B). { pCxt->pRootNode = createInsertStmt(pCxt, A, NULL, B); }
/************************************************ literal *************************************************************/ /************************************************ literal *************************************************************/
literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); } literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); }
@ -675,10 +677,11 @@ column_reference(A) ::= table_name(B) NK_DOT column_name(C).
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= table_name(B) NK_DOT TBNAME(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &C, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B)))); } pseudo_column(A) ::= table_name(B) NK_DOT TBNAME(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &C, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B)))); }
pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= QSTART(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= QENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= QEND(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= WSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= QDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= WENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= WSTART(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= WEND(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }

View File

@ -598,7 +598,7 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) {
nodesDestroyNode((SNode*)fill); nodesDestroyNode((SNode*)fill);
CHECK_OUT_OF_MEM(fill->pWStartTs); CHECK_OUT_OF_MEM(fill->pWStartTs);
} }
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstartts"); strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstart");
return (SNode*)fill; return (SNode*)fill;
} }
@ -740,6 +740,7 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
select->pFromTable = pTable; select->pFromTable = pTable;
sprintf(select->stmtName, "%p", select); sprintf(select->stmtName, "%p", select);
select->isTimeLineResult = true; select->isTimeLineResult = true;
select->timeRange = TSWINDOW_INITIALIZER;
return (SNode*)select; return (SNode*)select;
} }

View File

@ -240,12 +240,13 @@ static SKeyword keywordTable[] = {
{"WITH", TK_WITH}, {"WITH", TK_WITH},
{"WRITE", TK_WRITE}, {"WRITE", TK_WRITE},
{"_C0", TK_ROWTS}, {"_C0", TK_ROWTS},
{"_QENDTS", TK_QENDTS}, {"_QDURATION", TK_QDURATION},
{"_QSTARTTS", TK_QSTARTTS}, {"_QEND", TK_QEND},
{"_QSTART", TK_QSTART},
{"_ROWTS", TK_ROWTS}, {"_ROWTS", TK_ROWTS},
{"_WDURATION", TK_WDURATION}, {"_WDURATION", TK_WDURATION},
{"_WENDTS", TK_WENDTS}, {"_WEND", TK_WEND},
{"_WSTARTTS", TK_WSTARTTS}, {"_WSTART", TK_WSTART},
// {"ID", TK_ID}, // {"ID", TK_ID},
// {"STRING", TK_STRING}, // {"STRING", TK_STRING},
// {"EQ", TK_EQ}, // {"EQ", TK_EQ},

View File

@ -496,7 +496,7 @@ static bool isPrimaryKeyImpl(SNode* pExpr) {
SFunctionNode* pFunc = (SFunctionNode*)pExpr; SFunctionNode* pFunc = (SFunctionNode*)pExpr;
if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) { if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) {
return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0)); return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0));
} else if (FUNCTION_TYPE_WSTARTTS == pFunc->funcType || FUNCTION_TYPE_WENDTS == pFunc->funcType) { } else if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType) {
return true; return true;
} }
} }
@ -1197,7 +1197,7 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) {
} }
} }
static int32_t rewriteSystemInfoFuncImpl(STranslateContext* pCxt, char* pLiteral, SNode** pNode) { static int32_t rewriteFuncToValue(STranslateContext* pCxt, char* pLiteral, SNode** pNode) {
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
if (NULL == pVal) { if (NULL == pVal) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
@ -1228,7 +1228,7 @@ static int32_t rewriteDatabaseFunc(STranslateContext* pCxt, SNode** pNode) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
} }
return rewriteSystemInfoFuncImpl(pCxt, pCurrDb, pNode); return rewriteFuncToValue(pCxt, pCurrDb, pNode);
} }
static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) { static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
@ -1236,7 +1236,7 @@ static int32_t rewriteClentVersionFunc(STranslateContext* pCxt, SNode** pNode) {
if (NULL == pVer) { if (NULL == pVer) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
return rewriteSystemInfoFuncImpl(pCxt, pVer, pNode); return rewriteFuncToValue(pCxt, pVer, pNode);
} }
static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode) { static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode) {
@ -1244,7 +1244,7 @@ static int32_t rewriteServerVersionFunc(STranslateContext* pCxt, SNode** pNode)
if (NULL == pVer) { if (NULL == pVer) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
return rewriteSystemInfoFuncImpl(pCxt, pVer, pNode); return rewriteFuncToValue(pCxt, pVer, pNode);
} }
static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) { static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
@ -1252,7 +1252,7 @@ static int32_t rewriteServerStatusFunc(STranslateContext* pCxt, SNode** pNode) {
return TSDB_CODE_RPC_NETWORK_UNAVAIL; return TSDB_CODE_RPC_NETWORK_UNAVAIL;
} }
char* pStatus = taosMemoryStrDup((void*)"1"); char* pStatus = taosMemoryStrDup((void*)"1");
return rewriteSystemInfoFuncImpl(pCxt, pStatus, pNode); return rewriteFuncToValue(pCxt, pStatus, pNode);
} }
static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) { static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
@ -1263,7 +1263,7 @@ static int32_t rewriteUserFunc(STranslateContext* pCxt, SNode** pNode) {
if (NULL == pUserConn) { if (NULL == pUserConn) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
return rewriteSystemInfoFuncImpl(pCxt, pUserConn, pNode); return rewriteFuncToValue(pCxt, pUserConn, pNode);
} }
static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) { static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) {
@ -1317,10 +1317,60 @@ static int32_t translateNoramlFunction(STranslateContext* pCxt, SFunctionNode* p
return code; return code;
} }
static int32_t rewriteQueryTimeFunc(STranslateContext* pCxt, int64_t val, SNode** pNode) {
if (INT64_MIN == val || INT64_MAX == val) {
return rewriteFuncToValue(pCxt, NULL, pNode);
}
char* pStr = taosMemoryCalloc(1, 20);
if (NULL == pStr) {
return TSDB_CODE_OUT_OF_MEMORY;
}
snprintf(pStr, 20, "%" PRId64 "", val);
return rewriteFuncToValue(pCxt, pStr, pNode);
}
static int32_t rewriteQstartFunc(STranslateContext* pCxt, SNode** pNode) {
return rewriteQueryTimeFunc(pCxt, ((SSelectStmt*)pCxt->pCurrStmt)->timeRange.skey, pNode);
}
static int32_t rewriteQendFunc(STranslateContext* pCxt, SNode** pNode) {
return rewriteQueryTimeFunc(pCxt, ((SSelectStmt*)pCxt->pCurrStmt)->timeRange.ekey, pNode);
}
static int32_t rewriteQdurationFunc(STranslateContext* pCxt, SNode** pNode) {
STimeWindow range = ((SSelectStmt*)pCxt->pCurrStmt)->timeRange;
if (INT64_MIN == range.skey || INT64_MAX == range.ekey) {
return rewriteQueryTimeFunc(pCxt, INT64_MIN, pNode);
}
return rewriteQueryTimeFunc(pCxt, range.ekey - range.skey + 1, pNode);
}
static int32_t rewriteClientPseudoColumnFunc(STranslateContext* pCxt, SNode** pNode) {
if (NULL == pCxt->pCurrStmt || QUERY_NODE_SELECT_STMT != nodeType(pCxt->pCurrStmt) ||
pCxt->currClause <= SQL_CLAUSE_WHERE) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "Illegal pseudo column");
}
switch (((SFunctionNode*)*pNode)->funcType) {
case FUNCTION_TYPE_QSTART:
return rewriteQstartFunc(pCxt, pNode);
case FUNCTION_TYPE_QEND:
return rewriteQendFunc(pCxt, pNode);
case FUNCTION_TYPE_QDURATION:
return rewriteQdurationFunc(pCxt, pNode);
default:
break;
}
return TSDB_CODE_PAR_INTERNAL_ERROR;
}
static int32_t translateFunctionImpl(STranslateContext* pCxt, SFunctionNode** pFunc) { static int32_t translateFunctionImpl(STranslateContext* pCxt, SFunctionNode** pFunc) {
if (fmIsSystemInfoFunc((*pFunc)->funcId)) { if (fmIsSystemInfoFunc((*pFunc)->funcId)) {
return rewriteSystemInfoFunc(pCxt, (SNode**)pFunc); return rewriteSystemInfoFunc(pCxt, (SNode**)pFunc);
} }
if (fmIsClientPseudoColumnFunc((*pFunc)->funcId)) {
return rewriteClientPseudoColumnFunc(pCxt, (SNode**)pFunc);
}
return translateNoramlFunction(pCxt, *pFunc); return translateNoramlFunction(pCxt, *pFunc);
} }
@ -2077,7 +2127,7 @@ static int32_t getTimeRange(SNode** pPrimaryKeyCond, STimeWindow* pTimeRange, bo
return code; return code;
} }
static int32_t getFillTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWindow* pTimeRange) { static int32_t getQueryTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWindow* pTimeRange) {
if (NULL == pWhere) { if (NULL == pWhere) {
*pTimeRange = TSWINDOW_INITIALIZER; *pTimeRange = TSWINDOW_INITIALIZER;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -2138,16 +2188,13 @@ static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode*
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t translateFill(STranslateContext* pCxt, SNode* pWhere, SIntervalWindowNode* pInterval) { static int32_t translateFill(STranslateContext* pCxt, SSelectStmt* pSelect, SIntervalWindowNode* pInterval) {
if (NULL == pInterval->pFill) { if (NULL == pInterval->pFill) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t code = getFillTimeRange(pCxt, pWhere, &(((SFillNode*)pInterval->pFill)->timeRange)); ((SFillNode*)pInterval->pFill)->timeRange = pSelect->timeRange;
if (TSDB_CODE_SUCCESS == code) { return checkFill(pCxt, (SFillNode*)pInterval->pFill, (SValueNode*)pInterval->pInterval);
code = checkFill(pCxt, (SFillNode*)pInterval->pFill, (SValueNode*)pInterval->pInterval);
}
return code;
} }
static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) { static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) {
@ -2234,7 +2281,7 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
static int32_t translateIntervalWindow(STranslateContext* pCxt, SSelectStmt* pSelect, SIntervalWindowNode* pInterval) { static int32_t translateIntervalWindow(STranslateContext* pCxt, SSelectStmt* pSelect, SIntervalWindowNode* pInterval) {
int32_t code = checkIntervalWindow(pCxt, pInterval); int32_t code = checkIntervalWindow(pCxt, pInterval);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = translateFill(pCxt, pSelect->pWhere, pInterval); code = translateFill(pCxt, pSelect, pInterval);
} }
return code; return code;
} }
@ -2329,7 +2376,7 @@ static int32_t translateInterpFill(STranslateContext* pCxt, SSelectStmt* pSelect
code = translateExpr(pCxt, &pSelect->pFill); code = translateExpr(pCxt, &pSelect->pFill);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = getFillTimeRange(pCxt, pSelect->pRange, &(((SFillNode*)pSelect->pFill)->timeRange)); code = getQueryTimeRange(pCxt, pSelect->pRange, &(((SFillNode*)pSelect->pFill)->timeRange));
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = checkFill(pCxt, (SFillNode*)pSelect->pFill, (SValueNode*)pSelect->pEvery); code = checkFill(pCxt, (SFillNode*)pSelect->pFill, (SValueNode*)pSelect->pEvery);
@ -2361,9 +2408,13 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartiti
return translateExprList(pCxt, pPartitionByList); return translateExprList(pCxt, pPartitionByList);
} }
static int32_t translateWhere(STranslateContext* pCxt, SNode** pWhere) { static int32_t translateWhere(STranslateContext* pCxt, SSelectStmt* pSelect) {
pCxt->currClause = SQL_CLAUSE_WHERE; pCxt->currClause = SQL_CLAUSE_WHERE;
return translateExpr(pCxt, pWhere); int32_t code = translateExpr(pCxt, &pSelect->pWhere);
if (TSDB_CODE_SUCCESS == code) {
code = getQueryTimeRange(pCxt, pSelect->pWhere, &pSelect->timeRange);
}
return code;
} }
static int32_t translateFrom(STranslateContext* pCxt, SNode* pTable) { static int32_t translateFrom(STranslateContext* pCxt, SNode* pTable) {
@ -2494,7 +2545,7 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
int32_t code = translateFrom(pCxt, pSelect->pFromTable); int32_t code = translateFrom(pCxt, pSelect->pFromTable);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision; pSelect->precision = ((STableNode*)pSelect->pFromTable)->precision;
code = translateWhere(pCxt, &pSelect->pWhere); code = translateWhere(pCxt, pSelect);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = translatePartitionBy(pCxt, pSelect->pPartitionByList); code = translatePartitionBy(pCxt, pSelect->pPartitionByList);
@ -2680,7 +2731,8 @@ static int32_t partitionDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelet
} }
static int32_t translateDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelete) { static int32_t translateDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelete) {
int32_t code = translateWhere(pCxt, &pDelete->pWhere); pCxt->currClause = SQL_CLAUSE_WHERE;
int32_t code = translateExpr(pCxt, &pDelete->pWhere);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = partitionDeleteWhere(pCxt, pDelete); code = partitionDeleteWhere(pCxt, pDelete);
} }
@ -3507,7 +3559,7 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
nodesDestroyNode((SNode*)pSelect); nodesDestroyNode((SNode*)pSelect);
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
strcpy(pFunc->functionName, "_wstartts"); strcpy(pFunc->functionName, "_wstart");
nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc); nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
SNode* pProject = NULL; SNode* pProject = NULL;
FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); } FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); }
@ -4333,14 +4385,14 @@ static int32_t addWstartTsToCreateStreamQuery(SNode* pStmt) {
SSelectStmt* pSelect = (SSelectStmt*)pStmt; SSelectStmt* pSelect = (SSelectStmt*)pStmt;
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0); SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0);
if (NULL == pSelect->pWindow || if (NULL == pSelect->pWindow ||
(QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstartts", ((SFunctionNode*)pProj)->functionName))) { (QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_wstart", ((SFunctionNode*)pProj)->functionName))) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
if (NULL == pFunc) { if (NULL == pFunc) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
strcpy(pFunc->functionName, "_wstartts"); strcpy(pFunc->functionName, "_wstart");
strcpy(pFunc->node.aliasName, pFunc->functionName); strcpy(pFunc->node.aliasName, pFunc->functionName);
int32_t code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc); int32_t code = nodesListPushFront(pSelect->pProjectionList, (SNode*)pFunc);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {

View File

@ -187,7 +187,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC: case TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC:
return "%s function is not supported in fill query"; return "%s function is not supported in fill query";
case TSDB_CODE_PAR_INVALID_WINDOW_PC: case TSDB_CODE_PAR_INVALID_WINDOW_PC:
return "_WSTARTTS, _WENDTS and _WDURATION can only be used in window query"; return "_WSTART, _WEND and _WDURATION can only be used in window query";
case TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC: case TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC:
return "%s function is not supported in time window query"; return "%s function is not supported in time window query";
case TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC: case TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC:

File diff suppressed because it is too large Load Diff

View File

@ -75,7 +75,7 @@ TEST_F(ParserSelectTest, condition) {
TEST_F(ParserSelectTest, pseudoColumn) { TEST_F(ParserSelectTest, pseudoColumn) {
useDb("root", "test"); useDb("root", "test");
run("SELECT _WSTARTTS, _WENDTS, COUNT(*) FROM t1 INTERVAL(10s)"); run("SELECT _WSTART, _WEND, COUNT(*) FROM t1 INTERVAL(10s)");
} }
TEST_F(ParserSelectTest, pseudoColumnSemanticCheck) { TEST_F(ParserSelectTest, pseudoColumnSemanticCheck) {
@ -286,7 +286,7 @@ TEST_F(ParserSelectTest, intervalSemanticCheck) {
run("SELECT HISTOGRAM(c1, 'log_bin', '{\"start\": -33,\"factor\": 55,\"count\": 5,\"infinity\": false}', 1) FROM t1 " run("SELECT HISTOGRAM(c1, 'log_bin', '{\"start\": -33,\"factor\": 55,\"count\": 5,\"infinity\": false}', 1) FROM t1 "
"WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)", "WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)",
TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC); TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC);
run("SELECT _WSTARTTS, _WENDTS, _WDURATION, sum(c1) FROM t1", TSDB_CODE_PAR_INVALID_WINDOW_PC); run("SELECT _WSTART, _WEND, _WDURATION, sum(c1) FROM t1", TSDB_CODE_PAR_INVALID_WINDOW_PC);
} }
TEST_F(ParserSelectTest, interp) { TEST_F(ParserSelectTest, interp) {
@ -310,11 +310,11 @@ TEST_F(ParserSelectTest, subquery) {
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 INTERVAL(1m)) INTERVAL(1n)"); run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 INTERVAL(1m)) INTERVAL(1n)");
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 INTERVAL(1m)) INTERVAL(1n)"); run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstart FROM st1s1 INTERVAL(1m)) INTERVAL(1n)");
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"); run("SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)");
run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"); run("SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstart FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)");
run("SELECT _C0 FROM (SELECT _ROWTS, ts FROM st1s1)"); run("SELECT _C0 FROM (SELECT _ROWTS, ts FROM st1s1)");

View File

@ -59,7 +59,7 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
strcpy(pCol->node.aliasName, pToBeRewrittenExpr->aliasName); strcpy(pCol->node.aliasName, pToBeRewrittenExpr->aliasName);
strcpy(pCol->colName, ((SExprNode*)pExpr)->aliasName); strcpy(pCol->colName, ((SExprNode*)pExpr)->aliasName);
if (QUERY_NODE_FUNCTION == nodeType(pExpr)) { if (QUERY_NODE_FUNCTION == nodeType(pExpr)) {
if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pExpr)->funcType) { if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pExpr)->funcType) {
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
} else if (FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pExpr)->funcType) { } else if (FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pExpr)->funcType) {
pCol->colType = COLUMN_TYPE_TBNAME; pCol->colType = COLUMN_TYPE_TBNAME;

View File

@ -795,15 +795,15 @@ static EDealRes rewriteAggGroupKeyCondForPushDownImpl(SNode** pNode, void* pCont
if (0 == strcmp(((SExprNode*)pGroup)->aliasName, ((SColumnNode*)(*pNode))->colName)) { if (0 == strcmp(((SExprNode*)pGroup)->aliasName, ((SColumnNode*)(*pNode))->colName)) {
SNode* pExpr = nodesCloneNode(pGroup); SNode* pExpr = nodesCloneNode(pGroup);
if (pExpr == NULL) { if (pExpr == NULL) {
pCxt->errCode = terrno; pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
return DEAL_RES_ERROR; return DEAL_RES_ERROR;
} }
nodesDestroyNode(*pNode); nodesDestroyNode(*pNode);
*pNode = pExpr; *pNode = pExpr;
return DEAL_RES_IGNORE_CHILD;
} }
} }
} }
return DEAL_RES_IGNORE_CHILD;
} }
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
@ -864,16 +864,16 @@ static EDealRes rewriteProjectCondForPushDownImpl(SNode** ppNode, void* pContext
if (0 == strcmp(((SExprNode*)pProjection)->aliasName, ((SColumnNode*)(*ppNode))->colName)) { if (0 == strcmp(((SExprNode*)pProjection)->aliasName, ((SColumnNode*)(*ppNode))->colName)) {
SNode* pExpr = nodesCloneNode(pProjection); SNode* pExpr = nodesCloneNode(pProjection);
if (pExpr == NULL) { if (pExpr == NULL) {
pCxt->errCode = terrno; pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
return DEAL_RES_ERROR; return DEAL_RES_ERROR;
} }
nodesDestroyNode(*ppNode); nodesDestroyNode(*ppNode);
*ppNode = pExpr; *ppNode = pExpr;
return DEAL_RES_IGNORE_CHILD;
} // end if expr alias name equal column name } // end if expr alias name equal column name
} // end for each project } // end for each project
} // end if target node equals cond column node } // end if target node equals cond column node
} // end for each targets } // end for each targets
return DEAL_RES_IGNORE_CHILD;
} }
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
@ -1211,7 +1211,7 @@ static int32_t smaIndexOptCreateSmaCols(SNodeList* pFuncs, uint64_t tableId, SNo
int32_t smaFuncIndex = -1; int32_t smaFuncIndex = -1;
*pWStrartIndex = -1; *pWStrartIndex = -1;
FOREACH(pFunc, pFuncs) { FOREACH(pFunc, pFuncs) {
if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pFunc)->funcType) { if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pFunc)->funcType) {
*pWStrartIndex = index; *pWStrartIndex = index;
} }
smaFuncIndex = smaIndexOptFindSmaFunc(pFunc, pSmaFuncs); smaFuncIndex = smaIndexOptFindSmaFunc(pFunc, pSmaFuncs);
@ -1255,7 +1255,7 @@ static SNode* smaIndexOptCreateWStartTs() {
if (NULL == pWStart) { if (NULL == pWStart) {
return NULL; return NULL;
} }
strcpy(pWStart->functionName, "_wstartts"); strcpy(pWStart->functionName, "_wstart");
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart); snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) { if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) {
nodesDestroyNode((SNode*)pWStart); nodesDestroyNode((SNode*)pWStart);
@ -2057,11 +2057,11 @@ static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) {
((SExprNode*)*pNode)->aliasName); ((SExprNode*)*pNode)->aliasName);
nodesDestroyNode(*pNode); nodesDestroyNode(*pNode);
*pNode = pExpr; *pNode = pExpr;
return DEAL_RES_IGNORE_CHILD;
} }
} }
} }
} }
return DEAL_RES_IGNORE_CHILD;
} }
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
@ -2103,11 +2103,12 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode) || (SCAN_TYPE_TAG == ((SScanLogicNode*)pNode)->scanType)) { if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode) || (SCAN_TYPE_TAG == ((SScanLogicNode*)pNode)->scanType)) {
return false; return false;
} }
SScanLogicNode *pScan = (SScanLogicNode*)pNode; SScanLogicNode* pScan = (SScanLogicNode*)pNode;
if (NULL != pScan->pScanCols) { if (NULL != pScan->pScanCols) {
return false; return false;
} }
if (NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) || 1 != LIST_LENGTH(pNode->pParent->pChildren)) { if (NULL == pNode->pParent || QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) ||
1 != LIST_LENGTH(pNode->pParent->pChildren)) {
return false; return false;
} }

View File

@ -308,7 +308,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
int32_t index = 0; int32_t index = 0;
SNode* pFunc = NULL; SNode* pFunc = NULL;
FOREACH(pFunc, pFuncs) { FOREACH(pFunc, pFuncs) {
if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pFunc)->funcType) { if (FUNCTION_TYPE_WSTART == ((SFunctionNode*)pFunc)->funcType) {
*pIndex = index; *pIndex = index;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -319,7 +319,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
if (NULL == pWStart) { if (NULL == pWStart) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
strcpy(pWStart->functionName, "_wstartts"); strcpy(pWStart->functionName, "_wstart");
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart); snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
int32_t code = fmGetFuncInfo(pWStart, NULL, 0); int32_t code = fmGetFuncInfo(pWStart, NULL, 0);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
@ -333,7 +333,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
int32_t index = 0; int32_t index = 0;
SNode* pFunc = NULL; SNode* pFunc = NULL;
FOREACH(pFunc, pWin->pFuncs) { FOREACH(pFunc, pWin->pFuncs) {
if (FUNCTION_TYPE_WENDTS == ((SFunctionNode*)pFunc)->funcType) { if (FUNCTION_TYPE_WEND == ((SFunctionNode*)pFunc)->funcType) {
*pIndex = index; *pIndex = index;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
@ -344,7 +344,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
if (NULL == pWEnd) { if (NULL == pWEnd) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
strcpy(pWEnd->functionName, "_wendts"); strcpy(pWEnd->functionName, "_wend");
snprintf(pWEnd->node.aliasName, sizeof(pWEnd->node.aliasName), "%s.%p", pWEnd->functionName, pWEnd); snprintf(pWEnd->node.aliasName, sizeof(pWEnd->node.aliasName), "%s.%p", pWEnd->functionName, pWEnd);
int32_t code = fmGetFuncInfo(pWEnd, NULL, 0); int32_t code = fmGetFuncInfo(pWEnd, NULL, 0);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {

View File

@ -137,6 +137,17 @@ TEST_F(PlanBasicTest, sampleFunc) {
run("SELECT SAMPLE(c1, 10) FROM st1 PARTITION BY TBNAME"); run("SELECT SAMPLE(c1, 10) FROM st1 PARTITION BY TBNAME");
} }
TEST_F(PlanBasicTest, pseudoColumn) {
useDb("root", "test");
run("SELECT _QSTART, _QEND, _QDURATION FROM t1");
run("SELECT _QSTART, _QEND, _QDURATION FROM t1 WHERE ts BETWEEN '2017-7-14 18:00:00' AND '2017-7-14 19:00:00'");
run("SELECT _QSTART, _QEND, _QDURATION, _WSTART, _WEND, _WDURATION, COUNT(*) FROM t1 "
"WHERE ts BETWEEN '2017-7-14 18:00:00' AND '2017-7-14 19:00:00' INTERVAL(10S)");
}
TEST_F(PlanBasicTest, withoutFrom) { TEST_F(PlanBasicTest, withoutFrom) {
useDb("root", "test"); useDb("root", "test");

View File

@ -29,7 +29,7 @@ TEST_F(PlanIntervalTest, basic) {
TEST_F(PlanIntervalTest, pseudoCol) { TEST_F(PlanIntervalTest, pseudoCol) {
useDb("root", "test"); useDb("root", "test");
run("SELECT _WSTARTTS, _WDURATION, _WENDTS, COUNT(*) FROM t1 INTERVAL(10s)"); run("SELECT _WSTART, _WDURATION, _WEND, COUNT(*) FROM t1 INTERVAL(10s)");
} }
TEST_F(PlanIntervalTest, fill) { TEST_F(PlanIntervalTest, fill) {
@ -59,9 +59,9 @@ TEST_F(PlanIntervalTest, stable) {
run("SELECT COUNT(*) FROM st1 INTERVAL(10s)"); run("SELECT COUNT(*) FROM st1 INTERVAL(10s)");
run("SELECT _WSTARTTS, COUNT(*) FROM st1 INTERVAL(10s)"); run("SELECT _WSTART, COUNT(*) FROM st1 INTERVAL(10s)");
run("SELECT _WSTARTTS, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"); run("SELECT _WSTART, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
run("SELECT TBNAME, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"); run("SELECT TBNAME, COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)");
} }

View File

@ -55,7 +55,7 @@ TEST_F(PlanOptimizeTest, sortPrimaryKey) {
run("SELECT c1 FROM t1 ORDER BY ts DESC"); run("SELECT c1 FROM t1 ORDER BY ts DESC");
run("SELECT COUNT(*) FROM t1 INTERVAL(10S) ORDER BY _WSTARTTS DESC"); run("SELECT COUNT(*) FROM t1 INTERVAL(10S) ORDER BY _WSTART DESC");
} }
TEST_F(PlanOptimizeTest, PartitionTags) { TEST_F(PlanOptimizeTest, PartitionTags) {

View File

@ -49,7 +49,7 @@ TEST_F(PlanOtherTest, createSmaIndex) {
run("SELECT SUM(c4) FROM t1 INTERVAL(10s)"); run("SELECT SUM(c4) FROM t1 INTERVAL(10s)");
run("SELECT _WSTARTTS, MIN(c3 + 10) FROM t1 " run("SELECT _WSTART, MIN(c3 + 10) FROM t1 "
"WHERE ts BETWEEN TIMESTAMP '2022-04-01 00:00:00' AND TIMESTAMP '2022-04-30 23:59:59.999' INTERVAL(10s)"); "WHERE ts BETWEEN TIMESTAMP '2022-04-01 00:00:00' AND TIMESTAMP '2022-04-30 23:59:59.999' INTERVAL(10s)");
run("SELECT SUM(c4), MAX(c3) FROM t1 INTERVAL(10s)"); run("SELECT SUM(c4), MAX(c3) FROM t1 INTERVAL(10s)");

View File

@ -18,7 +18,7 @@ class TDTestCase:
tdSql.execute('create table ownsampling_ct1 using downsampling_stb tags(10, 10.1, "beijing", True);') tdSql.execute('create table ownsampling_ct1 using downsampling_stb tags(10, 10.1, "beijing", True);')
tdSql.execute('create table if not exists scalar_stb (ts timestamp, c1 int, c2 double, c3 binary(20)) tags (t1 int);') tdSql.execute('create table if not exists scalar_stb (ts timestamp, c1 int, c2 double, c3 binary(20)) tags (t1 int);')
tdSql.execute('create table scalar_ct1 using scalar_stb tags(10);') tdSql.execute('create table scalar_ct1 using scalar_stb tags(10);')
tdSql.execute('create stream downsampling_stream into output_downsampling_stb as select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);') tdSql.execute('create stream downsampling_stream into output_downsampling_stb as select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
tdSql.execute('create stream scalar_stream into output_scalar_stb as select ts, abs(c1) a1 , abs(c2) a2 from scalar_stb;') tdSql.execute('create stream scalar_stream into output_scalar_stb as select ts, abs(c1) a1 , abs(c2) a2 from scalar_stb;')
tdSql.execute('insert into scalar_ct1 values (1653471881952, 100, 100.1, "beijing");') tdSql.execute('insert into scalar_ct1 values (1653471881952, 100, 100.1, "beijing");')
tdSql.execute('insert into scalar_ct1 values (1653471881952+1s, -50, -50.1, "tianjin");') tdSql.execute('insert into scalar_ct1 values (1653471881952+1s, -50, -50.1, "tianjin");')

View File

@ -22,23 +22,23 @@ class TDTestCase:
tdSql.execute('create table downsampling_ct1 using downsampling_stb tags(10, 10.1, "Beijing", True);') tdSql.execute('create table downsampling_ct1 using downsampling_stb tags(10, 10.1, "Beijing", True);')
tdSql.execute('create table if not exists scalar_stb (ts timestamp, c1 int, c2 double, c3 binary(20), c4 nchar(20), c5 nchar(20)) tags (t1 int);') tdSql.execute('create table if not exists scalar_stb (ts timestamp, c1 int, c2 double, c3 binary(20), c4 nchar(20), c5 nchar(20)) tags (t1 int);')
tdSql.execute('create table scalar_ct1 using scalar_stb tags(10);') tdSql.execute('create table scalar_ct1 using scalar_stb tags(10);')
tdSql.execute('create stream downsampling_stream into output_downsampling_stb as select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);') tdSql.execute('create stream downsampling_stream into output_downsampling_stb as select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
tdSql.execute('insert into downsampling_ct1 values (1653547828591, 100, 100.1, "Beijing", True);') tdSql.execute('insert into downsampling_ct1 values (1653547828591, 100, 100.1, "Beijing", True);')
tdSql.execute('insert into downsampling_ct1 values (1653547828591+1s, -100, -100.1, "Tianjin", False);') tdSql.execute('insert into downsampling_ct1 values (1653547828591+1s, -100, -100.1, "Tianjin", False);')
tdSql.execute('insert into downsampling_ct1 values (1653547828591+2s, 50, 50.3, "HeBei", False);') tdSql.execute('insert into downsampling_ct1 values (1653547828591+2s, 50, 50.3, "HeBei", False);')
tdSql.execute('select * from output_downsampling_stb;') tdSql.execute('select * from output_downsampling_stb;')
tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;') tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;')
tdSql.execute('select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);') tdSql.execute('select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
tdSql.execute('insert into downsampling_ct1 values (1653547828591+10m, 60, 60.3, "heilongjiang", True);') tdSql.execute('insert into downsampling_ct1 values (1653547828591+10m, 60, 60.3, "heilongjiang", True);')
tdSql.execute('insert into downsampling_ct1 values (1653547828591+11m, 70, 70.3, "JiLin", True);') tdSql.execute('insert into downsampling_ct1 values (1653547828591+11m, 70, 70.3, "JiLin", True);')
tdSql.execute('select * from output_downsampling_stb;') tdSql.execute('select * from output_downsampling_stb;')
tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;') tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;')
tdSql.execute('select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);') tdSql.execute('select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
tdSql.execute('insert into downsampling_ct1 values (1653547828591+21m, 70, 70.3, "JiLin", True);') tdSql.execute('insert into downsampling_ct1 values (1653547828591+21m, 70, 70.3, "JiLin", True);')
tdSql.execute('select * from output_downsampling_stb;') tdSql.execute('select * from output_downsampling_stb;')
tdSql.execute('select * from output_downsampling_stb;') tdSql.execute('select * from output_downsampling_stb;')
tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;') tdSql.execute('select start, `min(c1)`, `max(c2)`, `sum(c1)` from output_downsampling_stb;')
tdSql.execute('select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);') tdSql.execute('select _wstart AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);')
tdSql.execute('create stream abs_stream into output_abs_stb as select ts, abs(c1), abs(c2), c3 from scalar_stb;') tdSql.execute('create stream abs_stream into output_abs_stb as select ts, abs(c1), abs(c2), c3 from scalar_stb;')
tdSql.query('describe output_abs_stb') tdSql.query('describe output_abs_stb')
tdSql.execute('create stream acos_stream into output_acos_stb as select ts, acos(c1), acos(c2), c3 from scalar_stb;') tdSql.execute('create stream acos_stream into output_acos_stb as select ts, acos(c1), acos(c2), c3 from scalar_stb;')

View File

@ -68,8 +68,8 @@ sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8 )
sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9 ) sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9 )
print ================ start query ====================== print ================ start query ======================
sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from ct1 interval(10s, 2s)
print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) print ===> select _wstart, _wend, _wduration, _qstart, _qend, count(*) from ct1 interval(10s, 2s)
print ===> rows: $rows print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data05 print ===> rows0: $data00 $data01 $data02 $data05
print ===> rows1: $data10 $data11 $data12 $data15 print ===> rows1: $data10 $data11 $data12 $data15
@ -89,8 +89,8 @@ if $data45 != 1 then
return -1 return -1
endi endi
sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sliding(10s) sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from ct1 interval(10s, 2s) sliding(10s)
print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sliding(10s) print ===> select _wstart, _wend, _wduration, _qstart, _qend, count(*) from ct1 interval(10s, 2s) sliding(10s)
print ===> rows: $rows print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data05 print ===> rows0: $data00 $data01 $data02 $data05
print ===> rows1: $data10 $data11 $data12 $data15 print ===> rows1: $data10 $data11 $data12 $data15
@ -177,7 +177,7 @@ if $data70 != 1 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sql select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct3 interval(1n, 1w)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w)
print ===> rows: $rows print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows0: $data00 $data01 $data02 $data03 $data04
@ -200,11 +200,11 @@ if $data02 != 2678400000 then
return -1 return -1
endi endi
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w) sql_error select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct3 interval(1n, 1w) sliding(2w)
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w) sql_error select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct3 interval(1n, 1w) sliding(4w)
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sql select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct4 interval(1y, 6n)
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) print ===> select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct4 interval(1y, 6n)
print ===> rows: $rows print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows1: $data10 $data11 $data12 $data13 $data14
@ -220,7 +220,7 @@ if $data04 != 2 then
endi endi
sql_error select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n) sql_error select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n) sql_error select _wstart, count(tbcol), _wduration, _wstart, count(*) from ct4 interval(1y, 6n) sliding(12n)
#================================================= #=================================================
print =============== stop and restart taosd print =============== stop and restart taosd

View File

@ -82,8 +82,8 @@ print =============== step4
#$cc = 1 * 60000 #$cc = 1 * 60000
#$ms2 = 1601481600000 - $cc #$ms2 = 1601481600000 - $cc
sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(tbcol) from $tb interval(1m) sql select _wstart, _wend, _wduration, _qstart, _qend, count(tbcol) from $tb interval(1m)
print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(tbcol) from $tb interval(1m) print ===> select _wstart, _wend, _wduration, _qstart, _qend, count(tbcol) from $tb interval(1m)
print ===> $rows $data01 $data05 print ===> $rows $data01 $data05
if $rows != $rowNum then if $rows != $rowNum then
return -1 return -1

View File

@ -81,7 +81,7 @@ sql use $dbNamme
# session(ts,5a) # session(ts,5a)
print ====> select count(*) from dev_001 session(ts,5a) print ====> select count(*) from dev_001 session(ts,5a)
sql select _wstartts, count(*) from dev_001 session(ts,5a) sql select _wstart, count(*) from dev_001 session(ts,5a)
print ====> rows: $rows print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05 print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15 print ====> $data10 $data11 $data12 $data13 $data14 $data15
@ -102,7 +102,7 @@ endi
# #
#print ====> select count(*) from (select * from dev_001) session(ts,5a) #print ====> select count(*) from (select * from dev_001) session(ts,5a)
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,5a) #sql select _wstart, count(*) from (select * from dev_001) session(ts,5a)
#if $rows != 15 then #if $rows != 15 then
# return -1 # return -1
#endi #endi
@ -111,7 +111,7 @@ endi
#endi #endi
print ====> select count(*) from dev_001 session(ts,1s) print ====> select count(*) from dev_001 session(ts,1s)
sql select _wstartts, count(*) from dev_001 session(ts,1s) sql select _wstart, count(*) from dev_001 session(ts,1s)
if $rows != 12 then if $rows != 12 then
return -1 return -1
endi endi
@ -120,7 +120,7 @@ if $data01 != 5 then
endi endi
#print ====> select count(*) from (select * from dev_001) session(ts,1s) #print ====> select count(*) from (select * from dev_001) session(ts,1s)
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1s) #sql select _wstart, count(*) from (select * from dev_001) session(ts,1s)
#if $rows != 12 then #if $rows != 12 then
# return -1 # return -1
#endi #endi
@ -129,7 +129,7 @@ endi
#endi #endi
print ====> select count(*) from dev_001 session(ts,1000a) print ====> select count(*) from dev_001 session(ts,1000a)
sql select _wstartts, count(*) from dev_001 session(ts,1000a) sql select _wstart, count(*) from dev_001 session(ts,1000a)
if $rows != 12 then if $rows != 12 then
return -1 return -1
endi endi
@ -138,7 +138,7 @@ if $data01 != 5 then
endi endi
#print ====> select count(*) from (select * from dev_001) session(ts,1000a) #print ====> select count(*) from (select * from dev_001) session(ts,1000a)
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1000a) #sql select _wstart, count(*) from (select * from dev_001) session(ts,1000a)
#if $rows != 12 then #if $rows != 12 then
# return -1 # return -1
#endi #endi
@ -147,7 +147,7 @@ endi
#endi #endi
print ====> select count(*) from dev_001 session(ts,1m) print ====> select count(*) from dev_001 session(ts,1m)
sql select _wstartts, count(*) from dev_001 session(ts,1m) sql select _wstart, count(*) from dev_001 session(ts,1m)
if $rows != 9 then if $rows != 9 then
return -1 return -1
endi endi
@ -156,7 +156,7 @@ if $data01 != 8 then
endi endi
#print ====> select count(*) from (select * from dev_001) session(ts,1m) #print ====> select count(*) from (select * from dev_001) session(ts,1m)
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1m) #sql select _wstart, count(*) from (select * from dev_001) session(ts,1m)
#if $rows != 9 then #if $rows != 9 then
# return -1 # return -1
#endi #endi
@ -165,7 +165,7 @@ endi
#endi #endi
print ====> select count(*) from dev_001 session(ts,1h) print ====> select count(*) from dev_001 session(ts,1h)
sql select _wstartts, count(*) from dev_001 session(ts,1h) sql select _wstart, count(*) from dev_001 session(ts,1h)
if $rows != 6 then if $rows != 6 then
return -1 return -1
endi endi
@ -174,7 +174,7 @@ if $data01 != 11 then
endi endi
#print ====> select count(*) from (select * from dev_001) session(ts,1h) #print ====> select count(*) from (select * from dev_001) session(ts,1h)
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1h) #sql select _wstart, count(*) from (select * from dev_001) session(ts,1h)
#if $rows != 6 then #if $rows != 6 then
# return -1 # return -1
#endi #endi
@ -183,7 +183,7 @@ endi
#endi #endi
print ====> select count(*) from dev_001 session(ts,1d) print ====> select count(*) from dev_001 session(ts,1d)
sql select _wstartts, count(*) from dev_001 session(ts,1d) sql select _wstart, count(*) from dev_001 session(ts,1d)
if $rows != 4 then if $rows != 4 then
return -1 return -1
endi endi
@ -192,7 +192,7 @@ if $data01 != 13 then
endi endi
#print ====> select count(*) from (select * from dev_001) session(ts,1d) #print ====> select count(*) from (select * from dev_001) session(ts,1d)
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1d) #sql select _wstart, count(*) from (select * from dev_001) session(ts,1d)
#if $rows != 4 then #if $rows != 4 then
# return -1 # return -1
#endi #endi
@ -201,7 +201,7 @@ endi
#endi #endi
print ====> select count(*) from dev_001 session(ts,1w) print ====> select count(*) from dev_001 session(ts,1w)
sql select _wstartts, count(*) from dev_001 session(ts,1w) sql select _wstart, count(*) from dev_001 session(ts,1w)
if $rows != 2 then if $rows != 2 then
return -1 return -1
endi endi
@ -210,7 +210,7 @@ if $data01 != 15 then
endi endi
#print ====> select count(*) from (select * from dev_001) session(ts,1w) #print ====> select count(*) from (select * from dev_001) session(ts,1w)
#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1w) #sql select _wstart, count(*) from (select * from dev_001) session(ts,1w)
#if $rows != 2 then #if $rows != 2 then
# return -1 # return -1
#endi #endi
@ -298,7 +298,7 @@ sql_error select count(*) from dev_001 session(i,1y)
sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0' sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'
#print ====> select count(*) from dev_001 session(ts,1u) #print ====> select count(*) from dev_001 session(ts,1u)
#sql select _wstartts, count(*) from dev_001 session(ts,1u) #sql select _wstart, count(*) from dev_001 session(ts,1u)
#print rows: $rows #print rows: $rows
#print $data00 $data01 $data02 $data03 #print $data00 $data01 $data02 $data03
#print $data10 $data11 $data12 $data13 #print $data10 $data11 $data12 $data13

View File

@ -103,29 +103,29 @@ if $rows != 1 then
return -1 return -1
endi endi
print =====sql : select _wstartts, stddev(c1) as b from ct4 interval(1y) print =====sql : select _wstart, stddev(c1) as b from ct4 interval(1y)
sql select _wstartts, stddev(c1) as b from ct4 interval(1y) sql select _wstart, stddev(c1) as b from ct4 interval(1y)
print ===> $rows print ===> $rows
if $rows != 4 then if $rows != 4 then
return -1 return -1
endi endi
print =====sql : select _wstartts, stddev(c1) as b from t1 interval(1y) print =====sql : select _wstart, stddev(c1) as b from t1 interval(1y)
sql select _wstartts, stddev(c1) as b from t1 interval(1y) sql select _wstart, stddev(c1) as b from t1 interval(1y)
print ===> $rows print ===> $rows
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
print =====select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) print =====select _wstart, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
sql select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) sql select _wstart, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
# print ===> $rows # print ===> $rows
# if $rows != 3 then # if $rows != 3 then
# return -1 # return -1
# endi # endi
print =====select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) print =====select _wstart, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
sql select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) sql select _wstart, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
# print ===> $rows # print ===> $rows
# if $rows != 3 then # if $rows != 3 then
# return -1 # return -1
@ -281,29 +281,29 @@ if $rows != 1 then
return -1 return -1
endi endi
print =====sql : select _wstartts, stddev(c1) as b from ct4 interval(1y) print =====sql : select _wstart, stddev(c1) as b from ct4 interval(1y)
sql select _wstartts, stddev(c1) as b from ct4 interval(1y) sql select _wstart, stddev(c1) as b from ct4 interval(1y)
print ===> $rows print ===> $rows
if $rows != 4 then if $rows != 4 then
return -1 return -1
endi endi
print =====sql : select _wstartts, stddev(c1) as b from t1 interval(1y) print =====sql : select _wstart, stddev(c1) as b from t1 interval(1y)
sql select _wstartts, stddev(c1) as b from t1 interval(1y) sql select _wstart, stddev(c1) as b from t1 interval(1y)
print ===> $rows print ===> $rows
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
print =====select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) print =====select _wstart, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
sql select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) sql select _wstart, stddev(c1) as b from ct4 where c1 <= 6 interval(180d)
print ===> $rows print ===> $rows
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
print =====select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) print =====select _wstart, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
sql select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) sql select _wstart, stddev(c1) as b from t1 where c1 <= 6 interval(180d)
print ===> $rows print ===> $rows
if $rows != 3 then if $rows != 3 then
return -1 return -1

View File

@ -58,7 +58,7 @@ if $rows != 5 then
endi endi
print =============== select * from stb from memory in designated vgroup print =============== select * from stb from memory in designated vgroup
sql select _wstartts, _wendts, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m); sql select _wstart, _wend, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m);
print $data00 $data01 $data02 $data03 $data04 print $data00 $data01 $data02 $data03 $data04
if $rows != 1 then if $rows != 1 then
print rows $rows != 1 print rows $rows != 1
@ -81,7 +81,7 @@ if $data04 != 20 then
endi endi
print =============== select * from stb from memory in common vgroups print =============== select * from stb from memory in common vgroups
sql select _wstartts, _wendts, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m); sql select _wstart, _wend, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m);
print $data00 $data01 $data02 $data03 $data04 $data05 print $data00 $data01 $data02 $data03 $data04 $data05
if $rows != 1 then if $rows != 1 then
print rows $rows != 1 print rows $rows != 1
@ -128,7 +128,7 @@ if $rows != 5 then
endi endi
print =============== select * from stb from file in designated vgroup print =============== select * from stb from file in designated vgroup
sql select _wstartts, _wendts, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m); sql select _wstart, _wend, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m);
print $data00 $data01 $data02 $data03 $data04 print $data00 $data01 $data02 $data03 $data04
if $rows != 1 then if $rows != 1 then
print rows $rows != 1 print rows $rows != 1
@ -151,7 +151,7 @@ if $data04 != 20 then
endi endi
print =============== select * from stb from file in common vgroups print =============== select * from stb from file in common vgroups
sql select _wstartts, _wendts, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m); sql select _wstart, _wend, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m);
print $data00 $data01 $data02 $data03 $data04 $data05 print $data00 $data01 $data02 $data03 $data04 $data05
if $rows != 1 then if $rows != 1 then
print rows $rows != 1 print rows $rows != 1

View File

@ -33,7 +33,7 @@ if $rows != 3 then
return -1 return -1
endi endi
sql create stream s1 trigger at_once into outstb as select _wstartts, min(k), max(k), sum(k) as sum_alias from ct1 interval(10m) sql create stream s1 trigger at_once into outstb as select _wstart, min(k), max(k), sum(k) as sum_alias from ct1 interval(10m)
sql show stables sql show stables
if $rows != 2 then if $rows != 2 then
@ -48,7 +48,7 @@ sleep 100
#=================================================================== #===================================================================
print =============== query data from child table print =============== query data from child table
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
print rows: $rows print rows: $rows
print $data00 $data01 $data02 $data03 print $data00 $data01 $data02 $data03
if $rows != 1 then if $rows != 1 then
@ -77,7 +77,7 @@ sleep 100
#=================================================================== #===================================================================
print =============== query data from child table print =============== query data from child table
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
print rows: $rows print rows: $rows
print $data00 $data01 $data02 $data03 print $data00 $data01 $data02 $data03
if $rows != 1 then if $rows != 1 then
@ -105,7 +105,7 @@ sleep 100
#=================================================================== #===================================================================
print =============== query data from child table print =============== query data from child table
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
print rows: $rows print rows: $rows
print $data00 $data01 $data02 $data03 print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13 print $data10 $data11 $data12 $data13

View File

@ -17,14 +17,14 @@ sql use test
sql create table t1(ts timestamp, a int, b int , c int, d double); sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s); sql create stream streams1 trigger at_once into streamt as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s);
sql insert into t1 values(1648791213000,1,2,3,1.0); sql insert into t1 values(1648791213000,1,2,3,1.0);
sql insert into t1 values(1648791223001,2,2,3,1.1); sql insert into t1 values(1648791223001,2,2,3,1.1);
sql insert into t1 values(1648791233002,3,2,3,2.1); sql insert into t1 values(1648791233002,3,2,3,2.1);
sql insert into t1 values(1648791243003,4,2,3,3.1); sql insert into t1 values(1648791243003,4,2,3,3.1);
sql insert into t1 values(1648791213004,4,2,3,4.1); sql insert into t1 values(1648791213004,4,2,3,4.1);
sleep 1000 sleep 1000
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt; sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
if $rows != 4 then if $rows != 4 then
print ======$rows print ======$rows
@ -254,7 +254,7 @@ endi
sql insert into t1 values(1648791223002,12,14,13,11.1); sql insert into t1 values(1648791223002,12,14,13,11.1);
sleep 100 sleep 100
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt; sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
# row 1 # row 1
if $data11 != 2 then if $data11 != 2 then
@ -284,7 +284,7 @@ endi
sql insert into t1 values(1648791223003,12,14,13,11.1); sql insert into t1 values(1648791223003,12,14,13,11.1);
sleep 100 sleep 100
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt; sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
# row 1 # row 1
if $data11 != 3 then if $data11 != 3 then
@ -316,7 +316,7 @@ sql insert into t1 values(1648791223001,1,1,1,1.1);
sql insert into t1 values(1648791223002,2,2,2,2.1); sql insert into t1 values(1648791223002,2,2,2,2.1);
sql insert into t1 values(1648791223003,3,3,3,3.1); sql insert into t1 values(1648791223003,3,3,3,3.1);
sleep 100 sleep 100
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt; sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
# row 1 # row 1
if $data11 != 3 then if $data11 != 3 then
@ -348,7 +348,7 @@ sql insert into t1 values(1648791233003,3,2,3,2.1);
sql insert into t1 values(1648791233002,5,6,7,8.1); sql insert into t1 values(1648791233002,5,6,7,8.1);
sql insert into t1 values(1648791233002,3,2,3,2.1); sql insert into t1 values(1648791233002,3,2,3,2.1);
sleep 100 sleep 100
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt; sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
# row 2 # row 2
if $data21 != 2 then if $data21 != 2 then
@ -378,7 +378,7 @@ endi
sql insert into t1 values(1648791213004,4,2,3,4.1) (1648791213006,5,4,7,9.1) (1648791213004,40,20,30,40.1) (1648791213005,4,2,3,4.1); sql insert into t1 values(1648791213004,4,2,3,4.1) (1648791213006,5,4,7,9.1) (1648791213004,40,20,30,40.1) (1648791213005,4,2,3,4.1);
sleep 100 sleep 100
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt; sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
# row 0 # row 0
if $data01 != 4 then if $data01 != 4 then
@ -408,7 +408,7 @@ endi
sql insert into t1 values(1648791223004,4,2,3,4.1) (1648791233006,5,4,7,9.1) (1648791223004,40,20,30,40.1) (1648791233005,4,2,3,4.1); sql insert into t1 values(1648791223004,4,2,3,4.1) (1648791233006,5,4,7,9.1) (1648791223004,40,20,30,40.1) (1648791233005,4,2,3,4.1);
sleep 100 sleep 100
sql select `_wstartts`, c1, c2 ,c3 ,c4, c5 from streamt; sql select `_wstart`, c1, c2 ,c3 ,c4, c5 from streamt;
# row 1 # row 1
if $data11 != 4 then if $data11 != 4 then

View File

@ -33,7 +33,7 @@ if $rows != 3 then
return -1 return -1
endi endi
sql create stream s1 trigger at_once into outstb as select _wstartts, min(k), max(k), sum(k) as sum_alias from ct1 interval(10m) sql create stream s1 trigger at_once into outstb as select _wstart, min(k), max(k), sum(k) as sum_alias from ct1 interval(10m)
sql show stables sql show stables
if $rows != 2 then if $rows != 2 then
@ -48,7 +48,7 @@ sleep 100
#=================================================================== #===================================================================
print =============== query data from child table print =============== query data from child table
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
print rows: $rows print rows: $rows
print $data00 $data01 $data02 $data03 print $data00 $data01 $data02 $data03
if $rows != 1 then if $rows != 1 then
@ -77,7 +77,7 @@ sleep 100
#=================================================================== #===================================================================
print =============== query data from child table print =============== query data from child table
sql select `_wstartts`,`min(k)`,`max(k)`,sum_alias from outstb sql select `_wstart`,`min(k)`,`max(k)`,sum_alias from outstb
print rows: $rows print rows: $rows
print $data00 $data01 $data02 $data03 print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13 print $data10 $data11 $data12 $data13

View File

@ -41,7 +41,7 @@ sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create table ts3 using st tags(3,2,2); sql create table ts3 using st tags(3,2,2);
sql create table ts4 using st tags(4,2,2); sql create table ts4 using st tags(4,2,2);
sql create stream stream_t1 trigger at_once watermark 1d into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); sql create stream stream_t1 trigger at_once watermark 1d into streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s);
sleep 1000 sleep 1000
@ -195,7 +195,7 @@ if $data35 != 3 then
return -1 return -1
endi endi
sql select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5, avg(d) from st interval(10s); sql select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5, avg(d) from st interval(10s);
sql create database test1 vgroups 1; sql create database test1 vgroups 1;
@ -203,7 +203,7 @@ sql use test1;
sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int); sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int);
sql create table ts1 using st tags(1,1,1); sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create stream stream_t2 trigger at_once watermark 20s into streamtST1 as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ; sql create stream stream_t2 trigger at_once watermark 20s into streamtST1 as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ;
sql insert into ts1 values(1648791211000,1,2,3); sql insert into ts1 values(1648791211000,1,2,3);
sql insert into ts1 values(1648791222001,2,2,3); sql insert into ts1 values(1648791222001,2,2,3);

View File

@ -41,7 +41,7 @@ sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create table ts3 using st tags(3,2,2); sql create table ts3 using st tags(3,2,2);
sql create table ts4 using st tags(4,2,2); sql create table ts4 using st tags(4,2,2);
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); sql create stream stream_t1 trigger at_once into streamtST1 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s);
sleep 1000 sleep 1000

View File

@ -39,7 +39,7 @@ sql use test;
sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table ts1 using st tags(1,1,1); sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create stream stream_t1 trigger at_once into streamtST as select _wstartts, count(*) c1, sum(a) c2 , max(b) c3 from st session(ts, 10s) ; sql create stream stream_t1 trigger at_once into streamtST as select _wstart, count(*) c1, sum(a) c2 , max(b) c3 from st session(ts, 10s) ;
sleep 1000 sleep 1000

View File

@ -45,9 +45,9 @@ print $data00 $data01 $data02
sql use test sql use test
sql create table t1(ts timestamp, a int, b int , c int, d double); sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams1 trigger at_once IGNORE EXPIRED into streamt1 as select _wstartts, count(*) c1, sum(a) c3 from t1 interval(10s); sql create stream streams1 trigger at_once IGNORE EXPIRED into streamt1 as select _wstart, count(*) c1, sum(a) c3 from t1 interval(10s);
sql create stream streams2 trigger at_once IGNORE EXPIRED into streamt2 as select _wstartts, count(*) c1, sum(a) c3 from t1 session(ts,10s); sql create stream streams2 trigger at_once IGNORE EXPIRED into streamt2 as select _wstart, count(*) c1, sum(a) c3 from t1 session(ts,10s);
sql create stream streams3 trigger at_once IGNORE EXPIRED into streamt3 as select _wstartts, count(*) c1, sum(a) c3 from t1 state_window(a); sql create stream streams3 trigger at_once IGNORE EXPIRED into streamt3 as select _wstart, count(*) c1, sum(a) c3 from t1 state_window(a);
sql insert into t1 values(1648791213000,1,2,3,1.0); sql insert into t1 values(1648791213000,1,2,3,1.0);
sql insert into t1 values(1648791223001,1,2,3,1.1); sql insert into t1 values(1648791223001,1,2,3,1.1);
sql insert into t1 values(1648791233002,2,2,3,2.1); sql insert into t1 values(1648791233002,2,2,3,2.1);
@ -111,8 +111,8 @@ sql use test1
sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table ts1 using st tags(1,1,1); sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create stream stream_t1 trigger at_once IGNORE EXPIRED into streamtST1 as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ; sql create stream stream_t1 trigger at_once IGNORE EXPIRED into streamtST1 as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ;
sql create stream stream_t2 trigger at_once IGNORE EXPIRED into streamtST2 as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st session(ts, 10s) ; sql create stream stream_t2 trigger at_once IGNORE EXPIRED into streamtST2 as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st session(ts, 10s) ;
sql insert into ts1 values(1648791211000,1,2,3); sql insert into ts1 values(1648791211000,1,2,3);
sql insert into ts1 values(1648791222001,2,2,3); sql insert into ts1 values(1648791222001,2,2,3);
sql insert into ts2 values(1648791211000,1,2,3); sql insert into ts2 values(1648791211000,1,2,3);

View File

@ -11,7 +11,7 @@ sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create table ts3 using st tags(3,2,2); sql create table ts3 using st tags(3,2,2);
sql create table ts4 using st tags(4,2,2); sql create table ts4 using st tags(4,2,2);
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by ta,tb,tc interval(10s); sql create stream stream_t1 trigger at_once into streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by ta,tb,tc interval(10s);
sql insert into ts1 values(1648791213001,1,12,3,1.0); sql insert into ts1 values(1648791213001,1,12,3,1.0);
sql insert into ts2 values(1648791213001,1,12,3,1.0); sql insert into ts2 values(1648791213001,1,12,3,1.0);
@ -43,7 +43,7 @@ sql create table ts1 using st tags(1,2,3);
sql create table ts2 using st tags(1,3,4); sql create table ts2 using st tags(1,3,4);
sql create table ts3 using st tags(1,4,5); sql create table ts3 using st tags(1,4,5);
sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(a) c2 from st partition by ta,tb,tc interval(10s); sql create stream streams1 trigger at_once into streamt as select _wstart, count(*) c1, count(a) c2 from st partition by ta,tb,tc interval(10s);
sql insert into ts1 values(1648791211000,1,2,3); sql insert into ts1 values(1648791211000,1,2,3);
@ -74,7 +74,7 @@ sql create stable st(ts timestamp,a int,b int,c int,id int) tags(ta int,tb int,t
sql create table ts1 using st tags(1,1,1); sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create stream stream_t2 trigger at_once watermark 20s into streamtST as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by ta interval(10s) ; sql create stream stream_t2 trigger at_once watermark 20s into streamtST as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by ta interval(10s) ;
sql insert into ts1 values(1648791211000,1,2,3,1); sql insert into ts1 values(1648791211000,1,2,3,1);
sql insert into ts1 values(1648791222001,2,2,3,2); sql insert into ts1 values(1648791222001,2,2,3,2);
sql insert into ts2 values(1648791211000,1,2,3,3); sql insert into ts2 values(1648791211000,1,2,3,3);

View File

@ -11,7 +11,7 @@ sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create table ts3 using st tags(3,2,2); sql create table ts3 using st tags(3,2,2);
sql create table ts4 using st tags(4,2,2); sql create table ts4 using st tags(4,2,2);
sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by tbname interval(10s); sql create stream stream_t1 trigger at_once into streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st partition by tbname interval(10s);
sql insert into ts1 values(1648791213001,1,12,3,1.0); sql insert into ts1 values(1648791213001,1,12,3,1.0);
sql insert into ts2 values(1648791213001,1,12,3,1.0); sql insert into ts2 values(1648791213001,1,12,3,1.0);
@ -43,7 +43,7 @@ sql create table ts1 using st tags(1,2,3);
sql create table ts2 using st tags(1,3,4); sql create table ts2 using st tags(1,3,4);
sql create table ts3 using st tags(1,4,5); sql create table ts3 using st tags(1,4,5);
sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(a) c2 from st partition by tbname interval(10s); sql create stream streams1 trigger at_once into streamt as select _wstart, count(*) c1, count(a) c2 from st partition by tbname interval(10s);
sql insert into ts1 values(1648791211000,1,2,3); sql insert into ts1 values(1648791211000,1,2,3);
@ -74,7 +74,7 @@ sql create stable st(ts timestamp,a int,b int,c int,id int) tags(ta int,tb int,t
sql create table ts1 using st tags(1,1,1); sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create stream stream_t2 trigger at_once into streamtST as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by tbname interval(10s) ; sql create stream stream_t2 trigger at_once into streamtST as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6, max(id) c7 from st partition by tbname interval(10s) ;
sql insert into ts1 values(1648791211000,1,2,3,1); sql insert into ts1 values(1648791211000,1,2,3,1);
sql insert into ts1 values(1648791222001,2,2,3,2); sql insert into ts1 values(1648791222001,2,2,3,2);
sql insert into ts2 values(1648791211000,1,2,3,3); sql insert into ts2 values(1648791211000,1,2,3,3);

View File

@ -16,7 +16,7 @@ sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2); sql create table ts2 using st tags(2,2,2);
sql create table ts3 using st tags(3,2,2); sql create table ts3 using st tags(3,2,2);
sql create table ts4 using st tags(4,2,2); sql create table ts4 using st tags(4,2,2);
sql create stream stream_t1 trigger at_once into target.streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); sql create stream stream_t1 trigger at_once into target.streamtST1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s);
sleep 1000 sleep 1000
@ -170,4 +170,4 @@ if $data35 != 3 then
return -1 return -1
endi endi
sql select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5, avg(d) from st interval(10s); sql select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5, avg(d) from st interval(10s);

View File

@ -17,7 +17,7 @@ sql use test
sql create table t1(ts timestamp, a int, b int , c int, d double,id int); sql create table t1(ts timestamp, a int, b int , c int, d double,id int);
sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, sum(a), max(a), min(d), stddev(a), last(a), first(d), max(id) s from t1 session(ts,10s); sql create stream streams1 trigger at_once into streamt as select _wstart, count(*) c1, sum(a), max(a), min(d), stddev(a), last(a), first(d), max(id) s from t1 session(ts,10s);
sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL,1); sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL,1);
sql insert into t1 values(1648791223001,10,2,3,1.1,2); sql insert into t1 values(1648791223001,10,2,3,1.1,2);
sql insert into t1 values(1648791233002,3,2,3,2.1,3); sql insert into t1 values(1648791233002,3,2,3,2.1,3);
@ -179,7 +179,7 @@ endi
sql create database test2 vgroups 1; sql create database test2 vgroups 1;
sql use test2; sql use test2;
sql create table t2(ts timestamp, a int, b int , c int, d double, id int); sql create table t2(ts timestamp, a int, b int , c int, d double, id int);
sql create stream streams2 trigger at_once watermark 1d into streamt2 as select _wstartts,apercentile(a,30) c1, apercentile(a,70), apercentile(a,20,"t-digest") c2, apercentile(a,60,"t-digest") c3, max(id) c4 from t2 session(ts,10s); sql create stream streams2 trigger at_once watermark 1d into streamt2 as select _wstart,apercentile(a,30) c1, apercentile(a,70), apercentile(a,20,"t-digest") c2, apercentile(a,60,"t-digest") c3, max(id) c4 from t2 session(ts,10s);
sql insert into t2 values(1648791213001,1,1,3,1.0,1); sql insert into t2 values(1648791213001,1,1,3,1.0,1);
sql insert into t2 values(1648791213002,2,2,6,3.4,2); sql insert into t2 values(1648791213002,2,2,6,3.4,2);
sql insert into t2 values(1648791213003,4,9,3,4.8,3); sql insert into t2 values(1648791213003,4,9,3,4.8,3);
@ -229,13 +229,13 @@ endi
sql create database test3 vgroups 1; sql create database test3 vgroups 1;
sql use test3; sql use test3;
sql create table t1(ts timestamp, a int, b int , c int, d double); sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams3 trigger at_once watermark 1d into streamt3 as select _wstartts, min(b), a,c from t1 session(ts,10s); sql create stream streams3 trigger at_once watermark 1d into streamt3 as select _wstart, min(b), a,c from t1 session(ts,10s);
sql create stream streams4 trigger at_once watermark 1d into streamt4 as select _wstartts, max(b), a,c from t1 session(ts,10s); sql create stream streams4 trigger at_once watermark 1d into streamt4 as select _wstart, max(b), a,c from t1 session(ts,10s);
# sql create stream streams5 trigger at_once watermark 1d into streamt5 as select _wstartts, top(b,3), a,c from t1 session(ts,10s); # sql create stream streams5 trigger at_once watermark 1d into streamt5 as select _wstart, top(b,3), a,c from t1 session(ts,10s);
# sql create stream streams6 trigger at_once watermark 1d into streamt6 as select _wstartts, bottom(b,3), a,c from t1 session(ts,10s); # sql create stream streams6 trigger at_once watermark 1d into streamt6 as select _wstart, bottom(b,3), a,c from t1 session(ts,10s);
# sql create stream streams7 trigger at_once watermark 1d into streamt7 as select _wstartts, spread(a), elapsed(ts), hyperloglog(a) from t1 session(ts,10s); # sql create stream streams7 trigger at_once watermark 1d into streamt7 as select _wstart, spread(a), elapsed(ts), hyperloglog(a) from t1 session(ts,10s);
sql create stream streams7 trigger at_once watermark 1d into streamt7 as select _wstartts, spread(a), hyperloglog(a) from t1 session(ts,10s); sql create stream streams7 trigger at_once watermark 1d into streamt7 as select _wstart, spread(a), hyperloglog(a) from t1 session(ts,10s);
# sql create stream streams8 trigger at_once watermark 1d into streamt8 as select _wstartts, histogram(a,"user_input", "[1,3,5,7]", 1), histogram(a,"user_input", "[1,3,5,7]", 0) from t1 session(ts,10s); # sql create stream streams8 trigger at_once watermark 1d into streamt8 as select _wstart, histogram(a,"user_input", "[1,3,5,7]", 1), histogram(a,"user_input", "[1,3,5,7]", 0) from t1 session(ts,10s);
sql insert into t1 values(1648791213001,1,1,1,1.0); sql insert into t1 values(1648791213001,1,1,1,1.0);
sql insert into t1 values(1648791213002,2,3,2,3.4); sql insert into t1 values(1648791213002,2,3,2,3.4);
sql insert into t1 values(1648791213003,4,9,3,4.8); sql insert into t1 values(1648791213003,4,9,3,4.8);

View File

@ -17,7 +17,7 @@ sql use test
sql create table t1(ts timestamp, a int, b int , c int, d double,id int); sql create table t1(ts timestamp, a int, b int , c int, d double,id int);
sql create stream streams2 trigger at_once into streamt as select _wstartts, count(*) c1, sum(a), min(b), max(id) s from t1 session(ts,10s); sql create stream streams2 trigger at_once into streamt as select _wstart, count(*) c1, sum(a), min(b), max(id) s from t1 session(ts,10s);
sql insert into t1 values(1648791210000,1,1,1,1.1,1); sql insert into t1 values(1648791210000,1,1,1,1.1,1);
sql insert into t1 values(1648791220000,2,2,2,2.1,2); sql insert into t1 values(1648791220000,2,2,2,2.1,2);
sql insert into t1 values(1648791230000,3,3,3,3.1,3); sql insert into t1 values(1648791230000,3,3,3,3.1,3);

View File

@ -16,7 +16,7 @@ print $data00 $data01 $data02
sql use test sql use test
sql create table t1(ts timestamp, a int, b int , c int, d double, id int); sql create table t1(ts timestamp, a int, b int , c int, d double, id int);
sql create stream streams1 trigger at_once into streamt1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); sql create stream streams1 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a);
sql insert into t1 values(1648791213000,1,2,3,1.0,1); sql insert into t1 values(1648791213000,1,2,3,1.0,1);
sql insert into t1 values(1648791213000,1,2,3,1.0,2); sql insert into t1 values(1648791213000,1,2,3,1.0,2);
@ -54,7 +54,7 @@ sql insert into t1 values(1648791213000,1,2,3,1.0,5);
sql insert into t1 values(1648791214000,1,2,3,1.0,6); sql insert into t1 values(1648791214000,1,2,3,1.0,6);
$loop_count = 0 $loop_count = 0
loop1: loop1:
sql select * from streamt1 where c >=4 order by `_wstartts`; sql select * from streamt1 where c >=4 order by `_wstart`;
sleep 300 sleep 300
$loop_count = $loop_count + 1 $loop_count = $loop_count + 1
if $loop_count == 10 then if $loop_count == 10 then
@ -163,7 +163,7 @@ sql insert into t1 values(1648791213011,1,2,3,1.0,7);
$loop_count = 0 $loop_count = 0
loop2: loop2:
sql select * from streamt1 where c in (5,4,7) order by `_wstartts`; sql select * from streamt1 where c in (5,4,7) order by `_wstart`;
sleep 300 sleep 300
$loop_count = $loop_count + 1 $loop_count = $loop_count + 1
if $loop_count == 10 then if $loop_count == 10 then
@ -207,7 +207,7 @@ sql insert into t1 values(1648791213011,1,2,3,1.0,8);
$loop_count = 0 $loop_count = 0
loop21: loop21:
sql select * from streamt1 where c in (5,4,8) order by `_wstartts`; sql select * from streamt1 where c in (5,4,8) order by `_wstart`;
sleep 300 sleep 300
$loop_count = $loop_count + 1 $loop_count = $loop_count + 1
if $loop_count == 10 then if $loop_count == 10 then
@ -227,7 +227,7 @@ sql insert into t1 values(1648791213011,10,20,10,10.0,12);
$loop_count = 0 $loop_count = 0
loop3: loop3:
sql select * from streamt1 where c in (5,4,10,11,12) order by `_wstartts`; sql select * from streamt1 where c in (5,4,10,11,12) order by `_wstart`;
sleep 300 sleep 300
$loop_count = $loop_count + 1 $loop_count = $loop_count + 1
if $loop_count == 10 then if $loop_count == 10 then
@ -339,7 +339,7 @@ sql insert into t1 values(1648791213030,3,14,14,14.0,15) (1648791214020,15,15,15
$loop_count = 0 $loop_count = 0
loop4: loop4:
sql select * from streamt1 where c in (14,15,16) order by `_wstartts`; sql select * from streamt1 where c in (14,15,16) order by `_wstart`;
sleep 300 sleep 300
$loop_count = $loop_count + 1 $loop_count = $loop_count + 1
@ -457,7 +457,7 @@ print $data00 $data01 $data02
sql use test1 sql use test1
sql create table t1(ts timestamp, a int, b int , c int, d double, id int); sql create table t1(ts timestamp, a int, b int , c int, d double, id int);
sql create stream streams2 trigger at_once into streamt1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); sql create stream streams2 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a);
sql insert into t1 values(1648791212000,2,2,3,1.0,1); sql insert into t1 values(1648791212000,2,2,3,1.0,1);
sql insert into t1 values(1648791213000,1,2,3,1.0,1); sql insert into t1 values(1648791213000,1,2,3,1.0,1);

View File

@ -15,7 +15,7 @@ print $data00 $data01 $data02
sql use test sql use test
sql create table t1(ts timestamp, a int, b int , c int, d double); sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams1 trigger window_close into streamt as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s); sql create stream streams1 trigger window_close into streamt as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s);
sql insert into t1 values(1648791213001,1,2,3,1.0); sql insert into t1 values(1648791213001,1,2,3,1.0);
sleep 300 sleep 300

View File

@ -15,7 +15,7 @@ print $data00 $data01 $data02
sql use test sql use test
sql create table t2(ts timestamp, a int, b int , c int, d double); sql create table t2(ts timestamp, a int, b int , c int, d double);
sql create stream streams2 trigger window_close into streamt2 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t2 session(ts, 10s); sql create stream streams2 trigger window_close into streamt2 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t2 session(ts, 10s);
sql insert into t2 values(1648791213000,1,2,3,1.0); sql insert into t2 values(1648791213000,1,2,3,1.0);
sql insert into t2 values(1648791222999,1,2,3,1.0); sql insert into t2 values(1648791222999,1,2,3,1.0);

View File

@ -18,7 +18,7 @@ sql create stable st(ts timestamp, a int) tags(t int);
sql create table tu1 using st tags(1); sql create table tu1 using st tags(1);
sql create table tu2 using st tags(2); sql create table tu2 using st tags(2);
sql create stream stream1 trigger window_close into streamt as select _wstartts, sum(a) from st interval(10s); sql create stream stream1 trigger window_close into streamt as select _wstart, sum(a) from st interval(10s);
sql insert into tu1 values(now, 1); sql insert into tu1 values(now, 1);

View File

@ -109,20 +109,20 @@ if $data00 != $rowNum then
endi endi
print =============== step5 print =============== step5
sql select _wstartts, count(tbcol) as b from $tb interval(1m) sql select _wstart, count(tbcol) as b from $tb interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 1 then if $data01 != 1 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol) as b from $tb interval(1d) sql select _wstart, count(tbcol) as b from $tb interval(1d)
print ===> $data01 print ===> $data01
if $data01 != $rowNum then if $data01 != $rowNum then
return -1 return -1
endi endi
print =============== step6 print =============== step6
sql select _wstartts, count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) sql select _wstart, count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 1 then if $data01 != 1 then
return -1 return -1
@ -164,13 +164,13 @@ if $data00 != 25 then
endi endi
print =============== step9 print =============== step9
sql select _wstartts, count(tbcol) as b from $mt interval(1m) sql select _wstart, count(tbcol) as b from $mt interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 10 then if $data01 != 10 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol) as b from $mt interval(1d) sql select _wstart, count(tbcol) as b from $mt interval(1d)
print ===> $data01 print ===> $data01
if $data01 != 200 then if $data01 != 200 then
return -1 return -1

View File

@ -138,13 +138,13 @@ if $data00 != 25 then
endi endi
print =============== step4 print =============== step4
sql select _wstartts, count(tbcol) as b from $mt interval(1m) sql select _wstart, count(tbcol) as b from $mt interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 10 then if $data01 != 10 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol) as b from $mt interval(1d) sql select _wstart, count(tbcol) as b from $mt interval(1d)
print ===> $data01 print ===> $data01
if $data01 != 200 then if $data01 != 200 then
return -1 return -1

View File

@ -111,20 +111,20 @@ if $data00 != $rowNum then
endi endi
print =============== step5 print =============== step5
sql select _wstartts, count(tbcol) as b from $tb interval(1m) sql select _wstart, count(tbcol) as b from $tb interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 1 then if $data01 != 1 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol) as b from $tb interval(1d) sql select _wstart, count(tbcol) as b from $tb interval(1d)
print ===> $data01 print ===> $data01
if $data01 != $rowNum then if $data01 != $rowNum then
return -1 return -1
endi endi
print =============== step6 print =============== step6
sql select _wstartts, count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) sql select _wstart, count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 1 then if $data01 != 1 then
return -1 return -1
@ -166,13 +166,13 @@ if $data00 != 25 then
endi endi
print =============== step9 print =============== step9
sql select _wstartts, count(tbcol) as b from $mt interval(1m) sql select _wstart, count(tbcol) as b from $mt interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 10 then if $data01 != 10 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol) as b from $mt interval(1d) sql select _wstart, count(tbcol) as b from $mt interval(1d)
print ===> $data01 print ===> $data01
if $data01 != 200 then if $data01 != 200 then
return -1 return -1

View File

@ -140,20 +140,20 @@ if $data00 != $rowNum then
endi endi
print =============== step5 print =============== step5
sql select _wstartts, count(tbcol) as b from $tb interval(1m) sql select _wstart, count(tbcol) as b from $tb interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 1 then if $data01 != 1 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol) as b from $tb interval(1d) sql select _wstart, count(tbcol) as b from $tb interval(1d)
print ===> $data01 print ===> $data01
if $data01 != $rowNum then if $data01 != $rowNum then
return -1 return -1
endi endi
print =============== step6 print =============== step6
sql select _wstartts, count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) sql select _wstart, count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 1 then if $data01 != 1 then
return -1 return -1
@ -195,13 +195,13 @@ if $data00 != 25 then
endi endi
print =============== step9 print =============== step9
#sql select _wstartts, count(tbcol) as b from $mt interval(1m) #sql select _wstart, count(tbcol) as b from $mt interval(1m)
#print ===> $data01 #print ===> $data01
#if $data01 != 10 then #if $data01 != 10 then
# return -1 # return -1
#endi #endi
sql select _wstartts, count(tbcol) as b from $mt interval(1d) sql select _wstart, count(tbcol) as b from $mt interval(1d)
print ===> $data01 print ===> $data01
if $data01 != 200 then if $data01 != 200 then
return -1 return -1

View File

@ -124,20 +124,20 @@ if $data00 != $rowNum then
endi endi
print =============== step5 print =============== step5
sql select _wstartts, count(tbcol) as b from $tb interval(1m) sql select _wstart, count(tbcol) as b from $tb interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 1 then if $data01 != 1 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol) as b from $tb interval(1d) sql select _wstart, count(tbcol) as b from $tb interval(1d)
print ===> $data01 print ===> $data01
if $data01 != $rowNum then if $data01 != $rowNum then
return -1 return -1
endi endi
print =============== step6 print =============== step6
sql select _wstartts, count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m) sql select _wstart, count(tbcol) as b from $tb where ts <= 1519833840000 interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 1 then if $data01 != 1 then
return -1 return -1
@ -180,13 +180,13 @@ if $data00 != 25 then
endi endi
print =============== step9 print =============== step9
sql select _wstartts, count(tbcol) as b from $mt interval(1m) sql select _wstart, count(tbcol) as b from $mt interval(1m)
print ===> $data01 print ===> $data01
if $data01 != 10 then if $data01 != 10 then
return -1 return -1
endi endi
sql select _wstartts, count(tbcol) as b from $mt interval(1d) sql select _wstart, count(tbcol) as b from $mt interval(1d)
print ===> $data01 print ===> $data01
if $data01 != 200 then if $data01 != 200 then
return -1 return -1