Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d09d9a2e
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
d09d9a2e
编写于
6月 02, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-4520]<enhance>: support the tbname column alias name.
上级
0d7a58f0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
12 deletion
+28
-12
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+16
-6
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+6
-6
tests/script/general/parser/nestquery.sim
tests/script/general/parser/nestquery.sim
+6
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
d09d9a2e
...
...
@@ -1931,8 +1931,10 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
}
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
SSchema
*
colSchema
=
tGetTbnameColumnSchema
();
tscAddFuncInSelectClause
(
pQueryInfo
,
startPos
,
TSDB_FUNC_TAGPRJ
,
&
index
,
colSchema
,
TSDB_COL_TAG
,
getNewResColId
(
pCmd
));
SSchema
colSchema
=
*
tGetTbnameColumnSchema
();
getColumnName
(
pItem
,
colSchema
.
name
,
colSchema
.
name
,
sizeof
(
colSchema
.
name
)
-
1
);
/*SExprInfo* pExpr = */
tscAddFuncInSelectClause
(
pQueryInfo
,
startPos
,
TSDB_FUNC_TAGPRJ
,
&
index
,
&
colSchema
,
TSDB_COL_TAG
,
getNewResColId
(
pCmd
));
}
else
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
...
...
@@ -3887,7 +3889,8 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
return
code
;
}
if
(
index
.
columnIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// query on time range
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
index
.
columnIndex
);
if
(
pSchema
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
// query on time range
if
(
!
validateJoinExprNode
(
pCmd
,
pQueryInfo
,
*
pExpr
,
&
index
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
...
...
@@ -6754,6 +6757,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
const
char
*
msg5
=
"sql too long"
;
// todo ADD support
const
char
*
msg6
=
"from missing in subclause"
;
const
char
*
msg7
=
"time interval is required"
;
const
char
*
msg8
=
"the first column should be primary timestamp column"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
...
...
@@ -6807,13 +6811,19 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
isTimeWindowQuery
(
pQueryInfo
)
&&
(
validateFunctionsInIntervalOrGroupbyQuery
(
pCmd
,
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
if
(
!
tscIsProjectionQuery
(
pQueryInfo
)
&&
pQueryInfo
->
interval
.
interval
==
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
if
(
tscIsProjectionQuery
(
pQueryInfo
))
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
0
);
if
(
pExpr
->
base
.
colInfo
.
colId
!=
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg8
);
}
}
else
{
if
(
pQueryInfo
->
interval
.
interval
==
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
}
}
// set the created table[stream] name
...
...
src/query/src/qAggMain.c
浏览文件 @
d09d9a2e
...
...
@@ -4481,7 +4481,7 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
static
double
do_calc_rate
(
const
SRateInfo
*
pRateInfo
,
int64_t
tickPerSec
)
{
if
((
INT64_MIN
==
pRateInfo
->
lastKey
)
||
(
INT64_MIN
==
pRateInfo
->
firstKey
)
||
(
pRateInfo
->
firstKey
>=
pRateInfo
->
lastKey
))
{
return
0
;
return
0
.
0
;
}
double
diff
=
0
;
...
...
@@ -4504,7 +4504,7 @@ static double do_calc_rate(const SRateInfo* pRateInfo, int64_t tickPerSec) {
return
0
;
}
return
(
duration
>
0
)
?
((
double
)
diff
)
/
(
duration
/
((
double
)
tickPerSec
))
:
0
;
return
(
duration
>
0
)
?
((
double
)
diff
)
/
(
duration
/
((
double
)
tickPerSec
))
:
0
.
0
;
}
static
bool
rate_function_setup
(
SQLFunctionCtx
*
pCtx
)
{
...
...
@@ -4545,7 +4545,7 @@ static void rate_function(SQLFunctionCtx *pCtx) {
notNullElems
++
;
int64_t
v
=
0
;
GET_TYPED_DATA
(
v
,
int64_t
,
pCtx
->
inputType
,
pData
);
GET_TYPED_DATA
(
v
,
double
,
pCtx
->
inputType
,
pData
);
if
((
INT64_MIN
==
pRateInfo
->
firstValue
)
||
(
INT64_MIN
==
pRateInfo
->
firstKey
))
{
pRateInfo
->
firstValue
=
v
;
...
...
@@ -4592,7 +4592,7 @@ static void rate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
TSKEY
*
primaryKey
=
GET_TS_LIST
(
pCtx
);
int64_t
v
=
0
;
GET_TYPED_DATA
(
v
,
int64_t
,
pCtx
->
inputType
,
pData
);
GET_TYPED_DATA
(
v
,
double
,
pCtx
->
inputType
,
pData
);
if
((
INT64_MIN
==
pRateInfo
->
firstValue
)
||
(
INT64_MIN
==
pRateInfo
->
firstKey
))
{
pRateInfo
->
firstValue
=
v
;
...
...
@@ -4637,7 +4637,7 @@ static void rate_finalizer(SQLFunctionCtx *pCtx) {
return
;
}
*
(
double
*
)
pCtx
->
pOutput
=
do_calc_rate
(
pRateInfo
,
TSDB_TICK_PER_SECOND
(
pCtx
->
param
[
0
].
i64
));
*
(
double
*
)
pCtx
->
pOutput
=
do_calc_rate
(
pRateInfo
,
TSDB_TICK_PER_SECOND
(
pCtx
->
param
[
0
].
i64
));
// cannot set the numOfIteratedElems again since it is set during previous iteration
pResInfo
->
numOfRes
=
1
;
...
...
@@ -4702,7 +4702,7 @@ static void irate_function_f(SQLFunctionCtx *pCtx, int32_t index) {
TSKEY
*
primaryKey
=
GET_TS_LIST
(
pCtx
);
int64_t
v
=
0
;
GET_TYPED_DATA
(
v
,
int64_t
,
pCtx
->
inputType
,
pData
);
GET_TYPED_DATA
(
v
,
double
,
pCtx
->
inputType
,
pData
);
pRateInfo
->
firstKey
=
pRateInfo
->
lastKey
;
pRateInfo
->
firstValue
=
pRateInfo
->
lastValue
;
...
...
tests/script/general/parser/nestquery.sim
浏览文件 @
d09d9a2e
...
...
@@ -124,6 +124,12 @@ if $rows != 2 then
return -1
endi
sql select * from (select count(*) a from nest_mt0 group by tbname) t where t.a<0
if $rows != 0 then
return -1
endi
print ===================> nest query interval
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录