Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fadd69c6
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看板
提交
fadd69c6
编写于
11月 15, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] refactor and add test cases.
上级
b7f8ee37
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
29 deletion
+27
-29
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+27
-29
未找到文件。
source/libs/parser/src/astValidate.c
浏览文件 @
fadd69c6
...
...
@@ -2652,14 +2652,12 @@ static int32_t validateScalarFunctionParamNum(tSqlExpr* pSqlExpr, int32_t functi
return
code
;
}
// todo merge with the addScalarExprAndResColumn
int32_t
doAddOneProjectCol
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
SSchema
*
pSchema
,
const
char
*
aliasName
,
int32_t
colId
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
name
=
(
aliasName
==
NULL
)
?
pSchema
->
name
:
aliasName
;
SSchema
s
=
createSchema
(
pSchema
->
type
,
pSchema
->
bytes
,
colId
,
name
);
tExprNode
*
pNode
=
NULL
;
bool
keepTableCols
=
true
;
SArray
*
pColumnList
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
SToken
colNameToken
=
{.
z
=
pSchema
->
name
,
.
n
=
strlen
(
pSchema
->
name
)};
...
...
@@ -2667,7 +2665,9 @@ int32_t doAddOneProjectCol(SQueryStmtInfo* pQueryInfo, int32_t outputColIndex, S
sqlNode
.
type
=
SQL_NODE_TABLE_COLUMN
;
sqlNode
.
columnName
=
colNameToken
;
int32_t
ret
=
sqlExprToExprNode
(
&
pNode
,
&
sqlNode
,
pQueryInfo
,
pColumnList
,
&
keepTableCols
,
pMsgBuf
);
tExprNode
*
pNode
=
NULL
;
bool
keepTableCols
=
true
;
int32_t
ret
=
sqlExprToExprNode
(
&
pNode
,
&
sqlNode
,
pQueryInfo
,
pColumnList
,
&
keepTableCols
,
pMsgBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tExprTreeDestroy
(
pNode
,
NULL
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
"invalid expression in select clause"
);
...
...
@@ -2689,6 +2689,12 @@ int32_t doAddOneProjectCol(SQueryStmtInfo* pQueryInfo, int32_t outputColIndex, S
}
pExpr
->
base
.
numOfCols
=
num
;
if
(
pQueryInfo
->
exprListLevelIndex
==
0
)
{
int32_t
exists
=
getNumOfFields
(
&
pQueryInfo
->
fieldsInfo
);
addResColumnInfo
(
pQueryInfo
,
exists
,
&
pExpr
->
base
.
resSchema
,
pExpr
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2923,17 +2929,29 @@ static tExprNode* doCreateColumnNode(SQueryStmtInfo* pQueryInfo, SColumnIndex* p
pExpr
->
nodeType
=
TEXPR_COL_NODE
;
pExpr
->
pSchema
=
calloc
(
1
,
sizeof
(
SSchema
));
SSchema
*
pSchema
=
getOneColumnSchema
(
pTableMeta
,
pIndex
->
columnIndex
);
SSchema
*
pSchema
=
NULL
;
if
(
pIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
pSchema
=
getTbnameColumnSchema
();
}
else
{
pSchema
=
getOneColumnSchema
(
pTableMeta
,
pIndex
->
columnIndex
);
}
*
(
SSchema
*
)(
pExpr
->
pSchema
)
=
*
pSchema
;
if
(
keepTableCols
)
{
if
(
keepTableCols
&&
TSDB_COL_IS_NORMAL_COL
(
pIndex
->
type
)
)
{
SColumn
c
=
createColumn
(
pTableMeta
->
uid
,
pTableMetaInfo
->
aliasName
,
pIndex
->
type
,
pExpr
->
pSchema
);
taosArrayPush
(
pCols
,
&
c
);
}
columnListInsert
(
pQueryInfo
->
colList
,
pTableMeta
->
uid
,
pSchema
,
TSDB_COL_NORMAL
);
SSchema
*
pTsSchema
=
getOneColumnSchema
(
pTableMeta
,
0
);
insertPrimaryTsColumn
(
pQueryInfo
->
colList
,
pTsSchema
->
name
,
pTableMeta
->
uid
);
if
(
TSDB_COL_IS_NORMAL_COL
(
pIndex
->
type
))
{
columnListInsert
(
pQueryInfo
->
colList
,
pTableMeta
->
uid
,
pSchema
,
TSDB_COL_NORMAL
);
SSchema
*
pTsSchema
=
getOneColumnSchema
(
pTableMeta
,
0
);
insertPrimaryTsColumn
(
pQueryInfo
->
colList
,
pTsSchema
->
name
,
pTableMeta
->
uid
);
}
else
{
columnListInsert
(
pTableMetaInfo
->
tagColList
,
pTableMeta
->
uid
,
pSchema
,
TSDB_COL_TAG
);
}
return
pExpr
;
}
...
...
@@ -3231,26 +3249,6 @@ int32_t sqlExprToExprNode(tExprNode **pExpr, const tSqlExpr* pSqlExpr, SQueryStm
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
multiColumnListInsert
(
SQueryStmtInfo
*
pQueryInfo
,
SArray
*
pColumnList
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"tag can not be used in expression"
;
SColumn
*
p1
=
taosArrayGet
(
pColumnList
,
0
);
size_t
numOfNode
=
taosArrayGetSize
(
pColumnList
);
for
(
int32_t
k
=
0
;
k
<
numOfNode
;
++
k
)
{
SColumn
*
p
=
taosArrayGet
(
pColumnList
,
k
);
if
(
TSDB_COL_IS_TAG
(
p
->
flag
))
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
SSchema
s
=
createSchema
(
p
->
info
.
type
,
p
->
info
.
bytes
,
p
->
info
.
colId
,
p
->
name
);
columnListInsert
(
pQueryInfo
->
colList
,
p
->
uid
,
&
s
,
p
->
flag
);
}
insertPrimaryTsColumn
(
pQueryInfo
->
colList
,
NULL
,
p1
->
uid
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
addScalarExprAndResColumn
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
exprIndex
,
tSqlExprItem
*
pItem
,
SMsgBuf
*
pMsgBuf
)
{
SArray
*
pColumnList
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
SSchema
s
=
createSchema
(
TSDB_DATA_TYPE_DOUBLE
,
sizeof
(
double
),
getNewResColId
(),
""
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录