Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
01ea3858
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看板
提交
01ea3858
编写于
4月 15, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: CREATE STREAM statement implement, and syntax of JSON data type implement.
上级
ba1f3f78
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
60 addition
and
35 deletion
+60
-35
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+9
-9
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+42
-18
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+1
-1
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+1
-1
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+6
-6
未找到文件。
source/libs/parser/inc/sql.y
浏览文件 @
01ea3858
...
...
@@ -592,15 +592,15 @@ 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) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); }
pseudo_column(A) ::=
NOW(B).
{ A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::=
TODAY(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) ::=
QSTARTTS(B).
{ A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::=
QENDTS(B).
{ A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::=
WSTARTTS(B).
{ A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, 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) ::=
NOW(B).
{ A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::=
TODAY(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) ::=
QSTARTTS(B).
{ A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::=
QENDTS(B).
{ A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); }
pseudo_column(A) ::=
WSTARTTS(B).
{ A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, 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)); }
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)); }
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
01ea3858
...
...
@@ -51,6 +51,7 @@ static SKeyword keywordTable[] = {
{
"BY"
,
TK_BY
},
{
"CACHE"
,
TK_CACHE
},
{
"CACHELAST"
,
TK_CACHELAST
},
{
"CAST"
,
TK_CAST
},
{
"COLUMN"
,
TK_COLUMN
},
{
"COMMENT"
,
TK_COMMENT
},
{
"COMP"
,
TK_COMP
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
01ea3858
...
...
@@ -807,31 +807,32 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
return
(
SNode
*
)
pFunc
;
}
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
SNodeList
**
pOutput
)
{
if
(
NULL
==
*
pOutput
)
{
*
pOutput
=
nodesMakeList
();
}
if
(
NULL
==
*
pOutput
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
}
bool
foundTable
=
false
;
static
int32_t
findTable
(
STranslateContext
*
pCxt
,
const
char
*
pTableAlias
,
STableNode
**
pOutput
)
{
SArray
*
pTables
=
taosArrayGetP
(
pCxt
->
pNsLevel
,
pCxt
->
currLevel
);
size_t
nums
=
taosArrayGetSize
(
pTables
);
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
if
(
0
==
strcmp
(
pTable
->
tableAlias
,
pCol
->
tableAlias
))
{
int32_t
code
=
createColumnNodeByTable
(
pCxt
,
pTable
,
*
pOutput
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
foundTable
=
true
;
break
;
if
(
NULL
==
pTableAlias
||
0
==
strcmp
(
pTable
->
tableAlias
,
pTableAlias
))
{
*
pOutput
=
pTable
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
foundTable
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pCol
->
tableAlias
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pTableAlias
);
}
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
SNodeList
**
pOutput
)
{
STableNode
*
pTable
=
NULL
;
int32_t
code
=
findTable
(
pCxt
,
pCol
->
tableAlias
,
&
pTable
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
*
pOutput
)
{
*
pOutput
=
nodesMakeList
();
if
(
NULL
==
*
pOutput
)
{
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
}
}
return
TSDB_CODE_SUCCESS
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnNodeByTable
(
pCxt
,
pTable
,
*
pOutput
);
}
return
code
;
}
static
bool
isStar
(
SNode
*
pNode
)
{
...
...
@@ -909,6 +910,24 @@ static int32_t createMultiResFuncsFromStar(STranslateContext* pCxt, SFunctionNod
return
code
;
}
static
bool
isCountStar
(
SNode
*
pNode
)
{
if
(
QUERY_NODE_FUNCTION
!=
nodeType
(
pNode
))
{
return
false
;
}
SNode
*
pPara
=
nodesListGetNode
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
,
0
);
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pPara
)
&&
0
==
strcmp
(((
SColumnNode
*
)
pPara
)
->
colName
,
"*"
));
}
static
int32_t
rewriteCountStar
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pCount
)
{
SColumnNode
*
pCol
=
nodesListGetNode
(
pCount
->
pParameterList
,
0
);
STableNode
*
pTable
=
NULL
;
int32_t
code
=
findTable
(
pCxt
,
(
'\0'
==
pCol
->
tableAlias
[
0
]
?
NULL
:
pCol
->
tableAlias
),
&
pTable
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
setColumnInfoBySchema
((
SRealTableNode
*
)
pTable
,
((
SRealTableNode
*
)
pTable
)
->
pMeta
->
schema
,
false
,
pCol
);
}
return
code
;
}
static
int32_t
translateStar
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
(
NULL
==
pSelect
->
pProjectionList
)
{
// select * ...
return
createAllColumns
(
pCxt
,
&
pSelect
->
pProjectionList
);
...
...
@@ -931,6 +950,11 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
INSERT_LIST
(
pSelect
->
pProjectionList
,
pCols
);
ERASE_NODE
(
pSelect
->
pProjectionList
);
continue
;
}
else
if
(
isCountStar
(
pNode
))
{
int32_t
code
=
rewriteCountStar
(
pCxt
,
(
SFunctionNode
*
)
pNode
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
}
WHERE_NEXT
;
}
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
01ea3858
...
...
@@ -264,7 +264,7 @@ private:
}
std
::
string
ftToString
(
int16_t
colid
,
int16_t
numOfColumns
)
const
{
return
(
0
==
colid
?
"column"
:
(
colid
<
=
numOfColumns
?
"tag"
:
"column
"
));
return
(
0
==
colid
?
"column"
:
(
colid
<
numOfColumns
?
"column"
:
"tag
"
));
}
STableMeta
*
getTableSchemaMeta
(
const
std
::
string
&
db
,
const
std
::
string
&
tbname
)
const
{
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
01ea3858
...
...
@@ -64,7 +64,7 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
return
false
;
}
if
(
NULL
==
pNode
->
pParent
||
(
QUERY_NODE_LOGIC_PLAN_WINDOW
!=
nodeType
(
pNode
->
pParent
)
&&
QUERY_NODE_LOGIC_PLAN_AGG
=
=
nodeType
(
pNode
->
pParent
)))
{
(
QUERY_NODE_LOGIC_PLAN_WINDOW
!=
nodeType
(
pNode
->
pParent
)
&&
QUERY_NODE_LOGIC_PLAN_AGG
!
=
nodeType
(
pNode
->
pParent
)))
{
return
false
;
}
return
true
;
...
...
source/libs/planner/test/plannerTest.cpp
浏览文件 @
01ea3858
...
...
@@ -196,14 +196,14 @@ TEST_F(PlannerTest, selectGroupBy) {
bind
(
"SELECT count(*) FROM t1"
);
ASSERT_TRUE
(
run
());
// bind("SELECT c1, max(c3), min(c2
), count(*) FROM t1 GROUP BY c1");
//
ASSERT_TRUE(run());
bind
(
"SELECT c1, max(c3), min(c3
), count(*) FROM t1 GROUP BY c1"
);
ASSERT_TRUE
(
run
());
//
bind("SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3");
//
ASSERT_TRUE(run());
bind
(
"SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3"
);
ASSERT_TRUE
(
run
());
//
bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3");
//
ASSERT_TRUE(run());
bind
(
"SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
PlannerTest
,
selectSubquery
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录