This is an automated email from the ASF dual-hosted git repository.

rong pushed a commit to branch nested-operations
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/nested-operations by this push:
     new ebad755  add user doc for nested queries
ebad755 is described below

commit ebad755b267700f4d3ff052961fc022c01682aa6
Author: Steve Yurong Su <[email protected]>
AuthorDate: Wed Sep 22 18:00:47 2021 +0800

    add user doc for nested queries
---
 .../DML-Data-Manipulation-Language.md              | 67 ++++++++++++++++++++
 .../DML-Data-Manipulation-Language.md              | 71 +++++++++++++++++++++-
 site/src/main/.vuepress/config.js                  |  4 +-
 3 files changed, 138 insertions(+), 4 deletions(-)

diff --git 
a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md 
b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index 17ac0b8..76e1bc9 100644
--- a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -427,6 +427,73 @@ It costs 0.014s
 
 Please refer to [UDF (User Defined 
Function)](../Advanced-Features/UDF-User-Defined-Function.md).
 
+Known Implementation UDF Libraries:
+
++ [IoTDB-Quality](https://thulab.github.io/iotdb-quality), a UDF library about 
data quality, including data profiling, data quality evalution and data 
repairing, etc.
+
+### Nested Query (Subquery)
+
+"Nested query" is also called "subquery", that is, in a SQL statement, the 
result of the "inner query" can be used as the input of the "outer query".
+
+IoTDB supports the execution of arbitrary nested expressions consisting of 
**time series, arithmetic expressions, and time series generation functions 
(including user-defined functions)** in the `select` clause.
+
+#### Syntax
+
+The following is the syntax definition of the `select` clause:
+
+```sql
+selectClause
+    : SELECT resultColumn (',' resultColumn)*
+    ;
+
+resultColumn
+    : expression (AS ID)?
+    ;
+
+expression
+    : '(' expression ')'
+    | '-' expression
+    | expression ('*' | '/' | '%') expression
+    | expression ('+' | '-') expression
+    | functionName '(' expression (',' expression)* functionAttribute* ')'
+    | timeSeriesSuffixPath
+    ;
+```
+
+#### Example
+
+SQL: 
+
+```sql
+select 
+  a, 
+  b, 
+  sin(a + sin(a + sin(b))), 
+  -(a + b) * (sin(a + b) * sin(a + b) + cos(a + b) * cos(a + b)) 
+from root.sg1.d1;
+```
+
+Result:
+
+```
++-----------------------------+-------------+-------------+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|                         Time|root.sg1.d1.a|root.sg1.d1.b|sin(root.sg1.d1.a + 
sin(root.sg1.d1.a + sin(root.sg1.d1.b)))|-root.sg1.d1.a + root.sg1.d1.b * 
sin(root.sg1.d1.a + root.sg1.d1.b) * sin(root.sg1.d1.a + root.sg1.d1.b) + 
cos(root.sg1.d1.a + root.sg1.d1.b) * cos(root.sg1.d1.a + root.sg1.d1.b)|
++-----------------------------+-------------+-------------+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|1970-01-01T08:00:00.000+08:00|            0|            0|                    
                                     0.0|                                       
                                                                                
                                                       -0.0|
+|1970-01-01T08:00:00.001+08:00|            1|            1|                    
                      0.9238430524420609|                                       
                                                                                
                                                       -2.0|
+|1970-01-01T08:00:00.002+08:00|            2|            2|                    
                      0.7903505371876317|                                       
                                                                                
                                                       -4.0|
+|1970-01-01T08:00:00.003+08:00|            3|            3|                    
                     0.14065207680386618|                                       
                                                                                
                                         -5.999999999999999|
+|1970-01-01T08:00:00.004+08:00|            4|            4|                    
                     -0.6867272852305377|                                       
                                                                                
                                                       -8.0|
+|1970-01-01T08:00:00.005+08:00|            5|            5|                    
                     -0.8797812615294988|                                       
                                                                                
                                                      -10.0|
+|1970-01-01T08:00:00.006+08:00|            6|            6|                    
                     -0.7288037411970917|                                       
                                                                                
                                                      -12.0|
+|1970-01-01T08:00:00.007+08:00|            7|            7|                    
                      0.9919871278709939|                                       
                                                                                
                                                      -14.0|
+|1970-01-01T08:00:00.008+08:00|            8|            8|                    
                      0.8430810955779515|                                       
                                                                                
                                                      -16.0|
+|1970-01-01T08:00:00.009+08:00|            9|            9|                    
                      0.4005516488102476|                                       
                                                                                
                                                      -18.0|
++-----------------------------+-------------+-------------+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+Total line number = 10
+It costs 0.029s
+```
+
 ### Aggregate Query
 
 This section mainly introduces the related examples of aggregate query.
diff --git 
a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md 
b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index fdd21dc..4795de2 100644
--- a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -432,11 +432,78 @@ Total line number = 5
 It costs 0.014s
 ```
 
-#### 自定义序列生成函数
+#### 自定义时间序列生成函数
 
 请参考 [UDF (用户定义函数)](../Advanced-Features/UDF-User-Defined-Function.md)。
 
-### 聚合函数
+已知的自定义时间序列生成函数库实现:
+
++ [IoTDB-Quality](https://thulab.github.io/iotdb-quality),一个关于数据质量的 UDF 
库实现,包括数据画像、数据质量评估与修复等一系列函数。
+
+### 嵌套查询(子查询)
+
+“嵌套查询”又称为“子查询,即在一条 SQL 语句中,“内层查询”的计算结果可以作为“外层查询”的计算对象来使用。
+
+IoTDB 支持在 `select` 字句中执行由**时间序列、算数运算表达式和时间序列生成函数(包括用户自定义函数)**组成的任意嵌套表达式。
+
+#### 语法
+
+下面是 `select` 子句的语法定义:
+
+```sql
+selectClause
+    : SELECT resultColumn (',' resultColumn)*
+    ;
+
+resultColumn
+    : expression (AS ID)?
+    ;
+
+expression
+    : '(' expression ')'
+    | '-' expression
+    | expression ('*' | '/' | '%') expression
+    | expression ('+' | '-') expression
+    | functionName '(' expression (',' expression)* functionAttribute* ')'
+    | timeSeriesSuffixPath
+    ;
+```
+
+#### 示例
+
+输入:
+
+```sql
+select 
+  a, 
+  b, 
+  sin(a + sin(a + sin(b))), 
+  -(a + b) * (sin(a + b) * sin(a + b) + cos(a + b) * cos(a + b)) 
+from root.sg1.d1;
+```
+
+结果:
+
+```
++-----------------------------+-------------+-------------+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|                         Time|root.sg1.d1.a|root.sg1.d1.b|sin(root.sg1.d1.a + 
sin(root.sg1.d1.a + sin(root.sg1.d1.b)))|-root.sg1.d1.a + root.sg1.d1.b * 
sin(root.sg1.d1.a + root.sg1.d1.b) * sin(root.sg1.d1.a + root.sg1.d1.b) + 
cos(root.sg1.d1.a + root.sg1.d1.b) * cos(root.sg1.d1.a + root.sg1.d1.b)|
++-----------------------------+-------------+-------------+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|1970-01-01T08:00:00.000+08:00|            0|            0|                    
                                     0.0|                                       
                                                                                
                                                       -0.0|
+|1970-01-01T08:00:00.001+08:00|            1|            1|                    
                      0.9238430524420609|                                       
                                                                                
                                                       -2.0|
+|1970-01-01T08:00:00.002+08:00|            2|            2|                    
                      0.7903505371876317|                                       
                                                                                
                                                       -4.0|
+|1970-01-01T08:00:00.003+08:00|            3|            3|                    
                     0.14065207680386618|                                       
                                                                                
                                         -5.999999999999999|
+|1970-01-01T08:00:00.004+08:00|            4|            4|                    
                     -0.6867272852305377|                                       
                                                                                
                                                       -8.0|
+|1970-01-01T08:00:00.005+08:00|            5|            5|                    
                     -0.8797812615294988|                                       
                                                                                
                                                      -10.0|
+|1970-01-01T08:00:00.006+08:00|            6|            6|                    
                     -0.7288037411970917|                                       
                                                                                
                                                      -12.0|
+|1970-01-01T08:00:00.007+08:00|            7|            7|                    
                      0.9919871278709939|                                       
                                                                                
                                                      -14.0|
+|1970-01-01T08:00:00.008+08:00|            8|            8|                    
                      0.8430810955779515|                                       
                                                                                
                                                      -16.0|
+|1970-01-01T08:00:00.009+08:00|            9|            9|                    
                      0.4005516488102476|                                       
                                                                                
                                                      -18.0|
++-----------------------------+-------------+-------------+------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+Total line number = 10
+It costs 0.029s
+```
+
+### 聚合查询
 
 本章节主要介绍聚合查询的相关示例,
 主要使用的是 IoTDB SELECT 语句的聚合查询函数。
diff --git a/site/src/main/.vuepress/config.js 
b/site/src/main/.vuepress/config.js
index 4e478da..619c26e 100644
--- a/site/src/main/.vuepress/config.js
+++ b/site/src/main/.vuepress/config.js
@@ -688,7 +688,7 @@ var config = {
                                        },
                                        {
                                                title: 'IoTDB-SQL Language',
-                                               sidebarDepth: 1,
+                                               sidebarDepth: 2,
                                                children: [
                                                        
['IoTDB-SQL-Language/DDL-Data-Definition-Language','DDL (Data Definition 
Language)'],
                                                        
['IoTDB-SQL-Language/DML-Data-Manipulation-Language','DML (Data Manipulation 
Language)'],
@@ -1484,7 +1484,7 @@ var config = {
                                        },
                                        {
                                                title: 'IoTDB-SQL 语言',
-                                               sidebarDepth: 1,
+                                               sidebarDepth: 2,
                                                children: [
                                                        
['IoTDB-SQL-Language/DDL-Data-Definition-Language','数据定义语言(DDL)'],
                                                        
['IoTDB-SQL-Language/DML-Data-Manipulation-Language','数据操作语言(DML)'],

Reply via email to