You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/UserGuide/Master/Table/SQL-Manual/From-Join-Clause.md
+94-1Lines changed: 94 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,8 @@ relation
34
34
joinType
35
35
: INNER?
36
36
| FULL OUTER?
37
+
| CROSS?
38
+
| ASOF?
37
39
;
38
40
39
41
joinCriteria
@@ -73,6 +75,7 @@ In the current version of IoTDB, the following joins are supported:
73
75
1.**Inner Join**: Combines rows that meet the join condition, effectively returning the intersection of the two tables. The join condition must be an equality condition on the `time` column.
74
76
2.**Full Outer Join**: Returns all records from both tables, inserting `NULL` values for unmatched rows. The join condition can be any equality expression.
75
77
3.**Cross Join**: Represents the Cartesian product of two tables.
78
+
4. **ASOF JOIN** (AS OF a specific point in time) is a specialized join operation based on temporal or approximate matching conditions, designed for scenarios where timestamps between two datasets are not perfectly aligned. It matches each row from the left table with the closest corresponding row in the right table that meets the specified conditions (typically the nearest preceding or succeeding timestamp). This operation is widely used for time-series data analysis (e.g., sensor data, financial market feeds).
76
79
77
80
### 3.1 Inner Join
78
81
@@ -132,6 +135,43 @@ joinCriteria
132
135
### 3.3 Cross Join
133
136
A cross join represents the Cartesian product of two tables, returning all possible combinations of the N rows from the left table and the M rows from the right table, resulting in N*M rows. This type of join is the least commonly used in practice.
134
137
138
+
### 3.4 Asof Join
139
+
140
+
IoTDB ASOF JOIN is an approximate point join method that allows users to perform matching based on the closest timestamp according to specified rules. The current version only supports ASOF INNER JOIN for Time columns.
* ASOF JOIN defaults to ASOF INNER JOIN implementation.
162
+
* When using the ON keyword for joining, the join condition must include an inequality join condition for the Time column. Only four operators are supported: `">", ">=", "<", "<="`. The corresponding join matching rules are as follows (where lt represents the left table and rt represents the right table):
|`lt.time >= rt.time`| The closest timestamp in the left table that is greater than or equal to the right table's timestamp. |
167
+
|`lt.time > rt.time`| The closest timestamp in the left table that is greater than the right table's timestamp. |
168
+
|`lt.time <= rt.time`| The closest timestamp in the left table that is less than or equal to the right table's timestamp. |
169
+
|`lt.time < rt.time`| The closest timestamp in the left table that is less than the right table's timestamp. |
170
+
171
+
*`Tolerance parameter`: The maximum allowed time difference for searching data in the right table (expressed as a TimeDuration, e.g., 1d for one day). If the Tolerance parameter is not specified, the search time range defaults to infinity. Note: Currently, this parameter is only supported in ASOF INNER JOIN.
172
+
173
+
174
+
135
175
## 4. Example Queries
136
176
137
177
The [Example Data page](../Reference/Sample-Data.md)page provides SQL statements to construct table schemas and insert data. By downloading and executing these statements in the IoTDB CLI, you can import the data into IoTDB. This data can be used to test and run the example SQL queries included in this documentation, allowing you to reproduce the described results.
Example 1: Without specifying the tolerance parameter, where the timestamp in table1 is greater than or equal to and closest to the timestamp in table2.
Copy file name to clipboardExpand all lines: src/UserGuide/latest-Table/SQL-Manual/From-Join-Clause.md
+94-1Lines changed: 94 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,8 @@ relation
34
34
joinType
35
35
: INNER?
36
36
| FULL OUTER?
37
+
| CROSS?
38
+
| ASOF?
37
39
;
38
40
39
41
joinCriteria
@@ -73,6 +75,7 @@ In the current version of IoTDB, the following joins are supported:
73
75
1.**Inner Join**: Combines rows that meet the join condition, effectively returning the intersection of the two tables. The join condition must be an equality condition on the `time` column.
74
76
2.**Full Outer Join**: Returns all records from both tables, inserting `NULL` values for unmatched rows. The join condition can be any equality expression.
75
77
3.**Cross Join**: Represents the Cartesian product of two tables.
78
+
4. **ASOF JOIN** (AS OF a specific point in time) is a specialized join operation based on temporal or approximate matching conditions, designed for scenarios where timestamps between two datasets are not perfectly aligned. It matches each row from the left table with the closest corresponding row in the right table that meets the specified conditions (typically the nearest preceding or succeeding timestamp). This operation is widely used for time-series data analysis (e.g., sensor data, financial market feeds).
76
79
77
80
### 3.1 Inner Join
78
81
@@ -132,6 +135,43 @@ joinCriteria
132
135
### 3.3 Cross Join
133
136
A cross join represents the Cartesian product of two tables, returning all possible combinations of the N rows from the left table and the M rows from the right table, resulting in N*M rows. This type of join is the least commonly used in practice.
134
137
138
+
### 3.4 Asof Join
139
+
140
+
IoTDB ASOF JOIN is an approximate point join method that allows users to perform matching based on the closest timestamp according to specified rules. The current version only supports ASOF INNER JOIN for Time columns.
* ASOF JOIN defaults to ASOF INNER JOIN implementation.
162
+
* When using the ON keyword for joining, the join condition must include an inequality join condition for the Time column. Only four operators are supported: `">", ">=", "<", "<="`. The corresponding join matching rules are as follows (where lt represents the left table and rt represents the right table):
|`lt.time >= rt.time`| The closest timestamp in the left table that is greater than or equal to the right table's timestamp. |
167
+
|`lt.time > rt.time`| The closest timestamp in the left table that is greater than the right table's timestamp. |
168
+
|`lt.time <= rt.time`| The closest timestamp in the left table that is less than or equal to the right table's timestamp. |
169
+
|`lt.time < rt.time`| The closest timestamp in the left table that is less than the right table's timestamp. |
170
+
171
+
*`Tolerance parameter`: The maximum allowed time difference for searching data in the right table (expressed as a TimeDuration, e.g., 1d for one day). If the Tolerance parameter is not specified, the search time range defaults to infinity. Note: Currently, this parameter is only supported in ASOF INNER JOIN.
172
+
173
+
174
+
135
175
## 4. Example Queries
136
176
137
177
The [Example Data page](../Reference/Sample-Data.md)page provides SQL statements to construct table schemas and insert data. By downloading and executing these statements in the IoTDB CLI, you can import the data into IoTDB. This data can be used to test and run the example SQL queries included in this documentation, allowing you to reproduce the described results.
Example 1: Without specifying the tolerance parameter, where the timestamp in table1 is greater than or equal to and closest to the timestamp in table2.
0 commit comments