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

xiaoyekanren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iotdb-docs.git


The following commit(s) were added to refs/heads/main by this push:
     new e4992eae add if in table basic function from 2091 (#1090)
e4992eae is described below

commit e4992eaef5a99429e49cd94e1c148d6ed5e7ba1a
Author: leto-b <[email protected]>
AuthorDate: Thu Apr 23 17:44:56 2026 +0800

    add if in table basic function from 2091 (#1090)
---
 .../Table/SQL-Manual/Basis-Function_apache.md      | 44 +++++++++++++++++++
 .../Table/SQL-Manual/Basis-Function_timecho.md     | 45 ++++++++++++++++++++
 .../SQL-Manual/Basis-Function_apache.md            | 44 +++++++++++++++++++
 .../SQL-Manual/Basis-Function_timecho.md           | 45 ++++++++++++++++++++
 .../Table/SQL-Manual/Basis-Function_apache.md      | 49 +++++++++++++++++++++-
 .../Table/SQL-Manual/Basis-Function_timecho.md     | 49 ++++++++++++++++++++++
 .../SQL-Manual/Basis-Function_apache.md            | 47 +++++++++++++++++++++
 .../SQL-Manual/Basis-Function_timecho.md           | 49 ++++++++++++++++++++++
 8 files changed, 371 insertions(+), 1 deletion(-)

diff --git a/src/UserGuide/Master/Table/SQL-Manual/Basis-Function_apache.md 
b/src/UserGuide/Master/Table/SQL-Manual/Basis-Function_apache.md
index 575551b3..96564dbc 100644
--- a/src/UserGuide/Master/Table/SQL-Manual/Basis-Function_apache.md
+++ b/src/UserGuide/Master/Table/SQL-Manual/Basis-Function_apache.md
@@ -1286,6 +1286,50 @@ Returns the first non-null value from the given list of 
parameters.
 coalesce(value1, value2[, ...])
 ```
 
+### 7.3 IF Expression
+The IF expression has two forms: one that specifies only the true value, and 
another that specifies both the true value and the false value.
+
+| Form                                         | Description                   
                                                                                
                       | Output Type Restrictions |
+| ---------------------------------------------- | 
------------------------------------------------------------------------------------------------------------------------------------
 | ------------------------ |
+| `IF(condition, true_value)`              | If the condition evaluates to 
true, `true_value` is computed and returned; otherwise, `null` is returned and 
`true_value` is not evaluated. | — |
+| `IF(condition, true_value, false_value)` | If the condition evaluates to 
true, `true_value` is computed and returned; otherwise, `false_value` is 
computed and returned. | The data types of `true_value` and `false_value` 
**must be exactly the same**. Implicit type conversion is not supported. |
+
+> Supported since V2.0.9-beta
+
+**Examples:**
+
+1. Equivalent examples of IF and CASE expressions:
+```SQL
+-- IF syntax
+SELECT 
+  device_id,
+  temperature,  
+  IF(temperature > 85, 'High Value', 'Low Value')
+FROM table1;
+
+-- Equivalent CASE syntax
+SELECT
+  device_id,  
+  temperature,  
+  CASE    
+    WHEN temperature > 85 THEN 'High Value'
+    ELSE 'Low Value'  
+  END
+FROM table1;
+```
+
+2. Output type restriction examples:
+```SQL
+-- Succeeds
+-- temperature (float) and humidity (float) have matching types
+SELECT IF(temperature > 85, temperature, humidity) FROM table1;
+
+-- Fails
+-- temperature (float) and status (boolean) have mismatched types
+SELECT IF(temperature > 85, temperature, status) FROM table1;
+```
+
+
 ## 8. Conversion Functions
 
 ### 8.1 Conversion Functions
diff --git a/src/UserGuide/Master/Table/SQL-Manual/Basis-Function_timecho.md 
b/src/UserGuide/Master/Table/SQL-Manual/Basis-Function_timecho.md
index 7f354dc8..caf0988b 100644
--- a/src/UserGuide/Master/Table/SQL-Manual/Basis-Function_timecho.md
+++ b/src/UserGuide/Master/Table/SQL-Manual/Basis-Function_timecho.md
@@ -1287,6 +1287,51 @@ Returns the first non-null value from the given list of 
parameters.
 coalesce(value1, value2[, ...])
 ```
 
+### 7.3 IF Expression
+
+The IF expression has two forms: one that specifies only the true value, and 
another that specifies both the true value and the false value.
+
+| Form                                         | Description                   
                                                                                
                       | Output Type Restrictions |
+| ---------------------------------------------- | 
------------------------------------------------------------------------------------------------------------------------------------
 | ------------------------ |
+| `IF(condition, true_value)`              | If the condition evaluates to 
true, `true_value` is computed and returned; otherwise, `null` is returned and 
`true_value` is not evaluated. | — |
+| `IF(condition, true_value, false_value)` | If the condition evaluates to 
true, `true_value` is computed and returned; otherwise, `false_value` is 
computed and returned. | The data types of `true_value` and `false_value` 
**must be exactly the same**. Implicit type conversion is not supported. |
+
+> Supported since V2.0.9.1
+
+**Examples:**
+
+1. Equivalent examples of IF and CASE expressions:
+```SQL
+-- IF syntax
+SELECT 
+  device_id,
+  temperature,  
+  IF(temperature > 85, 'High Value', 'Low Value')
+FROM table1;
+
+-- Equivalent CASE syntax
+SELECT
+  device_id,  
+  temperature,  
+  CASE    
+    WHEN temperature > 85 THEN 'High Value'
+    ELSE 'Low Value'  
+  END
+FROM table1;
+```
+
+2. Output type restriction examples:
+```SQL
+-- Succeeds
+-- temperature (float) and humidity (float) have matching types
+SELECT IF(temperature > 85, temperature, humidity) FROM table1;
+
+-- Fails
+-- temperature (float) and status (boolean) have mismatched types
+SELECT IF(temperature > 85, temperature, status) FROM table1;
+```
+
+
 ## 8. Conversion Functions
 
 ### 8.1 Conversion Functions
diff --git a/src/UserGuide/latest-Table/SQL-Manual/Basis-Function_apache.md 
b/src/UserGuide/latest-Table/SQL-Manual/Basis-Function_apache.md
index 575551b3..96564dbc 100644
--- a/src/UserGuide/latest-Table/SQL-Manual/Basis-Function_apache.md
+++ b/src/UserGuide/latest-Table/SQL-Manual/Basis-Function_apache.md
@@ -1286,6 +1286,50 @@ Returns the first non-null value from the given list of 
parameters.
 coalesce(value1, value2[, ...])
 ```
 
+### 7.3 IF Expression
+The IF expression has two forms: one that specifies only the true value, and 
another that specifies both the true value and the false value.
+
+| Form                                         | Description                   
                                                                                
                       | Output Type Restrictions |
+| ---------------------------------------------- | 
------------------------------------------------------------------------------------------------------------------------------------
 | ------------------------ |
+| `IF(condition, true_value)`              | If the condition evaluates to 
true, `true_value` is computed and returned; otherwise, `null` is returned and 
`true_value` is not evaluated. | — |
+| `IF(condition, true_value, false_value)` | If the condition evaluates to 
true, `true_value` is computed and returned; otherwise, `false_value` is 
computed and returned. | The data types of `true_value` and `false_value` 
**must be exactly the same**. Implicit type conversion is not supported. |
+
+> Supported since V2.0.9-beta
+
+**Examples:**
+
+1. Equivalent examples of IF and CASE expressions:
+```SQL
+-- IF syntax
+SELECT 
+  device_id,
+  temperature,  
+  IF(temperature > 85, 'High Value', 'Low Value')
+FROM table1;
+
+-- Equivalent CASE syntax
+SELECT
+  device_id,  
+  temperature,  
+  CASE    
+    WHEN temperature > 85 THEN 'High Value'
+    ELSE 'Low Value'  
+  END
+FROM table1;
+```
+
+2. Output type restriction examples:
+```SQL
+-- Succeeds
+-- temperature (float) and humidity (float) have matching types
+SELECT IF(temperature > 85, temperature, humidity) FROM table1;
+
+-- Fails
+-- temperature (float) and status (boolean) have mismatched types
+SELECT IF(temperature > 85, temperature, status) FROM table1;
+```
+
+
 ## 8. Conversion Functions
 
 ### 8.1 Conversion Functions
diff --git a/src/UserGuide/latest-Table/SQL-Manual/Basis-Function_timecho.md 
b/src/UserGuide/latest-Table/SQL-Manual/Basis-Function_timecho.md
index 7f354dc8..caf0988b 100644
--- a/src/UserGuide/latest-Table/SQL-Manual/Basis-Function_timecho.md
+++ b/src/UserGuide/latest-Table/SQL-Manual/Basis-Function_timecho.md
@@ -1287,6 +1287,51 @@ Returns the first non-null value from the given list of 
parameters.
 coalesce(value1, value2[, ...])
 ```
 
+### 7.3 IF Expression
+
+The IF expression has two forms: one that specifies only the true value, and 
another that specifies both the true value and the false value.
+
+| Form                                         | Description                   
                                                                                
                       | Output Type Restrictions |
+| ---------------------------------------------- | 
------------------------------------------------------------------------------------------------------------------------------------
 | ------------------------ |
+| `IF(condition, true_value)`              | If the condition evaluates to 
true, `true_value` is computed and returned; otherwise, `null` is returned and 
`true_value` is not evaluated. | — |
+| `IF(condition, true_value, false_value)` | If the condition evaluates to 
true, `true_value` is computed and returned; otherwise, `false_value` is 
computed and returned. | The data types of `true_value` and `false_value` 
**must be exactly the same**. Implicit type conversion is not supported. |
+
+> Supported since V2.0.9.1
+
+**Examples:**
+
+1. Equivalent examples of IF and CASE expressions:
+```SQL
+-- IF syntax
+SELECT 
+  device_id,
+  temperature,  
+  IF(temperature > 85, 'High Value', 'Low Value')
+FROM table1;
+
+-- Equivalent CASE syntax
+SELECT
+  device_id,  
+  temperature,  
+  CASE    
+    WHEN temperature > 85 THEN 'High Value'
+    ELSE 'Low Value'  
+  END
+FROM table1;
+```
+
+2. Output type restriction examples:
+```SQL
+-- Succeeds
+-- temperature (float) and humidity (float) have matching types
+SELECT IF(temperature > 85, temperature, humidity) FROM table1;
+
+-- Fails
+-- temperature (float) and status (boolean) have mismatched types
+SELECT IF(temperature > 85, temperature, status) FROM table1;
+```
+
+
 ## 8. Conversion Functions
 
 ### 8.1 Conversion Functions
diff --git a/src/zh/UserGuide/Master/Table/SQL-Manual/Basis-Function_apache.md 
b/src/zh/UserGuide/Master/Table/SQL-Manual/Basis-Function_apache.md
index 78febd1b..cacb56d9 100644
--- a/src/zh/UserGuide/Master/Table/SQL-Manual/Basis-Function_apache.md
+++ b/src/zh/UserGuide/Master/Table/SQL-Manual/Basis-Function_apache.md
@@ -1265,6 +1265,53 @@ SELECT a, b,
 coalesce(value1, value2[, ...])
 ```
 
+### 7.3 IF 表达式
+
+IF 表达式有两种形式:一种仅指定真值(true\_value),另一种同时指定真值和假值(false\_value)。
+
+| 形式                                         | 说明                              
                                                                        | 
输出类型限制                                                                          
        |
+| ---------------------------------------------- | 
-----------------------------------------------------------------------------------------------------------
 | 
-----------------------------------------------------------------------------------------------
 |
+| `if(condition, true_value)`              | 
若条件(condition)为真,则计算并返回`true_value`;否则返回`null`,且`true_value`不会被计算。 |            
                                                                                
   |
+| `if(condition, true_value, false_value)` | 
若条件(condition)为真,则计算并返回`true_value`;否则计算并返回`false_value`。                  | 
`true_value`和`false_value`的数据类型​**必须完全一致**​,不支持隐式类型转换。 |
+
+> V 2.0.9-beta 版本起支持
+
+**示例:**
+
+1. IF 表达式和 CASE 表达式等价示例:
+
+```SQL
+-- IF 写法
+SELECT 
+  device_id,
+  temperature,  
+  IF(temperature > 85, 'High Value', 'Low Value')
+FROM table1;
+
+-- CASE 等价写法
+SELECT
+  device_id,  
+  temperature,  
+  CASE    
+    WHEN temperature > 85 THEN 'High Value'
+    ELSE 'Low Value'  
+  END
+FROM table1;
+```
+
+2. 输出类型限制示例:
+
+```SQL
+-- 成功
+-- temperature(float) 和 humidity(float) 类型一致
+select if(temperature > 85, temperature, humidity) from table1 
+
+-- 失败
+-- temperature(float) 和 status(boolean) 类型不一致
+select if(temperature > 85, temperature, status) from table1  
+```
+
+
 ## 8. 转换函数
 
 ### 8.1 转换函数
@@ -1272,7 +1319,7 @@ coalesce(value1, value2[, ...])
 #### 8.1.1 cast(value AS type) → type
 
 1. 显式地将一个值转换为指定类型。
-2. 可以用于将字符串(varchar)转换为数值类型,或数值转换为字符串类型。
+2. 可以用于将字符串(varchar)转换为数值类型,或数值转换为字符串类型
 3. 如果转换失败,将抛出运行时错误。
 
 示例:
diff --git a/src/zh/UserGuide/Master/Table/SQL-Manual/Basis-Function_timecho.md 
b/src/zh/UserGuide/Master/Table/SQL-Manual/Basis-Function_timecho.md
index 210eb261..160e96a3 100644
--- a/src/zh/UserGuide/Master/Table/SQL-Manual/Basis-Function_timecho.md
+++ b/src/zh/UserGuide/Master/Table/SQL-Manual/Basis-Function_timecho.md
@@ -1265,6 +1265,55 @@ SELECT a, b,
 coalesce(value1, value2[, ...])
 ```
 
+
+### 7.3 IF 表达式
+
+IF 表达式有两种形式:一种仅指定真值(true\_value),另一种同时指定真值和假值(false\_value)。
+
+| 形式                                         | 说明                              
                                                                        | 
输出类型限制                                                                          
        |
+| ---------------------------------------------- | 
-----------------------------------------------------------------------------------------------------------
 | 
-----------------------------------------------------------------------------------------------
 |
+| `if(condition, true_value)`              | 
若条件(condition)为真,则计算并返回`true_value`;否则返回`null`,且`true_value`不会被计算。 |            
                                                                                
   |
+| `if(condition, true_value, false_value)` | 
若条件(condition)为真,则计算并返回`true_value`;否则计算并返回`false_value`。                  | 
`true_value`和`false_value`的数据类型​**必须完全一致**​,不支持隐式类型转换。 |
+
+> V 2.0.9.1 版本起支持
+
+**示例:**
+
+1. IF 表达式和 CASE 表达式等价示例:
+
+```SQL
+-- IF 写法
+SELECT 
+  device_id,
+  temperature,  
+  IF(temperature > 85, 'High Value', 'Low Value')
+FROM table1;
+
+-- CASE 等价写法
+SELECT
+  device_id,  
+  temperature,  
+  CASE    
+    WHEN temperature > 85 THEN 'High Value'
+    ELSE 'Low Value'  
+  END
+FROM table1;
+```
+
+2. 输出类型限制示例:
+
+```SQL
+-- 成功
+-- temperature(float) 和 humidity(float) 类型一致
+select if(temperature > 85, temperature, humidity) from table1 
+
+-- 失败
+-- temperature(float) 和 status(boolean) 类型不一致
+select if(temperature > 85, temperature, status) from table1  
+```
+
+
+
 ## 8. 转换函数
 
 ### 8.1 转换函数
diff --git a/src/zh/UserGuide/latest-Table/SQL-Manual/Basis-Function_apache.md 
b/src/zh/UserGuide/latest-Table/SQL-Manual/Basis-Function_apache.md
index b1c772aa..bcb814cf 100644
--- a/src/zh/UserGuide/latest-Table/SQL-Manual/Basis-Function_apache.md
+++ b/src/zh/UserGuide/latest-Table/SQL-Manual/Basis-Function_apache.md
@@ -1265,6 +1265,53 @@ SELECT a, b,
 coalesce(value1, value2[, ...])
 ```
 
+### 7.3 IF 表达式
+
+IF 表达式有两种形式:一种仅指定真值(true\_value),另一种同时指定真值和假值(false\_value)。
+
+| 形式                                         | 说明                              
                                                                        | 
输出类型限制                                                                          
        |
+| ---------------------------------------------- | 
-----------------------------------------------------------------------------------------------------------
 | 
-----------------------------------------------------------------------------------------------
 |
+| `if(condition, true_value)`              | 
若条件(condition)为真,则计算并返回`true_value`;否则返回`null`,且`true_value`不会被计算。 |            
                                                                                
   |
+| `if(condition, true_value, false_value)` | 
若条件(condition)为真,则计算并返回`true_value`;否则计算并返回`false_value`。                  | 
`true_value`和`false_value`的数据类型​**必须完全一致**​,不支持隐式类型转换。 |
+
+> V2.0.9-beta 版本起支持
+
+**示例:**
+
+1. IF 表达式和 CASE 表达式等价示例:
+
+```SQL
+-- IF 写法
+SELECT 
+  device_id,
+  temperature,  
+  IF(temperature > 85, 'High Value', 'Low Value')
+FROM table1;
+
+-- CASE 等价写法
+SELECT
+  device_id,  
+  temperature,  
+  CASE    
+    WHEN temperature > 85 THEN 'High Value'
+    ELSE 'Low Value'  
+  END
+FROM table1;
+```
+
+2. 输出类型限制示例:
+
+```SQL
+-- 成功
+-- temperature(float) 和 humidity(float) 类型一致
+select if(temperature > 85, temperature, humidity) from table1 
+
+-- 失败
+-- temperature(float) 和 status(boolean) 类型不一致
+select if(temperature > 85, temperature, status) from table1  
+```
+
+
 ## 8. 转换函数
 
 ### 8.1 转换函数
diff --git a/src/zh/UserGuide/latest-Table/SQL-Manual/Basis-Function_timecho.md 
b/src/zh/UserGuide/latest-Table/SQL-Manual/Basis-Function_timecho.md
index 210eb261..160e96a3 100644
--- a/src/zh/UserGuide/latest-Table/SQL-Manual/Basis-Function_timecho.md
+++ b/src/zh/UserGuide/latest-Table/SQL-Manual/Basis-Function_timecho.md
@@ -1265,6 +1265,55 @@ SELECT a, b,
 coalesce(value1, value2[, ...])
 ```
 
+
+### 7.3 IF 表达式
+
+IF 表达式有两种形式:一种仅指定真值(true\_value),另一种同时指定真值和假值(false\_value)。
+
+| 形式                                         | 说明                              
                                                                        | 
输出类型限制                                                                          
        |
+| ---------------------------------------------- | 
-----------------------------------------------------------------------------------------------------------
 | 
-----------------------------------------------------------------------------------------------
 |
+| `if(condition, true_value)`              | 
若条件(condition)为真,则计算并返回`true_value`;否则返回`null`,且`true_value`不会被计算。 |            
                                                                                
   |
+| `if(condition, true_value, false_value)` | 
若条件(condition)为真,则计算并返回`true_value`;否则计算并返回`false_value`。                  | 
`true_value`和`false_value`的数据类型​**必须完全一致**​,不支持隐式类型转换。 |
+
+> V 2.0.9.1 版本起支持
+
+**示例:**
+
+1. IF 表达式和 CASE 表达式等价示例:
+
+```SQL
+-- IF 写法
+SELECT 
+  device_id,
+  temperature,  
+  IF(temperature > 85, 'High Value', 'Low Value')
+FROM table1;
+
+-- CASE 等价写法
+SELECT
+  device_id,  
+  temperature,  
+  CASE    
+    WHEN temperature > 85 THEN 'High Value'
+    ELSE 'Low Value'  
+  END
+FROM table1;
+```
+
+2. 输出类型限制示例:
+
+```SQL
+-- 成功
+-- temperature(float) 和 humidity(float) 类型一致
+select if(temperature > 85, temperature, humidity) from table1 
+
+-- 失败
+-- temperature(float) 和 status(boolean) 类型不一致
+select if(temperature > 85, temperature, status) from table1  
+```
+
+
+
 ## 8. 转换函数
 
 ### 8.1 转换函数

Reply via email to