Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9e9805f7
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9e9805f7
编写于
4月 02, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
condition bugfix
上级
62856b04
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
836 addition
and
824 deletion
+836
-824
include/common/ttokendef.h
include/common/ttokendef.h
+1
-2
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
include/util/tdef.h
include/util/tdef.h
+5
-2
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+13
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+18
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+7
-32
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+5
-9
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+3
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+778
-776
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+5
-2
未找到文件。
include/common/ttokendef.h
浏览文件 @
9e9805f7
...
@@ -172,7 +172,7 @@
...
@@ -172,7 +172,7 @@
#define TK_SYNCDB 154
#define TK_SYNCDB 154
#define TK_NULL 155
#define TK_NULL 155
#define TK_NK_VARIABLE 156
#define TK_NK_VARIABLE 156
#define TK_N
K_UNDERLINE
157
#define TK_N
OW
157
#define TK_ROWTS 158
#define TK_ROWTS 158
#define TK_TBNAME 159
#define TK_TBNAME 159
#define TK_QSTARTTS 160
#define TK_QSTARTTS 160
...
@@ -229,7 +229,6 @@
...
@@ -229,7 +229,6 @@
#define TK_NK_COLON 500
#define TK_NK_COLON 500
#define TK_NK_BITNOT 501
#define TK_NK_BITNOT 501
#define TK_INSERT 502
#define TK_INSERT 502
#define TK_NOW 504
#define TK_VALUES 507
#define TK_VALUES 507
#define TK_IMPORT 509
#define TK_IMPORT 509
#define TK_NK_SEMI 508
#define TK_NK_SEMI 508
...
...
include/libs/nodes/querynodes.h
浏览文件 @
9e9805f7
...
@@ -306,6 +306,7 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
...
@@ -306,6 +306,7 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
bool
nodesIsExprNode
(
const
SNode
*
pNode
);
bool
nodesIsExprNode
(
const
SNode
*
pNode
);
bool
nodesIsUnaryOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsArithmeticOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsArithmeticOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsComparisonOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsComparisonOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsJsonOp
(
const
SOperatorNode
*
pOp
);
bool
nodesIsJsonOp
(
const
SOperatorNode
*
pOp
);
...
...
include/util/tdef.h
浏览文件 @
9e9805f7
...
@@ -128,18 +128,20 @@ extern const int32_t TYPE_BYTES[15];
...
@@ -128,18 +128,20 @@ extern const int32_t TYPE_BYTES[15];
} while (0)
} while (0)
typedef
enum
EOperatorType
{
typedef
enum
EOperatorType
{
// arithmetic operator
//
binary
arithmetic operator
OP_TYPE_ADD
=
1
,
OP_TYPE_ADD
=
1
,
OP_TYPE_SUB
,
OP_TYPE_SUB
,
OP_TYPE_MULTI
,
OP_TYPE_MULTI
,
OP_TYPE_DIV
,
OP_TYPE_DIV
,
OP_TYPE_MOD
,
OP_TYPE_MOD
,
// unary arithmetic operator
OP_TYPE_MINUS
,
// bit operator
// bit operator
OP_TYPE_BIT_AND
,
OP_TYPE_BIT_AND
,
OP_TYPE_BIT_OR
,
OP_TYPE_BIT_OR
,
// comparison operator
//
binary
comparison operator
OP_TYPE_GREATER_THAN
,
OP_TYPE_GREATER_THAN
,
OP_TYPE_GREATER_EQUAL
,
OP_TYPE_GREATER_EQUAL
,
OP_TYPE_LOWER_THAN
,
OP_TYPE_LOWER_THAN
,
...
@@ -152,6 +154,7 @@ typedef enum EOperatorType {
...
@@ -152,6 +154,7 @@ typedef enum EOperatorType {
OP_TYPE_NOT_LIKE
,
OP_TYPE_NOT_LIKE
,
OP_TYPE_MATCH
,
OP_TYPE_MATCH
,
OP_TYPE_NMATCH
,
OP_TYPE_NMATCH
,
// unary comparison operator
OP_TYPE_IS_NULL
,
OP_TYPE_IS_NULL
,
OP_TYPE_IS_NOT_NULL
,
OP_TYPE_IS_NOT_NULL
,
OP_TYPE_IS_TRUE
,
OP_TYPE_IS_TRUE
,
...
...
source/libs/function/src/builtins.c
浏览文件 @
9e9805f7
...
@@ -361,6 +361,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -361,6 +361,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
initFunc
=
NULL
,
.
initFunc
=
NULL
,
.
sprocessFunc
=
winDurFunction
,
.
sprocessFunc
=
winDurFunction
,
.
finalizeFunc
=
NULL
.
finalizeFunc
=
NULL
},
{
.
name
=
"now"
,
.
type
=
FUNCTION_TYPE_NOW
,
.
classification
=
FUNC_MGT_SCALAR_FUNC
|
FUNC_MGT_DATETIME_FUNC
,
.
checkFunc
=
stubCheckAndGetResultType
,
.
getEnvFunc
=
getTimePseudoFuncEnv
,
.
initFunc
=
NULL
,
.
sprocessFunc
=
winDurFunction
,
.
finalizeFunc
=
NULL
}
}
};
};
...
@@ -436,7 +446,9 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
...
@@ -436,7 +446,9 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
,
.
type
=
TSDB_DATA_TYPE_DOUBLE
};
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
,
.
type
=
TSDB_DATA_TYPE_DOUBLE
};
break
;
break
;
}
}
case
FUNCTION_TYPE_NOW
:
// todo
break
;
default:
default:
ASSERT
(
0
);
// to found the fault ASAP.
ASSERT
(
0
);
// to found the fault ASAP.
}
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
9e9805f7
...
@@ -860,6 +860,24 @@ bool nodesIsExprNode(const SNode* pNode) {
...
@@ -860,6 +860,24 @@ bool nodesIsExprNode(const SNode* pNode) {
return
(
QUERY_NODE_COLUMN
==
type
||
QUERY_NODE_VALUE
==
type
||
QUERY_NODE_OPERATOR
==
type
||
QUERY_NODE_FUNCTION
==
type
);
return
(
QUERY_NODE_COLUMN
==
type
||
QUERY_NODE_VALUE
==
type
||
QUERY_NODE_OPERATOR
==
type
||
QUERY_NODE_FUNCTION
==
type
);
}
}
bool
nodesIsUnaryOp
(
const
SOperatorNode
*
pOp
)
{
switch
(
pOp
->
opType
)
{
case
OP_TYPE_MINUS
:
case
OP_TYPE_IS_NULL
:
case
OP_TYPE_IS_NOT_NULL
:
case
OP_TYPE_IS_TRUE
:
case
OP_TYPE_IS_FALSE
:
case
OP_TYPE_IS_UNKNOWN
:
case
OP_TYPE_IS_NOT_TRUE
:
case
OP_TYPE_IS_NOT_FALSE
:
case
OP_TYPE_IS_NOT_UNKNOWN
:
return
true
;
default:
break
;
}
return
false
;
}
bool
nodesIsArithmeticOp
(
const
SOperatorNode
*
pOp
)
{
bool
nodesIsArithmeticOp
(
const
SOperatorNode
*
pOp
)
{
switch
(
pOp
->
opType
)
{
switch
(
pOp
->
opType
)
{
case
OP_TYPE_ADD
:
case
OP_TYPE_ADD
:
...
...
source/libs/parser/inc/sql.y
浏览文件 @
9e9805f7
...
@@ -513,7 +513,7 @@ expression(A) ::= NK_PLUS(B) expression(C).
...
@@ -513,7 +513,7 @@ expression(A) ::= NK_PLUS(B) expression(C).
}
}
expression(A) ::= NK_MINUS(B) expression(C). {
expression(A) ::= NK_MINUS(B) expression(C). {
SToken t = getTokenFromRawExprNode(pCxt, C);
SToken t = getTokenFromRawExprNode(pCxt, C);
A = createRawExprNodeExt(pCxt, &B, &t, createOperatorNode(pCxt, OP_TYPE_
SUB
, releaseRawExprNode(pCxt, C), NULL));
A = createRawExprNodeExt(pCxt, &B, &t, createOperatorNode(pCxt, OP_TYPE_
MINUS
, releaseRawExprNode(pCxt, C), NULL));
}
}
expression(A) ::= expression(B) NK_PLUS expression(C). {
expression(A) ::= expression(B) NK_PLUS expression(C). {
SToken s = getTokenFromRawExprNode(pCxt, B);
SToken s = getTokenFromRawExprNode(pCxt, B);
...
@@ -549,39 +549,14 @@ expression_list(A) ::= expression_list(B) NK_COMMA expression(C).
...
@@ -549,39 +549,14 @@ expression_list(A) ::= expression_list(B) NK_COMMA expression(C).
column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); }
column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); }
column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); }
column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); }
//pseudo_column(A) ::= NK_NOW. { A = createFunctionNode(pCxt, NULL, NULL); }
pseudo_column(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
//pseudo_column(A) ::= NK_UNDERLINE(B) ROWTS(C). {
// SToken t = B;
// t.n = (C.z + C.n) - B.z;
// A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
// }
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= NK_UNDERLINE(B) QSTARTTS(C). {
pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
SToken t = B;
pseudo_column(A) ::= QENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
t.n = (C.z + C.n) - B.z;
pseudo_column(A) ::= WSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
pseudo_column(A) ::= WENDTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
}
pseudo_column(A) ::= WDURATION(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::= NK_UNDERLINE(B) QENDTS(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
}
pseudo_column(A) ::= NK_UNDERLINE(B) WSTARTTS(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
}
pseudo_column(A) ::= NK_UNDERLINE(B) WENDTS(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
}
pseudo_column(A) ::= NK_UNDERLINE(B) WDURATION(C). {
SToken t = B;
t.n = (C.z + C.n) - B.z;
A = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL));
}
/************************************************ predicate ***********************************************************/
/************************************************ predicate ***********************************************************/
predicate(A) ::= expression(B) compare_op(C) expression(D). {
predicate(A) ::= expression(B) compare_op(C) expression(D). {
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
9e9805f7
...
@@ -125,10 +125,10 @@ static SKeyword keywordTable[] = {
...
@@ -125,10 +125,10 @@ static SKeyword keywordTable[] = {
{
"PRECISION"
,
TK_PRECISION
},
{
"PRECISION"
,
TK_PRECISION
},
{
"PRIVILEGE"
,
TK_PRIVILEGE
},
{
"PRIVILEGE"
,
TK_PRIVILEGE
},
{
"PREV"
,
TK_PREV
},
{
"PREV"
,
TK_PREV
},
{
"QENDTS"
,
TK_QENDTS
},
{
"
_
QENDTS"
,
TK_QENDTS
},
{
"QNODE"
,
TK_QNODE
},
{
"QNODE"
,
TK_QNODE
},
{
"QNODES"
,
TK_QNODES
},
{
"QNODES"
,
TK_QNODES
},
{
"QSTARTTS"
,
TK_QSTARTTS
},
{
"
_
QSTARTTS"
,
TK_QSTARTTS
},
{
"QTIME"
,
TK_QTIME
},
{
"QTIME"
,
TK_QTIME
},
{
"QUERIES"
,
TK_QUERIES
},
{
"QUERIES"
,
TK_QUERIES
},
{
"QUERY"
,
TK_QUERY
},
{
"QUERY"
,
TK_QUERY
},
...
@@ -184,10 +184,10 @@ static SKeyword keywordTable[] = {
...
@@ -184,10 +184,10 @@ static SKeyword keywordTable[] = {
{
"VGROUPS"
,
TK_VGROUPS
},
{
"VGROUPS"
,
TK_VGROUPS
},
{
"VNODES"
,
TK_VNODES
},
{
"VNODES"
,
TK_VNODES
},
{
"WAL"
,
TK_WAL
},
{
"WAL"
,
TK_WAL
},
{
"WDURATION"
,
TK_WDURATION
},
{
"
_
WDURATION"
,
TK_WDURATION
},
{
"WENDTS"
,
TK_WENDTS
},
{
"
_
WENDTS"
,
TK_WENDTS
},
{
"WHERE"
,
TK_WHERE
},
{
"WHERE"
,
TK_WHERE
},
{
"
WSTARTTS"
,
TK_WSTARTTS
},
{
"
_WSTARTTS"
,
TK_WSTARTTS
},
// {"ID", TK_ID},
// {"ID", TK_ID},
// {"STRING", TK_STRING},
// {"STRING", TK_STRING},
// {"EQ", TK_EQ},
// {"EQ", TK_EQ},
...
@@ -440,10 +440,6 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
...
@@ -440,10 +440,6 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
*
tokenId
=
TK_NK_QUESTION
;
*
tokenId
=
TK_NK_QUESTION
;
return
1
;
return
1
;
}
}
// case '_': {
// *tokenId = TK_NK_UNDERLINE;
// return 1;
// }
case
'`'
:
case
'`'
:
case
'\''
:
case
'\''
:
case
'"'
:
{
case
'"'
:
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
9e9805f7
...
@@ -439,6 +439,9 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
...
@@ -439,6 +439,9 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
}
}
static
EDealRes
translateOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOp
)
{
static
EDealRes
translateOperator
(
STranslateContext
*
pCxt
,
SOperatorNode
*
pOp
)
{
if
(
nodesIsUnaryOp
(
pOp
))
{
return
DEAL_RES_CONTINUE
;
}
SDataType
ldt
=
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
;
SDataType
ldt
=
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
;
SDataType
rdt
=
((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
;
SDataType
rdt
=
((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
;
if
(
nodesIsArithmeticOp
(
pOp
))
{
if
(
nodesIsArithmeticOp
(
pOp
))
{
...
...
source/libs/parser/src/sql.c
浏览文件 @
9e9805f7
此差异已折叠。
点击以展开。
source/libs/planner/test/plannerTest.cpp
浏览文件 @
9e9805f7
...
@@ -193,14 +193,17 @@ TEST_F(PlannerTest, interval) {
...
@@ -193,14 +193,17 @@ TEST_F(PlannerTest, interval) {
// bind("SELECT count(*) FROM t1 interval(10s)");
// bind("SELECT count(*) FROM t1 interval(10s)");
// ASSERT_TRUE(run());
// ASSERT_TRUE(run());
bind
(
"SELECT _wstartts, count(*) FROM t1 interval(10s)"
);
ASSERT_TRUE
(
run
());
// bind("SELECT _wstartts, _wduration, _wendts, count(*) FROM t1 interval(10s)");
// bind("SELECT _wstartts, _wduration, _wendts, count(*) FROM t1 interval(10s)");
// ASSERT_TRUE(run());
// ASSERT_TRUE(run());
// bind("SELECT count(*) FROM t1 interval(10s) fill(linear)");
// bind("SELECT count(*) FROM t1 interval(10s) fill(linear)");
// ASSERT_TRUE(run());
// ASSERT_TRUE(run());
bind
(
"SELECT count(*), sum(c1) FROM t1 interval(10s) fill(value, 10, 20)"
);
//
bind("SELECT count(*), sum(c1) FROM t1 interval(10s) fill(value, 10, 20)");
ASSERT_TRUE
(
run
());
//
ASSERT_TRUE(run());
}
}
TEST_F
(
PlannerTest
,
sessionWindow
)
{
TEST_F
(
PlannerTest
,
sessionWindow
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录