Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b4bba7ee
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看板
提交
b4bba7ee
编写于
11月 08, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] Refactor the sql function parse procedure.
上级
f80294fc
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
25 addition
and
26 deletion
+25
-26
include/libs/function/function.h
include/libs/function/function.h
+2
-2
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+1
-1
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+1
-1
source/libs/function/src/tfill.c
source/libs/function/src/tfill.c
+1
-1
source/libs/parser/inc/queryInfoUtil.h
source/libs/parser/inc/queryInfoUtil.h
+1
-1
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+5
-5
source/libs/parser/src/queryInfoUtil.c
source/libs/parser/src/queryInfoUtil.c
+13
-14
未找到文件。
include/libs/function/function.h
浏览文件 @
b4bba7ee
...
...
@@ -182,8 +182,8 @@ typedef struct tExprNode {
struct
SVariant
*
pVal
;
// value node
struct
{
// function node
char
*
functionName
;
int32_t
functionId
;
char
functionName
[
FUNCTIONS_NAME_MAX_LENGTH
]
;
//
int32_t functionId;
int32_t
num
;
// Note that the attribute of pChild is not the parameter of function, it is the columns that involved in the
...
...
include/libs/parser/parser.h
浏览文件 @
b4bba7ee
...
...
@@ -175,7 +175,7 @@ typedef struct SSourceParam {
int32_t
num
;
}
SSourceParam
;
SExprInfo
*
createExprInfo
(
STableMetaInfo
*
pTableMetaInfo
,
int16_t
functionId
,
SSourceParam
*
pSource
,
SSchema
*
pResSchema
,
int16_t
interSize
);
SExprInfo
*
createExprInfo
(
STableMetaInfo
*
pTableMetaInfo
,
const
char
*
funcName
,
SSourceParam
*
pSource
,
SSchema
*
pResSchema
,
int16_t
interSize
);
int32_t
copyExprInfoList
(
SArray
*
dst
,
const
SArray
*
src
,
uint64_t
uid
,
bool
deepcopy
);
STableMetaInfo
*
getMetaInfo
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
tableIndex
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
b4bba7ee
...
...
@@ -162,7 +162,7 @@ int64_t genQueryId(void) {
static
int32_t
getExprFunctionId
(
SExprInfo
*
pExprInfo
)
{
assert
(
pExprInfo
!=
NULL
&&
pExprInfo
->
pExpr
!=
NULL
&&
pExprInfo
->
pExpr
->
nodeType
==
TEXPR_UNARYEXPR_NODE
);
return
pExprInfo
->
pExpr
->
_function
.
functionId
;
return
0
;
}
static
void
getNextTimeWindow
(
SQueryAttr
*
pQueryAttr
,
STimeWindow
*
tw
)
{
...
...
source/libs/function/src/taggfunction.c
浏览文件 @
b4bba7ee
...
...
@@ -4810,7 +4810,7 @@ SAggFunctionInfo aggFunc[35] = {{
},
{
// 33
"
_
block_dist"
,
// return table id and the corresponding tags for join match and subscribe
"block_dist"
,
// return table id and the corresponding tags for join match and subscribe
FUNCTION_TYPE_AGG
,
FUNCTION_BLKINFO
,
FUNCTION_BLKINFO
,
...
...
source/libs/function/src/tfill.c
浏览文件 @
b4bba7ee
...
...
@@ -544,7 +544,7 @@ struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, co
pFillCol
[
i
].
col
.
colId
=
pExprInfo
->
base
.
resSchema
.
colId
;
pFillCol
[
i
].
tagIndex
=
-
2
;
pFillCol
[
i
].
flag
=
pExprInfo
->
base
.
pColumns
->
flag
;
// always be the normal column for table query
pFillCol
[
i
].
functionId
=
pExprInfo
->
pExpr
->
_function
.
functionId
;
//
pFillCol[i].functionId = pExprInfo->pExpr->_function.functionId;
pFillCol
[
i
].
fillVal
.
i
=
fillVal
[
i
];
offset
+=
pExprInfo
->
base
.
resSchema
.
bytes
;
...
...
source/libs/parser/inc/queryInfoUtil.h
浏览文件 @
b4bba7ee
...
...
@@ -43,7 +43,7 @@ void addExprInfoParam(SSqlExpr* pExpr, char* argument, int32_t type, int32
void
cleanupFieldInfo
(
SFieldInfo
*
pFieldInfo
);
STableComInfo
getTableInfo
(
const
STableMeta
*
pTableMeta
);
SArray
*
extractFunctionId
List
(
SArray
*
pExprInfoList
);
SArray
*
extractFunction
List
(
SArray
*
pExprInfoList
);
#ifdef __cplusplus
}
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
b4bba7ee
...
...
@@ -1709,9 +1709,9 @@ void setResultColName(char* name, tSqlExprItem* pItem, SToken* pToken, SToken* f
}
SExprInfo
*
doAddOneExprInfo
(
SQueryStmtInfo
*
pQueryInfo
,
int16_t
functionId
,
SSourceParam
*
pSourceParam
,
int32_t
outputIndex
,
SExprInfo
*
doAddOneExprInfo
(
SQueryStmtInfo
*
pQueryInfo
,
const
char
*
funcName
,
SSourceParam
*
pSourceParam
,
int32_t
outputIndex
,
STableMetaInfo
*
pTableMetaInfo
,
SSchema
*
pResultSchema
,
int32_t
interSize
,
const
char
*
token
,
bool
finalResult
)
{
SExprInfo
*
pExpr
=
createExprInfo
(
pTableMetaInfo
,
func
tionId
,
pSourceParam
,
pResultSchema
,
interSize
);
SExprInfo
*
pExpr
=
createExprInfo
(
pTableMetaInfo
,
func
Name
,
pSourceParam
,
pResultSchema
,
interSize
);
SArray
*
pExprList
=
getCurrentExprList
(
pQueryInfo
);
addExprInfo
(
pExprList
,
outputIndex
,
pExpr
,
pQueryInfo
->
exprListLevelIndex
);
...
...
@@ -2978,8 +2978,8 @@ int32_t sqlExprToExprNode(tExprNode **pExpr, const tSqlExpr* pSqlExpr, SQuerySt
(
*
pExpr
)
->
nodeType
=
TEXPR_FUNCTION_NODE
;
(
*
pExpr
)
->
_function
.
pChild
=
p
;
(
*
pExpr
)
->
_function
.
functionId
=
functionId
;
(
*
pExpr
)
->
_function
.
functionName
=
strndup
(
pSqlExpr
->
Expr
.
operand
.
z
,
pSqlExpr
->
Expr
.
operand
.
n
);
//
(*pExpr)->_function.functionId = functionId;
strncpy
((
*
pExpr
)
->
_function
.
functionName
,
pSqlExpr
->
Expr
.
operand
.
z
,
pSqlExpr
->
Expr
.
operand
.
n
);
return
TSDB_CODE_SUCCESS
;
}
else
{
printf
(
"agg function found, %s
\n
"
,
pSqlExpr
->
exprToken
.
z
);
...
...
@@ -3826,7 +3826,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
validateSqlNode
(
p
,
pQueryInfo
,
&
buf
);
}
SArray
*
functionList
=
extractFunction
Id
List
(
pQueryInfo
->
exprList
[
0
]);
SArray
*
functionList
=
extractFunctionList
(
pQueryInfo
->
exprList
[
0
]);
extractFunctionDesc
(
functionList
,
&
pQueryInfo
->
info
);
if
((
code
=
checkForInvalidExpr
(
pQueryInfo
,
&
buf
))
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/libs/parser/src/queryInfoUtil.c
浏览文件 @
b4bba7ee
...
...
@@ -61,7 +61,7 @@ SSchema* getTableTagSchema(const STableMeta* pTableMeta) {
return
getOneColumnSchema
(
pTableMeta
,
getTableInfo
(
pTableMeta
).
numOfColumns
);
}
static
tExprNode
*
createFunctionExprNode
(
int32_t
functionId
,
struct
SSourceParam
*
pParam
)
{
//SSchema* pSchema, tExprNode* pColumnNode, int32_t numOfCols
) {
static
tExprNode
*
createFunctionExprNode
(
const
char
*
funcName
,
struct
SSourceParam
*
pParam
)
{
tExprNode
**
p
=
malloc
(
pParam
->
num
*
POINTER_BYTES
);
if
(
pParam
->
pColumnList
!=
NULL
)
{
...
...
@@ -81,7 +81,7 @@ static tExprNode* createFunctionExprNode(int32_t functionId, struct SSourceParam
tExprNode
*
pNode
=
calloc
(
1
,
sizeof
(
tExprNode
));
pNode
->
nodeType
=
TEXPR_FUNCTION_NODE
;
pNode
->
_function
.
functionId
=
functionId
;
tstrncpy
(
pNode
->
_function
.
functionName
,
funcName
,
tListLen
(
pNode
->
_function
.
functionName
))
;
pNode
->
_function
.
pChild
=
p
;
pNode
->
_function
.
num
=
pParam
->
num
;
...
...
@@ -101,7 +101,7 @@ SExprInfo* createBinaryExprInfo(tExprNode* pNode, SSchema* pResSchema) {
return
pExpr
;
}
SExprInfo
*
createExprInfo
(
STableMetaInfo
*
pTableMetaInfo
,
int16_t
functionId
,
SSourceParam
*
pSourceParam
,
SSchema
*
pResSchema
,
int16_t
interSize
)
{
SExprInfo
*
createExprInfo
(
STableMetaInfo
*
pTableMetaInfo
,
const
char
*
funcName
,
SSourceParam
*
pSourceParam
,
SSchema
*
pResSchema
,
int16_t
interSize
)
{
SExprInfo
*
pExpr
=
calloc
(
1
,
sizeof
(
SExprInfo
));
if
(
pExpr
==
NULL
)
{
return
NULL
;
...
...
@@ -120,7 +120,7 @@ SExprInfo* createExprInfo(STableMetaInfo* pTableMetaInfo, int16_t functionId, SS
memcpy
(
&
p
->
resSchema
,
pResSchema
,
sizeof
(
SSchema
));
if
(
pSourceParam
->
pExprNodeList
!=
NULL
)
{
pExpr
->
pExpr
=
createFunctionExprNode
(
func
tionId
,
pSourceParam
);
pExpr
->
pExpr
=
createFunctionExprNode
(
func
Name
,
pSourceParam
);
return
pExpr
;
}
...
...
@@ -131,16 +131,16 @@ SExprInfo* createExprInfo(STableMetaInfo* pTableMetaInfo, int16_t functionId, SS
SSchema
*
s
=
getTbnameColumnSchema
();
setColumn
(
p
->
pColumns
,
uid
,
pTableMetaInfo
->
aliasName
,
TSDB_COL_TAG
,
s
);
pExpr
->
pExpr
=
createFunctionExprNode
(
func
tionId
,
pSourceParam
);
}
else
if
(
TSDB_COL_IS_UD_COL
(
pCol
->
flag
)
||
functionId
==
FUNCTION_BLKINFO
)
{
pExpr
->
pExpr
=
createFunctionExprNode
(
func
Name
,
pSourceParam
);
}
else
if
(
TSDB_COL_IS_UD_COL
(
pCol
->
flag
)
||
strcmp
(
funcName
,
"block_dist"
)
==
0
)
{
setColumn
(
p
->
pColumns
,
uid
,
pTableMetaInfo
->
aliasName
,
TSDB_COL_UDC
,
pResSchema
);
pExpr
->
pExpr
=
createFunctionExprNode
(
func
tionId
,
pSourceParam
);
pExpr
->
pExpr
=
createFunctionExprNode
(
func
Name
,
pSourceParam
);
}
else
{
for
(
int32_t
i
=
0
;
i
<
pSourceParam
->
num
;
++
i
)
{
SColumn
*
c
=
taosArrayGetP
(
pSourceParam
->
pColumnList
,
i
);
p
->
pColumns
[
i
]
=
*
c
;
}
pExpr
->
pExpr
=
createFunctionExprNode
(
func
tionId
,
pSourceParam
);
pExpr
->
pExpr
=
createFunctionExprNode
(
func
Name
,
pSourceParam
);
}
return
pExpr
;
...
...
@@ -156,14 +156,13 @@ void addExprInfo(SArray* pExprList, int32_t index, SExprInfo* pExprInfo, int32_t
taosArrayInsert
(
pExprList
,
index
,
&
pExprInfo
);
}
printf
(
"add function, id:%
d, level:%d, total:%ld
\n
"
,
pExprInfo
->
pExpr
->
_function
.
functionId
,
level
,
taosArrayGetSize
(
pExprList
));
printf
(
"add function, id:%
s, level:%d, total:%ld
\n
"
,
pExprInfo
->
pExpr
->
_function
.
functionName
,
level
,
taosArrayGetSize
(
pExprList
));
}
void
updateExprInfo
(
SExprInfo
*
pExprInfo
,
int16_t
functionId
,
int32_t
colId
,
int16_t
srcColumnIndex
,
int16_t
resType
,
int16_t
resSize
)
{
assert
(
pExprInfo
!=
NULL
);
SSqlExpr
*
pse
=
&
pExprInfo
->
base
;
pExprInfo
->
pExpr
->
_function
.
functionId
=
functionId
;
assert
(
0
);
pse
->
resSchema
.
type
=
resType
;
...
...
@@ -172,7 +171,7 @@ void updateExprInfo(SExprInfo* pExprInfo, int16_t functionId, int32_t colId, int
SExprInfo
*
getExprInfo
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
index
)
{
assert
(
pQueryInfo
!=
NULL
&&
pQueryInfo
->
exprList
&&
index
>=
0
);
return
taosArrayGetP
(
pQueryInfo
->
exprList
,
index
);
return
taosArrayGetP
(
getCurrentExprList
(
pQueryInfo
->
exprList
)
,
index
);
}
void
destroyExprInfo
(
SExprInfo
*
pExprInfo
)
{
...
...
@@ -214,7 +213,7 @@ void addExprInfoParam(SSqlExpr* pExpr, char* argument, int32_t type, int32_t byt
int32_t
getExprFunctionId
(
SExprInfo
*
pExprInfo
)
{
assert
(
pExprInfo
!=
NULL
&&
pExprInfo
->
pExpr
!=
NULL
&&
pExprInfo
->
pExpr
->
nodeType
==
TEXPR_UNARYEXPR_NODE
);
return
pExprInfo
->
pExpr
->
_function
.
functionId
;
return
0
;
}
void
assignExprInfo
(
SExprInfo
*
dst
,
const
SExprInfo
*
src
)
{
...
...
@@ -310,14 +309,14 @@ int32_t getResRowLength(SArray* pExprList) {
return
size
;
}
SArray
*
extractFunction
Id
List
(
SArray
*
pExprInfoList
)
{
SArray
*
extractFunctionList
(
SArray
*
pExprInfoList
)
{
assert
(
pExprInfoList
!=
NULL
);
size_t
len
=
taosArrayGetSize
(
pExprInfoList
);
SArray
*
p
=
taosArrayInit
(
len
,
sizeof
(
int32_t
));
for
(
int32_t
i
=
0
;
i
<
len
;
++
i
)
{
SExprInfo
*
pExprInfo
=
taosArrayGetP
(
pExprInfoList
,
i
);
taosArrayPush
(
p
,
&
pExprInfo
->
pExpr
->
_function
.
function
Id
);
taosArrayPush
(
p
,
&
pExprInfo
->
pExpr
->
_function
.
function
Name
);
}
return
p
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录