feat: rollup options adjust
This commit is contained in:
parent
30db51ab21
commit
aea4f9c69b
|
@ -428,8 +428,10 @@ STSchema* tdGetSTSChemaFromSSChema(SSchema** pSchema, int32_t nCols);
|
|||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
int8_t igExists;
|
||||
float xFilesFactor;
|
||||
int32_t delay;
|
||||
int64_t delay1;
|
||||
int64_t delay2;
|
||||
int64_t watermark1;
|
||||
int64_t watermark2;
|
||||
int32_t ttl;
|
||||
int32_t numOfColumns;
|
||||
int32_t numOfTags;
|
||||
|
|
|
@ -127,134 +127,133 @@
|
|||
#define TK_BLOB 109
|
||||
#define TK_VARBINARY 110
|
||||
#define TK_DECIMAL 111
|
||||
#define TK_FILE_FACTOR 112
|
||||
#define TK_NK_FLOAT 113
|
||||
#define TK_MAX_DELAY 112
|
||||
#define TK_WATERMARK 113
|
||||
#define TK_ROLLUP 114
|
||||
#define TK_TTL 115
|
||||
#define TK_SMA 116
|
||||
#define TK_SHOW 117
|
||||
#define TK_DATABASES 118
|
||||
#define TK_TABLES 119
|
||||
#define TK_STABLES 120
|
||||
#define TK_MNODES 121
|
||||
#define TK_MODULES 122
|
||||
#define TK_QNODES 123
|
||||
#define TK_FUNCTIONS 124
|
||||
#define TK_INDEXES 125
|
||||
#define TK_ACCOUNTS 126
|
||||
#define TK_APPS 127
|
||||
#define TK_CONNECTIONS 128
|
||||
#define TK_LICENCE 129
|
||||
#define TK_GRANTS 130
|
||||
#define TK_QUERIES 131
|
||||
#define TK_SCORES 132
|
||||
#define TK_TOPICS 133
|
||||
#define TK_VARIABLES 134
|
||||
#define TK_BNODES 135
|
||||
#define TK_SNODES 136
|
||||
#define TK_CLUSTER 137
|
||||
#define TK_TRANSACTIONS 138
|
||||
#define TK_LIKE 139
|
||||
#define TK_INDEX 140
|
||||
#define TK_FULLTEXT 141
|
||||
#define TK_FUNCTION 142
|
||||
#define TK_INTERVAL 143
|
||||
#define TK_TOPIC 144
|
||||
#define TK_AS 145
|
||||
#define TK_CONSUMER 146
|
||||
#define TK_GROUP 147
|
||||
#define TK_DESC 148
|
||||
#define TK_DESCRIBE 149
|
||||
#define TK_RESET 150
|
||||
#define TK_QUERY 151
|
||||
#define TK_CACHE 152
|
||||
#define TK_EXPLAIN 153
|
||||
#define TK_ANALYZE 154
|
||||
#define TK_VERBOSE 155
|
||||
#define TK_NK_BOOL 156
|
||||
#define TK_RATIO 157
|
||||
#define TK_COMPACT 158
|
||||
#define TK_VNODES 159
|
||||
#define TK_IN 160
|
||||
#define TK_OUTPUTTYPE 161
|
||||
#define TK_AGGREGATE 162
|
||||
#define TK_BUFSIZE 163
|
||||
#define TK_STREAM 164
|
||||
#define TK_INTO 165
|
||||
#define TK_TRIGGER 166
|
||||
#define TK_AT_ONCE 167
|
||||
#define TK_WINDOW_CLOSE 168
|
||||
#define TK_MAX_DELAY 169
|
||||
#define TK_WATERMARK 170
|
||||
#define TK_KILL 171
|
||||
#define TK_CONNECTION 172
|
||||
#define TK_TRANSACTION 173
|
||||
#define TK_BALANCE 174
|
||||
#define TK_VGROUP 175
|
||||
#define TK_MERGE 176
|
||||
#define TK_REDISTRIBUTE 177
|
||||
#define TK_SPLIT 178
|
||||
#define TK_SYNCDB 179
|
||||
#define TK_DELETE 180
|
||||
#define TK_NULL 181
|
||||
#define TK_NK_QUESTION 182
|
||||
#define TK_NK_ARROW 183
|
||||
#define TK_ROWTS 184
|
||||
#define TK_TBNAME 185
|
||||
#define TK_QSTARTTS 186
|
||||
#define TK_QENDTS 187
|
||||
#define TK_WSTARTTS 188
|
||||
#define TK_WENDTS 189
|
||||
#define TK_WDURATION 190
|
||||
#define TK_CAST 191
|
||||
#define TK_NOW 192
|
||||
#define TK_TODAY 193
|
||||
#define TK_TIMEZONE 194
|
||||
#define TK_COUNT 195
|
||||
#define TK_FIRST 196
|
||||
#define TK_LAST 197
|
||||
#define TK_LAST_ROW 198
|
||||
#define TK_BETWEEN 199
|
||||
#define TK_IS 200
|
||||
#define TK_NK_LT 201
|
||||
#define TK_NK_GT 202
|
||||
#define TK_NK_LE 203
|
||||
#define TK_NK_GE 204
|
||||
#define TK_NK_NE 205
|
||||
#define TK_MATCH 206
|
||||
#define TK_NMATCH 207
|
||||
#define TK_CONTAINS 208
|
||||
#define TK_JOIN 209
|
||||
#define TK_INNER 210
|
||||
#define TK_SELECT 211
|
||||
#define TK_DISTINCT 212
|
||||
#define TK_WHERE 213
|
||||
#define TK_PARTITION 214
|
||||
#define TK_BY 215
|
||||
#define TK_SESSION 216
|
||||
#define TK_STATE_WINDOW 217
|
||||
#define TK_SLIDING 218
|
||||
#define TK_FILL 219
|
||||
#define TK_VALUE 220
|
||||
#define TK_NONE 221
|
||||
#define TK_PREV 222
|
||||
#define TK_LINEAR 223
|
||||
#define TK_NEXT 224
|
||||
#define TK_HAVING 225
|
||||
#define TK_ORDER 226
|
||||
#define TK_SLIMIT 227
|
||||
#define TK_SOFFSET 228
|
||||
#define TK_LIMIT 229
|
||||
#define TK_OFFSET 230
|
||||
#define TK_ASC 231
|
||||
#define TK_NULLS 232
|
||||
#define TK_ID 233
|
||||
#define TK_NK_BITNOT 234
|
||||
#define TK_INSERT 235
|
||||
#define TK_VALUES 236
|
||||
#define TK_IMPORT 237
|
||||
#define TK_NK_SEMI 238
|
||||
#define TK_FILE 239
|
||||
#define TK_FIRST 117
|
||||
#define TK_LAST 118
|
||||
#define TK_SHOW 119
|
||||
#define TK_DATABASES 120
|
||||
#define TK_TABLES 121
|
||||
#define TK_STABLES 122
|
||||
#define TK_MNODES 123
|
||||
#define TK_MODULES 124
|
||||
#define TK_QNODES 125
|
||||
#define TK_FUNCTIONS 126
|
||||
#define TK_INDEXES 127
|
||||
#define TK_ACCOUNTS 128
|
||||
#define TK_APPS 129
|
||||
#define TK_CONNECTIONS 130
|
||||
#define TK_LICENCE 131
|
||||
#define TK_GRANTS 132
|
||||
#define TK_QUERIES 133
|
||||
#define TK_SCORES 134
|
||||
#define TK_TOPICS 135
|
||||
#define TK_VARIABLES 136
|
||||
#define TK_BNODES 137
|
||||
#define TK_SNODES 138
|
||||
#define TK_CLUSTER 139
|
||||
#define TK_TRANSACTIONS 140
|
||||
#define TK_LIKE 141
|
||||
#define TK_INDEX 142
|
||||
#define TK_FULLTEXT 143
|
||||
#define TK_FUNCTION 144
|
||||
#define TK_INTERVAL 145
|
||||
#define TK_TOPIC 146
|
||||
#define TK_AS 147
|
||||
#define TK_CONSUMER 148
|
||||
#define TK_GROUP 149
|
||||
#define TK_DESC 150
|
||||
#define TK_DESCRIBE 151
|
||||
#define TK_RESET 152
|
||||
#define TK_QUERY 153
|
||||
#define TK_CACHE 154
|
||||
#define TK_EXPLAIN 155
|
||||
#define TK_ANALYZE 156
|
||||
#define TK_VERBOSE 157
|
||||
#define TK_NK_BOOL 158
|
||||
#define TK_RATIO 159
|
||||
#define TK_NK_FLOAT 160
|
||||
#define TK_COMPACT 161
|
||||
#define TK_VNODES 162
|
||||
#define TK_IN 163
|
||||
#define TK_OUTPUTTYPE 164
|
||||
#define TK_AGGREGATE 165
|
||||
#define TK_BUFSIZE 166
|
||||
#define TK_STREAM 167
|
||||
#define TK_INTO 168
|
||||
#define TK_TRIGGER 169
|
||||
#define TK_AT_ONCE 170
|
||||
#define TK_WINDOW_CLOSE 171
|
||||
#define TK_KILL 172
|
||||
#define TK_CONNECTION 173
|
||||
#define TK_TRANSACTION 174
|
||||
#define TK_BALANCE 175
|
||||
#define TK_VGROUP 176
|
||||
#define TK_MERGE 177
|
||||
#define TK_REDISTRIBUTE 178
|
||||
#define TK_SPLIT 179
|
||||
#define TK_SYNCDB 180
|
||||
#define TK_DELETE 181
|
||||
#define TK_NULL 182
|
||||
#define TK_NK_QUESTION 183
|
||||
#define TK_NK_ARROW 184
|
||||
#define TK_ROWTS 185
|
||||
#define TK_TBNAME 186
|
||||
#define TK_QSTARTTS 187
|
||||
#define TK_QENDTS 188
|
||||
#define TK_WSTARTTS 189
|
||||
#define TK_WENDTS 190
|
||||
#define TK_WDURATION 191
|
||||
#define TK_CAST 192
|
||||
#define TK_NOW 193
|
||||
#define TK_TODAY 194
|
||||
#define TK_TIMEZONE 195
|
||||
#define TK_COUNT 196
|
||||
#define TK_LAST_ROW 197
|
||||
#define TK_BETWEEN 198
|
||||
#define TK_IS 199
|
||||
#define TK_NK_LT 200
|
||||
#define TK_NK_GT 201
|
||||
#define TK_NK_LE 202
|
||||
#define TK_NK_GE 203
|
||||
#define TK_NK_NE 204
|
||||
#define TK_MATCH 205
|
||||
#define TK_NMATCH 206
|
||||
#define TK_CONTAINS 207
|
||||
#define TK_JOIN 208
|
||||
#define TK_INNER 209
|
||||
#define TK_SELECT 210
|
||||
#define TK_DISTINCT 211
|
||||
#define TK_WHERE 212
|
||||
#define TK_PARTITION 213
|
||||
#define TK_BY 214
|
||||
#define TK_SESSION 215
|
||||
#define TK_STATE_WINDOW 216
|
||||
#define TK_SLIDING 217
|
||||
#define TK_FILL 218
|
||||
#define TK_VALUE 219
|
||||
#define TK_NONE 220
|
||||
#define TK_PREV 221
|
||||
#define TK_LINEAR 222
|
||||
#define TK_NEXT 223
|
||||
#define TK_HAVING 224
|
||||
#define TK_ORDER 225
|
||||
#define TK_SLIMIT 226
|
||||
#define TK_SOFFSET 227
|
||||
#define TK_LIMIT 228
|
||||
#define TK_OFFSET 229
|
||||
#define TK_ASC 230
|
||||
#define TK_NULLS 231
|
||||
#define TK_ID 232
|
||||
#define TK_NK_BITNOT 233
|
||||
#define TK_INSERT 234
|
||||
#define TK_VALUES 235
|
||||
#define TK_IMPORT 236
|
||||
#define TK_NK_SEMI 237
|
||||
#define TK_FILE 238
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -88,8 +88,12 @@ typedef struct SAlterDatabaseStmt {
|
|||
typedef struct STableOptions {
|
||||
ENodeType type;
|
||||
char comment[TSDB_TB_COMMENT_LEN];
|
||||
SNode* pMaxDelay;
|
||||
SNode* pWatermark;
|
||||
SNodeList* pMaxDelay;
|
||||
int64_t maxDelay1;
|
||||
int64_t maxDelay2;
|
||||
SNodeList* pWatermark;
|
||||
int64_t watermark1;
|
||||
int64_t watermark2;
|
||||
SNodeList* pRollupFuncs;
|
||||
int32_t ttl;
|
||||
SNodeList* pSma;
|
||||
|
|
|
@ -661,6 +661,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2659)
|
||||
#define TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265A)
|
||||
#define TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265B)
|
||||
#define TSDB_CODE_PAR_INVALID_TABLE_OPTION TAOS_DEF_ERROR_CODE(0, 0x265C)
|
||||
|
||||
//planner
|
||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||
|
|
|
@ -266,7 +266,7 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq)
|
|||
if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &desc.pid) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, (int8_t*)&desc.stableQuery) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, (int8_t *)&desc.stableQuery) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1;
|
||||
|
||||
|
@ -474,8 +474,10 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
|
|||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1;
|
||||
if (tEncodeFloat(&encoder, pReq->xFilesFactor) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->delay) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->delay1) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->delay2) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->watermark1) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->watermark2) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->numOfColumns) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1;
|
||||
|
@ -522,8 +524,10 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
|
|||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1;
|
||||
if (tDecodeFloat(&decoder, &pReq->xFilesFactor) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->delay) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->delay1) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->delay2) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->watermark1) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->watermark2) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->numOfColumns) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1;
|
||||
|
|
|
@ -669,8 +669,8 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
|
|||
pDst->tagVer = 1;
|
||||
pDst->colVer = 1;
|
||||
pDst->nextColId = 1;
|
||||
pDst->xFilesFactor = pCreate->xFilesFactor;
|
||||
pDst->delay = pCreate->delay;
|
||||
// pDst->xFilesFactor = pCreate->xFilesFactor;
|
||||
// pDst->delay = pCreate->delay;
|
||||
pDst->ttl = pCreate->ttl;
|
||||
pDst->numOfColumns = pCreate->numOfColumns;
|
||||
pDst->numOfTags = pCreate->numOfTags;
|
||||
|
|
|
@ -317,8 +317,8 @@ tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP.
|
|||
|
||||
table_options(A) ::= . { A = createDefaultTableOptions(pCxt); }
|
||||
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
|
||||
table_options(A) ::= table_options(B) MAXDELAY duration_literal(C). { A = setTableOption(pCxt, B, TABLE_OPTION_MAXDELAY, C); }
|
||||
table_options(A) ::= table_options(B) WATERMARK duration_literal(C). { A = setTableOption(pCxt, B, TABLE_OPTION_WATERMARK, C); }
|
||||
table_options(A) ::= table_options(B) MAX_DELAY duration_list(C). { A = setTableOption(pCxt, B, TABLE_OPTION_MAXDELAY, C); }
|
||||
table_options(A) ::= table_options(B) WATERMARK duration_list(C). { A = setTableOption(pCxt, B, TABLE_OPTION_WATERMARK, C); }
|
||||
table_options(A) ::= table_options(B) ROLLUP NK_LP rollup_func_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_ROLLUP, C); }
|
||||
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
|
||||
table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableOption(pCxt, B, TABLE_OPTION_SMA, C); }
|
||||
|
@ -331,6 +331,11 @@ alter_table_options(A) ::= alter_table_options(B) alter_table_option(C).
|
|||
alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; }
|
||||
alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; }
|
||||
|
||||
%type duration_list { SNodeList* }
|
||||
%destructor duration_list { nodesDestroyList($$); }
|
||||
duration_list(A) ::= duration_literal(B). { A = createNodeList(pCxt, releaseRawExprNode(pCxt, B)); }
|
||||
duration_list(A) ::= duration_list(B) NK_COMMA duration_literal(C). { A = addNodeToList(pCxt, B, releaseRawExprNode(pCxt, C)); }
|
||||
|
||||
%type rollup_func_list { SNodeList* }
|
||||
%destructor rollup_func_list { nodesDestroyList($$); }
|
||||
rollup_func_list(A) ::= rollup_func_name(B). { A = createNodeList(pCxt, B); }
|
||||
|
|
|
@ -869,6 +869,10 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
|
|||
CHECK_PARSER_STATUS(pCxt);
|
||||
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->maxDelay1 = -1;
|
||||
pOptions->maxDelay2 = -1;
|
||||
pOptions->watermark1 = TSDB_DEFAULT_ROLLUP_WATERMARK;
|
||||
pOptions->watermark2 = TSDB_DEFAULT_ROLLUP_WATERMARK;
|
||||
pOptions->ttl = TSDB_DEFAULT_TABLE_TTL;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ static SKeyword keywordTable[] = {
|
|||
{"DURATION", TK_DURATION},
|
||||
{"EXISTS", TK_EXISTS},
|
||||
{"EXPLAIN", TK_EXPLAIN},
|
||||
{"FILE_FACTOR", TK_FILE_FACTOR},
|
||||
// {"FILE_FACTOR", TK_FILE_FACTOR},
|
||||
{"FILL", TK_FILL},
|
||||
{"FIRST", TK_FIRST},
|
||||
{"FLOAT", TK_FLOAT},
|
||||
|
|
|
@ -2623,7 +2623,7 @@ static int32_t checkDbDaysOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
|||
if (TIME_UNIT_MINUTE != pOptions->pDaysPerFile->unit && TIME_UNIT_HOUR != pOptions->pDaysPerFile->unit &&
|
||||
TIME_UNIT_DAY != pOptions->pDaysPerFile->unit) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_OPTION_UNIT, "daysPerFile",
|
||||
pOptions->pDaysPerFile->unit);
|
||||
pOptions->pDaysPerFile->unit, TIME_UNIT_MINUTE, TIME_UNIT_HOUR, TIME_UNIT_DAY);
|
||||
}
|
||||
pOptions->daysPerFile = getBigintFromValueNode(pOptions->pDaysPerFile);
|
||||
}
|
||||
|
@ -3074,25 +3074,74 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkTableMaxDelayOption(STranslateContext* pCxt, STableOptions* pOptions) {
|
||||
if (NULL != pOptions->pMaxDelay) {
|
||||
if (DEAL_RES_ERROR == translateValue(pCxt, pOptions->pMaxDelay)) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
if (TIME_UNIT_MINUTE != pOptions->pDaysPerFile->unit) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_OPTION_UNIT, "daysPerFile",
|
||||
pOptions->pDaysPerFile->unit);
|
||||
}
|
||||
pOptions->daysPerFile = getBigintFromValueNode(pOptions->pDaysPerFile);
|
||||
static int32_t getTableDelayOrWatermarkOption(STranslateContext* pCxt, const char* pName, int64_t minVal,
|
||||
int64_t maxVal, SValueNode* pVal, int64_t* pMaxDelay) {
|
||||
int32_t code = (DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS);
|
||||
if (TSDB_CODE_SUCCESS == code && TIME_UNIT_MILLISECOND != pVal->unit && TIME_UNIT_SECOND != pVal->unit &&
|
||||
TIME_UNIT_MINUTE != pVal->unit) {
|
||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_OPTION_UNIT, pName, pVal->unit,
|
||||
TIME_UNIT_MILLISECOND, TIME_UNIT_SECOND, TIME_UNIT_MINUTE);
|
||||
}
|
||||
return checkRangeOption(pCxt, "maxDelay", pOptions->pMaxDelay, TSDB_MIN_ROLLUP_MAX_DELAY, TSDB_MAX_ROLLUP_MAX_DELAY);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkRangeOption(pCxt, pName, pVal->datum.i, minVal, maxVal);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pMaxDelay = pVal->datum.i;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t getTableMaxDelayOption(STranslateContext* pCxt, SValueNode* pVal, int64_t* pMaxDelay) {
|
||||
return getTableDelayOrWatermarkOption(pCxt, "maxDelay", TSDB_MIN_ROLLUP_MAX_DELAY, TSDB_MAX_ROLLUP_MAX_DELAY, pVal,
|
||||
pMaxDelay);
|
||||
}
|
||||
|
||||
static int32_t checkTableMaxDelayOption(STranslateContext* pCxt, STableOptions* pOptions) {
|
||||
if (NULL == pOptions->pMaxDelay) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (LIST_LENGTH(pOptions->pMaxDelay) > 2) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "maxdelay");
|
||||
}
|
||||
|
||||
int32_t code =
|
||||
getTableMaxDelayOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pMaxDelay, 0), &pOptions->maxDelay1);
|
||||
if (TSDB_CODE_SUCCESS == code && 2 == LIST_LENGTH(pOptions->pMaxDelay)) {
|
||||
code = getTableMaxDelayOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pMaxDelay, 1), &pOptions->maxDelay2);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t getTableWatermarkOption(STranslateContext* pCxt, SValueNode* pVal, int64_t* pMaxDelay) {
|
||||
return getTableDelayOrWatermarkOption(pCxt, "watermark", TSDB_MIN_ROLLUP_WATERMARK, TSDB_MAX_ROLLUP_WATERMARK, pVal,
|
||||
pMaxDelay);
|
||||
}
|
||||
|
||||
static int32_t checkTableWatermarkOption(STranslateContext* pCxt, STableOptions* pOptions) {
|
||||
if (NULL == pOptions->pWatermark) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (LIST_LENGTH(pOptions->pWatermark) > 2) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TABLE_OPTION, "watermark");
|
||||
}
|
||||
|
||||
int32_t code =
|
||||
getTableWatermarkOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pWatermark, 0), &pOptions->watermark1);
|
||||
if (TSDB_CODE_SUCCESS == code && 2 == LIST_LENGTH(pOptions->pWatermark)) {
|
||||
code = getTableWatermarkOption(pCxt, (SValueNode*)nodesListGetNode(pOptions->pWatermark, 1), &pOptions->watermark2);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
||||
int32_t code = checkTableMaxDelayOption(pCxt, pStmt->pOptions->pMaxDelay);
|
||||
// if (TSDB_CODE_SUCCESS == code) {
|
||||
// code = checkRangeOption(pCxt, "delay", pStmt->pOptions->delay, TSDB_MIN_ROLLUP_DELAY, TSDB_MAX_ROLLUP_DELAY);
|
||||
// }
|
||||
int32_t code = checkTableMaxDelayOption(pCxt, pStmt->pOptions);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkTableWatermarkOption(pCxt, pStmt->pOptions);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs);
|
||||
}
|
||||
|
@ -3335,8 +3384,10 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
|
|||
|
||||
static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStmt, SMCreateStbReq* pReq) {
|
||||
pReq->igExists = pStmt->ignoreExists;
|
||||
// pReq->delay = pStmt->pOptions->delay;
|
||||
// pReq->xFilesFactor = pStmt->pOptions->filesFactor;
|
||||
pReq->delay1 = pStmt->pOptions->maxDelay1;
|
||||
pReq->delay2 = pStmt->pOptions->maxDelay2;
|
||||
pReq->watermark1 = pStmt->pOptions->watermark1;
|
||||
pReq->watermark2 = pStmt->pOptions->watermark2;
|
||||
pReq->ttl = pStmt->pOptions->ttl;
|
||||
columnDefNodeToField(pStmt->pCols, &pReq->pColumns);
|
||||
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
|
||||
|
|
|
@ -90,7 +90,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
case TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST:
|
||||
return "GROUP BY and WINDOW-clause can't be used together";
|
||||
case TSDB_CODE_PAR_INVALID_OPTION_UNIT:
|
||||
return "Invalid option %s unit: %c, only m, h, d allowed";
|
||||
return "Invalid option %s unit: %c, only %c, %c, %c allowed";
|
||||
case TSDB_CODE_PAR_INVALID_KEEP_UNIT:
|
||||
return "Invalid option keep unit: %c, only m, h, d allowed";
|
||||
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
||||
|
@ -194,6 +194,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
return "%s function does not supportted in stream query";
|
||||
case TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC:
|
||||
return "%s function does not supportted in group query";
|
||||
case TSDB_CODE_PAR_INVALID_TABLE_OPTION:
|
||||
return "Invalid option %s";
|
||||
case TSDB_CODE_OUT_OF_MEMORY:
|
||||
return "Out of memory";
|
||||
default:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -322,13 +322,17 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
memset(&expect, 0, sizeof(SMCreateStbReq));
|
||||
};
|
||||
|
||||
auto setCreateStbReqFunc = [&](const char* pTbname, int8_t igExists = 0,
|
||||
float xFilesFactor = TSDB_DEFAULT_ROLLUP_FILE_FACTOR,
|
||||
auto setCreateStbReqFunc = [&](const char* pTbname, int8_t igExists = 0, int64_t delay1 = -1, int64_t delay2 = -1,
|
||||
int64_t watermark1 = TSDB_DEFAULT_ROLLUP_WATERMARK,
|
||||
int64_t watermark2 = TSDB_DEFAULT_ROLLUP_WATERMARK,
|
||||
int32_t ttl = TSDB_DEFAULT_TABLE_TTL, const char* pComment = nullptr) {
|
||||
int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname);
|
||||
expect.name[len] = '\0';
|
||||
expect.igExists = igExists;
|
||||
expect.xFilesFactor = xFilesFactor;
|
||||
expect.delay1 = delay1;
|
||||
expect.delay2 = delay2;
|
||||
expect.watermark1 = watermark1;
|
||||
expect.watermark2 = watermark2;
|
||||
expect.ttl = ttl;
|
||||
if (nullptr != pComment) {
|
||||
expect.comment = strdup(pComment);
|
||||
|
@ -366,8 +370,10 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
|
||||
ASSERT_EQ(std::string(req.name), std::string(expect.name));
|
||||
ASSERT_EQ(req.igExists, expect.igExists);
|
||||
ASSERT_EQ(req.xFilesFactor, expect.xFilesFactor);
|
||||
ASSERT_EQ(req.delay, expect.delay);
|
||||
ASSERT_EQ(req.delay1, expect.delay1);
|
||||
ASSERT_EQ(req.delay2, expect.delay2);
|
||||
ASSERT_EQ(req.watermark1, expect.watermark1);
|
||||
ASSERT_EQ(req.watermark2, expect.watermark2);
|
||||
ASSERT_EQ(req.ttl, expect.ttl);
|
||||
ASSERT_EQ(req.numOfColumns, expect.numOfColumns);
|
||||
ASSERT_EQ(req.numOfTags, expect.numOfTags);
|
||||
|
@ -418,7 +424,8 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
run("CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)");
|
||||
clearCreateStbReq();
|
||||
|
||||
setCreateStbReqFunc("t1", 1, 0.1, 100, "test create table");
|
||||
setCreateStbReqFunc("t1", 1, 100 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_MINUTE, 10,
|
||||
1 * MILLISECOND_PER_MINUTE, 100, "test create table");
|
||||
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
|
||||
addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT);
|
||||
addFieldToCreateStbReqFunc(true, "c2", TSDB_DATA_TYPE_UINT);
|
||||
|
@ -456,15 +463,20 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, "
|
||||
"a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, "
|
||||
"a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) "
|
||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1");
|
||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) MAX_DELAY 100s,10m WATERMARK 10a,1m");
|
||||
clearCreateStbReq();
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createStableSemanticCheck) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(CEIL) FILE_FACTOR 0.1",
|
||||
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION, PARSER_STAGE_TRANSLATE);
|
||||
run("CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(CEIL)", TSDB_CODE_PAR_INVALID_ROLLUP_OPTION);
|
||||
|
||||
run("CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 0s WATERMARK 1m",
|
||||
TSDB_CODE_PAR_INVALID_RANGE_OPTION);
|
||||
|
||||
run("CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 10s WATERMARK 18m",
|
||||
TSDB_CODE_PAR_INVALID_RANGE_OPTION);
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createStream) {
|
||||
|
@ -477,7 +489,7 @@ TEST_F(ParserInitialCTest, createStream) {
|
|||
memset(&expect, 0, sizeof(SCMCreateStreamReq));
|
||||
};
|
||||
|
||||
auto setCreateStbReqFunc =
|
||||
auto setCreateStreamReqFunc =
|
||||
[&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb = nullptr, int8_t igExists = 0,
|
||||
int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0) {
|
||||
snprintf(expect.name, sizeof(expect.name), "0.%s", pStream);
|
||||
|
@ -509,21 +521,21 @@ TEST_F(ParserInitialCTest, createStream) {
|
|||
tFreeSCMCreateStreamReq(&req);
|
||||
});
|
||||
|
||||
setCreateStbReqFunc("s1", "test", "create stream s1 as select * from t1");
|
||||
setCreateStreamReqFunc("s1", "test", "create stream s1 as select * from t1");
|
||||
run("CREATE STREAM s1 AS SELECT * FROM t1");
|
||||
clearCreateStreamReq();
|
||||
|
||||
setCreateStbReqFunc("s1", "test", "create stream if not exists s1 as select * from t1", nullptr, 1);
|
||||
setCreateStreamReqFunc("s1", "test", "create stream if not exists s1 as select * from t1", nullptr, 1);
|
||||
run("CREATE STREAM IF NOT EXISTS s1 AS SELECT * FROM t1");
|
||||
clearCreateStreamReq();
|
||||
|
||||
setCreateStbReqFunc("s1", "test", "create stream s1 into st1 as select * from t1", "st1");
|
||||
setCreateStreamReqFunc("s1", "test", "create stream s1 into st1 as select * from t1", "st1");
|
||||
run("CREATE STREAM s1 INTO st1 AS SELECT * FROM t1");
|
||||
clearCreateStreamReq();
|
||||
|
||||
setCreateStbReqFunc("s1", "test",
|
||||
"create stream if not exists s1 trigger max_delay 20s watermark 10s into st1 as select * from t1",
|
||||
"st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND);
|
||||
setCreateStreamReqFunc(
|
||||
"s1", "test", "create stream if not exists s1 trigger max_delay 20s watermark 10s into st1 as select * from t1",
|
||||
"st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND);
|
||||
run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s INTO st1 AS SELECT * FROM t1");
|
||||
clearCreateStreamReq();
|
||||
}
|
||||
|
@ -552,7 +564,7 @@ TEST_F(ParserInitialCTest, createTable) {
|
|||
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, a8 BINARY(20), "
|
||||
"a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, a12 TINYINT UNSIGNED, a13 BOOL, "
|
||||
"a14 NCHAR(30), a15 VARCHAR(50)) "
|
||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1");
|
||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN)");
|
||||
|
||||
run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW)");
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ sql create database d0 keep 365000d,365000d,365000d
|
|||
sql use d0
|
||||
|
||||
print =============== create super table and register rsma
|
||||
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min) file_factor 0.1;
|
||||
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min);
|
||||
|
||||
sql show stables
|
||||
if $rows != 1 then
|
||||
|
|
|
@ -9,7 +9,7 @@ sql create database d0 retentions 15s:7d,1m:21d,15m:365d;
|
|||
sql use d0
|
||||
|
||||
print =============== create super table and register rsma
|
||||
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min) file_factor 0.1;
|
||||
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min);
|
||||
|
||||
sql show stables
|
||||
if $rows != 1 then
|
||||
|
|
Loading…
Reference in New Issue