Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
52f952f9
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
52f952f9
编写于
11月 15, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] Refactor projection parse.
上级
8ba07803
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
10 addition
and
31 deletion
+10
-31
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+9
-30
source/libs/parser/src/queryInfoUtil.c
source/libs/parser/src/queryInfoUtil.c
+1
-1
未找到文件。
source/libs/parser/src/astValidate.c
浏览文件 @
52f952f9
...
@@ -2652,12 +2652,8 @@ static int32_t validateScalarFunctionParamNum(tSqlExpr* pSqlExpr, int32_t functi
...
@@ -2652,12 +2652,8 @@ static int32_t validateScalarFunctionParamNum(tSqlExpr* pSqlExpr, int32_t functi
return
code
;
return
code
;
}
}
int32_t
doAddProjectCol
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
SColumnIndex
*
pColIndex
,
int32_t
doAddProjectCol
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
SSchema
*
pSchema
,
const
char
*
aliasName
,
const
char
*
aliasName
,
int32_t
colId
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
colId
,
SMsgBuf
*
pMsgBuf
)
{
STableMeta
*
pTableMeta
=
getMetaInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
)
->
pTableMeta
;
SSchema
*
pSchema
=
getOneColumnSchema
(
pTableMeta
,
pColIndex
->
columnIndex
);
const
char
*
name
=
(
aliasName
==
NULL
)
?
pSchema
->
name
:
aliasName
;
const
char
*
name
=
(
aliasName
==
NULL
)
?
pSchema
->
name
:
aliasName
;
SSchema
s
=
createSchema
(
pSchema
->
type
,
pSchema
->
bytes
,
colId
,
name
);
SSchema
s
=
createSchema
(
pSchema
->
type
,
pSchema
->
bytes
,
colId
,
name
);
...
@@ -2708,8 +2704,8 @@ static int32_t doAddProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, SColu
...
@@ -2708,8 +2704,8 @@ static int32_t doAddProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, SColu
}
}
for
(
int32_t
j
=
0
;
j
<
numOfTotalColumns
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfTotalColumns
;
++
j
)
{
pIndex
->
columnIndex
=
j
;
SSchema
*
pSchema
=
getOneColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
j
)
;
doAddProjectCol
(
pQueryInfo
,
startPos
+
j
,
p
Index
,
NULL
,
getNewResColId
(),
pMsgBuf
);
doAddProjectCol
(
pQueryInfo
,
startPos
+
j
,
p
Schema
,
NULL
,
getNewResColId
(),
pMsgBuf
);
}
}
return
numOfTotalColumns
;
return
numOfTotalColumns
;
...
@@ -2748,11 +2744,9 @@ static SSchema createConstantColumnSchema(SVariant* pVal, const SToken* exprStr,
...
@@ -2748,11 +2744,9 @@ static SSchema createConstantColumnSchema(SVariant* pVal, const SToken* exprStr,
}
}
static
int32_t
handleTbnameProjection
(
SQueryStmtInfo
*
pQueryInfo
,
tSqlExprItem
*
pItem
,
SColumnIndex
*
pIndex
,
int32_t
startPos
,
bool
outerQuery
,
SMsgBuf
*
pMsgBuf
)
{
static
int32_t
handleTbnameProjection
(
SQueryStmtInfo
*
pQueryInfo
,
tSqlExprItem
*
pItem
,
SColumnIndex
*
pIndex
,
int32_t
startPos
,
bool
outerQuery
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg
3
=
"tbname not allowed in outer query"
;
const
char
*
msg
1
=
"tbname not allowed in outer query"
;
SSchema
colSchema
=
{
0
};
SSchema
colSchema
=
{
0
};
char
*
funcName
=
NULL
;
if
(
outerQuery
)
{
// todo??
if
(
outerQuery
)
{
// todo??
STableMetaInfo
*
pTableMetaInfo
=
getMetaInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
getMetaInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
...
@@ -2769,36 +2763,20 @@ static int32_t handleTbnameProjection(SQueryStmtInfo* pQueryInfo, tSqlExprItem*
...
@@ -2769,36 +2763,20 @@ static int32_t handleTbnameProjection(SQueryStmtInfo* pQueryInfo, tSqlExprItem*
}
}
if
(
!
existed
)
{
if
(
!
existed
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg
3
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg
1
);
}
}
colSchema
=
pSchema
[
pIndex
->
columnIndex
];
colSchema
=
pSchema
[
pIndex
->
columnIndex
];
funcName
=
"project_col"
;
}
else
{
}
else
{
colSchema
=
*
getTbnameColumnSchema
();
colSchema
=
*
getTbnameColumnSchema
();
funcName
=
"project_tag"
;
}
}
SSchema
resultSchema
=
colSchema
;
return
doAddProjectCol
(
pQueryInfo
,
startPos
,
&
colSchema
,
pItem
->
aliasName
,
getNewResColId
(),
pMsgBuf
);
resultSchema
.
colId
=
getNewResColId
();
char
rawName
[
TSDB_COL_NAME_LEN
]
=
{
0
};
setTokenAndResColumnName
(
pItem
,
resultSchema
.
name
,
rawName
,
sizeof
(
colSchema
.
name
)
-
1
);
STableMetaInfo
*
pTableMetaInfo
=
getMetaInfo
(
pQueryInfo
,
pIndex
->
tableIndex
);
SColumn
c
=
createColumn
(
pTableMetaInfo
->
pTableMeta
->
uid
,
pTableMetaInfo
->
aliasName
,
pIndex
->
type
,
&
colSchema
);
SSourceParam
param
=
{
0
};
addIntoSourceParam
(
&
param
,
NULL
,
&
c
);
doAddOneExprInfo
(
pQueryInfo
,
"project_tag"
,
&
param
,
startPos
,
pTableMetaInfo
,
&
colSchema
,
0
,
rawName
,
true
);
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
addProjectionExprAndResColumn
(
SQueryStmtInfo
*
pQueryInfo
,
tSqlExprItem
*
pItem
,
bool
outerQuery
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
addProjectionExprAndResColumn
(
SQueryStmtInfo
*
pQueryInfo
,
tSqlExprItem
*
pItem
,
bool
outerQuery
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"tag for normal table query is not allowed"
;
const
char
*
msg1
=
"tag for normal table query is not allowed"
;
const
char
*
msg2
=
"invalid column name"
;
const
char
*
msg2
=
"invalid column name"
;
const
char
*
msg3
=
"tbname not allowed in outer query"
;
if
(
checkForAliasName
(
pMsgBuf
,
pItem
->
aliasName
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
checkForAliasName
(
pMsgBuf
,
pItem
->
aliasName
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
...
@@ -2861,7 +2839,8 @@ int32_t addProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, tSqlExprItem*
...
@@ -2861,7 +2839,8 @@ int32_t addProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, tSqlExprItem*
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
}
doAddProjectCol
(
pQueryInfo
,
startPos
,
&
index
,
pItem
->
aliasName
,
getNewResColId
(),
pMsgBuf
);
SSchema
*
pSchema
=
getOneColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
index
.
columnIndex
);
doAddProjectCol
(
pQueryInfo
,
startPos
,
pSchema
,
pItem
->
aliasName
,
getNewResColId
(),
pMsgBuf
);
}
}
// add the primary timestamp column even though it is not required by user
// add the primary timestamp column even though it is not required by user
...
...
source/libs/parser/src/queryInfoUtil.c
浏览文件 @
52f952f9
...
@@ -330,7 +330,7 @@ SArray* extractFunctionList(SArray* pExprInfoList) {
...
@@ -330,7 +330,7 @@ SArray* extractFunctionList(SArray* pExprInfoList) {
if
(
pExprInfo
->
pExpr
->
nodeType
==
TEXPR_FUNCTION_NODE
)
{
if
(
pExprInfo
->
pExpr
->
nodeType
==
TEXPR_FUNCTION_NODE
)
{
taosArrayPush
(
p
,
&
pExprInfo
->
pExpr
->
_function
.
functionName
);
taosArrayPush
(
p
,
&
pExprInfo
->
pExpr
->
_function
.
functionName
);
}
else
{
}
else
{
taosArrayPush
(
p
,
""
);
taosArrayPush
(
p
,
"
project
"
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录