Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/vnode_refact1
This commit is contained in:
commit
cb744ab67b
|
@ -195,45 +195,46 @@
|
|||
#define TK_CAST 177
|
||||
#define TK_NOW 178
|
||||
#define TK_TODAY 179
|
||||
#define TK_COUNT 180
|
||||
#define TK_FIRST 181
|
||||
#define TK_LAST 182
|
||||
#define TK_LAST_ROW 183
|
||||
#define TK_BETWEEN 184
|
||||
#define TK_IS 185
|
||||
#define TK_NK_LT 186
|
||||
#define TK_NK_GT 187
|
||||
#define TK_NK_LE 188
|
||||
#define TK_NK_GE 189
|
||||
#define TK_NK_NE 190
|
||||
#define TK_MATCH 191
|
||||
#define TK_NMATCH 192
|
||||
#define TK_CONTAINS 193
|
||||
#define TK_JOIN 194
|
||||
#define TK_INNER 195
|
||||
#define TK_SELECT 196
|
||||
#define TK_DISTINCT 197
|
||||
#define TK_WHERE 198
|
||||
#define TK_PARTITION 199
|
||||
#define TK_BY 200
|
||||
#define TK_SESSION 201
|
||||
#define TK_STATE_WINDOW 202
|
||||
#define TK_SLIDING 203
|
||||
#define TK_FILL 204
|
||||
#define TK_VALUE 205
|
||||
#define TK_NONE 206
|
||||
#define TK_PREV 207
|
||||
#define TK_LINEAR 208
|
||||
#define TK_NEXT 209
|
||||
#define TK_GROUP 210
|
||||
#define TK_HAVING 211
|
||||
#define TK_ORDER 212
|
||||
#define TK_SLIMIT 213
|
||||
#define TK_SOFFSET 214
|
||||
#define TK_LIMIT 215
|
||||
#define TK_OFFSET 216
|
||||
#define TK_ASC 217
|
||||
#define TK_NULLS 218
|
||||
#define TK_TIMEZONE 180
|
||||
#define TK_COUNT 181
|
||||
#define TK_FIRST 182
|
||||
#define TK_LAST 183
|
||||
#define TK_LAST_ROW 184
|
||||
#define TK_BETWEEN 185
|
||||
#define TK_IS 186
|
||||
#define TK_NK_LT 187
|
||||
#define TK_NK_GT 188
|
||||
#define TK_NK_LE 189
|
||||
#define TK_NK_GE 190
|
||||
#define TK_NK_NE 191
|
||||
#define TK_MATCH 192
|
||||
#define TK_NMATCH 193
|
||||
#define TK_CONTAINS 194
|
||||
#define TK_JOIN 195
|
||||
#define TK_INNER 196
|
||||
#define TK_SELECT 197
|
||||
#define TK_DISTINCT 198
|
||||
#define TK_WHERE 199
|
||||
#define TK_PARTITION 200
|
||||
#define TK_BY 201
|
||||
#define TK_SESSION 202
|
||||
#define TK_STATE_WINDOW 203
|
||||
#define TK_SLIDING 204
|
||||
#define TK_FILL 205
|
||||
#define TK_VALUE 206
|
||||
#define TK_NONE 207
|
||||
#define TK_PREV 208
|
||||
#define TK_LINEAR 209
|
||||
#define TK_NEXT 210
|
||||
#define TK_GROUP 211
|
||||
#define TK_HAVING 212
|
||||
#define TK_ORDER 213
|
||||
#define TK_SLIMIT 214
|
||||
#define TK_SOFFSET 215
|
||||
#define TK_LIMIT 216
|
||||
#define TK_OFFSET 217
|
||||
#define TK_ASC 218
|
||||
#define TK_NULLS 219
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -53,6 +53,11 @@ typedef struct SScanLogicNode {
|
|||
double ratio;
|
||||
SNodeList* pDynamicScanFuncs;
|
||||
int32_t dataRequired;
|
||||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
int8_t intervalUnit;
|
||||
int8_t slidingUnit;
|
||||
} SScanLogicNode;
|
||||
|
||||
typedef struct SJoinLogicNode {
|
||||
|
@ -208,6 +213,11 @@ typedef struct STableScanPhysiNode {
|
|||
double ratio;
|
||||
int32_t dataRequired;
|
||||
SNodeList* pDynamicScanFuncs;
|
||||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
int8_t intervalUnit;
|
||||
int8_t slidingUnit;
|
||||
} STableScanPhysiNode;
|
||||
|
||||
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||
|
@ -264,7 +274,6 @@ typedef struct SIntervalPhysiNode {
|
|||
int64_t sliding;
|
||||
int8_t intervalUnit;
|
||||
int8_t slidingUnit;
|
||||
uint8_t precision;
|
||||
SFillNode* pFill;
|
||||
} SIntervalPhysiNode;
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef enum EColumnType {
|
|||
typedef struct SColumnNode {
|
||||
SExprNode node; // QUERY_NODE_COLUMN
|
||||
uint64_t tableId;
|
||||
int8_t tableType;
|
||||
col_id_t colId;
|
||||
EColumnType colType; // column or tag
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
|
@ -196,8 +197,8 @@ typedef struct SStateWindowNode {
|
|||
|
||||
typedef struct SSessionWindowNode {
|
||||
ENodeType type; // QUERY_NODE_SESSION_WINDOW
|
||||
SNode* pCol; // timestamp primary key
|
||||
SNode* pGap; // gap between two session window(in microseconds)
|
||||
SColumnNode* pCol; // timestamp primary key
|
||||
SValueNode* pGap; // gap between two session window(in microseconds)
|
||||
} SSessionWindowNode;
|
||||
|
||||
typedef struct SIntervalWindowNode {
|
||||
|
|
|
@ -80,6 +80,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
|||
int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
int32_t timezoneFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
||||
bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
|
||||
|
|
|
@ -579,7 +579,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
|
||||
#define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613)
|
||||
#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614)
|
||||
#define TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615)
|
||||
#define TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615)
|
||||
#define TSDB_CODE_PAR_DB_NOT_SPECIFIED TAOS_DEF_ERROR_CODE(0, 0x2616)
|
||||
#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617)
|
||||
#define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618)
|
||||
|
@ -598,6 +598,17 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INVALID_OPTION_UNIT TAOS_DEF_ERROR_CODE(0, 0x2625)
|
||||
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
|
||||
#define TSDB_CODE_PAR_AGG_FUNC_NESTING TAOS_DEF_ERROR_CODE(0, 0x2627)
|
||||
#define TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE TAOS_DEF_ERROR_CODE(0, 0x2628)
|
||||
#define TSDB_CODE_PAR_INVALID_STATE_WIN_COL TAOS_DEF_ERROR_CODE(0, 0x2629)
|
||||
#define TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE TAOS_DEF_ERROR_CODE(0, 0x262A)
|
||||
#define TSDB_CODE_PAR_INTER_SESSION_GAP TAOS_DEF_ERROR_CODE(0, 0x262B)
|
||||
#define TSDB_CODE_PAR_INTER_SESSION_COL TAOS_DEF_ERROR_CODE(0, 0x262C)
|
||||
#define TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE TAOS_DEF_ERROR_CODE(0, 0x262D)
|
||||
#define TSDB_CODE_PAR_INTER_OFFSET_UNIT TAOS_DEF_ERROR_CODE(0, 0x262E)
|
||||
#define TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x262F)
|
||||
#define TSDB_CODE_PAR_INTER_SLIDING_UNIT TAOS_DEF_ERROR_CODE(0, 0x2630)
|
||||
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x2631)
|
||||
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
|
||||
|
||||
//planner
|
||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||
|
|
|
@ -316,6 +316,9 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t getIntervalPrecision(SIntervalPhysiNode* pIntNode) {
|
||||
return ((SColumnNode*)pIntNode->window.pTspk)->node.resType.precision;
|
||||
}
|
||||
|
||||
int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) {
|
||||
int32_t tlen = 0;
|
||||
|
@ -658,10 +661,10 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize);
|
||||
EXPLAIN_ROW_END();
|
||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||
|
||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT, INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, pIntNode->precision),
|
||||
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(pIntNode->precision),
|
||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, pIntNode->precision), pIntNode->slidingUnit);
|
||||
uint8_t precision = getIntervalPrecision(pIntNode);
|
||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT, INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision),
|
||||
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision), pIntNode->slidingUnit);
|
||||
EXPLAIN_ROW_END();
|
||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||
|
||||
|
|
|
@ -6831,7 +6831,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
.intervalUnit = pIntervalPhyNode->intervalUnit,
|
||||
.slidingUnit = pIntervalPhyNode->slidingUnit,
|
||||
.offset = pIntervalPhyNode->offset,
|
||||
.precision = pIntervalPhyNode->precision
|
||||
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision
|
||||
};
|
||||
|
||||
int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId;
|
||||
|
|
|
@ -138,6 +138,12 @@ static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, in
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTimezone(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// pseudo column do not need to check parameters
|
||||
pFunc->node.resType = (SDataType){.bytes = TD_TIMEZONE_LEN, .type = TSDB_DATA_TYPE_BINARY};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
|
@ -399,7 +405,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
{
|
||||
.name = "sum",
|
||||
.type = FUNCTION_TYPE_SUM,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateSum,
|
||||
.getEnvFunc = getSumFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
@ -816,6 +822,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.sprocessFunc = todayFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "timezone",
|
||||
.type = FUNCTION_TYPE_TIMEZONE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTimezone,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timezoneFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_rowts",
|
||||
.type = FUNCTION_TYPE_ROWTS,
|
||||
|
|
|
@ -748,6 +748,11 @@ static const char* jkTableScanPhysiPlanEndKey = "EndKey";
|
|||
static const char* jkTableScanPhysiPlanRatio = "Ratio";
|
||||
static const char* jkTableScanPhysiPlanDataRequired = "DataRequired";
|
||||
static const char* jkTableScanPhysiPlanDynamicScanFuncs = "DynamicScanFuncs";
|
||||
static const char* jkTableScanPhysiPlanInterval = "Interval";
|
||||
static const char* jkTableScanPhysiPlanOffset = "Offset";
|
||||
static const char* jkTableScanPhysiPlanSliding = "Sliding";
|
||||
static const char* jkTableScanPhysiPlanIntervalUnit = "intervalUnit";
|
||||
static const char* jkTableScanPhysiPlanSlidingUnit = "slidingUnit";
|
||||
|
||||
static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
|
||||
|
@ -771,6 +776,21 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkTableScanPhysiPlanDynamicScanFuncs, pNode->pDynamicScanFuncs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanInterval, pNode->interval);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanOffset, pNode->offset);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanSliding, pNode->sliding);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -797,6 +817,21 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1159,7 +1194,6 @@ static const char* jkIntervalPhysiPlanSliding = "Sliding";
|
|||
static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit";
|
||||
static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit";
|
||||
static const char* jkIntervalPhysiPlanFill = "Fill";
|
||||
static const char* jkIntervalPhysiPlanPrecision = "Precision";
|
||||
|
||||
static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
|
||||
|
@ -1183,9 +1217,6 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanPrecision, pNode->precision);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -1212,9 +1243,6 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetUTinyIntValue(pJson, jkIntervalPhysiPlanPrecision, &pNode->precision);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -87,9 +87,9 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
|
|||
}
|
||||
case QUERY_NODE_SESSION_WINDOW: {
|
||||
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
||||
res = walkNode(pSession->pCol, order, walker, pContext);
|
||||
res = walkNode((SNode*)pSession->pCol, order, walker, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = walkNode(pSession->pGap, order, walker, pContext);
|
||||
res = walkNode((SNode*)pSession->pGap, order, walker, pContext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -227,9 +227,9 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
|
|||
}
|
||||
case QUERY_NODE_SESSION_WINDOW: {
|
||||
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
||||
res = rewriteNode(&pSession->pCol, order, rewriter, pContext);
|
||||
res = rewriteNode((SNode**)&pSession->pCol, order, rewriter, pContext);
|
||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||
res = rewriteNode(&pSession->pGap, order, rewriter, pContext);
|
||||
res = rewriteNode((SNode**)&pSession->pGap, order, rewriter, pContext);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
|
|||
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
|
||||
SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName);
|
||||
SNode* createFunctionNodeNoArg(SAstCreateContext* pCxt, const SToken* pFuncName);
|
||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt);
|
||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
||||
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
||||
|
|
|
@ -603,12 +603,13 @@ pseudo_column(A) ::= WDURATION(B).
|
|||
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) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
function_expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
function_expression(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
||||
function_expression(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNodeNoArg(pCxt, &B)); }
|
||||
|
||||
%type noarg_func { SToken }
|
||||
%destructor noarg_func { }
|
||||
noarg_func(A) ::= NOW(B). { A = B; }
|
||||
noarg_func(A) ::= TODAY(B). { A = B; }
|
||||
noarg_func(A) ::= TIMEZONE(B). { A = B; }
|
||||
|
||||
%type star_func { SToken }
|
||||
%destructor star_func { }
|
||||
|
|
|
@ -260,7 +260,8 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken*
|
|||
CHECK_OUT_OF_MEM(val);
|
||||
if (NULL != pLiteral) {
|
||||
val->literal = strndup(pLiteral->z, pLiteral->n);
|
||||
if (TK_NK_ID != pLiteral->type && (IS_VAR_DATA_TYPE(dataType) || TSDB_DATA_TYPE_TIMESTAMP == dataType)) {
|
||||
if (TK_NK_ID != pLiteral->type && TK_TIMEZONE != pLiteral->type &&
|
||||
(IS_VAR_DATA_TYPE(dataType) || TSDB_DATA_TYPE_TIMESTAMP == dataType)) {
|
||||
trimString(pLiteral->z, pLiteral->n, val->literal, pLiteral->n);
|
||||
}
|
||||
CHECK_OUT_OF_MEM(val->literal);
|
||||
|
@ -367,7 +368,7 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod
|
|||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName) {
|
||||
SNode* createFunctionNodeNoArg(SAstCreateContext* pCxt, const SToken* pFuncName) {
|
||||
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
CHECK_OUT_OF_MEM(func);
|
||||
char buf[64] = {0};
|
||||
|
@ -386,11 +387,11 @@ SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncNam
|
|||
dataType = TSDB_DATA_TYPE_BIGINT;
|
||||
break;
|
||||
}
|
||||
//case TK_TIMEZONE: {
|
||||
// strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr));
|
||||
// dataType = TSDB_DATA_TYPE_BINARY;
|
||||
// break;
|
||||
//}
|
||||
case TK_TIMEZONE: {
|
||||
strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr));
|
||||
dataType = TSDB_DATA_TYPE_BINARY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SToken token = {.type = pFuncName->type, .n = strlen(buf), .z = buf};
|
||||
|
||||
|
@ -499,8 +500,8 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order
|
|||
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap) {
|
||||
SSessionWindowNode* session = (SSessionWindowNode*)nodesMakeNode(QUERY_NODE_SESSION_WINDOW);
|
||||
CHECK_OUT_OF_MEM(session);
|
||||
session->pCol = pCol;
|
||||
session->pGap = pGap;
|
||||
session->pCol = (SColumnNode*)pCol;
|
||||
session->pGap = (SValueNode*)pGap;
|
||||
return (SNode*)session;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ static SKeyword keywordTable[] = {
|
|||
{"TAGS", TK_TAGS},
|
||||
{"TBNAME", TK_TBNAME},
|
||||
{"TIMESTAMP", TK_TIMESTAMP},
|
||||
{"TIMEZONE", TK_TIMEZONE},
|
||||
{"TINYINT", TK_TINYINT},
|
||||
{"TODAY", TK_TODAY},
|
||||
{"TOPIC", TK_TOPIC},
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "cmdnodes.h"
|
||||
#include "functionMgt.h"
|
||||
#include "parUtil.h"
|
||||
#include "tglobal.h"
|
||||
#include "ttime.h"
|
||||
|
||||
#define GET_OPTION_VAL(pVal, defaultVal) (NULL == (pVal) ? (defaultVal) : getBigintFromValueNode((SValueNode*)(pVal)))
|
||||
|
@ -227,6 +228,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p
|
|||
strcpy(pCol->node.aliasName, pColSchema->name);
|
||||
}
|
||||
pCol->tableId = pTable->pMeta->uid;
|
||||
pCol->tableType = pTable->pMeta->tableType;
|
||||
pCol->colId = pColSchema->colId;
|
||||
pCol->colType = isTag ? COLUMN_TYPE_TAG : COLUMN_TYPE_COLUMN;
|
||||
pCol->node.resType.type = pColSchema->type;
|
||||
|
@ -364,18 +366,38 @@ static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode* pCol)
|
|||
}
|
||||
|
||||
static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
|
||||
// count(*)/first(*)/last(*)
|
||||
// count(*)/first(*)/last(*) and so on
|
||||
if (0 == strcmp(pCol->colName, "*")) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes res = DEAL_RES_CONTINUE;
|
||||
if ('\0' != pCol->tableAlias[0]) {
|
||||
return translateColumnWithPrefix(pCxt, pCol);
|
||||
res = translateColumnWithPrefix(pCxt, pCol);
|
||||
} else {
|
||||
bool found = false;
|
||||
if (SQL_CLAUSE_ORDER_BY == pCxt->currClause) {
|
||||
found = translateColumnUseAlias(pCxt, pCol);
|
||||
}
|
||||
res = (found ? DEAL_RES_CONTINUE : translateColumnWithoutPrefix(pCxt, pCol));
|
||||
}
|
||||
bool found = false;
|
||||
if (SQL_CLAUSE_ORDER_BY == pCxt->currClause) {
|
||||
found = translateColumnUseAlias(pCxt, pCol);
|
||||
|
||||
if (DEAL_RES_ERROR == res) {
|
||||
return res;
|
||||
}
|
||||
return found ? DEAL_RES_CONTINUE : translateColumnWithoutPrefix(pCxt, pCol);
|
||||
|
||||
if (SQL_CLAUSE_WINDOW == pCxt->currClause && QUERY_NODE_STATE_WINDOW == nodeType(pCxt->pCurrStmt->pWindow)) {
|
||||
if (!IS_INTEGER_TYPE(pCol->node.resType.type)) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE);
|
||||
}
|
||||
if (COLUMN_TYPE_TAG == pCol->colType) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_COL);
|
||||
}
|
||||
if (TSDB_SUPER_TABLE == pCol->tableType) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE);
|
||||
}
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||
|
@ -466,8 +488,18 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
|||
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||
}
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
||||
if (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||
}
|
||||
|
||||
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BIGINT == rdt.type) ||
|
||||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BIGINT == ldt.type)) {
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
|
||||
} else {
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
||||
}
|
||||
} else if (nodesIsComparisonOp(pOp)) {
|
||||
if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type ||
|
||||
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
||||
|
@ -639,7 +671,7 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
|
|||
if (!pSelect->isDistinct) {
|
||||
nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
|
||||
}
|
||||
if (cxt.existAggFunc && cxt.existCol) {
|
||||
if ((cxt.existAggFunc || NULL != pSelect->pWindow) && cxt.existCol) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1091,20 +1123,100 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
return translateExprList(pCxt, pSelect->pGroupByList);
|
||||
}
|
||||
|
||||
static int32_t translateIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) {
|
||||
SValueNode* pIntervalVal = (SValueNode*)pInterval->pInterval;
|
||||
SValueNode* pIntervalOffset = (SValueNode*)pInterval->pOffset;
|
||||
SValueNode* pSliding = (SValueNode*)pInterval->pSliding;
|
||||
if (pIntervalVal->datum.i <= 0) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL, pIntervalVal->literal);
|
||||
static bool isValTimeUnit(char unit) {
|
||||
return ('n' == unit || 'y' == unit);
|
||||
}
|
||||
|
||||
static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) {
|
||||
int64_t days = convertTimeFromPrecisionToUnit(val, fromPrecision, 'd');
|
||||
switch (unit) {
|
||||
case 'b':
|
||||
case 'u':
|
||||
case 'a':
|
||||
case 's':
|
||||
case 'm':
|
||||
case 'h':
|
||||
case 'd':
|
||||
case 'w':
|
||||
return days / 28;
|
||||
case 'n':
|
||||
return val;
|
||||
case 'y':
|
||||
return val * 12;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) {
|
||||
uint8_t precision = ((SColumnNode*)pInterval->pCol)->node.resType.precision;
|
||||
|
||||
SValueNode* pInter = (SValueNode*)pInterval->pInterval;
|
||||
bool valInter = isValTimeUnit(pInter->unit);
|
||||
if (pInter->datum.i <= 0 ||
|
||||
(!valInter && convertTimePrecision(pInter->datum.i, precision, TSDB_TIME_PRECISION_MICRO) < tsMinIntervalTime)) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL, tsMinIntervalTime);
|
||||
}
|
||||
|
||||
if (NULL != pInterval->pOffset) {
|
||||
SValueNode* pOffset = (SValueNode*)pInterval->pOffset;
|
||||
if (pOffset->datum.i <= 0) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE);
|
||||
}
|
||||
if (pInter->unit == 'n' && pOffset->unit == 'y') {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_UNIT);
|
||||
}
|
||||
bool fixed = !isValTimeUnit(pOffset->unit) && !valInter;
|
||||
if ((fixed && pOffset->datum.i >= pInter->datum.i) ||
|
||||
(!fixed && getMonthsFromTimeVal(pOffset->datum.i, precision, pOffset->unit) >= getMonthsFromTimeVal(pInter->datum.i, precision, pInter->unit))) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != pInterval->pSliding) {
|
||||
const static int32_t INTERVAL_SLIDING_FACTOR = 100;
|
||||
|
||||
SValueNode* pSliding = (SValueNode*)pInterval->pSliding;
|
||||
if (pInter->unit == 'n' || pInter->unit == 'y') {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_UNIT);
|
||||
}
|
||||
if ((pSliding->datum.i < convertTimePrecision(tsMinSlidingTime, TSDB_TIME_PRECISION_MILLI, precision)) ||
|
||||
(pInter->datum.i / pSliding->datum.i > INTERVAL_SLIDING_FACTOR)) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL);
|
||||
}
|
||||
if (pSliding->datum.i > pInter->datum.i) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG);
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t doTranslateWindow(STranslateContext* pCxt, SNode* pWindow) {
|
||||
static int32_t checkStateWindow(STranslateContext* pCxt, SStateWindowNode* pState) {
|
||||
// todo check for "function not support for state_window"
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t checkSessionWindow(STranslateContext* pCxt, SSessionWindowNode* pSession) {
|
||||
if ('y' == pSession->pGap->unit || 'n' == pSession->pGap->unit || 0 == pSession->pGap->datum.i) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SESSION_GAP);
|
||||
}
|
||||
if (PRIMARYKEY_TIMESTAMP_COL_ID != pSession->pCol->colId) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SESSION_COL);
|
||||
}
|
||||
// todo check for "function not support for session"
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t checkWindow(STranslateContext* pCxt, SNode* pWindow) {
|
||||
switch (nodeType(pWindow)) {
|
||||
case QUERY_NODE_STATE_WINDOW:
|
||||
return checkStateWindow(pCxt, (SStateWindowNode*)pWindow);
|
||||
case QUERY_NODE_SESSION_WINDOW:
|
||||
return checkSessionWindow(pCxt, (SSessionWindowNode*)pWindow);
|
||||
case QUERY_NODE_INTERVAL_WINDOW:
|
||||
return translateIntervalWindow(pCxt, (SIntervalWindowNode*)pWindow);
|
||||
return checkIntervalWindow(pCxt, (SIntervalWindowNode*)pWindow);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1118,7 +1230,7 @@ static int32_t translateWindow(STranslateContext* pCxt, SNode* pWindow) {
|
|||
pCxt->currClause = SQL_CLAUSE_WINDOW;
|
||||
int32_t code = translateExpr(pCxt, pWindow);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = doTranslateWindow(pCxt, pWindow);
|
||||
code = checkWindow(pCxt, pWindow);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
return "Endpoint should be in the format of 'fqdn:port'";
|
||||
case TSDB_CODE_PAR_EXPRIE_STATEMENT:
|
||||
return "This statement is no longer supported";
|
||||
case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL:
|
||||
return "This interval value is too small : %s";
|
||||
case TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL:
|
||||
return "Interval cannot be less than %d us";
|
||||
case TSDB_CODE_PAR_DB_NOT_SPECIFIED:
|
||||
return "Database not specified";
|
||||
case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME:
|
||||
|
@ -93,6 +93,28 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
return "Invalid option keep unit: %c, %c, %c, only m, h, d allowed";
|
||||
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
||||
return "Aggregate functions do not support nesting";
|
||||
case TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE:
|
||||
return "Only support STATE_WINDOW on integer column";
|
||||
case TSDB_CODE_PAR_INVALID_STATE_WIN_COL:
|
||||
return "Not support STATE_WINDOW on tag column";
|
||||
case TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE:
|
||||
return "STATE_WINDOW not support for super table query";
|
||||
case TSDB_CODE_PAR_INTER_SESSION_GAP:
|
||||
return "SESSION gap should be fixed time window, and greater than 0";
|
||||
case TSDB_CODE_PAR_INTER_SESSION_COL:
|
||||
return "Only support SESSION on primary timestamp column";
|
||||
case TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE:
|
||||
return "Interval offset cannot be negative";
|
||||
case TSDB_CODE_PAR_INTER_OFFSET_UNIT:
|
||||
return "Cannot use 'year' as offset when interval is 'month'";
|
||||
case TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG:
|
||||
return "Interval offset should be shorter than interval";
|
||||
case TSDB_CODE_PAR_INTER_SLIDING_UNIT:
|
||||
return "Does not support sliding when interval is natural month/year";
|
||||
case TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG:
|
||||
return "sliding value no larger than the interval value";
|
||||
case TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL:
|
||||
return "sliding value can not less than 1% of interval value";
|
||||
case TSDB_CODE_OUT_OF_MEMORY:
|
||||
return "Out of memory";
|
||||
default:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -166,12 +166,24 @@ static int32_t osdGetDataRequired(SNodeList* pFuncs) {
|
|||
return dataRequired;
|
||||
}
|
||||
|
||||
static void setScanWindowInfo(SScanLogicNode* pScan) {
|
||||
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pScan->node.pParent) &&
|
||||
WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pScan->node.pParent)->winType) {
|
||||
pScan->interval = ((SWindowLogicNode*)pScan->node.pParent)->interval;
|
||||
pScan->offset = ((SWindowLogicNode*)pScan->node.pParent)->offset;
|
||||
pScan->sliding = ((SWindowLogicNode*)pScan->node.pParent)->sliding;
|
||||
pScan->intervalUnit = ((SWindowLogicNode*)pScan->node.pParent)->intervalUnit;
|
||||
pScan->slidingUnit = ((SWindowLogicNode*)pScan->node.pParent)->slidingUnit;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||
SOsdInfo info = {0};
|
||||
int32_t code = osdMatch(pCxt, pLogicNode, &info);
|
||||
if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) {
|
||||
info.pScan->dataRequired = osdGetDataRequired(info.pSdrFuncs);
|
||||
info.pScan->pDynamicScanFuncs = info.pDsoFuncs;
|
||||
setScanWindowInfo((SScanLogicNode*)info.pScan);
|
||||
OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_OSD);
|
||||
pCxt->optimized = true;
|
||||
}
|
||||
|
|
|
@ -443,6 +443,11 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
|||
nodesDestroyNode(pTableScan);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pTableScan->interval = pScanLogicNode->interval;
|
||||
pTableScan->offset = pScanLogicNode->offset;
|
||||
pTableScan->sliding = pScanLogicNode->sliding;
|
||||
pTableScan->intervalUnit = pScanLogicNode->intervalUnit;
|
||||
pTableScan->slidingUnit = pScanLogicNode->slidingUnit;
|
||||
|
||||
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
||||
}
|
||||
|
@ -819,7 +824,6 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
|
|||
pInterval->sliding = pWindowLogicNode->sliding;
|
||||
pInterval->intervalUnit = pWindowLogicNode->intervalUnit;
|
||||
pInterval->slidingUnit = pWindowLogicNode->slidingUnit;
|
||||
pInterval->precision = ((SColumnNode*)pWindowLogicNode->pTspk)->node.resType.precision;
|
||||
|
||||
pInterval->pFill = nodesCloneNode(pWindowLogicNode->pFill);
|
||||
if (NULL != pWindowLogicNode->pFill && NULL == pInterval->pFill) {
|
||||
|
|
|
@ -666,18 +666,14 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
}
|
||||
|
||||
int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
if (inputNum!= 3) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
int16_t inputType = pInput[0].columnData->info.type;
|
||||
int16_t outputType = *(int16_t *)pInput[1].columnData->pData;
|
||||
int16_t outputType = pOutput[0].columnData->info.type;
|
||||
if (outputType != TSDB_DATA_TYPE_BIGINT && outputType != TSDB_DATA_TYPE_UBIGINT &&
|
||||
outputType != TSDB_DATA_TYPE_VARCHAR && outputType != TSDB_DATA_TYPE_NCHAR &&
|
||||
outputType != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
int64_t outputLen = *(int64_t *)pInput[2].columnData->pData;
|
||||
int64_t outputLen = pOutput[0].columnData->info.bytes;
|
||||
|
||||
char *input = NULL;
|
||||
char *outputBuf = taosMemoryCalloc(outputLen * pInput[0].numOfRows, 1);
|
||||
|
@ -1275,6 +1271,14 @@ int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t timezoneFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
if (inputNum != 1) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
colDataAppend(pOutput->columnData, pOutput->numOfRows, (char *)colDataGetData(pInput->columnData, 0), false);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
return doScalarFunctionUnique(pInput, inputNum, pOutput, atan);
|
||||
}
|
||||
|
|
|
@ -79,6 +79,8 @@ _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) {
|
|||
p = getVectorBigintValue_FLOAT;
|
||||
}else if(srcType==TSDB_DATA_TYPE_DOUBLE) {
|
||||
p = getVectorBigintValue_DOUBLE;
|
||||
}else if(srcType==TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
p = getVectorBigintValue_BIGINT;
|
||||
}else {
|
||||
assert(0);
|
||||
}
|
||||
|
@ -565,6 +567,25 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
|||
}
|
||||
}
|
||||
|
||||
static void vectorMathBigintAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) {
|
||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, 0);
|
||||
}
|
||||
pOutputCol->hasNull = pLeftCol->hasNull;
|
||||
if (pOutputCol->hasNull) {
|
||||
memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static SColumnInfoData* doVectorConvert(SScalarParam* pInput, int32_t* doConvert) {
|
||||
SScalarParam convertParam = {0};
|
||||
|
||||
|
@ -599,27 +620,53 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
|||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
||||
|
||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||
if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BIGINT) ||
|
||||
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { //timestamp plus duration
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||
}
|
||||
|
||||
pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull);
|
||||
if (pOutputCol->hasNull) {
|
||||
int32_t numOfBitLen = BitmapLen(pLeft->numOfRows);
|
||||
for (int32_t j = 0; j < numOfBitLen; ++j) {
|
||||
pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j];
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, i);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
vectorMathAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i);
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
vectorMathAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i);
|
||||
pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull);
|
||||
if (pOutputCol->hasNull) {
|
||||
int32_t numOfBitLen = BitmapLen(pLeft->numOfRows);
|
||||
for (int32_t j = 0; j < numOfBitLen; ++j) {
|
||||
pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j];
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
vectorMathBigintAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i);
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
vectorMathBigintAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i);
|
||||
}
|
||||
} else {
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||
}
|
||||
|
||||
pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull);
|
||||
if (pOutputCol->hasNull) {
|
||||
int32_t numOfBitLen = BitmapLen(pLeft->numOfRows);
|
||||
for (int32_t j = 0; j < numOfBitLen; ++j) {
|
||||
pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j];
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
vectorMathAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i);
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
vectorMathAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i);
|
||||
}
|
||||
}
|
||||
|
||||
doReleaseVec(pLeftCol, leftConvert);
|
||||
|
@ -646,6 +693,25 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
|||
}
|
||||
}
|
||||
|
||||
static void vectorMathBigintSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t factor, int32_t i) {
|
||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
*output = (getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, 0)) * factor;
|
||||
}
|
||||
pOutputCol->hasNull = pLeftCol->hasNull;
|
||||
if (pOutputCol->hasNull) {
|
||||
memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||
|
||||
|
@ -658,27 +724,53 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
|||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
||||
|
||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||
if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BIGINT) ||
|
||||
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { //timestamp minus duration
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||
}
|
||||
|
||||
pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull);
|
||||
if (pOutputCol->hasNull) {
|
||||
int32_t numOfBitLen = BitmapLen(pLeft->numOfRows);
|
||||
for (int32_t j = 0; j < numOfBitLen; ++j) {
|
||||
pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j];
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, i);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
vectorMathSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i);
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
vectorMathSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
||||
pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull);
|
||||
if (pOutputCol->hasNull) {
|
||||
int32_t numOfBitLen = BitmapLen(pLeft->numOfRows);
|
||||
for (int32_t j = 0; j < numOfBitLen; ++j) {
|
||||
pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j];
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
vectorMathBigintSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i);
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
vectorMathBigintSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
||||
}
|
||||
} else {
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||
}
|
||||
|
||||
pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull);
|
||||
if (pOutputCol->hasNull) {
|
||||
int32_t numOfBitLen = BitmapLen(pLeft->numOfRows);
|
||||
for (int32_t j = 0; j < numOfBitLen; ++j) {
|
||||
pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j];
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
vectorMathSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i);
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
vectorMathSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
doReleaseVec(pLeftCol, leftConvert);
|
||||
|
|
|
@ -45,8 +45,8 @@ sql explain select * from information_schema.user_stables;
|
|||
sql explain select count(*),sum(f1) from tb1;
|
||||
sql explain select count(*),sum(f1) from st1;
|
||||
sql explain select count(*),sum(f1) from st1 group by f1;
|
||||
sql explain select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
|
||||
sql explain select min(f1) from st1 interval(1m, 2a) sliding(3n);
|
||||
sql explain select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||
sql explain select min(f1) from st1 interval(1m, 2a) sliding(30s);
|
||||
|
||||
print ======== step3
|
||||
sql explain verbose true select * from st1 where -2;
|
||||
|
@ -65,8 +65,8 @@ sql explain analyze select * from information_schema.user_stables;
|
|||
sql explain analyze select count(*),sum(f1) from tb1;
|
||||
sql explain analyze select count(*),sum(f1) from st1;
|
||||
sql explain analyze select count(*),sum(f1) from st1 group by f1;
|
||||
sql explain analyze select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
|
||||
sql explain analyze select min(f1) from st1 interval(3n, 2a) sliding(1n);
|
||||
sql explain analyze select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||
sql explain analyze select min(f1) from st1 interval(3m, 2a) sliding(1m);
|
||||
|
||||
print ======== step5
|
||||
sql explain analyze verbose true select ts from st1 where -2;
|
||||
|
@ -78,20 +78,20 @@ sql explain analyze verbose true select * from information_schema.user_stables;
|
|||
sql explain analyze verbose true select count(*),sum(f1) from tb1;
|
||||
sql explain analyze verbose true select count(*),sum(f1) from st1;
|
||||
sql explain analyze verbose true select count(*),sum(f1) from st1 group by f1;
|
||||
sql explain analyze verbose true select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
|
||||
sql explain analyze verbose true select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||
sql explain analyze verbose true select ts from tb1 where f1 > 0;
|
||||
sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
|
||||
sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2';
|
||||
sql explain analyze verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
|
||||
sql explain analyze verbose true select min(f1) from st1 interval(3n, 2a) sliding(1n);
|
||||
sql explain analyze verbose true select min(f1) from st1 interval(3m, 2a) sliding(1m);
|
||||
sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0;
|
||||
|
||||
#not pass case
|
||||
#sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa;
|
||||
#sql explain verbose true select * from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
|
||||
#sql explain verbose true select count(*),sum(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
|
||||
#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1s, 2d) sliding(3s) order by ts;
|
||||
#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(3n) fill(linear) order by ts;
|
||||
#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(10s, 2s) sliding(3s) order by ts;
|
||||
#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(30s) fill(linear) order by ts;
|
||||
#sql explain select max(f1) from tb1 SESSION(ts, 1s);
|
||||
#sql explain select max(f1) from st1 SESSION(ts, 1s);
|
||||
#sql explain select * from tb1, tb2 where tb1.ts=tb2.ts;
|
||||
|
|
|
@ -200,43 +200,8 @@ if $data02 != 2678400000 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w)
|
||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @21-11-30 08:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != NULL then
|
||||
print expect null, actual: $data01
|
||||
return -1
|
||||
endi
|
||||
if $data31 != $data34 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w)
|
||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, 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 select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
|
||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
|
||||
|
@ -254,37 +219,8 @@ if $data04 != 2 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n)
|
||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 2 then
|
||||
return -1
|
||||
endi
|
||||
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)
|
||||
|
||||
#=================================================
|
||||
print =============== stop and restart taosd
|
||||
|
|
|
@ -290,32 +290,33 @@ print ================> syntax error check not active ================> reactive
|
|||
sql_error select * from dev_001 session(ts,1w)
|
||||
sql_error select count(*) from st session(ts,1w)
|
||||
sql_error select count(*) from dev_001 group by tagtype session(ts,1w)
|
||||
sql select count(*) from dev_001 session(ts,1n)
|
||||
sql select count(*) from dev_001 session(ts,1y)
|
||||
sql select count(*) from dev_001 session(ts,0s)
|
||||
sql_error sql select count(*) from dev_001 session(ts,1n)
|
||||
sql_error sql select count(*) from dev_001 session(ts,1y)
|
||||
sql_error sql select count(*) from dev_001 session(ts,0s)
|
||||
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'
|
||||
|
||||
print ====> create database d1 precision 'us'
|
||||
sql create database d1 precision 'us'
|
||||
sql use d1
|
||||
sql create table dev_001 (ts timestamp ,i timestamp ,j int)
|
||||
sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
|
||||
print ====> select count(*) from dev_001 session(ts,1u)
|
||||
sql select _wstartts, count(*) from dev_001 session(ts,1u)
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
print $data10 $data11 $data12 $data13
|
||||
print $data20 $data21 $data22 $data23
|
||||
print $data30 $data31 $data32 $data33
|
||||
if $rows != 4 then
|
||||
print expect 2, actual: $rows
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
# vnode does not return the precision of the table
|
||||
#print ====> create database d1 precision 'us'
|
||||
#sql create database d1 precision 'us'
|
||||
#sql use d1
|
||||
#sql create table dev_001 (ts timestamp ,i timestamp ,j int)
|
||||
#sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
|
||||
#print ====> select count(*) from dev_001 session(ts,1u)
|
||||
#sql select _wstartts, count(*) from dev_001 session(ts,1u)
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#print $data10 $data11 $data12 $data13
|
||||
#print $data20 $data21 $data22 $data23
|
||||
#print $data30 $data31 $data32 $data33
|
||||
#if $rows != 4 then
|
||||
# print expect 2, actual: $rows
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#if $data01 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
#sql_error select count(*) from dev_001 session(i,1s)
|
||||
sql create table secondts(ts timestamp,t2 timestamp,i int)
|
||||
|
|
Loading…
Reference in New Issue