Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
4454b077
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4454b077
编写于
9月 15, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1456]
上级
4d6e0ef4
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
53 addition
and
12 deletion
+53
-12
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+20
-9
src/common/src/tname.c
src/common/src/tname.c
+2
-3
tests/script/general/parser/lastrow_query.sim
tests/script/general/parser/lastrow_query.sim
+31
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
4454b077
...
...
@@ -2601,7 +2601,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery) {
continue
;
}
if
(
functionId
==
TSDB_FUNC_PRJ
&&
pExpr1
->
colInfo
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
if
(
functionId
==
TSDB_FUNC_PRJ
&&
(
pExpr1
->
colInfo
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
||
TSDB_COL_IS_UD_COL
(
pExpr1
->
colInfo
.
flag
))
)
{
continue
;
}
...
...
@@ -5246,7 +5246,8 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
->
functionId
!=
TSDB_FUNC_TAG_DUMMY
&&
pExpr
->
functionId
!=
TSDB_FUNC_TS_DUMMY
)
{
if
((
pExpr
->
functionId
!=
TSDB_FUNC_TAG_DUMMY
&&
pExpr
->
functionId
!=
TSDB_FUNC_TS_DUMMY
)
&&
!
(
pExpr
->
functionId
==
TSDB_FUNC_PRJ
&&
TSDB_COL_IS_UD_COL
(
pExpr
->
colInfo
.
flag
)))
{
SSchema
*
pColSchema
=
&
pSchema
[
pExpr
->
colInfo
.
colIndex
];
getResultDataInfo
(
pColSchema
->
type
,
pColSchema
->
bytes
,
pExpr
->
functionId
,
(
int32_t
)
pExpr
->
param
[
0
].
i64Key
,
&
pExpr
->
resType
,
&
pExpr
->
resBytes
,
&
pExpr
->
interBytes
,
tagLength
,
true
);
...
...
@@ -5354,16 +5355,23 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd)
const
char
*
msg1
=
"only one selectivity function allowed in presence of tags function"
;
const
char
*
msg3
=
"aggregation function should not be mixed up with projection"
;
bool
tagColExists
=
false
;
bool
tag
Ts
ColExists
=
false
;
int16_t
numOfSelectivity
=
0
;
int16_t
numOfAggregation
=
0
;
// todo is 0??
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
bool
isSTable
=
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
);
if
(
!
isSTable
)
{
return
TSDB_CODE_SUCCESS
;
}
size_t
numOfExprs
=
taosArrayGetSize
(
pQueryInfo
->
exprList
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
i
);
if
(
pExpr
->
functionId
==
TSDB_FUNC_TAGPRJ
||
(
pExpr
->
functionId
==
TSDB_FUNC_PRJ
&&
pExpr
->
colInfo
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
))
{
tagColExists
=
true
;
// selectivity + ts/tag column
tag
Ts
ColExists
=
true
;
// selectivity + ts/tag column
break
;
}
}
...
...
@@ -5384,7 +5392,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd)
}
}
if
(
tagColExists
)
{
// check if the selectivity function exists
if
(
tag
Ts
ColExists
)
{
// check if the selectivity function exists
// When the tag projection function on tag column that is not in the group by clause, aggregation function and
// selectivity function exist in select clause is not allowed.
if
(
numOfAggregation
>
0
)
{
...
...
@@ -5407,13 +5415,16 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, SSqlCmd* pCmd)
* Otherwise, return with error code.
*/
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
int16_t
functionId
=
tscSqlExprGet
(
pQueryInfo
,
i
)
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TAGPRJ
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
int16_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TAGPRJ
||
(
aAggs
[
functionId
].
nStatus
&
TSDB_FUNCSTATE_SELECTIVITY
)
==
0
)
{
continue
;
}
if
(((
aAggs
[
functionId
].
nStatus
&
TSDB_FUNCSTATE_SELECTIVITY
)
!=
0
)
&&
(
functionId
!=
TSDB_FUNC_LAST_ROW
))
{
if
((
functionId
==
TSDB_FUNC_LAST_ROW
)
||
(
functionId
==
TSDB_FUNC_LAST_DST
&&
(
pExpr
->
colInfo
.
flag
&
TSDB_COL_NULL
)
!=
0
))
{
// do nothing
}
else
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
}
...
...
src/common/src/tname.c
浏览文件 @
4454b077
...
...
@@ -62,10 +62,9 @@ SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const
if
(
name
!=
NULL
)
{
tstrncpy
(
s
.
name
,
name
,
sizeof
(
s
.
name
));
}
else
{
size_t
len
=
strdequote
(
exprStr
->
z
);
size_t
tlen
=
MIN
(
sizeof
(
s
.
name
),
len
+
1
);
size_t
tlen
=
MIN
(
sizeof
(
s
.
name
),
exprStr
->
n
+
1
);
tstrncpy
(
s
.
name
,
exprStr
->
z
,
tlen
);
strdequote
(
s
.
name
);
}
return
s
;
...
...
tests/script/general/parser/lastrow_query.sim
浏览文件 @
4454b077
...
...
@@ -172,3 +172,34 @@ sql select last_row(*) from m1 where tbname in ('t1')
if $rows != 0 then
return -1
endi
sql insert into t1 values('2019-1-1 1:1:1', 1);
print ===================> last_row query against normal table along with ts/tbname
sql select last_row(*),ts,'k' from t1;
if $rows != 1 then
return -1
endi
print ===================> last_row + user-defined column + normal tables
sql select last_row(ts), 'abc', 1234.9384, ts from t1
if $rows != 1 then
return -1
endi
if $data02 != 'abc' then
return -1
endi
if $data03 != 1234.938400000 then
return -1
endi
if $data04 != @2019-01-01 01:01:01.000@ then
return -1
endi
print ===================> last_row + stable + ts/tag column + condition + udf
sql select last_row(*), ts, 'abc', 123.981, tbname from m1
if $rows != 1 then
return -1
endi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录