TD-13675 create sma index grammar
This commit is contained in:
parent
7aeb0a2a07
commit
eae2d7b661
|
@ -1914,11 +1914,12 @@ typedef struct {
|
|||
int8_t slidingUnit;
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char timezone[TD_TIMEZONE_LEN]; // sma data is invalid if timezone change.
|
||||
uint16_t exprLen;
|
||||
uint16_t tagsFilterLen;
|
||||
int32_t exprLen;
|
||||
int32_t tagsFilterLen;
|
||||
int64_t indexUid;
|
||||
tb_uid_t tableUid; // super/child/common table uid
|
||||
int64_t interval;
|
||||
int64_t offset;
|
||||
int64_t sliding;
|
||||
char* expr; // sma expression
|
||||
char* tagsFilter;
|
||||
|
@ -2020,11 +2021,12 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
|
|||
tlen += taosEncodeFixedI8(buf, pSma->slidingUnit);
|
||||
tlen += taosEncodeString(buf, pSma->indexName);
|
||||
tlen += taosEncodeString(buf, pSma->timezone);
|
||||
tlen += taosEncodeFixedU16(buf, pSma->exprLen);
|
||||
tlen += taosEncodeFixedU16(buf, pSma->tagsFilterLen);
|
||||
tlen += taosEncodeFixedI32(buf, pSma->exprLen);
|
||||
tlen += taosEncodeFixedI32(buf, pSma->tagsFilterLen);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->indexUid);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->tableUid);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->interval);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->offset);
|
||||
tlen += taosEncodeFixedI64(buf, pSma->sliding);
|
||||
|
||||
if (pSma->exprLen > 0) {
|
||||
|
@ -2054,14 +2056,14 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
|
|||
buf = taosDecodeFixedI8(buf, &pSma->slidingUnit);
|
||||
buf = taosDecodeStringTo(buf, pSma->indexName);
|
||||
buf = taosDecodeStringTo(buf, pSma->timezone);
|
||||
buf = taosDecodeFixedU16(buf, &pSma->exprLen);
|
||||
buf = taosDecodeFixedU16(buf, &pSma->tagsFilterLen);
|
||||
buf = taosDecodeFixedI32(buf, &pSma->exprLen);
|
||||
buf = taosDecodeFixedI32(buf, &pSma->tagsFilterLen);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->indexUid);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->tableUid);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->interval);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->offset);
|
||||
buf = taosDecodeFixedI64(buf, &pSma->sliding);
|
||||
|
||||
|
||||
if (pSma->exprLen > 0) {
|
||||
pSma->expr = (char*)calloc(pSma->exprLen, 1);
|
||||
if (pSma->expr != NULL) {
|
||||
|
|
|
@ -25,6 +25,17 @@ extern "C" {
|
|||
|
||||
#define TIME_IS_VAR_DURATION(_t) ((_t) == 'n' || (_t) == 'y' || (_t) == 'N' || (_t) == 'Y')
|
||||
|
||||
#define TIME_UNIT_NANOSECOND 'b'
|
||||
#define TIME_UNIT_MICROSECOND 'u'
|
||||
#define TIME_UNIT_MILLISECOND 'a'
|
||||
#define TIME_UNIT_SECOND 's'
|
||||
#define TIME_UNIT_MINUTE 'm'
|
||||
#define TIME_UNIT_HOUR 'h'
|
||||
#define TIME_UNIT_DAY 'd'
|
||||
#define TIME_UNIT_WEEK 'w'
|
||||
#define TIME_UNIT_MONTH 'n'
|
||||
#define TIME_UNIT_YEAR 'y'
|
||||
|
||||
/*
|
||||
* @return timestamp decided by global conf variable, tsTimePrecision
|
||||
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
|
||||
|
|
|
@ -101,55 +101,58 @@
|
|||
#define TK_VARBINARY 83
|
||||
#define TK_DECIMAL 84
|
||||
#define TK_SMA 85
|
||||
#define TK_MNODES 86
|
||||
#define TK_NK_FLOAT 87
|
||||
#define TK_NK_BOOL 88
|
||||
#define TK_NK_VARIABLE 89
|
||||
#define TK_BETWEEN 90
|
||||
#define TK_IS 91
|
||||
#define TK_NULL 92
|
||||
#define TK_NK_LT 93
|
||||
#define TK_NK_GT 94
|
||||
#define TK_NK_LE 95
|
||||
#define TK_NK_GE 96
|
||||
#define TK_NK_NE 97
|
||||
#define TK_NK_EQ 98
|
||||
#define TK_LIKE 99
|
||||
#define TK_MATCH 100
|
||||
#define TK_NMATCH 101
|
||||
#define TK_IN 102
|
||||
#define TK_FROM 103
|
||||
#define TK_AS 104
|
||||
#define TK_JOIN 105
|
||||
#define TK_ON 106
|
||||
#define TK_INNER 107
|
||||
#define TK_SELECT 108
|
||||
#define TK_DISTINCT 109
|
||||
#define TK_WHERE 110
|
||||
#define TK_PARTITION 111
|
||||
#define TK_BY 112
|
||||
#define TK_SESSION 113
|
||||
#define TK_STATE_WINDOW 114
|
||||
#define TK_INTERVAL 115
|
||||
#define TK_SLIDING 116
|
||||
#define TK_FILL 117
|
||||
#define TK_VALUE 118
|
||||
#define TK_NONE 119
|
||||
#define TK_PREV 120
|
||||
#define TK_LINEAR 121
|
||||
#define TK_NEXT 122
|
||||
#define TK_GROUP 123
|
||||
#define TK_HAVING 124
|
||||
#define TK_ORDER 125
|
||||
#define TK_SLIMIT 126
|
||||
#define TK_SOFFSET 127
|
||||
#define TK_LIMIT 128
|
||||
#define TK_OFFSET 129
|
||||
#define TK_ASC 130
|
||||
#define TK_DESC 131
|
||||
#define TK_NULLS 132
|
||||
#define TK_FIRST 133
|
||||
#define TK_LAST 134
|
||||
#define TK_INDEX 86
|
||||
#define TK_ON 87
|
||||
#define TK_FULLTEXT 88
|
||||
#define TK_FUNCTION 89
|
||||
#define TK_INTERVAL 90
|
||||
#define TK_MNODES 91
|
||||
#define TK_NK_FLOAT 92
|
||||
#define TK_NK_BOOL 93
|
||||
#define TK_NK_VARIABLE 94
|
||||
#define TK_BETWEEN 95
|
||||
#define TK_IS 96
|
||||
#define TK_NULL 97
|
||||
#define TK_NK_LT 98
|
||||
#define TK_NK_GT 99
|
||||
#define TK_NK_LE 100
|
||||
#define TK_NK_GE 101
|
||||
#define TK_NK_NE 102
|
||||
#define TK_NK_EQ 103
|
||||
#define TK_LIKE 104
|
||||
#define TK_MATCH 105
|
||||
#define TK_NMATCH 106
|
||||
#define TK_IN 107
|
||||
#define TK_FROM 108
|
||||
#define TK_AS 109
|
||||
#define TK_JOIN 110
|
||||
#define TK_INNER 111
|
||||
#define TK_SELECT 112
|
||||
#define TK_DISTINCT 113
|
||||
#define TK_WHERE 114
|
||||
#define TK_PARTITION 115
|
||||
#define TK_BY 116
|
||||
#define TK_SESSION 117
|
||||
#define TK_STATE_WINDOW 118
|
||||
#define TK_SLIDING 119
|
||||
#define TK_FILL 120
|
||||
#define TK_VALUE 121
|
||||
#define TK_NONE 122
|
||||
#define TK_PREV 123
|
||||
#define TK_LINEAR 124
|
||||
#define TK_NEXT 125
|
||||
#define TK_GROUP 126
|
||||
#define TK_HAVING 127
|
||||
#define TK_ORDER 128
|
||||
#define TK_SLIMIT 129
|
||||
#define TK_SOFFSET 130
|
||||
#define TK_LIMIT 131
|
||||
#define TK_OFFSET 132
|
||||
#define TK_ASC 133
|
||||
#define TK_DESC 134
|
||||
#define TK_NULLS 135
|
||||
#define TK_FIRST 136
|
||||
#define TK_LAST 137
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
|||
#include "querynodes.h"
|
||||
|
||||
typedef struct SDatabaseOptions {
|
||||
ENodeType type;
|
||||
int32_t numOfBlocks;
|
||||
int32_t cacheBlockSize;
|
||||
int8_t cachelast;
|
||||
|
@ -46,7 +47,7 @@ typedef struct SCreateDatabaseStmt {
|
|||
ENodeType type;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
bool ignoreExists;
|
||||
SDatabaseOptions options;
|
||||
SDatabaseOptions* pOptions;
|
||||
} SCreateDatabaseStmt;
|
||||
|
||||
typedef struct SUseDatabaseStmt {
|
||||
|
@ -61,6 +62,7 @@ typedef struct SDropDatabaseStmt {
|
|||
} SDropDatabaseStmt;
|
||||
|
||||
typedef struct STableOptions {
|
||||
ENodeType type;
|
||||
int32_t keep;
|
||||
int32_t ttl;
|
||||
char comments[TSDB_STB_COMMENT_LEN];
|
||||
|
@ -81,7 +83,7 @@ typedef struct SCreateTableStmt {
|
|||
bool ignoreExists;
|
||||
SNodeList* pCols;
|
||||
SNodeList* pTags;
|
||||
STableOptions options;
|
||||
STableOptions* pOptions;
|
||||
} SCreateTableStmt;
|
||||
|
||||
typedef struct SCreateSubTableClause {
|
||||
|
@ -155,6 +157,28 @@ typedef struct SShowStmt {
|
|||
char dbName[TSDB_DB_NAME_LEN];
|
||||
} SShowStmt;
|
||||
|
||||
typedef enum EIndexType {
|
||||
INDEX_TYPE_SMA = 1,
|
||||
INDEX_TYPE_FULLTEXT
|
||||
} EIndexType;
|
||||
|
||||
typedef struct SIndexOptions {
|
||||
ENodeType type;
|
||||
SNodeList* pFuncs;
|
||||
SNode* pInterval;
|
||||
SNode* pOffset;
|
||||
SNode* pSliding;
|
||||
} SIndexOptions;
|
||||
|
||||
typedef struct SCreateIndexStmt {
|
||||
ENodeType type;
|
||||
EIndexType indexType;
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
SNodeList* pCols;
|
||||
SIndexOptions* pOptions;
|
||||
} SCreateIndexStmt;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -67,6 +67,9 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SLOT_DESC,
|
||||
QUERY_NODE_COLUMN_DEF,
|
||||
QUERY_NODE_DOWNSTREAM_SOURCE,
|
||||
QUERY_NODE_DATABASE_OPTIONS,
|
||||
QUERY_NODE_TABLE_OPTIONS,
|
||||
QUERY_NODE_INDEX_OPTIONS,
|
||||
|
||||
// Statement nodes are used in parser and planner module.
|
||||
QUERY_NODE_SET_OPERATOR,
|
||||
|
@ -93,6 +96,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_SHOW_DNODES_STMT,
|
||||
QUERY_NODE_SHOW_VGROUPS_STMT,
|
||||
QUERY_NODE_SHOW_MNODES_STMT,
|
||||
QUERY_NODE_CREATE_INDEX_STMT,
|
||||
|
||||
// logic plan node
|
||||
QUERY_NODE_LOGIC_PLAN_SCAN,
|
||||
|
@ -185,6 +189,9 @@ const char* nodesNodeName(ENodeType type);
|
|||
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
|
||||
|
||||
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesStringToList(const char* pStr, SNodeList** pList);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -82,6 +82,7 @@ typedef struct SValueNode {
|
|||
double d;
|
||||
char* p;
|
||||
} datum;
|
||||
char unit;
|
||||
} SValueNode;
|
||||
|
||||
typedef struct SOperatorNode {
|
||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
|||
typedef void SJson;
|
||||
|
||||
SJson* tjsonCreateObject();
|
||||
SJson* tjsonCreateArray();
|
||||
void tjsonDelete(SJson* pJson);
|
||||
|
||||
SJson* tjsonAddArrayToObject(SJson* pJson, const char* pName);
|
||||
|
|
|
@ -151,8 +151,7 @@ static int32_t nodeListToJson(SJson* pJson, const char* pName, const SNodeList*
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** pList) {
|
||||
const SJson* pJsonArray = tjsonGetObjectItem(pJson, pName);
|
||||
static int32_t jsonToNodeListImpl(const SJson* pJsonArray, SNodeList** pList) {
|
||||
int32_t size = (NULL == pJsonArray ? 0 : tjsonGetArraySize(pJsonArray));
|
||||
if (size > 0) {
|
||||
*pList = nodesMakeList();
|
||||
|
@ -176,6 +175,10 @@ static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList**
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** pList) {
|
||||
return jsonToNodeListImpl(tjsonGetObjectItem(pJson, pName), pList);
|
||||
}
|
||||
|
||||
static const char* jkTableMetaUid = "TableMetaUid";
|
||||
static const char* jkTableMetaSuid = "TableMetaSuid";
|
||||
|
||||
|
@ -1750,3 +1753,52 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode) {
|
|||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen) {
|
||||
if (NULL == pList || NULL == pStr || NULL == pLen) {
|
||||
terrno = TSDB_CODE_FAILED;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
if (0 == LIST_LENGTH(pList)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SJson* pJson = tjsonCreateArray();
|
||||
if (NULL == pJson) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pList) {
|
||||
int32_t code = tjsonAddItem(pJson, nodeToJson, pNode);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
*pStr = format ? tjsonToString(pJson) : tjsonToUnformattedString(pJson);
|
||||
tjsonDelete(pJson);
|
||||
|
||||
*pLen = strlen(*pStr) + 1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t nodesStringToList(const char* pStr, SNodeList** pList) {
|
||||
if (NULL == pStr || NULL == pList) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SJson* pJson = tjsonParse(pStr);
|
||||
if (NULL == pJson) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
int32_t code = jsonToNodeListImpl(pJson, pList);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(*pList);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,12 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SColumnDefNode));
|
||||
case QUERY_NODE_DOWNSTREAM_SOURCE:
|
||||
return makeNode(type, sizeof(SDownstreamSourceNode));
|
||||
case QUERY_NODE_DATABASE_OPTIONS:
|
||||
return makeNode(type, sizeof(SDatabaseOptions));
|
||||
case QUERY_NODE_TABLE_OPTIONS:
|
||||
return makeNode(type, sizeof(STableOptions));
|
||||
case QUERY_NODE_INDEX_OPTIONS:
|
||||
return makeNode(type, sizeof(SIndexOptions));
|
||||
case QUERY_NODE_SET_OPERATOR:
|
||||
return makeNode(type, sizeof(SSetOperator));
|
||||
case QUERY_NODE_SELECT_STMT:
|
||||
|
@ -122,6 +128,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||
return makeNode(type, sizeof(SCreateIndexStmt));
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return makeNode(type, sizeof(SScanLogicNode));
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
|
|
|
@ -109,17 +109,17 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit);
|
|||
SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable);
|
||||
SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight);
|
||||
|
||||
SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt);
|
||||
SDatabaseOptions* setDatabaseOption(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, EDatabaseOptionType type, const SToken* pVal);
|
||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SDatabaseOptions* pOptions);
|
||||
SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt);
|
||||
SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal);
|
||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions);
|
||||
SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pDbName);
|
||||
STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt);
|
||||
STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal);
|
||||
STableOptions* setTableSmaOption(SAstCreateContext* pCxt, STableOptions* pOptions, SNodeList* pSma);
|
||||
SNode* createDefaultTableOptions(SAstCreateContext* pCxt);
|
||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal);
|
||||
SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma);
|
||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment);
|
||||
SDataType createDataType(uint8_t type);
|
||||
SDataType createVarLenDataType(uint8_t type, const SToken* pLen);
|
||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, STableOptions* pOptions);
|
||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions);
|
||||
SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags);
|
||||
SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables);
|
||||
SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
||||
|
@ -132,6 +132,8 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, int
|
|||
SNode* createDropUserStmt(SAstCreateContext* pCxt, const SToken* pUserName);
|
||||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
||||
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -80,8 +80,6 @@ not_exists_opt(A) ::= .
|
|||
exists_opt(A) ::= IF EXISTS. { A = true; }
|
||||
exists_opt(A) ::= . { A = false; }
|
||||
|
||||
%type db_options { SDatabaseOptions* }
|
||||
%destructor db_options { tfree($$); }
|
||||
db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); }
|
||||
db_options(A) ::= db_options(B) BLOCKS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BLOCKS, &C); }
|
||||
db_options(A) ::= db_options(B) CACHE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHE, &C); }
|
||||
|
@ -179,8 +177,6 @@ tags_def_opt(A) ::= tags_def(B).
|
|||
%destructor tags_def { nodesDestroyList($$); }
|
||||
tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; }
|
||||
|
||||
%type table_options { STableOptions* }
|
||||
%destructor table_options { tfree($$); }
|
||||
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) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); }
|
||||
|
@ -194,6 +190,24 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C).
|
|||
|
||||
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
|
||||
|
||||
/************************************************ create index ********************************************************/
|
||||
cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); }
|
||||
cmd ::= CREATE FULLTEXT INDEX
|
||||
index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); }
|
||||
|
||||
index_options(A) ::= . { A = NULL; }
|
||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||
NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, C, NULL, D); }
|
||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, C, D, E); }
|
||||
|
||||
%type func_list { SNodeList* }
|
||||
%destructor func_list { nodesDestroyList($$); }
|
||||
func_list(A) ::= func(B). { A = createNodeList(pCxt, B); }
|
||||
func_list(A) ::= func_list(B) NK_COMMA func(C). { A = addNodeToList(pCxt, B, C); }
|
||||
|
||||
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
|
||||
|
||||
/************************************************ show vgroups ********************************************************/
|
||||
cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); }
|
||||
cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); }
|
||||
|
@ -248,6 +262,10 @@ column_alias(A) ::= NK_ID(B).
|
|||
%destructor user_name { }
|
||||
user_name(A) ::= NK_ID(B). { A = B; }
|
||||
|
||||
%type index_name { SToken }
|
||||
%destructor index_name { }
|
||||
index_name(A) ::= NK_ID(B). { A = B; }
|
||||
|
||||
/************************************************ expression **********************************************************/
|
||||
expression(A) ::= literal(B). { A = B; }
|
||||
//expression(A) ::= NK_QUESTION(B). { A = B; }
|
||||
|
@ -463,13 +481,13 @@ twindow_clause_opt(A) ::=
|
|||
SESSION NK_LP column_reference(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C); }
|
||||
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
|
||||
twindow_clause_opt(A) ::=
|
||||
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, B, NULL, C, D); }
|
||||
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); }
|
||||
twindow_clause_opt(A) ::=
|
||||
INTERVAL NK_LP duration_literal(B) NK_COMMA duration_literal(C) NK_RP
|
||||
sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, B, C, D, E); }
|
||||
sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), D, E); }
|
||||
|
||||
sliding_opt(A) ::= . { A = NULL; }
|
||||
sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = B; }
|
||||
sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = releaseRawExprNode(pCxt, B); }
|
||||
|
||||
fill_opt(A) ::= . { A = NULL; }
|
||||
fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); }
|
||||
|
|
|
@ -420,6 +420,14 @@ static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName)
|
|||
return pCxt->valid;
|
||||
}
|
||||
|
||||
static bool checkIndexName(SAstCreateContext* pCxt, const SToken* pIndexName) {
|
||||
if (NULL == pIndexName) {
|
||||
return false;
|
||||
}
|
||||
pCxt->valid = pIndexName->n < TSDB_INDEX_NAME_LEN ? true : false;
|
||||
return pCxt->valid;
|
||||
}
|
||||
|
||||
SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) {
|
||||
SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR);
|
||||
CHECK_OUT_OF_MEM(target);
|
||||
|
@ -741,8 +749,8 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
|
|||
return (SNode*)setOp;
|
||||
}
|
||||
|
||||
SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
||||
SDatabaseOptions* pOptions = calloc(1, sizeof(SDatabaseOptions));
|
||||
SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
||||
SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->numOfBlocks = TSDB_DEFAULT_TOTAL_BLOCKS;
|
||||
pOptions->cacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE;
|
||||
|
@ -761,14 +769,14 @@ SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
|
|||
pOptions->numOfVgroups = TSDB_DEFAULT_VN_PER_DB;
|
||||
pOptions->singleStable = TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION;
|
||||
pOptions->streamMode = TSDB_DEFAULT_DB_STREAM_MODE_OPTION;
|
||||
return pOptions;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
SDatabaseOptions* setDatabaseOption(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, EDatabaseOptionType type, const SToken* pVal) {
|
||||
return setDbOptionFuncs[type](pCxt, pOptions, pVal);
|
||||
SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal) {
|
||||
return (SNode*)setDbOptionFuncs[type](pCxt, (SDatabaseOptions*)pOptions, pVal);
|
||||
}
|
||||
|
||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SDatabaseOptions* pOptions) {
|
||||
SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions) {
|
||||
if (!checkDbName(pCxt, pDbName)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -776,8 +784,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, cons
|
|||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strncpy(pStmt->dbName, pDbName->z, pDbName->n);
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->options = *pOptions;
|
||||
tfree(pOptions);
|
||||
pStmt->pOptions = (SDatabaseOptions*)pOptions;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
|
@ -792,20 +799,20 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt) {
|
||||
STableOptions* pOptions = calloc(1, sizeof(STableOptions));
|
||||
SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
|
||||
STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->keep = TSDB_DEFAULT_KEEP;
|
||||
pOptions->ttl = TSDB_DEFAULT_DB_TTL_OPTION;
|
||||
return pOptions;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal) {
|
||||
return setTableOptionFuncs[type](pCxt, pOptions, pVal);
|
||||
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal) {
|
||||
return (SNode*)setTableOptionFuncs[type](pCxt, (STableOptions*)pOptions, pVal);
|
||||
}
|
||||
|
||||
STableOptions* setTableSmaOption(SAstCreateContext* pCxt, STableOptions* pOptions, SNodeList* pSma) {
|
||||
pOptions->pSma = pSma;
|
||||
SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma) {
|
||||
((STableOptions*)pOptions)->pSma = pSma;
|
||||
return pOptions;
|
||||
}
|
||||
|
||||
|
@ -831,7 +838,7 @@ SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
|||
}
|
||||
|
||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt,
|
||||
bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, STableOptions* pOptions) {
|
||||
bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions) {
|
||||
SCreateTableStmt* pStmt = (SCreateTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
||||
|
@ -839,9 +846,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
|
|||
pStmt->ignoreExists = ignoreExists;
|
||||
pStmt->pCols = pCols;
|
||||
pStmt->pTags = pTags;
|
||||
pStmt->options = *pOptions;
|
||||
nodesDestroyList(pOptions->pSma);
|
||||
tfree(pOptions);
|
||||
pStmt->pOptions = (STableOptions*)pOptions;
|
||||
nodesDestroyNode(pRealTable);
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
@ -992,3 +997,27 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
|
|||
}
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions) {
|
||||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
||||
return NULL;
|
||||
}
|
||||
SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->indexType = type;
|
||||
strncpy(pStmt->indexName, pIndexName->z, pIndexName->n);
|
||||
strncpy(pStmt->tableName, pTableName->z, pTableName->n);
|
||||
pStmt->pCols = pCols;
|
||||
pStmt->pOptions = (SIndexOptions*)pOptions;
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding) {
|
||||
SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
||||
CHECK_OUT_OF_MEM(pOptions);
|
||||
pOptions->pFuncs = pFuncs;
|
||||
pOptions->pInterval = pInterval;
|
||||
pOptions->pOffset = pOffset;
|
||||
pOptions->pSliding = pSliding;
|
||||
return (SNode*)pOptions;
|
||||
}
|
||||
|
|
|
@ -59,11 +59,13 @@ static SKeyword keywordTable[] = {
|
|||
{"FLOAT", TK_FLOAT},
|
||||
{"FROM", TK_FROM},
|
||||
{"FSYNC", TK_FSYNC},
|
||||
{"FUNCTION", TK_FUNCTION},
|
||||
{"GROUP", TK_GROUP},
|
||||
{"HAVING", TK_HAVING},
|
||||
{"IF", TK_IF},
|
||||
{"IMPORT", TK_IMPORT},
|
||||
{"IN", TK_IN},
|
||||
{"INDEX", TK_INDEX},
|
||||
{"INNER", TK_INNER},
|
||||
{"INT", TK_INT},
|
||||
{"INSERT", TK_INSERT},
|
||||
|
@ -230,7 +232,6 @@ static SKeyword keywordTable[] = {
|
|||
// {"TOPICS", TK_TOPICS},
|
||||
// {"COMPACT", TK_COMPACT},
|
||||
// {"MODIFY", TK_MODIFY},
|
||||
// {"FUNCTION", TK_FUNCTION},
|
||||
// {"FUNCTIONS", TK_FUNCTIONS},
|
||||
// {"OUTPUTTYPE", TK_OUTPUTTYPE},
|
||||
// {"AGGREGATE", TK_AGGREGATE},
|
||||
|
|
|
@ -254,8 +254,7 @@ static int32_t trimStringWithVarFormat(const char* src, int32_t len, bool format
|
|||
|
||||
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||
if (pVal->isDuration) {
|
||||
char unit = 0;
|
||||
if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) {
|
||||
if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||
}
|
||||
} else {
|
||||
|
@ -768,26 +767,26 @@ static void buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt
|
|||
SName name = {0};
|
||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
tNameGetFullDbName(&name, pReq->db);
|
||||
pReq->numOfVgroups = pStmt->options.numOfVgroups;
|
||||
pReq->cacheBlockSize = pStmt->options.cacheBlockSize;
|
||||
pReq->totalBlocks = pStmt->options.numOfBlocks;
|
||||
pReq->daysPerFile = pStmt->options.daysPerFile;
|
||||
pReq->daysToKeep0 = pStmt->options.keep;
|
||||
pReq->numOfVgroups = pStmt->pOptions->numOfVgroups;
|
||||
pReq->cacheBlockSize = pStmt->pOptions->cacheBlockSize;
|
||||
pReq->totalBlocks = pStmt->pOptions->numOfBlocks;
|
||||
pReq->daysPerFile = pStmt->pOptions->daysPerFile;
|
||||
pReq->daysToKeep0 = pStmt->pOptions->keep;
|
||||
pReq->daysToKeep1 = -1;
|
||||
pReq->daysToKeep2 = -1;
|
||||
pReq->minRows = pStmt->options.minRowsPerBlock;
|
||||
pReq->maxRows = pStmt->options.maxRowsPerBlock;
|
||||
pReq->minRows = pStmt->pOptions->minRowsPerBlock;
|
||||
pReq->maxRows = pStmt->pOptions->maxRowsPerBlock;
|
||||
pReq->commitTime = -1;
|
||||
pReq->fsyncPeriod = pStmt->options.fsyncPeriod;
|
||||
pReq->walLevel = pStmt->options.walLevel;
|
||||
pReq->precision = pStmt->options.precision;
|
||||
pReq->compression = pStmt->options.compressionLevel;
|
||||
pReq->replications = pStmt->options.replica;
|
||||
pReq->quorum = pStmt->options.quorum;
|
||||
pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod;
|
||||
pReq->walLevel = pStmt->pOptions->walLevel;
|
||||
pReq->precision = pStmt->pOptions->precision;
|
||||
pReq->compression = pStmt->pOptions->compressionLevel;
|
||||
pReq->replications = pStmt->pOptions->replica;
|
||||
pReq->quorum = pStmt->pOptions->quorum;
|
||||
pReq->update = -1;
|
||||
pReq->cacheLastRow = pStmt->options.cachelast;
|
||||
pReq->cacheLastRow = pStmt->pOptions->cachelast;
|
||||
pReq->ignoreExist = pStmt->ignoreExists;
|
||||
pReq->streamMode = pStmt->options.streamMode;
|
||||
pReq->streamMode = pStmt->pOptions->streamMode;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1141,6 +1140,63 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
SVCreateTSmaReq createSmaReq = {0};
|
||||
|
||||
if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) ||
|
||||
(NULL != pStmt->pOptions->pOffset && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) ||
|
||||
(NULL != pStmt->pOptions->pSliding && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
|
||||
createSmaReq.tSma.intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit;
|
||||
createSmaReq.tSma.slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : 0);
|
||||
strcpy(createSmaReq.tSma.indexName, pStmt->indexName);
|
||||
|
||||
SName name;
|
||||
name.type = TSDB_TABLE_NAME_T;
|
||||
name.acctId = pCxt->pParseCxt->acctId;
|
||||
strcpy(name.dbname, pCxt->pParseCxt->db);
|
||||
strcpy(name.tname, pStmt->tableName);
|
||||
STableMeta* pMeta = NULL;
|
||||
int32_t code = catalogGetTableMeta(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &pCxt->pParseCxt->mgmtEpSet, &name, &pMeta);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
createSmaReq.tSma.tableUid = pMeta->uid;
|
||||
createSmaReq.tSma.interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i;
|
||||
createSmaReq.tSma.sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : 0);
|
||||
code = nodesListToString(pStmt->pCols, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL== pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_VND_CREATE_SMA;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSVCreateTSmaReq(NULL, &createSmaReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL== pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSVCreateTSmaReq(pCxt->pCmdMsg->pMsg, &createSmaReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
if (INDEX_TYPE_SMA == pStmt->indexType) {
|
||||
return translateCreateSmaIndex(pCxt, pStmt);
|
||||
} else {
|
||||
// todo fulltext index
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pNode)) {
|
||||
|
@ -1191,6 +1247,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
code = translateShowTables(pCxt);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||
code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -398,3 +398,10 @@ TEST_F(ParserTest, createTable) {
|
|||
);
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
TEST_F(ParserTest, createSmaIndex) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4))");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
|
|
@ -26,6 +26,14 @@ SJson* tjsonCreateObject() {
|
|||
return pJson;
|
||||
}
|
||||
|
||||
SJson* tjsonCreateArray() {
|
||||
SJson* pJson = cJSON_CreateArray();
|
||||
if (pJson == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return pJson;
|
||||
}
|
||||
|
||||
void tjsonDelete(SJson* pJson) {
|
||||
if (pJson != NULL) {
|
||||
cJSON_Delete((cJSON*)pJson);
|
||||
|
|
Loading…
Reference in New Issue