Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
5151ad9a
I
Iotdb
项目概览
apache
/
Iotdb
12 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5151ad9a
编写于
4月 10, 2020
作者:
W
wshao08
提交者:
GitHub
4月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove disable align syntax within LAST query (#1016)
* remove disable align syntax within LAST query
上级
fe624997
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
19 addition
and
22 deletion
+19
-22
docs/UserGuide/5-Operation Manual/4-SQL Reference.md
docs/UserGuide/5-Operation Manual/4-SQL Reference.md
+7
-10
docs/zh/UserGuide/5-Operation Manual/4-SQL Reference.md
docs/zh/UserGuide/5-Operation Manual/4-SQL Reference.md
+7
-9
server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
...va/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
+3
-1
server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastIT.java
...est/java/org/apache/iotdb/db/integration/IoTDBLastIT.java
+1
-1
server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
...st/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
+1
-1
未找到文件。
docs/UserGuide/5-Operation Manual/4-SQL Reference.md
浏览文件 @
5151ad9a
...
...
@@ -469,20 +469,19 @@ You could expect a table like:
The LAST function returns the last time-value pair of the given timeseries. Currently filters are not supported in LAST queries.
```
SELECT LAST <SelectClause> FROM <FromClause>
<DisableAlignClause>
SELECT LAST <SelectClause> FROM <FromClause>
Select Clause : <Path> [COMMA <Path>]*
FromClause : < PrefixPath > [COMMA < PrefixPath >]*
DisableAlignClause : [DISABLE ALIGN]
Eg. SELECT LAST s1 FROM root.sg.d1
disable align
Eg. SELECT LAST s1, s2 FROM root.sg.d1
disable align
Eg. SELECT LAST s1 FROM root.sg.d1, root.sg.d2
disable align
Eg. SELECT LAST s1 FROM root.sg.d1
Eg. SELECT LAST s1, s2 FROM root.sg.d1
Eg. SELECT LAST s1 FROM root.sg.d1, root.sg.d2
Rules:
1. the statement needs to satisfy this constraint: <PrefixPath> + <Path> = <Timeseries>
2. The result set of last query will always be displayed in a
"disable-aligned" format showed below
.
For example, "select last s1, s2 from root.sg.d1, root.sg.d2
disable align
", the query result would be:
2. The result set of last query will always be displayed in a
fixed three column table format
.
For example, "select last s1, s2 from root.sg.d1, root.sg.d2", the query result would be:
| Time | Path | Value |
| --- | ------------ | ----- |
...
...
@@ -491,9 +490,7 @@ For example, "select last s1, s2 from root.sg.d1, root.sg.d2 disable align", the
| 4 | root.sg.d2.s1| 250 |
| 9 | root.sg.d2.s2| 600 |
3. LAST query syntax is expecting users to write a "diable align" keyword at the end of the query.
However, as it is a unique SQL syntax in IoTDB, IoTDB accepts LAST queries without "disable align" and treats them as "disable align" ones.
Query like "select last s1 from root.sg.d1" will be parsed exactly the same as "select last s1 from root.sg.d1 disable align".
3. It is not supported to use "diable align" in LAST query.
```
...
...
docs/zh/UserGuide/5-Operation Manual/4-SQL Reference.md
浏览文件 @
5151ad9a
...
...
@@ -457,22 +457,21 @@ root.sg1.d0.s0 is INT32 while root.sg2.d3.s0 is FLOAT.
Last 语句返回所要查询时间序列的最近时间戳的一条数据
```
SELECT LAST <SelectClause> FROM <FromClause>
<DisableAlignClause>
SELECT LAST <SelectClause> FROM <FromClause>
Select Clause : <Path> [COMMA <Path>]*
FromClause : < PrefixPath > [COMMA < PrefixPath >]*
DisableAlignClause : [DISABLE ALIGN]
Eg. SELECT LAST s1 FROM root.sg.d1
disable align
Eg. SELECT LAST s1, s2 FROM root.sg.d1
disable align
Eg. SELECT LAST s1 FROM root.sg.d1, root.sg.d2
disable align
Eg. SELECT LAST s1 FROM root.sg.d1
Eg. SELECT LAST s1, s2 FROM root.sg.d1
Eg. SELECT LAST s1 FROM root.sg.d1, root.sg.d2
规则:
1. 需要满足PrefixPath.Path 为一条完整的时间序列,即 <PrefixPath> + <Path> = <Timeseries>
2. SELECT LAST 语句不支持过滤条件.
3. 结果集以
"disable align"的形式返回,表现为总是包含三列的表格
。
例如 "select last s1, s2 from root.sg.d1, root.sg.d2
disable align
", 结果集返回如下:
3. 结果集以
三列的表格的固定形式返回
。
例如 "select last s1, s2 from root.sg.d1, root.sg.d2", 结果集返回如下:
| Time | Path | Value |
| --- | ------------ | ----- |
...
...
@@ -481,8 +480,7 @@ Eg. SELECT LAST s1 FROM root.sg.d1, root.sg.d2 disable align
| 4 | root.sg.d2.s1| 250 |
| 9 | root.sg.d2.s2| 600 |
4. SELECT LAST 查询语句要是总是和末尾的disable align在一起使用。如果用户不熟悉SELECT LAST的语法或者忘记在末尾添加"disable align",IoTDB 也会接受不包含"disable align"的SQL语句并且仍以"disable align"的形式返回结果集。
例如用户输入 "select last s1 from root.sg.d1" 所得到的查询结果与 "select last s1 from root.sg.d1 disable align". 的结果是完全相同的。
4. 注意LAST语句不支持与"disable align"关键词一起使用。
```
...
...
server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
浏览文件 @
5151ad9a
...
...
@@ -206,7 +206,9 @@ public class PhysicalGenerator {
}
if
(
queryPlan
instanceof
LastQueryPlan
)
{
// Last query result set will not be affected by alignment
queryPlan
.
setAlignByTime
(
true
);
if
(!
queryOperator
.
isAlignByTime
())
{
throw
new
QueryProcessException
(
"Disable align cannot be applied to LAST query."
);
}
List
<
Path
>
paths
=
queryOperator
.
getSelectedPaths
();
queryPlan
.
setPaths
(
paths
);
}
else
if
(
queryOperator
.
isAlignByDevice
())
{
...
...
server/src/test/java/org/apache/iotdb/db/integration/IoTDBLastIT.java
浏览文件 @
5151ad9a
...
...
@@ -121,7 +121,7 @@ public class IoTDBLastIT {
Statement
statement
=
connection
.
createStatement
())
{
boolean
hasResultSet
=
statement
.
execute
(
"select last temperature,status,id from root.ln.wf01.wt01
disable align
"
);
"select last temperature,status,id from root.ln.wf01.wt01"
);
Assert
.
assertTrue
(
hasResultSet
);
int
cnt
=
0
;
...
...
server/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
浏览文件 @
5151ad9a
...
...
@@ -610,7 +610,7 @@ public class PhysicalPlanTest {
@Test
public
void
testLastPlanPaths
()
throws
QueryProcessException
{
String
sqlStr1
=
"SELECT last s1 FROM root.vehicle.d1"
;
String
sqlStr2
=
"SELECT last s1 FROM root.vehicle.d1, root.vehicle.d2
disable align
"
;
String
sqlStr2
=
"SELECT last s1 FROM root.vehicle.d1, root.vehicle.d2"
;
PhysicalPlan
plan1
=
processor
.
parseSQLToPhysicalPlan
(
sqlStr1
);
PhysicalPlan
plan2
=
processor
.
parseSQLToPhysicalPlan
(
sqlStr2
);
Path
path1
=
new
Path
(
"root.vehicle.d1.s1"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录