Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
97ac79f5
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
97ac79f5
编写于
6月 16, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: rollup grammar adjust
上级
f6f4f65a
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
33 addition
and
47 deletion
+33
-47
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+2
-2
include/util/tdef.h
include/util/tdef.h
+7
-8
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+2
-2
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-2
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+5
-5
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+15
-28
未找到文件。
include/libs/nodes/cmdnodes.h
浏览文件 @
97ac79f5
...
...
@@ -88,8 +88,8 @@ typedef struct SAlterDatabaseStmt {
typedef
struct
STableOptions
{
ENodeType
type
;
char
comment
[
TSDB_TB_COMMENT_LEN
];
double
filesFactor
;
int32_t
delay
;
SNode
*
pMaxDelay
;
SNode
*
pWatermark
;
SNodeList
*
pRollupFuncs
;
int32_t
ttl
;
SNodeList
*
pSma
;
...
...
include/util/tdef.h
浏览文件 @
97ac79f5
...
...
@@ -344,12 +344,11 @@ typedef enum ELogicConditionType {
#define TSDB_DB_SCHEMALESS_OFF 0
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
// #define TSDB_MIN_ROLLUP_DELAY 1
// #define TSDB_MAX_ROLLUP_DELAY 10
// #define TSDB_DEFAULT_ROLLUP_DELAY 1
#define TSDB_MIN_ROLLUP_FILE_FACTOR 0
#define TSDB_MAX_ROLLUP_FILE_FACTOR 10
#define TSDB_DEFAULT_ROLLUP_FILE_FACTOR 0.1
#define TSDB_MIN_ROLLUP_MAX_DELAY 1 // unit millisecond
#define TSDB_MAX_ROLLUP_MAX_DELAY (15 * 60 * 1000)
#define TSDB_MIN_ROLLUP_WATERMARK 0 // unit millisecond
#define TSDB_MAX_ROLLUP_WATERMARK (15 * 60 * 1000)
#define TSDB_DEFAULT_ROLLUP_WATERMARK 5000
#define TSDB_MIN_TABLE_TTL 0
#define TSDB_DEFAULT_TABLE_TTL 0
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
97ac79f5
...
...
@@ -59,8 +59,8 @@ typedef enum EDatabaseOptionType {
typedef
enum
ETableOptionType
{
TABLE_OPTION_COMMENT
=
1
,
TABLE_OPTION_
FILE_FACTOR
,
TABLE_OPTION_
DELAY
,
TABLE_OPTION_
MAXDELAY
,
TABLE_OPTION_
WATERMARK
,
TABLE_OPTION_ROLLUP
,
TABLE_OPTION_TTL
,
TABLE_OPTION_SMA
...
...
source/libs/parser/inc/sql.y
浏览文件 @
97ac79f5
...
...
@@ -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) DELAY NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_DELAY, &
C); }
table_options(A) ::= table_options(B)
FILE_FACTOR NK_FLOAT(C). { A = setTableOption(pCxt, B, TABLE_OPTION_FILE_FACTOR, &
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) 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); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
97ac79f5
...
...
@@ -867,8 +867,6 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
CHECK_PARSER_STATUS
(
pCxt
);
STableOptions
*
pOptions
=
(
STableOptions
*
)
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
// pOptions->delay = TSDB_DEFAULT_ROLLUP_DELAY;
pOptions
->
filesFactor
=
TSDB_DEFAULT_ROLLUP_FILE_FACTOR
;
pOptions
->
ttl
=
TSDB_DEFAULT_TABLE_TTL
;
return
(
SNode
*
)
pOptions
;
}
...
...
@@ -877,7 +875,6 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
CHECK_PARSER_STATUS
(
pCxt
);
STableOptions
*
pOptions
=
(
STableOptions
*
)
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
delay
=
-
1
;
pOptions
->
ttl
=
-
1
;
return
(
SNode
*
)
pOptions
;
}
...
...
@@ -891,8 +888,11 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
sizeof
(((
STableOptions
*
)
pOptions
)
->
comment
));
}
break
;
case
TABLE_OPTION_DELAY
:
((
STableOptions
*
)
pOptions
)
->
delay
=
taosStr2Int32
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
case
TABLE_OPTION_MAXDELAY
:
((
STableOptions
*
)
pOptions
)
->
pMaxDelay
=
pVal
;
break
;
case
TABLE_OPTION_WATERMARK
:
((
STableOptions
*
)
pOptions
)
->
pWatermark
=
pVal
;
break
;
case
TABLE_OPTION_ROLLUP
:
((
STableOptions
*
)
pOptions
)
->
pRollupFuncs
=
pVal
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
97ac79f5
...
...
@@ -2668,14 +2668,6 @@ static SColumnDefNode* findColDef(SNodeList* pCols, const SColumnNode* pCol) {
return
NULL
;
}
static
int32_t
checTableFactorOption
(
STranslateContext
*
pCxt
,
float
val
)
{
if
(
val
<
TSDB_MIN_ROLLUP_FILE_FACTOR
||
val
>
TSDB_MAX_ROLLUP_FILE_FACTOR
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_F_RANGE_OPTION
,
"file_factor"
,
val
,
TSDB_MIN_ROLLUP_FILE_FACTOR
,
TSDB_MAX_ROLLUP_FILE_FACTOR
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkTableSmaOption
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
if
(
NULL
!=
pStmt
->
pOptions
->
pSma
)
{
SNode
*
pNode
=
NULL
;
...
...
@@ -2825,24 +2817,22 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
return
code
;
}
static
int32_t
checkSchemalessDb
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
)
{
// if (0 != pCxt->pParseCxt->schemalessType) {
// return TSDB_CODE_SUCCESS;
// }
// SDbCfgInfo info = {0};
// int32_t code = getDBCfg(pCxt, pDbName, &info);
// if (TSDB_CODE_SUCCESS == code) {
// code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS;
// }
// return code;
return
TSDB_CODE_SUCCESS
;
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
);
}
return
checkRangeOption
(
pCxt
,
"maxDelay"
,
pOptions
->
pMaxDelay
,
TSDB_MIN_ROLLUP_MAX_DELAY
,
TSDB_MAX_ROLLUP_MAX_DELAY
);
}
static
int32_t
checkCreateTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
int32_t
code
=
checkSchemalessDb
(
pCxt
,
pStmt
->
dbName
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checTableFactorOption
(
pCxt
,
pStmt
->
pOptions
->
filesFactor
);
}
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);
// }
...
...
@@ -3089,7 +3079,7 @@ 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->xFilesFactor = pStmt->pOptions->filesFactor;
pReq
->
ttl
=
pStmt
->
pOptions
->
ttl
;
columnDefNodeToField
(
pStmt
->
pCols
,
&
pReq
->
pColumns
);
columnDefNodeToField
(
pStmt
->
pTags
,
&
pReq
->
pTags
);
...
...
@@ -4757,10 +4747,7 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery)
SNode
*
pNode
;
FOREACH
(
pNode
,
pStmt
->
pSubTables
)
{
SCreateSubTableClause
*
pClause
=
(
SCreateSubTableClause
*
)
pNode
;
code
=
checkSchemalessDb
(
pCxt
,
pClause
->
dbName
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteCreateSubTable
(
pCxt
,
pClause
,
pVgroupHashmap
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
taosHashCleanup
(
pVgroupHashmap
);
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录