diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md index 074fbfbc8d..f538f0d58c 100755 --- a/docs/en/12-taos-sql/06-select.md +++ b/docs/en/12-taos-sql/06-select.md @@ -39,7 +39,7 @@ select_expr: { from_clause: { table_reference [, table_reference] ... - | join_clause [, join_clause] ... + | table_reference join_clause [, join_clause] ... } table_reference: @@ -52,7 +52,7 @@ table_expr: { } join_clause: - table_reference [INNER] JOIN table_reference ON condition + [INNER|LEFT|RIGHT|FULL] [OUTER|SEMI|ANTI|ASOF|WINDOW] JOIN table_reference [ON condition] [WINDOW_OFFSET(start_offset, end_offset)] [JLIMIT jlimit_num] window_clause: { SESSION(ts_col, tol_val) @@ -408,9 +408,11 @@ SELECT AVG(CASE WHEN voltage < 200 or voltage > 250 THEN 220 ELSE voltage END) F ## JOIN -TDengine supports the `INTER JOIN` based on the timestamp primary key, that is, the `JOIN` condition must contain the timestamp primary key. As long as the requirement of timestamp-based primary key is met, `INTER JOIN` can be made between normal tables, sub-tables, super tables and sub-queries at will, and there is no limit on the number of tables, primary key and other conditions must be combined with `AND` operator. +Before the 3.3.0.0 version, TDengine only supported Inner Join queries. Since the 3.3.0.0 version, TDengine supports a wider range of JOIN types, including LEFT JOIN, RIGHT JOIN, FULL JOIN, SEMI JOIN, ANTI-SEMI JOIN in traditional databases, as well as ASOF JOIN and WINDOW JOIN in time series databases. JOIN operations are supported between subtables, normal tables, super tables, and subqueries. -For standard tables: +### Examples + +INNER JOIN between normal tables: ```sql SELECT * @@ -418,23 +420,23 @@ FROM temp_tb_1 t1, pressure_tb_1 t2 WHERE t1.ts = t2.ts ``` -For supertables: +LEFT JOIN between super tables: ```sql SELECT * -FROM temp_stable t1, temp_stable t2 -WHERE t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; +FROM temp_stable t1 LEFT JOIN temp_stable t2 +ON t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; ``` -For sub-table and super table: +LEFT ASOF JOIN between child table and super table: ```sql SELECT * -FROM temp_ctable t1, temp_stable t2 -WHERE t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; +FROM temp_ctable t1 LEFT ASOF JOIN temp_stable t2 +ON t1.ts = t2.ts AND t1.deviceid = t2.deviceid; ``` -Similarly, join operations can be performed on the result sets of multiple subqueries. +For more information about JOIN operations, please refer to the page [TDengine Join] (../join). ## Nested Query diff --git a/docs/en/12-taos-sql/30-join.md b/docs/en/12-taos-sql/30-join.md new file mode 100755 index 0000000000..46573610cf --- /dev/null +++ b/docs/en/12-taos-sql/30-join.md @@ -0,0 +1,298 @@ +--- +sidebar_label: JOIN +title: JOIN +description: JOIN Description +--- + + +## Join Concept + +### Driving Table + +The table used for driving Join queries is the left table in the Left Join series and the right table in the Right Join series. + +### Join Conditions + +Join conditions refer to the conditions specified for join operation. All join queries supported by TDengine require specifying join conditions. Join conditions usually only appear in `ON` (except for Inner Join and Window Join). For Inner Join, conditions that appear in `WHERE` can also be regarded as join conditions. For Window Join join conditions are specified in `WINDOW_OFFSET` clause. + + Except for ASOF Join, all join types supported by TDengine must explicitly specify join conditions. Since ASOF Join has implicit join conditions defined by default, it is not necessary to explicitly specify the join conditions (if the default conditions meet the requirements). + +Except for ASOF/Window Join, the join condition can include not only the primary join condition(refer below), but also any number of other join conditions. The primary join condition must have an `AND` relationship with the other join conditions, while there is no such restriction between the other join conditions. The other join conditions can include any logical operation combination of primary key columns, Tag columns, normal columns, constants, and their scalar functions or operations. + + +Taking smart meters as an example, the following SQL statements all contain valid join conditions: + +```sql +SELECT a.* FROM meters a LEFT JOIN meters b ON a.ts = b.ts AND a.ts > '2023-10-18 10:00:00.000'; +SELECT a.* FROM meters a LEFT JOIN meters b ON a.ts = b.ts AND (a.ts > '2023-10-18 10:00:00.000' OR a.ts < '2023-10-17 10:00:00.000'); +SELECT a.* FROM meters a LEFT JOIN meters b ON timetruncate(a.ts, 1s) = timetruncate(b.ts, 1s) AND (a.ts + 1s > '2023-10-18 10:00:00.000' OR a.groupId > 0); +SELECT a.* FROM meters a LEFT ASOF JOIN meters b ON timetruncate(a.ts, 1s) < timetruncate(b.ts, 1s) AND a.groupId = b.groupId; +``` + +### Primary Join Condition + +As a time series database, all join queries of TDengine revolve around the primary timestamp column, so all join queries except ASOF/Window Join are required to contain equivalent join condition of the primary key column. The equivalent join condition of the primary key column that first appear in the join conditions in order will be used as the primary join condition. The primary join condition of ASOF Join can contain non-equivalent join condition, for Window Join the primary join condition is specified by `WINDOW_OFFSET` clause. + +Except for Window Join, TDengine supports performing `timetruncate` function operation in the primary join condition, e.g. `ON timetruncate(a.ts, 1s) = timetruncate(b.ts, 1s)`. Other functions and scalar operations to primary key column are not currently supported in the primary join condition. + +### Grouping Conditions + +ASOF/Window Join supports grouping the input data of join queries, and then performing join operations within each group. Grouping only applies to the input of join queries, and the output result will not include grouping information. Equivalent conditions that appear in `ON` in ASOF/Window Join (excluding the primary join condition of ASOF) will be used as grouping conditions. + + +### Primary Key Timeline + +TDengine, as a time series database, requires that each table must have a primary key timestamp column, which will perform many time-related operations as the primary key timeline of the table. It is also necessary to clarify which column will be regarded as the primary key timeline for subsequent time-related operations in the results of subqueries or join operations. In subqueries, the ordered first occurrence of the primary key column (or its operation) or the pseudo-column equivalent to the primary key column (`_wstart`/`_wend`) in the query results will be regarded as the primary key timeline of the output table. The selection of the primary key timeline in the join output results follows the following rules: + +- The primary key column of the driving table (subquery) in the Left/Right Join series will be used as the primary key timeline for subsequent queries. In addition, in each Window Join window, because the left and right tables are ordered at the same time, the primary key column of any table can be used as the primary key timeline in the window, and the primary key column of current table is preferentially selected as the primary key timeline. + +- The primary key column of any table in Inner Join can be treated as the primary key timeline. When there are similar grouping conditions (equivalent conditions of TAG columns and `AND` relationship with the primary join condition), there will be no available primary key timeline. + +- Full Join will not result in any primary key timeline because it cannot generate any valid primary key time series, so no timeline-related operations can be performed in or after a Full Join. + + +## Syntax Conventions +Because we will introduce the Left/Right Join series simultaneously through sharing below, the introductions of Left/Right Outer, Semi, Anti-Semi, ASOF, and Window series Joins will all use a similar "left/right" approach to introduce Left/Right Join simultaneously. Here is a brief introduction to the meaning of this writing method. The words written before "/" are the words applied to Left Join, and the words written after "/" are the words applied to Right Join. + +For example: + +The phrase "left/right table" means "left table" for Left Join and "right table" for Right Join. + +Similarly, + +The phrase "right/left table" means "right table" for Left Join and "left table" for Right Join. + +## Join Function + +### Inner Join + +#### Definition +Only data from both left and right tables that meet the join conditions will be returned, which can be regarded as the intersection of data from two tables that meet the join conditions. + +#### Grammar +```sql +SELECT ... FROM table_name1 [INNER] JOIN table_name2 [ON ...] [WHERE ...] [...] +Or +SELECT ... FROM table_name1, table_name2 WHERE ... [...] +``` +#### Result set +Cartesian product set of left and right table row data that meets the join conditions. + +#### Scope +Inner Join are supported between super tables, normal tables, child tables, and subqueries. + +#### Notes +- For the first type syntax, the `INNER` keyword is optional. The primary join condition and other join conditions can be specified in `ON` and/or `WHERE`, and filters can also be specified in `WHERE`. At least one of `ON`/`WHERE` must be specified. +- For the second type syntax, all primary join condition, other join conditions, and filters can be specified in `WHERE`. +- When performing Inner Join on the super table, the Tag column equivalent conditions with the `AND` relationship of the primary join condition will be used as a similar grouping condition, so the output result cannot remain time serious ordered. + +#### Examples + +The timestamp when the voltage is greater than 220V occurs simultaneously in table d1001 and table d1002 and their respective voltage values: +```sql +SELECT a.ts, a.voltage, b.voltage FROM d1001 a JOIN d1002 b ON a.ts = b.ts and a.voltage > 220 and b.voltage > 220 +``` + + +### Left/Right Outer Join + + +#### Definition +It returns data sets that meet the join conditions for both left and right tables, as well as data sets that do not meet the join conditions in the left/right tables. + +#### Grammar +```sql +SELECT ... FROM table_name1 LEFT|RIGHT [OUTER] JOIN table_name2 ON ... [WHERE ...] [...] +``` + +#### Result set +The result set of Inner Join are rows in the left/right table that do not meet the join conditions combining with null data (`NULL`) in the right/left table. + +#### Scope +Left/Right Outer Join are supported between super tables, normal tables, child tables, and subqueries. + +#### Notes +- the `OUTER` keyword is optional. + +#### Examples + +Timestamp and voltage values at all times in table d1001 and the timestamp when the voltage is greater than 220V occurs simultaneously in table d1001 and table d1002 and their respective voltage values: +```sql +SELECT a.ts, a.voltage, b.voltage FROM d1001 a LEFT JOIN d1002 b ON a.ts = b.ts and a.voltage > 220 and b.voltage > 220 +``` + +### Left/Right Semi Join + +#### Definition +It usually expresses the meaning of `IN`/`EXISTS`, which means that for any data in the left/right table, only when there is any row data in the right/left table that meets the join conditions, will the left/right table row data be returned. + +#### Grammar +```sql +SELECT ... FROM table_name1 LEFT|RIGHT SEMI JOIN table_name2 ON ... [WHERE ...] [...] +``` + +#### Result set +The row data set composed of rows that meet the join conditions in the left/right table and any one row that meets the join conditions in the right/left table. + +#### Scope +Left/Right Semi Join are supported between super tables, normal tables, child tables, and subqueries. + +#### Examples + +The timestamp when the voltage in table d1001 is greater than 220V and there are other meters with voltages greater than 220V at the same time: +```sql +SELECT a.ts FROM d1001 a LEFT SEMI JOIN meters b ON a.ts = b.ts and a.voltage > 220 and b.voltage > 220 and b.tbname != 'd1001' +``` + +### Left/Right Anti-Semi Join + +#### Definition +Opposite meaning to the Left/Right Semi Join. It usually expresses the meaning of `NOT IN`/`NOT EXISTS`, that is, for any row data in the left/right table, only will be returned when there is no row data that meets the join conditions in the right/left table. + +#### Grammar +```sql +SELECT ... FROM table_name1 LEFT|RIGHT ANTI JOIN table_name2 ON ... [WHERE ...] [...] +``` + +#### Result set +A collection of rows in the left/right table that do not meet the join conditions and null data (`NULL`) in the right/left table. + +#### Scope +Left/Right Anti-Semi Join are supported between super tables, normal tables, child tables, and subqueries. + +#### Examples + +The timestamp when the voltage in table d1001 is greater than 220V and there is not any other meters with voltages greater than 220V at the same time: +```sql +SELECT a.ts FROM d1001 a LEFT ANTI JOIN meters b ON a.ts = b.ts and b.voltage > 220 and b.tbname != 'd1001' WHERE a.voltage > 220 +``` + +### left/Right ASOF Join + +#### Definition +Different from other traditional join's exact matching patterns, ASOF Join allows for incomplete matching in a specified matching pattern, that is, matching in the manner closest to the primary key timestamp. + +#### Grammar +```sql +SELECT ... FROM table_name1 LEFT|RIGHT ASOF JOIN table_name2 [ON ...] [JLIMIT jlimit_num] [WHERE ...] [...] +``` + +##### Result set +The Cartesian product set of up to `jlimit_num` rows data or null data (`NULL`) closest to the timestamp of each row in the left/right table, ordered by primary key, that meets the join conditions in the right/left table. + + +##### Scope +Left/Right ASOF Join are supported between super tables, normal tables, child tables. + +#### Notes +- Only supports ASOF Join between tables, not between subqueries. +- The `ON` clause supports a single matching rule (primary join condition) with the primary key column or the timetruncate function operation of the primary key column (other scalar operations and functions are not supported). The supported operators and their meanings are as follows: + + + | **Operator** | **Meaning for Left ASOF Join** | + | :-------------: | ------------------------ | + | > | Match rows in the right table whose primary key timestamp is less than and the most closed to the left table's primary key timestamp | + | >= | Match rows in the right table whose primary key timestamp is less than or equal to and the most closed to the left table's primary key timestamp | + | = | Match rows in the right table whose primary key timestamp is equal to the left table's primary key timestamp | + | < | Match rows in the right table whose the primary key timestamp is greater than and the most closed to the left table's primary key timestamp | + | <= | Match rows in the right table whose primary key timestamp is greater than or equal to and the most closed to the left table's primary key timestamp | + + For Right ASOF Join, the above operators have the opposite meaning. + +- If there is no `ON` clause or no primary join condition is specified in the `ON` clause, the default primary join condition operator will be “>=”, that is, (for Left ASOF Join) matching rows in the right table whose primary key timestamp is less than or equal to the left table's primary key timestamp. Multiple primary join conditions are not supported. +- In the `ON` clause, except for the primary key column, equivalent conditions between Tag columns and ordinary columns (which do not support scalar functions and operations) can be specified for grouping calculations. Other types of conditions are not supported. +- Only `AND` operation is supported between all `ON` conditions. +- `JLIMIT` is used to specify the maximum number of rows for a single row match result. It's optional. The default value is 1 when not specified, which means that each row of data in the left/right table can obtain at most one row of matching results from the right/left table. The value range of `JLIMIT` is [0,1024]. All the `jlimit_num` rows data that meet the join conditions do not require the same timestamp. When there are not enough `jlimit_num` rows data that meet the conditions in the right/left table, the number of returned result rows may be less than `jlimit_num`. When there are more than `jlimit_num` rows data that meet the conditions in the right/left table and all their timestamps are the same, random `jlimit_num` rows data will be returned. + +#### Examples + +The moment that voltage in table d1001 is greater than 220V and at the same time or at the last moment the voltage in table d1002 is also greater than 220V and their respective voltage values: +```sql +SELECT a.ts, a.voltage, a.ts, b.voltage FROM d1001 a LEFT ASOF JOIN d1002 b ON a.ts >= b.ts where a.voltage > 220 and b.voltage > 220 +``` + +### Left/Right Window Join + +#### Definition +Construct windows based on the primary key timestamp of each row in the left/right table and the window boundary, and then perform window join accordingly, supporting projection, scalar, and aggregation operations within the window. + +#### Grammar +```sql +SELECT ... FROM table_name1 LEFT|RIGHT WINDOW JOIN table_name2 [ON ...] WINDOW_OFFSET(start_offset, end_offset) [JLIMIT jlimit_num] [WHERE ...] [...] +``` + +#### Result set +The Cartesian product of each row of data in the left/right table and null data (`NULL`) or up to `jlimit_num` rows of data in the constructed window(based on the left/right table primary key timestamp and `WINDOW_OFFSET`) in the right/left table. +Or +The Cartesian product of each row of data in the left/right table and null data (`NULL`) or the aggregation result of up to `jlimit_num` rows of data in the constructed window(based on the left/right table primary key timestamp and `WINDOW_OFFSET`) in the right/left table. + +#### Scope +Left/Right Window Join are supported between super tables, normal tables, child tables. + +#### Notes +- Only supports Window Join between tables, not between subqueries. +- The `ON` clause is optional. Except for the primary key column, equivalent conditions between Tag columns and ordinary columns (which do not support scalar functions and operations) can be specified in `ON` clause for grouping calculations. Other types of conditions are not supported. +- Only `AND` operation is supported between all `ON` conditions. +- `WINDOW_OFFSET` is used to specify the offset of the left and right boundaries of the window relative to the timestamp of the left/right table's primary key. It supports the form of built-in time units. For example: `WINDOW_OFFSET (-1a, 1a)`, for Left Window Join, it means that each window boundary is [left table primary key timestamp - 1 millisecond, left table primary key timestamp + 1 millisecond], and both the left and right boundaries are closed intervals. The time unit after the number can be `b` (nanosecond), `u` (microsecond), `a` (millisecond), `s` (second), `m` (minute), `h` (hour), `d` (day), `w` (week). Natural months (`n`) and natural years (`y`) are not supported. The minimum time unit supported is database precision. The precision of the databases where the left and right tables are located should be the same. +- `JLIMIT` is used to specify the maximum number of matching rows in a single window. Optional. If not specified, all matching rows in each window are obtained by default. The value range of `JLIMIT` is [0,1024]. Less than `jlimit_num` rows of data will be returned when there are not enough `jlimit_num` rows of data in the right table that meet the condition. When there are more than `jlimit_num` rows of data in the right table that meet the condition, `jlimit_num` rows of data with the smallest primary key timestamp in the window will be returned. +- No `GROUP BY`/`PARTITION BY`/Window queries could be used together with Window Join in one single SQL statement. +- Supports scalar filtering in the `WHERE` clause, aggregation function filtering for each window in the `HAVING` clause (does not support scalar filtering), does not support `SLIMIT`, and does not support various window pseudo-columns. + +#### Examples + +The voltage value of table d1002 within 1 second before and after the moment that voltage value of table d1001 is greater than 220V: +```sql +SELECT a.ts, a.voltage, b.voltage FROM d1001 a LEFT WINDOW JOIN d1002 b WINDOW_OFFSET(-1s, 1s) where a.voltage > 220 +``` + +The moment that the voltage value of table d1001 is greater than 220V and the average voltage value of table d1002 is also greater than 220V in the interval of 1 second before and after that: +```sql +SELECT a.ts, a.voltage, avg(b.voltage) FROM d1001 a LEFT WINDOW JOIN d1002 b WINDOW_OFFSET(-1s, 1s) where a.voltage > 220 HAVING(avg(b.voltage) > 220) +``` + +### Full Outer Join + +#### Definition +It includes data sets that meet the join conditions for both left and right tables, as well as data sets that do not meet the join conditions in the left and right tables. + +#### Grammar +SELECT ... FROM table_name1 FULL [OUTER] JOIN table_name2 ON ... [WHERE ...] [...] + +#### Result set +The result set of Inner Join + rows data set composed of rows in the left table that do not meet the join conditions and null data(`NULL`) in the right table + rows data set composed of rows in the right table that do not meet the join conditions and null data(`NULL`) in the left table. + +#### Scope +Full Outer Join is supported between super tables, normal tables, child tables, and subqueries. + +#### Notes +- the `OUTER` keyword is optional. + +#### Examples + +All timestamps and voltage values recorded in both tables d1001 and d1002: +```sql +SELECT a.ts, a.voltage, b.ts, b.voltage FROM d1001 a FULL JOIN d1002 b on a.ts = b.ts +``` + +## Limitations + +### Input timeline limits +- Currently, all types of join require input data to contain a valid primary key timeline, which can be satisfied by all table queries. Subqueries need to pay attention to whether the output data contains a valid primary key timeline. + +### Join conditions limits +- Except for ASOF and Window Join, the join conditions of other types of join must include the primary join condition; +- Only `AND` operation is supported between the primary join condition and other join conditions. +- The primary key column used in the primary join condition only supports `timetruncate` function operations (not other functions and scalar operations), and there are no restrictions when used as other join conditions. + +### Grouping conditions limits +- Only support equivalent conditions for Tag and ordinary columns except for primary key columns. +- Does not support scalar operations. +- Supports multiple grouping conditions, and only supports `AND` operation between conditions. + +### Query result order limits +- In scenarios where there are normal tables, subtables, and subqueries without grouping conditions or sorting, the query results will be output in the order of the primary key columns of the driving table. +- In scenarios such as super table queries, Full Join, or with grouping conditions and without sorting, there is no fixed output order for query results. +Therefore, in scenarios where sorting is required and the output is not in a fixed order, sorting operations need to be performed. Some functions that rely on timelines may not be able to execute without soring due to the lack of valid timeline output. + +### Nested join and multi-table join limits +- Currently, except for Inner Join which supports nesting and multi-table Join, other types of join do not support nesting and multi-table join. diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md index 573e854864..0db0c99c59 100755 --- a/docs/zh/12-taos-sql/06-select.md +++ b/docs/zh/12-taos-sql/06-select.md @@ -39,7 +39,7 @@ select_expr: { from_clause: { table_reference [, table_reference] ... - | join_clause [, join_clause] ... + | table_reference join_clause [, join_clause] ... } table_reference: @@ -52,7 +52,7 @@ table_expr: { } join_clause: - table_reference [INNER] JOIN table_reference ON condition + [INNER|LEFT|RIGHT|FULL] [OUTER|SEMI|ANTI|ASOF|WINDOW] JOIN table_reference [ON condition] [WINDOW_OFFSET(start_offset, end_offset)] [JLIMIT jlimit_num] window_clause: { SESSION(ts_col, tol_val) @@ -410,7 +410,9 @@ SELECT AVG(CASE WHEN voltage < 200 or voltage > 250 THEN 220 ELSE voltage END) F ## JOIN 子句 -TDengine 支持基于时间戳主键的内连接,即 JOIN 条件必须包含时间戳主键。只要满足基于时间戳主键这个要求,普通表、子表、超级表和子查询之间可以随意的进行内连接,且对表个数没有限制,其它连接条件与主键间必须是 AND 操作。 +在 3.3.0.0 版本之前 TDengine 只支持内连接,自 3.3.0.0 版本起 TDengine 支持了更为广泛的 JOIN 类型,这其中既包括传统数据库中的 LEFT JOIN、RIGHT JOIN、FULL JOIN、SEMI JOIN、ANTI-SEMI JOIN,也包括时序库中特色的 ASOF JOIN、WINDOW JOIN。JOIN 操作支持在子表、普通表、超级表以及子查询间进行。 + +### 示例 普通表与普通表之间的 JOIN 操作: @@ -420,23 +422,23 @@ FROM temp_tb_1 t1, pressure_tb_1 t2 WHERE t1.ts = t2.ts ``` -超级表与超级表之间的 JOIN 操作: +超级表与超级表之间的 LEFT JOIN 操作: ```sql SELECT * -FROM temp_stable t1, temp_stable t2 -WHERE t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; +FROM temp_stable t1 LEFT JOIN temp_stable t2 +ON t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; ``` -子表与超级表之间的 JOIN 操作: +子表与超级表之间的 LEFT ASOF JOIN 操作: ```sql SELECT * -FROM temp_ctable t1, temp_stable t2 -WHERE t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; +FROM temp_ctable t1 LEFT ASOF JOIN temp_stable t2 +ON t1.ts = t2.ts AND t1.deviceid = t2.deviceid; ``` -类似地,也可以对多个子查询的查询结果进行 JOIN 操作。 +更多 JOIN 操作相关介绍参见页面 [TDengine 关联查询](../join) ## 嵌套查询 diff --git a/docs/zh/12-taos-sql/30-join.md b/docs/zh/12-taos-sql/30-join.md new file mode 100755 index 0000000000..35bf6d8cfe --- /dev/null +++ b/docs/zh/12-taos-sql/30-join.md @@ -0,0 +1,290 @@ +--- +sidebar_label: 关联查询 +title: 关联查询 +description: 关联查询详细描述 +--- + +## Join 概念 + +### 驱动表 + +驱动关联查询进行的表,在 Left Join 系列中左表为驱动表,在 Right Join 系列中右表为驱动表。 + +### 连接条件 + +连接条件是指进行表关联所指定的条件,TDengine 支持的所有关联查询都需要指定连接条件,连接条件通常(Inner Join 和 Window Join 例外)只出现在 `ON` 之后。根据语义,Inner Join 中出现在 `WHERE` 之后的条件也可以视作连接条件,而 Window Join 是通过 `WINDOW_OFFSET` 来指定连接条件。 + + 除 ASOF Join 外,TDengine 支持的所有 Join 类型都必须显式指定连接条件,ASOF Join 因为默认定义有隐式的连接条件,所以(在默认条件可以满足需求的情况下)可以不必显式指定连接条件。 + +除 ASOF/Window Join 外,连接条件中除了包含主连接条件外,还可以包含任意多条其他连接条件,主连接条件与其他连接条件间必须是 `AND` 关系,而其他连接条件之间则没有这个限制。其他连接条件中可以包含主键列、Tag 、普通列、常量及其标量函数或运算的任意逻辑运算组合。 + +以智能电表为例,下面这几条 SQL 都包含合法的连接条件: + +```sql +SELECT a.* FROM meters a LEFT JOIN meters b ON a.ts = b.ts AND a.ts > '2023-10-18 10:00:00.000'; +SELECT a.* FROM meters a LEFT JOIN meters b ON a.ts = b.ts AND (a.ts > '2023-10-18 10:00:00.000' OR a.ts < '2023-10-17 10:00:00.000'); +SELECT a.* FROM meters a LEFT JOIN meters b ON timetruncate(a.ts, 1s) = timetruncate(b.ts, 1s) AND (a.ts + 1s > '2023-10-18 10:00:00.000' OR a.groupId > 0); +SELECT a.* FROM meters a LEFT ASOF JOIN meters b ON timetruncate(a.ts, 1s) < timetruncate(b.ts, 1s) AND a.groupId = b.groupId; +``` + +### 主连接条件 + +作为一款时序数据库,TDengine 所有的关联查询都围绕主键时戳列进行,因此要求除 ASOF/Window Join 外的所有关联查询都必须含有主键列的等值连接条件,而按照顺序首次出现在连接条件中的主键列等值连接条件将会被作为主连接条件。ASOF Join 的主连接条件可以包含非等值的连接条件,而 Window Join 的主连接条件则是通过 `WINDOW_OFFSET` 来指定。 + +除 Window Join 外,TDengine 支持在主连接条件中进行 `timetruncate` 函数操作,例如 `ON timetruncate(a.ts, 1s) = timetruncate(b.ts, 1s)`,除此之外,暂不支持其他函数及标量运算。 + +### 分组条件 + +时序数据库特色的 ASOF/Window Join 支持对关联查询的输入数据进行分组,然后每个分组内进行关联操作。分组只对关联查询的输入进行,输出结果将不包含分组信息。ASOF/Window Join 中出现在 `ON` 之后的等值条件(ASOF 的主连接条件除外)将被作为分组条件。 + +### 主键时间线 + +TDengine 作为时序数据库要求每个表(子表)中必须有主键时间戳列,它将作为该表的主键时间线进行很多跟时间相关的运算,而子查询的结果或者 Join 运算的结果中也需要明确哪一列将被视作主键时间线参与后续的时间相关的运算。在子查询中,查询结果中存在的有序的第一个出现的主键列(或其运算)或等同主键列的伪列(`_wstart`/`_wend`)将被视作该输出表的主键时间线。Join 输出结果中主键时间线的选择遵从以下规则: +- Left/Right Join 系列中驱动表(子查询)的主键列将被作为后续查询的主键时间线;此外,在 Window Join 窗口内,因为左右表同时有序所以在窗口内可以把任意一个表的主键列做作主键时间线,优先选择本表的主键列作为主键时间线。 +- Inner Join 可以把任意一个表的主键列做作主键时间线,当存在类似分组条件(Tag 列的等值条件且与主连接条件 `AND` 关系)时将无法产生主键时间线。 +- Full Join 因为无法产生任何一个有效的主键时间序列,因此没有主键时间线,这也就意味着 Full Join 中无法进行时间线相关的运算。 + + +## 语法说明 + +在接下来的章节中会通过共用的方式同时介绍 Left/Right Join 系列,因此后续的包括 Outer、Semi、Anti-Semi、ASOF、Window 系列介绍中都采用了类似 "left/right" 的写法来同时进行 Left/Right Join 的介绍。这里简要介绍这种写法的含义,写在 "/" 前面的表示应用于 Left Join,而写在 "/" 后面的表示应用于 Right Join。 + +举例说明: + +"左/右表" 表示对 Left Join 来说,它指的是"左表",对 Right Join 来说,它指的是“右表”; + +同理, + +"右/左表" 表示对 Left Join 来说,它指的是"右表",对 Right Join 来说,它指的是“左表”; + + +## Join 功能 + +### Inner Join + +#### 定义 +内连接 - 只有左右表中同时符合连接条件的数据才会被返回,可以视为两个表符合连接条件的数据的交集。 + +#### 语法 +```sql +SELECT ... FROM table_name1 [INNER] JOIN table_name2 [ON ...] [WHERE ...] [...] +或 +SELECT ... FROM table_name1, table_name2 WHERE ... [...] +``` +#### 结果集 +符合连接条件的左右表行数据的笛卡尔积集合。 + +#### 适用范围 +支持超级表、普通表、子表、子查询间 Inner Join。 + +#### 说明 +- 对于第一种语法,`INNER` 关键字可选, `ON` 和/或 `WHERE` 中可以指定主连接条件和其他连接条件,`WHERE` 中还可以指定过滤条件,`ON`/`WHERE` 两者至少指定一个。 +- 对于第二种语法,可以在 `WHERE` 中指定主连接条件、其他连接条件、过滤条件。 +- 对超级表进行 Inner Join 时,与主连接条件 `AND` 关系的 Tag 列等值条件将作为类似分组条件使用,因此输出结果不能保持有序。 + +#### 示例 + +表 d1001 和表 d1002 中同时出现电压大于 220V 的时刻及各自的电压值: +```sql +SELECT a.ts, a.voltage, b.voltage FROM d1001 a JOIN d1002 b ON a.ts = b.ts and a.voltage > 220 and b.voltage > 220 +``` + + +### Left/Right Outer Join + +#### 定义 +左/右(外)连接 - 既包含左右表同时符合连接条件的数据集合,也包括左/右表中不符合连接条件的数据集合。 + +#### 语法 +```sql +SELECT ... FROM table_name1 LEFT|RIGHT [OUTER] JOIN table_name2 ON ... [WHERE ...] [...] +``` + +#### 结果集 +Inner Join 的结果集 + 左/右表中不符合连接条件的行和右/左表的空数据(`NULL`)组成的行数据集合。 + +#### 适用范围 +支持超级表、普通表、子表、子查询间 Left/Right Join。 + +#### 说明 +- OUTER 关键字可选。 + +#### 示例 + +表 d1001 所有时刻的电压值以及和表 d1002 中同时出现电压大于 220V 的时刻及各自的电压值: +```sql +SELECT a.ts, a.voltage, b.voltage FROM d1001 a LEFT JOIN d1002 b ON a.ts = b.ts and a.voltage > 220 and b.voltage > 220 +``` + +### Left/Right Semi Join + +#### 定义 +左/右半连接 - 通常表达的是 `IN``/EXISTS` 的含义,即对左/右表任意一条数据来说,只有当右/左表中存在任一符合连接条件的数据时才返回左/右表行数据。 + +#### 语法 +```sql +SELECT ... FROM table_name1 LEFT|RIGHT SEMI JOIN table_name2 ON ... [WHERE ...] [...] +``` + +#### 结果集 +左/右表中符合连接条件的行和右/左表任一符合连接条件的行组成的行数据集合。 + +#### 适用范围 +支持超级表、普通表、子表、子查询间 Left/Right Semi Join。 + +#### 示例 + +表 d1001 中出现电压大于 220V 且存在其他电表同一时刻电压也大于 220V 的时间: +```sql +SELECT a.ts FROM d1001 a LEFT SEMI JOIN meters b ON a.ts = b.ts and a.voltage > 220 and b.voltage > 220 and b.tbname != 'd1001' +``` + +### Left/Right Anti-Semi Join + +#### 定义 +左/右反连接 - 同左/右半连接的逻辑正好相反,通常表达的是 `NOT IN`/`NOT EXISTS` 的含义,即对左/右表任意一条数据来说,只有当右/左表中不存在任何符合连接条件的数据时才返回左/右表行数据。 + +#### 语法 +```sql +SELECT ... FROM table_name1 LEFT|RIGHT ANTI JOIN table_name2 ON ... [WHERE ...] [...] +``` + +#### 结果集 +左/右表中不符合连接条件的行和右/左表的空数据(`NULL`)组成的行数据集合。 + +#### 适用范围 +支持超级表、普通表、子表、子查询间 Left/Right Anti-Semi Join。 + +#### 示例 + +表 d1001 中出现电压大于 220V 且不存在其他电表同一时刻电压也大于 220V 的时间: +```sql +SELECT a.ts FROM d1001 a LEFT ANTI JOIN meters b ON a.ts = b.ts and b.voltage > 220 and b.tbname != 'd1001' WHERE a.voltage > 220 +``` + +### left/Right ASOF Join + +#### 定义 +左/右不完全匹配连接 - 不同于其他传统 Join 的完全匹配模式,ASOF Join 允许以指定的匹配模式进行不完全匹配,即按照主键时间戳最接近的方式进行匹配。 + +#### 语法 +```sql +SELECT ... FROM table_name1 LEFT|RIGHT ASOF JOIN table_name2 [ON ...] [JLIMIT jlimit_num] [WHERE ...] [...] +``` + +##### 结果集 +左/右表中每一行数据与右/左表中符合连接条件的按主键列排序后时间戳最接近的最多 `jlimit_num` 条数据或空数据(`NULL`)的笛卡尔积集合。 + +##### 适用范围 +支持超级表、普通表、子表间 Left/Right ASOF Join。 + +#### 说明 +- 只支持表间 ASOF Join,不支持子查询间 ASOF Join。 +- ON 子句中支持指定主键列或主键列的 timetruncate 函数运算(不支持其他标量运算及函数)后的单个匹配规则(主连接条件),支持的运算符及其含义如下: + + + | **运算符** | **Left ASOF 时含义** | + | :-------------: | ------------------------ | + | > | 匹配右表中主键时间戳小于左表主键时间戳且时间戳最接近的数据行 | + | >= | 匹配右表中主键时间戳小于等于左表主键时间戳且时间戳最接近的数据行 | + | = | 匹配右表中主键时间戳等于左表主键时间戳的行 | + | < | 匹配右表中主键时间戳大于左表主键时间戳且时间戳最接近的数据行 | + | <= | 匹配右表中主键时间戳大于等于左表主键时间戳且时间戳最接近的数据行 | + + 对于 Right ASOF 来说,上述运算符含义正好相反。 + +- 如果不含 `ON` 子句或 `ON` 子句中未指定主键列的匹配规则,则默认主键匹配规则运算符是 “>=”, 即(对 Left ASOF Join 来说)右表中主键时戳小于等于左表主键时戳的行数据。不支持多个主连接条件。 +- `ON` 子句中还可以指定除主键列外的 Tag、普通列(不支持标量函数及运算)之间的等值条件用于分组计算,除此之外不支持其他类型的条件。 +- 所有 ON 条件间只支持 `AND` 运算。 +- `JLIMIT` 用于指定单行匹配结果的最大行数,可选,未指定时默认值为1,即左/右表每行数据最多从右/左表中获得一行匹配结果。`JLIMIT` 取值范围为 [0, 1024]。符合匹配条件的 `jlimit_num` 条数据不要求时间戳相同,当右/左表中不存在满足条件的 `jlimit_num` 条数据时,返回的结果行数可能小于 `jlimit_num`;当右/左表中存在符合条件的多于 `jlimit_num` 条数据时,如果时间戳相同将随机返回 `jlimit_num` 条数据。 + +#### 示例 + +表 d1001 电压值大于 220V 且表 d1002 中同一时刻或稍早前最后时刻出现电压大于 220V 的时间及各自的电压值: +```sql +SELECT a.ts, a.voltage, a.ts, b.voltage FROM d1001 a LEFT ASOF JOIN d1002 b ON a.ts >= b.ts where a.voltage > 220 and b.voltage > 220 +``` + +### Left/Right Window Join + +#### 定义 +左/右窗口连接 - 根据左/右表中每一行的主键时间戳和窗口边界构造窗口并据此进行窗口连接,支持窗口内进行投影、标量和聚合操作。 + +#### 语法 +```sql +SELECT ... FROM table_name1 LEFT|RIGHT WINDOW JOIN table_name2 [ON ...] WINDOW_OFFSET(start_offset, end_offset) [JLIMIT jlimit_num] [WHERE ...] [...] +``` + +#### 结果集 +左/右表中每一行数据与右/左表中基于左/右表主键时戳列和 `WINDOW_OFFSET` 划分的窗口内的至多 `jlimit_num` 条数据或空数据(`NULL`)的笛卡尔积集合 或 +左/右表中每一行数据与右/左表中基于左/右表主键时戳列和 `WINDOW_OFFSET` 划分的窗口内的至多 `jlimit_num` 条数据的聚合结果或空数据(`NULL`)组成的行数据集合。 + +#### 适用范围 +支持超级表、普通表、子表间 Left/Right Window Join。 + +#### 说明 +- 只支持表间 Window Join,不支持子查询间 Window Join; +- `ON` 子句可选,只支持指定除主键列外的 Tag、普通列(不支持标量函数及运算)之间的等值条件用于分组计算,所有条件间只支持 `AND` 运算; +- `WINDOW_OFFSET` 用于指定窗口的左右边界相对于左/右表主键时间戳的偏移量,支持自带时间单位的形式,例如:`WINDOW_OFFSET(-1a, 1a)`,对于 Left Window Join 来说,表示每个窗口为 [左表主键时间戳 - 1毫秒,左表主键时间戳 + 1毫秒] ,左右边界均为闭区间。数字后面的时间单位可以是 `b`(纳秒)、`u`(微秒)、`a`(毫秒)、`s`(秒)、`m`(分)、`h`(小时)、`d`(天)、`w`(周),不支持自然月(`n`)、自然年(`y`),支持的最小时间单位为数据库精度,左右表所在数据库精度需保持一致。 +- `JLIMIT` 用于指定单个窗口内的最大匹配行数,可选,未指定时默认获取每个窗口内的所有匹配行。`JLIMIT` 取值范围为 [0, 1024],当右表中不存在满足条件的 `jlimit_num` 条数据时,返回的结果行数可能小于 `jlimit_num`;当右表中存在超过 `jlimit_num` 条满足条件的数据时,优先返回窗口内主键时间戳最小的 `jlimit_num` 条数据。 +- SQL 语句中不能含其他 `GROUP BY`/`PARTITION BY`/窗口查询; +- 支持在 `WHERE` 子句中进行标量过滤,支持在 `HAVING` 子句中针对每个窗口进行聚合函数过滤(不支持标量过滤),不支持 `SLIMIT`,不支持各种窗口伪列; + +#### 示例 + +表 d1001 电压值大于 220V 时前后1秒的区间内表 d1002 的电压值: +```sql +SELECT a.ts, a.voltage, b.voltage FROM d1001 a LEFT WINDOW JOIN d1002 b WINDOW_OFFSET(-1s, 1s) where a.voltage > 220 +``` + +表 d1001 电压值大于 220V 且前后1秒的区间内表 d1002 的电压平均值也大于 220V 的时间及电压值: +```sql +SELECT a.ts, a.voltage, avg(b.voltage) FROM d1001 a LEFT WINDOW JOIN d1002 b WINDOW_OFFSET(-1s, 1s) where a.voltage > 220 HAVING(avg(b.voltage) > 220) +``` + +### Full Outer Join + +#### 定义 +全(外)连接 - 既包含左右表同时符合连接条件的数据集合,也包括左右表中不符合连接条件的数据集合。 + +#### 语法 +SELECT ... FROM table_name1 FULL [OUTER] JOIN table_name2 ON ... [WHERE ...] [...] + +#### 结果集 +Inner Join 的结果集 + 左表中不符合连接条件的行加上右表的空数据组成的行数据集合 + 右表中不符合连接条件的行加上左表的空数据(`NULL`)组成的行数据集合。 + +#### 适用范围 +支持超级表、普通表、子表、子查询间 Full Outer Join。 + +#### 说明 +- OUTER 关键字可选。 + +#### 示例 + +表 d1001 和表 d1002 中记录的所有时刻及电压值: +```sql +SELECT a.ts, a.voltage, b.ts, b.voltage FROM d1001 a FULL JOIN d1002 b on a.ts = b.ts +``` + +## 约束和限制 + +### 输入时间线限制 +- 目前所有 Join 都要求输入数据含有效的主键时间线,所有表查询都可以满足,子查询需要注意输出数据是否含有效的主键时间线。 + +### 连接条件限制 +- 除 ASOF 和 Window Join 之外,其他 Join 的连接条件中必须含主键列的主连接条件; 且 +- 主连接条件与其他连接条件间只支持 `AND` 运算; +- 作为主连接条件的主键列只支持 `timetruncate` 函数运算(不支持其他函数和标量运算),作为其他连接条件时无限制; + +### 分组条件限制 +- 只支持除主键列外的 Tag、普通列的等值条件; +- 不支持标量运算; +- 支持多个分组条件,条件间只支持 `AND` 运算; + +### 查询结果顺序限制 +- 普通表、子表、子查询且无分组条件无排序的场景下,查询结果会按照驱动表的主键列顺序输出; +- 超级表查询、Full Join或有分组条件无排序的场景下,查询结果没有固定的输出顺序; +因此,在有排序需求且输出无固定顺序的场景下,需要进行排序操作。部分依赖时间线的函数可能会因为没有有效的时间线输出而无法执行。 + +### 嵌套 Join 与多表 Join 限制 +- 目前除 Inner Join 支持嵌套与多表 Join 外,其他类型的 JoiN 暂不支持嵌套与多表 Join。 diff --git a/include/common/tcol.h b/include/common/tcol.h index 26957f67c7..38f7130cbf 100644 --- a/include/common/tcol.h +++ b/include/common/tcol.h @@ -86,16 +86,16 @@ bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRES bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]); bool checkColumnLevelOrSetDefault(uint8_t type, char level[TSDB_CL_COMPRESS_OPTION_LEN]); -void setColEncode(uint32_t* compress, uint8_t encode); -void setColCompress(uint32_t* compress, uint16_t compressType); -void setColLevel(uint32_t* compress, uint8_t level); -int8_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check, - uint32_t* compress); +void setColEncode(uint32_t* compress, uint8_t encode); +void setColCompress(uint32_t* compress, uint16_t compressType); +void setColLevel(uint32_t* compress, uint8_t level); +int32_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check, + uint32_t* compress); int8_t validColCompressLevel(uint8_t type, uint8_t level); int8_t validColCompress(uint8_t type, uint8_t l2); int8_t validColEncode(uint8_t type, uint8_t l1); uint32_t createDefaultColCmprByType(uint8_t type); -bool validColCmprByType(uint8_t type, uint32_t cmpr); +int32_t validColCmprByType(uint8_t type, uint32_t cmpr); #endif /*_TD_TCOL_H_*/ diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 0968c59399..2c4a00a72d 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -176,6 +176,7 @@ typedef enum EStreamType { STREAM_CREATE_CHILD_TABLE, STREAM_TRANS_STATE, STREAM_MID_RETRIEVE, + STREAM_PARTITION_DELETE_DATA, } EStreamType; #pragma pack(push, 1) diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 2fbed98604..18bc24d612 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -153,6 +153,7 @@ typedef struct SJoinLogicNode { bool seqWinGroup; bool grpJoin; bool hashJoinHint; + bool batchScanHint; // FOR HASH JOIN int32_t timeRangeTarget; //table onCond filter diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 0f399da8fd..1b30fdcb01 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -444,6 +444,7 @@ typedef struct STaskCheckInfo { int64_t startTs; int32_t notReadyTasks; int32_t inCheckProcess; + int32_t stopCheckProcess; tmr_h checkRspTmr; TdThreadMutex checkInfoLock; } STaskCheckInfo; @@ -805,7 +806,7 @@ void initRpcMsg(SRpcMsg* pMsg, int32_t msgType, void* pCont, int32_t contLen); void streamTaskCheckDownstream(SStreamTask* pTask); int32_t streamTaskCheckStatus(SStreamTask* pTask, int32_t upstreamId, int32_t vgId, int64_t stage, int64_t* oldStage); -int32_t streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList); +bool streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList); void streamTaskResetUpstreamStageInfo(SStreamTask* pTask); bool streamTaskIsAllUpstreamClosed(SStreamTask* pTask); bool streamTaskSetSchedStatusWait(SStreamTask* pTask); @@ -831,7 +832,7 @@ bool streamHistoryTaskSetVerRangeStep2(SStreamTask* pTask, int64_t latestVer) int32_t streamQueueGetNumOfItems(const SStreamQueue* pQueue); // common -void streamTaskPause(SStreamMeta* pMeta, SStreamTask* pTask); +void streamTaskPause(SStreamTask* pTask); void streamTaskResume(SStreamTask* pTask); int32_t streamTaskStop(SStreamTask* pTask); int32_t streamTaskSetUpstreamInfo(SStreamTask* pTask, const SStreamTask* pUpstreamTask); @@ -844,14 +845,12 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, void* pTask, char* key); bool streamTaskIsSinkTask(const SStreamTask* pTask); int32_t streamTaskSendCheckpointReq(SStreamTask* pTask); -int32_t streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutputInfo, int64_t startTs); int32_t streamTaskAddReqInfo(STaskCheckInfo* pInfo, int64_t reqId, int32_t taskId, const char* id); int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t status, int64_t rspTs, int64_t reqId, int32_t* pNotReady, const char* id); void streamTaskCleanCheckInfo(STaskCheckInfo* pInfo); -int32_t streamTaskStartCheckDownstream(STaskCheckInfo* pInfo, const char* id); -int32_t streamTaskCompleteCheck(STaskCheckInfo* pInfo, const char* id); int32_t streamTaskStartMonitorCheckRsp(SStreamTask* pTask); +int32_t streamTaskStopMonitorCheckRsp(STaskCheckInfo* pInfo, const char* id); void streamTaskStatusInit(STaskStatusEntry* pEntry, const SStreamTask* pTask); void streamTaskStatusCopy(STaskStatusEntry* pDst, const STaskStatusEntry* pSrc); diff --git a/include/util/talgo.h b/include/util/talgo.h index b065ea3705..29c51cc16b 100644 --- a/include/util/talgo.h +++ b/include/util/talgo.h @@ -54,6 +54,12 @@ typedef int32_t (*__ext_compar_fn_t)(const void *p1, const void *p2, const void */ void taosqsort(void *src, int64_t numOfElem, int64_t size, const void *param, __ext_compar_fn_t comparFn); +/** + * Non-recursive quick sort. + * + */ +void taosqsort_r(void *src, int64_t nelem, int64_t size, const void *arg, __ext_compar_fn_t cmp); + /** * merge sort, with the compare function requiring additional parameters support * diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 75e6fc87e7..916de6e715 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -182,6 +182,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSC_STMT_CACHE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0230) #define TSDB_CODE_TSC_ENCODE_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0231) #define TSDB_CODE_TSC_ENCODE_PARAM_NULL TAOS_DEF_ERROR_CODE(0, 0X0232) +#define TSDB_CODE_TSC_COMPRESS_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0233) +#define TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR TAOS_DEF_ERROR_CODE(0, 0X0234) #define TSDB_CODE_TSC_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0X02FF) // mnode-common @@ -283,7 +285,6 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x036E) #define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x036F) #define TSDB_CODE_MND_FIELD_VALUE_OVERFLOW TAOS_DEF_ERROR_CODE(0, 0x0370) -#define TSDB_CODE_MND_COLUMN_COMPRESS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0371) // mnode-func @@ -406,6 +407,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_INVALID_TARGET_TABLE TAOS_DEF_ERROR_CODE(0, 0x03F7) +#define TSDB_CODE_MND_COLUMN_COMPRESS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03F8) // dnode // #define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) // 2.x diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 6c20813118..7f73aa6845 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -538,7 +538,6 @@ void stopAllQueries(SRequestObj *pRequest) { pTmp = acquireRequest(tmpRefId); if (pTmp) { pReqList[++reqIdx] = pTmp; - releaseRequest(tmpRefId); } else { tscError("prev req ref 0x%" PRIx64 " is not there", tmpRefId); break; @@ -547,6 +546,7 @@ void stopAllQueries(SRequestObj *pRequest) { for (int32_t i = reqIdx; i >= 0; i--) { taosStopQueryImpl(pReqList[i]); + releaseRequest(pReqList[i]->self); } taosStopQueryImpl(pRequest); diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index db86561e9b..8eabbb8098 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -660,13 +660,13 @@ static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* us taosRLockLatch(&tmq->lock); int32_t numOfTopics = taosArrayGetSize(tmq->clientTopics); - tscInfo("consumer:0x%" PRIx64 " start to commit offset for %d topics", tmq->consumerId, numOfTopics); + tscDebug("consumer:0x%" PRIx64 " start to commit offset for %d topics", tmq->consumerId, numOfTopics); for (int32_t i = 0; i < numOfTopics; i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); - tscInfo("consumer:0x%" PRIx64 " commit offset for topics:%s, numOfVgs:%d", tmq->consumerId, pTopic->topicName, + tscDebug("consumer:0x%" PRIx64 " commit offset for topics:%s, numOfVgs:%d", tmq->consumerId, pTopic->topicName, numOfVgroups); for (int32_t j = 0; j < numOfVgroups; j++) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); @@ -688,19 +688,19 @@ static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* us continue; } - tscInfo("consumer:0x%" PRIx64 + tscDebug("consumer:0x%" PRIx64 " topic:%s on vgId:%d send commit msg success, send offset:%s committed:%s, ordinal:%d/%d", tmq->consumerId, pTopic->topicName, pVg->vgId, offsetBuf, commitBuf, j + 1, numOfVgroups); tOffsetCopy(&pVg->offsetInfo.committedOffset, &pVg->offsetInfo.endOffset); } else { - tscInfo("consumer:0x%" PRIx64 " topic:%s vgId:%d, no commit, current:%" PRId64 ", ordinal:%d/%d", + tscDebug("consumer:0x%" PRIx64 " topic:%s vgId:%d, no commit, current:%" PRId64 ", ordinal:%d/%d", tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->offsetInfo.endOffset.version, j + 1, numOfVgroups); } } } taosRUnLockLatch(&tmq->lock); - tscInfo("consumer:0x%" PRIx64 " total commit:%d for %d topics", tmq->consumerId, pParamSet->waitingRspNum - 1, + tscDebug("consumer:0x%" PRIx64 " total commit:%d for %d topics", tmq->consumerId, pParamSet->waitingRspNum - 1, numOfTopics); // request is sent @@ -815,7 +815,7 @@ void tmqSendHbReq(void* param, void* tmrId) { offRows->ever = pVg->offsetInfo.walVerEnd; char buf[TSDB_OFFSET_LEN] = {0}; tFormatOffset(buf, TSDB_OFFSET_LEN, &offRows->offset); - tscInfo("consumer:0x%" PRIx64 ",report offset, group:%s vgId:%d, offset:%s/%" PRId64 ", rows:%" PRId64, + tscDebug("consumer:0x%" PRIx64 ",report offset, group:%s vgId:%d, offset:%s/%" PRId64 ", rows:%" PRId64, tmq->consumerId, tmq->groupId, offRows->vgId, buf, offRows->ever, offRows->rows); } } @@ -1058,6 +1058,7 @@ static void tmqMgmtInit(void) { #define SET_ERROR_MSG_TMQ(MSG) \ if (errstr != NULL) snprintf(errstr, errstrLen, MSG); + tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { if (conf == NULL) { SET_ERROR_MSG_TMQ("configure is null") @@ -1504,7 +1505,7 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) int32_t topicNumGet = taosArrayGetSize(pRsp->topics); if (epoch < tmq->epoch || (epoch == tmq->epoch && topicNumGet == 0)) { - tscInfo("consumer:0x%" PRIx64 " no update ep epoch from %d to epoch %d, incoming topics:%d", tmq->consumerId, + tscDebug("consumer:0x%" PRIx64 " no update ep epoch from %d to epoch %d, incoming topics:%d", tmq->consumerId, tmq->epoch, epoch, topicNumGet); if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__RECOVER) { atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__READY); @@ -1800,14 +1801,14 @@ static int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { for (int j = 0; j < numOfVg; j++) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); if (taosGetTimestampMs() - pVg->emptyBlockReceiveTs < EMPTY_BLOCK_POLL_IDLE_DURATION) { // less than 10ms - tscTrace("consumer:0x%" PRIx64 " epoch %d, vgId:%d idle for 10ms before start next poll", tmq->consumerId, + tscDebug("consumer:0x%" PRIx64 " epoch %d, vgId:%d idle for 10ms before start next poll", tmq->consumerId, tmq->epoch, pVg->vgId); continue; } if (tmq->replayEnable && taosGetTimestampMs() - pVg->blockReceiveTs < pVg->blockSleepForReplay) { // less than 10ms - tscTrace("consumer:0x%" PRIx64 " epoch %d, vgId:%d idle for %" PRId64 "ms before start next poll when replay", + tscDebug("consumer:0x%" PRIx64 " epoch %d, vgId:%d idle for %" PRId64 "ms before start next poll when replay", tmq->consumerId, tmq->epoch, pVg->vgId, pVg->blockSleepForReplay); continue; } @@ -1815,7 +1816,7 @@ static int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { int32_t vgStatus = atomic_val_compare_exchange_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE, TMQ_VG_STATUS__WAIT); if (vgStatus == TMQ_VG_STATUS__WAIT) { int32_t vgSkipCnt = atomic_add_fetch_32(&pVg->vgSkipCnt, 1); - tscTrace("consumer:0x%" PRIx64 " epoch %d wait poll-rsp, skip vgId:%d skip cnt %d", tmq->consumerId, tmq->epoch, + tscDebug("consumer:0x%" PRIx64 " epoch %d wait poll-rsp, skip vgId:%d skip cnt %d", tmq->consumerId, tmq->epoch, pVg->vgId, vgSkipCnt); continue; } @@ -1875,7 +1876,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper; if (pRspWrapper->code == TSDB_CODE_TMQ_CONSUMER_MISMATCH) { atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__RECOVER); - tscDebug("consumer:0x%" PRIx64 " wait for the re-balance, set status to be RECOVER", tmq->consumerId); + tscDebug("consumer:0x%" PRIx64 " wait for the rebalance, set status to be RECOVER", tmq->consumerId); } else if (pRspWrapper->code == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) { terrno = pRspWrapper->code; tscError("consumer:0x%" PRIx64 " unexpected rsp from poll, code:%s", tmq->consumerId, @@ -2476,7 +2477,7 @@ int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) { SMqRspHead* head = pMsg->pData; int32_t epoch = atomic_load_32(&tmq->epoch); - tscInfo("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d", tmq->consumerId, head->epoch, epoch); + tscDebug("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d", tmq->consumerId, head->epoch, epoch); if (pParam->sync) { SMqAskEpRsp rsp = {0}; tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp); @@ -2581,7 +2582,7 @@ void askEp(tmq_t* pTmq, void* param, bool sync, bool updateEpSet) { sendInfo->msgType = TDMT_MND_TMQ_ASK_EP; SEpSet epSet = getEpSet_s(&pTmq->pTscObj->pAppInfo->mgmtEp); - tscInfo("consumer:0x%" PRIx64 " ask ep from mnode, reqId:0x%" PRIx64, pTmq->consumerId, sendInfo->requestId); + tscDebug("consumer:0x%" PRIx64 " ask ep from mnode, reqId:0x%" PRIx64, pTmq->consumerId, sendInfo->requestId); int64_t transporterId = 0; code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); diff --git a/source/common/src/tcol.c b/source/common/src/tcol.c index afd121633d..5fb496cf14 100644 --- a/source/common/src/tcol.c +++ b/source/common/src/tcol.c @@ -306,22 +306,22 @@ void setColLevel(uint32_t* compress, uint8_t level) { return; } -int8_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check, - uint32_t* compress) { - if (check && !validColEncode(type, encode)) return 0; +int32_t setColCompressByOption(uint8_t type, uint8_t encode, uint16_t compressType, uint8_t level, bool check, + uint32_t* compress) { + if (check && !validColEncode(type, encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; setColEncode(compress, encode); if (compressType == TSDB_COLVAL_COMPRESS_DISABLED) { setColCompress(compress, compressType); setColLevel(compress, TSDB_COLVAL_LEVEL_DISABLED); } else { - if (check && !validColCompress(type, compressType)) return 0; + if (check && !validColCompress(type, compressType)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR; setColCompress(compress, compressType); - if (check && !validColCompressLevel(type, level)) return 0; + if (check && !validColCompressLevel(type, level)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR; setColLevel(compress, level); } - return 1; + return TSDB_CODE_SUCCESS; } bool useCompress(uint8_t tableType) { return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType; } @@ -397,10 +397,17 @@ uint32_t createDefaultColCmprByType(uint8_t type) { SET_COMPRESS(encode, compress, lvl, ret); return ret; } -bool validColCmprByType(uint8_t type, uint32_t cmpr) { +int32_t validColCmprByType(uint8_t type, uint32_t cmpr) { DEFINE_VAR(cmpr); - if (validColEncode(type, l1) && validColCompress(type, l2) && validColCompressLevel(type, lvl)) { - return true; + if (!validColEncode(type, l1)) { + return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; } - return false; + if (!validColCompress(type, l2)) { + return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR; + } + + if (!validColCompressLevel(type, lvl)) { + return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR; + } + return TSDB_CODE_SUCCESS; } diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 09e13939a4..6630ad59b1 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -190,30 +190,29 @@ static int32_t doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t cur } } - size_t start = 1; - int32_t t = 0; - int32_t count = log(numOfRows) / log(2); - uint32_t startOffset = (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) ? pColumnInfoData->varmeta.length : (currentRow * itemLen); - + size_t start = 1; + int32_t t = 0; + int32_t count = log(numOfRows) / log(2); + uint32_t startOffset = + (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) ? pColumnInfoData->varmeta.length : (currentRow * itemLen); + // the first item memcpy(pColumnInfoData->pData + startOffset, pData, itemLen); - + while (t < count) { int32_t xlen = 1 << t; - memcpy(pColumnInfoData->pData + start * itemLen + startOffset, - pColumnInfoData->pData + startOffset, + memcpy(pColumnInfoData->pData + start * itemLen + startOffset, pColumnInfoData->pData + startOffset, xlen * itemLen); t += 1; start += xlen; } - + // the tail part if (numOfRows > start) { - memcpy(pColumnInfoData->pData + start * itemLen + startOffset, - pColumnInfoData->pData + startOffset, + memcpy(pColumnInfoData->pData + start * itemLen + startOffset, pColumnInfoData->pData + startOffset, (numOfRows - start) * itemLen); } - + if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { for (int32_t i = 0; i < numOfRows; ++i) { pColumnInfoData->varmeta.offset[i + currentRow] = pColumnInfoData->varmeta.length + i * itemLen; @@ -233,7 +232,7 @@ int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, len = getJsonValueLen(pData); } else { len = varDataTLen(pData); - } + } if (pColumnInfoData->varmeta.allocLen < (numOfRows * len + pColumnInfoData->varmeta.length)) { int32_t code = colDataReserve(pColumnInfoData, (numOfRows * len + pColumnInfoData->varmeta.length)); if (code != TSDB_CODE_SUCCESS) { @@ -247,7 +246,7 @@ int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, void colDataSetNItemsNull(SColumnInfoData* pColumnInfoData, uint32_t currentRow, uint32_t numOfRows) { pColumnInfoData->hasNull = true; - + if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { memset(&pColumnInfoData->varmeta.offset[currentRow], -1, sizeof(int32_t) * numOfRows); } else { @@ -268,7 +267,7 @@ void colDataSetNItemsNull(SColumnInfoData* pColumnInfoData, uint32_t currentRow, int32_t bytes = (numOfRows - i) / 8; memset(&BMCharPos(pColumnInfoData->nullbitmap, currentRow + i), 0xFF, bytes); i += bytes * 8; - + for (; i < numOfRows; ++i) { colDataSetNull_f(pColumnInfoData->nullbitmap, currentRow + i); } @@ -491,7 +490,8 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p return 0; } -int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnInfoData* pSrc, int32_t srcIdx, int32_t numOfRows) { +int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnInfoData* pSrc, int32_t srcIdx, + int32_t numOfRows) { if (pDst->info.type != pSrc->info.type || pDst->info.bytes != pSrc->info.bytes || pSrc->reassigned) { return TSDB_CODE_FAILED; } @@ -502,7 +502,7 @@ int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnI if (IS_VAR_DATA_TYPE(pDst->info.type)) { int32_t allLen = 0; - void* srcAddr = NULL; + void* srcAddr = NULL; if (pSrc->hasNull) { for (int32_t i = 0; i < numOfRows; ++i) { if (colDataIsNull_var(pSrc, srcIdx + i)) { @@ -526,7 +526,7 @@ int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnI } } else { for (int32_t i = 0; i < numOfRows; ++i) { - char* pData = colDataGetVarData(pSrc, srcIdx + i); + char* pData = colDataGetVarData(pSrc, srcIdx + i); int32_t dataLen = 0; if (pSrc->info.type == TSDB_DATA_TYPE_JSON) { dataLen = getJsonValueLen(pData); @@ -545,7 +545,7 @@ int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnI if (tmp == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - + pDst->pData = tmp; pDst->varmeta.allocLen = pDst->varmeta.length + allLen; } @@ -585,17 +585,17 @@ int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnI } } } - } + } if (pSrc->pData != NULL) { - memcpy(pDst->pData + pDst->info.bytes * dstIdx, pSrc->pData + pSrc->info.bytes * srcIdx, pDst->info.bytes * numOfRows); + memcpy(pDst->pData + pDst->info.bytes * dstIdx, pSrc->pData + pSrc->info.bytes * srcIdx, + pDst->info.bytes * numOfRows); } } return 0; } - size_t blockDataGetNumOfCols(const SSDataBlock* pBlock) { return taosArrayGetSize(pBlock->pDataBlock); } size_t blockDataGetNumOfRows(const SSDataBlock* pBlock) { return pBlock->info.rows; } @@ -636,7 +636,7 @@ int32_t blockDataUpdatePkRange(SSDataBlock* pDataBlock, int32_t pkColumnIndex, b return -1; } - SDataBlockInfo* pInfo = &pDataBlock->info; + SDataBlockInfo* pInfo = &pDataBlock->info; SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, pkColumnIndex); if (!IS_NUMERIC_TYPE(pColInfoData->info.type) && (pColInfoData->info.type != TSDB_DATA_TYPE_VARCHAR)) { return 0; @@ -732,7 +732,7 @@ void blockDataShrinkNRows(SSDataBlock* pBlock, int32_t numOfRows) { int32_t bytes = (pBlock->info.rows - i) / 8; memset(&BMCharPos(pCol->nullbitmap, i), 0, bytes); i += bytes * 8; - + for (; i < pBlock->info.rows; ++i) { colDataClearNull_f(pCol->nullbitmap, i); } @@ -742,7 +742,6 @@ void blockDataShrinkNRows(SSDataBlock* pBlock, int32_t numOfRows) { pBlock->info.rows -= numOfRows; } - size_t blockDataGetSize(const SSDataBlock* pBlock) { size_t total = 0; size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); @@ -827,19 +826,16 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3 return NULL; } - blockDataEnsureCapacity(pDst, rowCount); + /* may have disorder varchar data, TODO + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); + SColumnInfoData* pDstCol = taosArrayGet(pDst->pDataBlock, i); -/* may have disorder varchar data, TODO - for (int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i); - SColumnInfoData* pDstCol = taosArrayGet(pDst->pDataBlock, i); - - colDataAssignNRows(pDstCol, 0, pColData, startIndex, rowCount); - } -*/ - + colDataAssignNRows(pDstCol, 0, pColData, startIndex, rowCount); + } + */ size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); for (int32_t i = 0; i < numOfCols; ++i) { @@ -1322,7 +1318,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { } terrno = 0; - taosqsort(index, rows, sizeof(int32_t), &helper, dataBlockCompar); + taosqsort_r(index, rows, sizeof(int32_t), &helper, dataBlockCompar); if (terrno) return terrno; int64_t p1 = taosGetTimestampUs(); @@ -1400,14 +1396,13 @@ void blockDataReset(SSDataBlock* pDataBlock) { pInfo->id.groupId = 0; } - /* * NOTE: the type of the input column may be TSDB_DATA_TYPE_NULL, which is used to denote * the all NULL value in this column. It is an internal representation of all NULL value column, and no visible to * any users. The length of TSDB_DATA_TYPE_NULL is 0, and it is an special case. */ int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockInfo, uint32_t numOfRows, - bool clearPayload) { + bool clearPayload) { if (numOfRows <= 0 || pBlockInfo && numOfRows <= pBlockInfo->capacity) { return TSDB_CODE_SUCCESS; } @@ -2402,12 +2397,12 @@ _end: return TSDB_CODE_SUCCESS; } -void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId){ +void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId) { char tmp[TSDB_TABLE_NAME_LEN] = {0}; - if (stbName == NULL){ - snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%"PRIu64, groupId); - }else{ - snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%s_%"PRIu64, stbName, groupId); + if (stbName == NULL) { + snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%" PRIu64, groupId); + } else { + snprintf(tmp, TSDB_TABLE_NAME_LEN, "_%s_%" PRIu64, stbName, groupId); } ctbName[TSDB_TABLE_NAME_LEN - strlen(tmp) - 1] = 0; // put stbname + groupId to the end strcat(ctbName, tmp); diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index acd0a2009c..68c55e235f 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -166,7 +166,7 @@ typedef struct { int32_t failedTimes; void* rpcRsp; int32_t rpcRspLen; - int32_t redoActionPos; + int32_t actionPos; SArray* prepareActions; SArray* redoActions; SArray* undoActions; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index ef0d246171..6d638dab3b 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -860,11 +860,6 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) { SUserObj *pUser = NULL; SCreateDbReq createReq = {0}; - if ((terrno = grantCheck(TSDB_GRANT_DB)) != 0) { - code = terrno; - goto _OVER; - } - if (tDeserializeSCreateDbReq(pReq->pCont, pReq->contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; goto _OVER; @@ -903,6 +898,11 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) { } } + if ((terrno = grantCheck(TSDB_GRANT_DB)) != 0) { + code = terrno; + goto _OVER; + } + if ((code = mndCheckDbEncryptKey(pMnode, &createReq)) != 0) { terrno = code; goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index dd569b4c59..aaa0c42262 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -1526,6 +1526,8 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) { int32_t code = -1; STransAction createStreamRedoAction = {0}; STransAction createStreamUndoAction = {0}; + STransAction dropStbUndoAction = {0}; + SMDropStbReq dropStbReq = {0}; STrans *pTrans = mndTransCreate(pCxt->pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pCxt->pRpcReq, "create-tsma"); if (!pTrans) { @@ -1556,7 +1558,7 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) { createStreamUndoAction.epSet = createStreamRedoAction.epSet; createStreamUndoAction.acceptableCode = TSDB_CODE_MND_STREAM_NOT_EXIST; - createStreamUndoAction.actionType = TDMT_STREAM_DROP; + createStreamUndoAction.msgType = TDMT_STREAM_DROP; createStreamUndoAction.contLen = tSerializeSMDropStreamReq(0, 0, pCxt->pDropStreamReq); createStreamUndoAction.pCont = taosMemoryCalloc(1, createStreamUndoAction.contLen); if (!createStreamUndoAction.pCont) { @@ -1569,6 +1571,24 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) { goto _OVER; } + dropStbReq.igNotExists = true; + strncpy(dropStbReq.name, pCxt->targetStbFullName, TSDB_TABLE_FNAME_LEN); + dropStbUndoAction.epSet = createStreamRedoAction.epSet; + dropStbUndoAction.acceptableCode = TSDB_CODE_MND_STB_NOT_EXIST; + dropStbUndoAction.retryCode = TSDB_CODE_MND_STREAM_MUST_BE_DELETED; + dropStbUndoAction.msgType = TDMT_MND_STB_DROP; + dropStbUndoAction.contLen = tSerializeSMDropStbReq(0, 0, &dropStbReq); + dropStbUndoAction.pCont = taosMemoryCalloc(1, dropStbUndoAction.contLen); + if (!dropStbUndoAction.pCont) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + if (dropStbUndoAction.contLen != tSerializeSMDropStbReq(dropStbUndoAction.pCont, dropStbUndoAction.contLen, &dropStbReq)) { + mError("sma: %s, failed to create due to drop stb req encode failure", pCxt->pCreateSmaReq->name); + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + SDbObj newDb = {0}; memcpy(&newDb, pCxt->pDb, sizeof(SDbObj)); newDb.tsmaVersion++; @@ -1579,6 +1599,7 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) { if (mndSetCreateSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma) != 0) goto _OVER; if (mndTransAppendRedoAction(pTrans, &createStreamRedoAction) != 0) goto _OVER; if (mndTransAppendUndoAction(pTrans, &createStreamUndoAction) != 0) goto _OVER; + if (mndTransAppendUndoAction(pTrans, &dropStbUndoAction) != 0) goto _OVER; if (mndTransPrepare(pCxt->pMnode, pTrans) != 0) goto _OVER; code = TSDB_CODE_SUCCESS; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index e7276c3e57..b50ed095bd 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -63,7 +63,7 @@ static int32_t mndProcessCreateIndexReq(SRpcMsg *pReq); static int32_t mndProcessDropIndexReq(SRpcMsg *pReq); static int32_t mndProcessDropStbReqFromMNode(SRpcMsg *pReq); -static int32_t mndProcessDropTbWithTsma(SRpcMsg* pReq); +static int32_t mndProcessDropTbWithTsma(SRpcMsg *pReq); static int32_t mndProcessFetchTtlExpiredTbs(SRpcMsg *pReq); int32_t mndInitStb(SMnode *pMnode) { @@ -1006,7 +1006,8 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) { pHead->vgId = htonl(pVgroup->vgId); tSerializeSVDropTtlTableReq((char *)pHead + sizeof(SMsgHead), reqLen, &ttlReq); - SRpcMsg rpcMsg = {.msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS, .pCont = pHead, .contLen = contLen, .info = pReq->info}; + SRpcMsg rpcMsg = { + .msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS, .pCont = pHead, .contLen = contLen, .info = pReq->info}; SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup); int32_t code = tmsgSendReq(&epSet, &rpcMsg); if (code != 0) { @@ -1752,9 +1753,10 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj * if (mndAllocStbSchemas(pOld, pNew) != 0) { return -1; } - if (!validColCmprByType(pTarget->type, p->bytes)) { - terrno = TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - return -1; + code = validColCmprByType(pTarget->type, p->bytes); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + return code; } int8_t updated = 0; @@ -3885,32 +3887,33 @@ typedef struct SMDropTbDbInfo { } SMDropTbDbInfo; typedef struct SMDropTbTsmaInfo { - char tsmaResTbDbFName[TSDB_DB_FNAME_LEN]; - char tsmaResTbNamePrefix[TSDB_TABLE_NAME_LEN]; - int32_t suid; - SMDropTbDbInfo dbInfo; // reference to DbInfo in pDbMap + char tsmaResTbDbFName[TSDB_DB_FNAME_LEN]; + char tsmaResTbNamePrefix[TSDB_TABLE_NAME_LEN]; + int32_t suid; + SMDropTbDbInfo dbInfo; // reference to DbInfo in pDbMap } SMDropTbTsmaInfo; typedef struct SMDropTbTsmaInfos { - SArray* pTsmaInfos; // SMDropTbTsmaInfo + SArray *pTsmaInfos; // SMDropTbTsmaInfo } SMDropTbTsmaInfos; typedef struct SMndDropTbsWithTsmaCtx { - SHashObj* pTsmaMap; // - SHashObj* pDbMap; // - SHashObj* pVgMap; // - SArray* pResTbNames; // SArray + SHashObj *pTsmaMap; // + SHashObj *pDbMap; // + SHashObj *pVgMap; // + SArray *pResTbNames; // SArray } SMndDropTbsWithTsmaCtx; -static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWithTsmaCtx* pCtx, SArray* pTbs, int32_t vgId); +static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWithTsmaCtx *pCtx, SArray *pTbs, + int32_t vgId); -static void mndDestroyDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx* p) { +static void mndDestroyDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx *p) { if (!p) return; if (p->pDbMap) { - void* pIter = taosHashIterate(p->pDbMap, NULL); + void *pIter = taosHashIterate(p->pDbMap, NULL); while (pIter) { - SMDropTbDbInfo* pInfo = pIter; + SMDropTbDbInfo *pInfo = pIter; taosArrayDestroy(pInfo->dbVgInfos); pIter = taosHashIterate(p->pDbMap, pIter); } @@ -3920,9 +3923,9 @@ static void mndDestroyDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx* p) { taosArrayDestroyP(p->pResTbNames, taosMemoryFree); } if (p->pTsmaMap) { - void* pIter = taosHashIterate(p->pTsmaMap, NULL); + void *pIter = taosHashIterate(p->pTsmaMap, NULL); while (pIter) { - SMDropTbTsmaInfos* pInfos = pIter; + SMDropTbTsmaInfos *pInfos = pIter; taosArrayDestroy(pInfos->pTsmaInfos); pIter = taosHashIterate(p->pTsmaMap, pIter); } @@ -3930,7 +3933,7 @@ static void mndDestroyDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx* p) { } if (p->pVgMap) { - void* pIter = taosHashIterate(p->pVgMap, NULL); + void *pIter = taosHashIterate(p->pVgMap, NULL); while (pIter) { SVDropTbVgReqs *pReqs = pIter; taosArrayDestroy(pReqs->req.pArray); @@ -3941,9 +3944,9 @@ static void mndDestroyDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx* p) { taosMemoryFree(p); } -static int32_t mndInitDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx** ppCtx) { - int32_t code = 0; - SMndDropTbsWithTsmaCtx* pCtx = taosMemoryCalloc(1, sizeof(SMndDropTbsWithTsmaCtx)); +static int32_t mndInitDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx **ppCtx) { + int32_t code = 0; + SMndDropTbsWithTsmaCtx *pCtx = taosMemoryCalloc(1, sizeof(SMndDropTbsWithTsmaCtx)); if (!pCtx) return TSDB_CODE_OUT_OF_MEMORY; pCtx->pTsmaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); if (!pCtx->pTsmaMap) { @@ -3969,12 +3972,12 @@ _end: return code; } - -static void* mndBuildVDropTbsReq(SMnode* pMnode, const SVgroupInfo* pVgInfo, const SVDropTbBatchReq* pReq, int32_t *len) { - int32_t contLen = 0; - int32_t ret = 0; - SMsgHead *pHead = NULL; - SEncoder encoder = {0}; +static void *mndBuildVDropTbsReq(SMnode *pMnode, const SVgroupInfo *pVgInfo, const SVDropTbBatchReq *pReq, + int32_t *len) { + int32_t contLen = 0; + int32_t ret = 0; + SMsgHead *pHead = NULL; + SEncoder encoder = {0}; tEncodeSize(tEncodeSVDropTbBatchReq, pReq, contLen, ret); if (ret < 0) return NULL; @@ -3999,7 +4002,8 @@ static void* mndBuildVDropTbsReq(SMnode* pMnode, const SVgroupInfo* pVgInfo, con return pHead; } -static int32_t mndSetDropTbsRedoActions(SMnode* pMnode, STrans* pTrans, const SVDropTbVgReqs* pVgReqs, void* pCont, int32_t contLen) { +static int32_t mndSetDropTbsRedoActions(SMnode *pMnode, STrans *pTrans, const SVDropTbVgReqs *pVgReqs, void *pCont, + int32_t contLen) { STransAction action = {0}; action.epSet = pVgReqs->info.epSet; action.pCont = pCont; @@ -4009,7 +4013,7 @@ static int32_t mndSetDropTbsRedoActions(SMnode* pMnode, STrans* pTrans, const SV return mndTransAppendRedoAction(pTrans, &action); } -static int32_t mndCreateDropTbsTxnPrepare(SRpcMsg* pRsp, SMndDropTbsWithTsmaCtx* pCtx) { +static int32_t mndCreateDropTbsTxnPrepare(SRpcMsg *pRsp, SMndDropTbsWithTsmaCtx *pCtx) { SMnode *pMnode = pRsp->info.node; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pRsp, "drop-tbs"); mndTransSetChangeless(pTrans); @@ -4017,11 +4021,11 @@ static int32_t mndCreateDropTbsTxnPrepare(SRpcMsg* pRsp, SMndDropTbsWithTsmaCtx* if (mndTransCheckConflict(pMnode, pTrans) != 0) goto _OVER; - void* pIter = taosHashIterate(pCtx->pVgMap, NULL); + void *pIter = taosHashIterate(pCtx->pVgMap, NULL); while (pIter) { - const SVDropTbVgReqs* pVgReqs = pIter; - int32_t len = 0; - void* p = mndBuildVDropTbsReq(pMnode, &pVgReqs->info, &pVgReqs->req, &len); + const SVDropTbVgReqs *pVgReqs = pIter; + int32_t len = 0; + void *p = mndBuildVDropTbsReq(pMnode, &pVgReqs->info, &pVgReqs->req, &len); if (!p || mndSetDropTbsRedoActions(pMnode, pTrans, pVgReqs, p, len) != 0) { taosHashCancelIterate(pCtx->pVgMap, pIter); goto _OVER; @@ -4035,28 +4039,27 @@ _OVER: return terrno; } -static int32_t mndProcessDropTbWithTsma(SRpcMsg* pReq) { - int32_t code = -1; - SMnode *pMnode = pReq->info.node; - SDbObj *pDb = NULL; - SStbObj *pStb = NULL; - SMDropTbsReq dropReq = {0}; - bool locked = false; +static int32_t mndProcessDropTbWithTsma(SRpcMsg *pReq) { + int32_t code = -1; + SMnode *pMnode = pReq->info.node; + SDbObj *pDb = NULL; + SStbObj *pStb = NULL; + SMDropTbsReq dropReq = {0}; + bool locked = false; if (tDeserializeSMDropTbsReq(pReq->pCont, pReq->contLen, &dropReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; goto _OVER; } - SMndDropTbsWithTsmaCtx* pCtx = NULL; + SMndDropTbsWithTsmaCtx *pCtx = NULL; terrno = mndInitDropTbsWithTsmaCtx(&pCtx); if (terrno) goto _OVER; for (int32_t i = 0; i < dropReq.pVgReqs->size; ++i) { - SMDropTbReqsOnSingleVg* pReq = taosArrayGet(dropReq.pVgReqs, i); + SMDropTbReqsOnSingleVg *pReq = taosArrayGet(dropReq.pVgReqs, i); terrno = mndDropTbAddTsmaResTbsForSingleVg(pMnode, pCtx, pReq->pTbs, pReq->vgInfo.vgId); if (terrno) goto _OVER; } - if (mndCreateDropTbsTxnPrepare(pReq, pCtx) == 0) - code = 0; + if (mndCreateDropTbsTxnPrepare(pReq, pCtx) == 0) code = 0; _OVER: tFreeSMDropTbsReq(&dropReq); if (pCtx) mndDestroyDropTbsWithTsmaCtx(pCtx); @@ -4067,8 +4070,8 @@ static int32_t mndDropTbAdd(SMnode *pMnode, SHashObj *pVgHashMap, const SVgroupI bool ignoreNotExists) { SVDropTbReq req = {.name = name, .suid = suid, .igNotExists = ignoreNotExists}; - SVDropTbVgReqs * pReqs = taosHashGet(pVgHashMap, &pVgInfo->vgId, sizeof(pVgInfo->vgId)); - SVDropTbVgReqs reqs = {0}; + SVDropTbVgReqs *pReqs = taosHashGet(pVgHashMap, &pVgInfo->vgId, sizeof(pVgInfo->vgId)); + SVDropTbVgReqs reqs = {0}; if (pReqs == NULL) { reqs.info = *pVgInfo; reqs.req.pArray = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVDropTbReq)); @@ -4080,16 +4083,16 @@ static int32_t mndDropTbAdd(SMnode *pMnode, SHashObj *pVgHashMap, const SVgroupI return 0; } -static int32_t mndGetDbVgInfoForTsma(SMnode* pMnode, const char* dbname, SMDropTbTsmaInfo* pInfo) { +static int32_t mndGetDbVgInfoForTsma(SMnode *pMnode, const char *dbname, SMDropTbTsmaInfo *pInfo) { int32_t code = 0; - SDbObj* pDb = mndAcquireDb(pMnode, dbname); + SDbObj *pDb = mndAcquireDb(pMnode, dbname); if (!pDb) { code = TSDB_CODE_MND_DB_NOT_EXIST; goto _end; } pInfo->dbInfo.dbVgInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo)); - if ( !pInfo->dbInfo.dbVgInfos) { + if (!pInfo->dbInfo.dbVgInfos) { code = TSDB_CODE_OUT_OF_MEMORY; goto _end; } @@ -4108,9 +4111,9 @@ _end: return code; } -int32_t vgHashValCmp(const void* lp, const void* rp) { - uint32_t* key = (uint32_t*)lp; - SVgroupInfo* pVg = (SVgroupInfo*)rp; +int32_t vgHashValCmp(const void *lp, const void *rp) { + uint32_t *key = (uint32_t *)lp; + SVgroupInfo *pVg = (SVgroupInfo *)rp; if (*key < pVg->hashBegin) { return -1; @@ -4121,23 +4124,26 @@ int32_t vgHashValCmp(const void* lp, const void* rp) { return 0; } -static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWithTsmaCtx* pCtx, SArray* pTbs, int32_t vgId) { +static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWithTsmaCtx *pCtx, SArray *pTbs, + int32_t vgId) { int32_t code = 0; - SVgObj* pVgObj = mndAcquireVgroup(pMnode, vgId); + SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId); if (!pVgObj) { code = 0; goto _end; } - SVgroupInfo vgInfo = {.hashBegin = pVgObj->hashBegin, .hashEnd = pVgObj->hashEnd, .numOfTable = pVgObj->numOfTables, .vgId = pVgObj->vgId}; + SVgroupInfo vgInfo = {.hashBegin = pVgObj->hashBegin, + .hashEnd = pVgObj->hashEnd, + .numOfTable = pVgObj->numOfTables, + .vgId = pVgObj->vgId}; vgInfo.epSet = mndGetVgroupEpset(pMnode, pVgObj); mndReleaseVgroup(pMnode, pVgObj); // get all stb uids for (int32_t i = 0; i < pTbs->size; ++i) { - const SVDropTbReq* pTb = taosArrayGet(pTbs, i); + const SVDropTbReq *pTb = taosArrayGet(pTbs, i); if (taosHashGet(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid))) { - } else { SMDropTbTsmaInfos infos = {0}; infos.pTsmaInfos = taosArrayInit(2, sizeof(SMDropTbTsmaInfo)); @@ -4156,14 +4162,14 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWith while (1) { pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSma); if (!pIter) break; - SMDropTbTsmaInfos* pInfos = taosHashGet(pCtx->pTsmaMap, &pSma->stbUid, sizeof(pSma->stbUid)); + SMDropTbTsmaInfos *pInfos = taosHashGet(pCtx->pTsmaMap, &pSma->stbUid, sizeof(pSma->stbUid)); if (pInfos) { SMDropTbTsmaInfo info = {0}; - int32_t len = sprintf(buf, "%s", pSma->name); + int32_t len = sprintf(buf, "%s", pSma->name); len = taosCreateMD5Hash(buf, len); sprintf(info.tsmaResTbDbFName, "%s", pSma->db); snprintf(info.tsmaResTbNamePrefix, TSDB_TABLE_NAME_LEN, "%s", buf); - SMDropTbDbInfo* pDbInfo = taosHashGet(pCtx->pDbMap, pSma->db, TSDB_DB_FNAME_LEN); + SMDropTbDbInfo *pDbInfo = taosHashGet(pCtx->pDbMap, pSma->db, TSDB_DB_FNAME_LEN); info.suid = pSma->dstTbUid; if (!pDbInfo) { code = mndGetDbVgInfoForTsma(pMnode, pSma->db, &info); @@ -4183,7 +4189,7 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWith // generate vg req map for (int32_t i = 0; i < pTbs->size; ++i) { - SVDropTbReq* pTb = taosArrayGet(pTbs, i); + SVDropTbReq *pTb = taosArrayGet(pTbs, i); mndDropTbAdd(pMnode, pCtx->pVgMap, &vgInfo, pTb->name, pTb->suid, pTb->igNotExists); SMDropTbTsmaInfos *pInfos = taosHashGet(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid)); @@ -4195,7 +4201,7 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWith uint32_t hashVal = taosGetTbHashVal(buf, len, pInfo->dbInfo.hashMethod, pInfo->dbInfo.hashPrefix, pInfo->dbInfo.hashSuffix); const SVgroupInfo *pVgInfo = taosArraySearch(pInfo->dbInfo.dbVgInfos, &hashVal, vgHashValCmp, TD_EQ); - void* p = taosStrdup(buf + strlen(pInfo->tsmaResTbDbFName) + TSDB_NAME_DELIMITER_LEN); + void *p = taosStrdup(buf + strlen(pInfo->tsmaResTbDbFName) + TSDB_NAME_DELIMITER_LEN); taosArrayPush(pCtx->pResTbNames, &p); mndDropTbAdd(pMnode, pCtx->pVgMap, pVgInfo, p, pInfo->suid, true); } @@ -4225,8 +4231,7 @@ static int32_t mndProcessFetchTtlExpiredTbs(SRpcMsg *pRsp) { terrno = mndDropTbAddTsmaResTbsForSingleVg(pMnode, pCtx, rsp.pExpiredTbs, rsp.vgId); if (terrno) goto _end; - if (mndCreateDropTbsTxnPrepare(pRsp, pCtx) == 0) - code = 0; + if (mndCreateDropTbsTxnPrepare(pRsp, pCtx) == 0) code = 0; _end: if (pCtx) mndDestroyDropTbsWithTsmaCtx(pCtx); tDecoderClear(&decoder); diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 521f359f73..796553b5ad 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -699,10 +699,6 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { int32_t sqlLen = 0; terrno = TSDB_CODE_SUCCESS; - if ((terrno = grantCheck(TSDB_GRANT_STREAMS)) < 0) { - return terrno; - } - SCMCreateStreamReq createReq = {0}; if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -733,6 +729,10 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { goto _OVER; } + if ((terrno = grantCheck(TSDB_GRANT_STREAMS)) < 0) { + goto _OVER; + } + if (createReq.sql != NULL) { sqlLen = strlen(createReq.sql); sql = taosMemoryMalloc(sqlLen + 1); diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index c875deb972..8bbaadd203 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -438,10 +438,10 @@ static void processSubOffsetRows(SMnode *pMnode, const SMqRebInputObj *pInput, S } static void printRebalanceLog(SMqRebOutputObj *pOutput){ - mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", pOutput->pSub->key); + mInfo("sub:%s mq rebalance calculation completed, re-balanced vg", pOutput->pSub->key); for (int32_t i = 0; i < taosArrayGetSize(pOutput->rebVgs); i++) { SMqRebOutputVg *pOutputRebVg = taosArrayGet(pOutput->rebVgs, i); - mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, pOutput->pSub->key, + mInfo("sub:%s mq rebalance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, pOutput->pSub->key, pOutputRebVg->pVgEp->vgId, pOutputRebVg->oldConsumerId, pOutputRebVg->newConsumerId); } @@ -451,10 +451,10 @@ static void printRebalanceLog(SMqRebOutputObj *pOutput){ if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t sz = taosArrayGetSize(pConsumerEp->vgs); - mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", pOutput->pSub->key, pConsumerEp->consumerId, sz); + mInfo("sub:%s mq rebalance final cfg: consumer:0x%" PRIx64 " has %d vg", pOutput->pSub->key, pConsumerEp->consumerId, sz); for (int32_t i = 0; i < sz; i++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i); - mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, pOutput->pSub->key, pVgEp->vgId, + mInfo("sub:%s mq rebalance final cfg: vg %d to consumer:0x%" PRIx64, pOutput->pSub->key, pVgEp->vgId, pConsumerEp->consumerId); } } @@ -762,18 +762,18 @@ static void mndCheckConsumer(SRpcMsg *pMsg, SHashObj* rebSubHash) { bool mndRebTryStart() { int32_t old = atomic_val_compare_exchange_32(&mqRebInExecCnt, 0, 1); - mInfo("rebalance counter old val:%d", old); + if (old > 0) mInfo("[rebalance] counter old val:%d", old) return old == 0; } void mndRebCntInc() { int32_t val = atomic_add_fetch_32(&mqRebInExecCnt, 1); - mInfo("rebalance cnt inc, value:%d", val); + if (val > 0) mInfo("[rebalance] cnt inc, value:%d", val) } void mndRebCntDec() { int32_t val = atomic_sub_fetch_32(&mqRebInExecCnt, 1); - mInfo("rebalance cnt sub, value:%d", val); + if (val > 0) mInfo("[rebalance] cnt sub, value:%d", val) } static void clearRebOutput(SMqRebOutputObj *rebOutput){ @@ -848,10 +848,10 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { int code = 0; void *pIter = NULL; SMnode *pMnode = pMsg->info.node; - mInfo("[rebalance] start to process mq timer"); + mDebug("[rebalance] start to process mq timer") if (!mndRebTryStart()) { - mInfo("[rebalance] mq rebalance already in progress, do nothing"); + mInfo("[rebalance] mq rebalance already in progress, do nothing") return code; } @@ -863,7 +863,9 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { taosHashSetFreeFp(rebSubHash, freeRebalanceItem); mndCheckConsumer(pMsg, rebSubHash); - mInfo("[rebalance] mq re-balance start, total required re-balanced trans:%d", taosHashGetSize(rebSubHash)); + if (taosHashGetSize(rebSubHash) > 0) { + mInfo("[rebalance] mq rebalance start, total required re-balanced trans:%d", taosHashGetSize(rebSubHash)) + } while (1) { pIter = taosHashIterate(rebSubHash, pIter); @@ -887,13 +889,15 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { mndDoRebalance(pMnode, &rebInput, &rebOutput); if (mndPersistRebResult(pMnode, pMsg, &rebOutput) != 0) { - mError("mq re-balance persist output error, possibly vnode splitted or dropped,msg:%s", terrstr()); + mError("mq rebalance persist output error, possibly vnode splitted or dropped,msg:%s", terrstr()) } clearRebOutput(&rebOutput); } - mInfo("[rebalance] mq re-balance completed successfully, wait trans finish"); + if (taosHashGetSize(rebSubHash) > 0) { + mInfo("[rebalance] mq rebalance completed successfully, wait trans finish") + } END: taosHashCancelIterate(rebSubHash, pIter); diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 4a0d58a32e..8a06b4a613 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -561,15 +561,6 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { SMqTopicObj *pTopic = NULL; SDbObj *pDb = NULL; SCMCreateTopicReq createTopicReq = {0}; - if (sdbGetSize(pMnode->pSdb, SDB_TOPIC) >= tmqMaxTopicNum){ - terrno = TSDB_CODE_TMQ_TOPIC_OUT_OF_RANGE; - mError("topic num out of range"); - return code; - } - - if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) { - return code; - } if (tDeserializeSCMCreateTopicReq(pReq->pCont, pReq->contLen, &createTopicReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -609,6 +600,16 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { goto _OVER; } + if (sdbGetSize(pMnode->pSdb, SDB_TOPIC) >= tmqMaxTopicNum){ + terrno = TSDB_CODE_TMQ_TOPIC_OUT_OF_RANGE; + mError("topic num out of range"); + goto _OVER; + } + + if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) { + goto _OVER; + } + code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb, pReq->info.conn.user); if (code == 0) { code = TSDB_CODE_ACTION_IN_PROGRESS; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 41ff45038f..84940e01d4 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -169,7 +169,7 @@ SSdbRaw *mndTransEncode(STrans *pTrans) { SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, _OVER) SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_BINARY(pRaw, dataPos, pTrans->stbname, TSDB_TABLE_FNAME_LEN, _OVER) - SDB_SET_INT32(pRaw, dataPos, pTrans->redoActionPos, _OVER) + SDB_SET_INT32(pRaw, dataPos, pTrans->actionPos, _OVER) int32_t prepareActionNum = taosArrayGetSize(pTrans->prepareActions); int32_t redoActionNum = taosArrayGetSize(pTrans->redoActions); @@ -317,7 +317,7 @@ SSdbRow *mndTransDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, _OVER) SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_TABLE_FNAME_LEN, _OVER) SDB_GET_BINARY(pRaw, dataPos, pTrans->stbname, TSDB_TABLE_FNAME_LEN, _OVER) - SDB_GET_INT32(pRaw, dataPos, &pTrans->redoActionPos, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pTrans->actionPos, _OVER) if (sver > TRANS_VER1_NUMBER) { SDB_GET_INT32(pRaw, dataPos, &prepareActionNum, _OVER) @@ -525,7 +525,7 @@ static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) { mndTransUpdateActions(pOld->undoActions, pNew->undoActions); mndTransUpdateActions(pOld->commitActions, pNew->commitActions); pOld->stage = pNew->stage; - pOld->redoActionPos = pNew->redoActionPos; + pOld->actionPos = pNew->actionPos; if (pOld->stage == TRN_STAGE_COMMIT) { pOld->stage = TRN_STAGE_COMMIT_ACTION; @@ -1109,7 +1109,7 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) { goto _OVER; } - int32_t actionNum = taosArrayGetSize(pTrans->redoActions); + int32_t actionNum = taosArrayGetSize(pArray); if (action < 0 || action >= actionNum) { mError("trans:%d, invalid action:%d", transId, action); goto _OVER; @@ -1360,22 +1360,19 @@ static int32_t mndTransExecuteCommitActions(SMnode *pMnode, STrans *pTrans, bool return code; } -static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) { +static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArray *pActions, bool topHalf) { int32_t code = 0; - int32_t numOfActions = taosArrayGetSize(pTrans->redoActions); + int32_t numOfActions = taosArrayGetSize(pActions); if (numOfActions == 0) return code; - taosThreadMutexLock(&pTrans->mutex); - - if (pTrans->redoActionPos >= numOfActions) { - taosThreadMutexUnlock(&pTrans->mutex); + if (pTrans->actionPos >= numOfActions) { return code; } - mInfo("trans:%d, execute %d actions serial, current redoAction:%d", pTrans->id, numOfActions, pTrans->redoActionPos); + mInfo("trans:%d, execute %d actions serial, current redoAction:%d", pTrans->id, numOfActions, pTrans->actionPos); - for (int32_t action = pTrans->redoActionPos; action < numOfActions; ++action) { - STransAction *pAction = taosArrayGet(pTrans->redoActions, pTrans->redoActionPos); + for (int32_t action = pTrans->actionPos; action < numOfActions; ++action) { + STransAction *pAction = taosArrayGet(pActions, pTrans->actionPos); code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf); if (code == 0) { @@ -1409,14 +1406,14 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans, if (code == 0) { pTrans->code = 0; - pTrans->redoActionPos++; + pTrans->actionPos++; mInfo("trans:%d, %s:%d is executed and need sync to other mnodes", pTrans->id, mndTransStr(pAction->stage), pAction->id); taosThreadMutexUnlock(&pTrans->mutex); code = mndTransSync(pMnode, pTrans); taosThreadMutexLock(&pTrans->mutex); if (code != 0) { - pTrans->redoActionPos--; + pTrans->actionPos--; pTrans->code = terrno; mError("trans:%d, %s:%d is executed and failed to sync to other mnodes since %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, terrstr()); @@ -1442,8 +1439,26 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans, } } - taosThreadMutexUnlock(&pTrans->mutex); + return code; +} +static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) { + int32_t code = TSDB_CODE_ACTION_IN_PROGRESS; + taosThreadMutexLock(&pTrans->mutex); + if (pTrans->stage == TRN_STAGE_REDO_ACTION) { + code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->redoActions, topHalf); + } + taosThreadMutexUnlock(&pTrans->mutex); + return code; +} + +static int32_t mndTransExecuteUndoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) { + int32_t code = TSDB_CODE_ACTION_IN_PROGRESS; + taosThreadMutexLock(&pTrans->mutex); + if (pTrans->stage == TRN_STAGE_UNDO_ACTION) { + code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->undoActions, topHalf); + } + taosThreadMutexUnlock(&pTrans->mutex); return code; } @@ -1563,13 +1578,22 @@ static bool mndTransPerformCommitActionStage(SMnode *pMnode, STrans *pTrans, boo static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans, bool topHalf) { bool continueExec = true; - int32_t code = mndTransExecuteUndoActions(pMnode, pTrans, topHalf); + int32_t code = 0; + + if (pTrans->exec == TRN_EXEC_SERIAL) { + code = mndTransExecuteUndoActionsSerial(pMnode, pTrans, topHalf); + } else { + code = mndTransExecuteUndoActions(pMnode, pTrans, topHalf); + } + + if (mndCannotExecuteTransAction(pMnode, topHalf)) return false; + terrno = code; if (code == 0) { pTrans->stage = TRN_STAGE_PRE_FINISH; mInfo("trans:%d, stage from undoAction to pre-finish", pTrans->id); continueExec = true; - } else if (code == TSDB_CODE_ACTION_IN_PROGRESS) { + } else if (code == TSDB_CODE_ACTION_IN_PROGRESS || code == TSDB_CODE_MND_TRANS_CTX_SWITCH) { mInfo("trans:%d, stage keep on undoAction since %s", pTrans->id, tstrerror(code)); continueExec = false; } else { diff --git a/source/dnode/vnode/src/meta/metaEntry.c b/source/dnode/vnode/src/meta/metaEntry.c index eb41ffc0a5..9a111ae2d4 100644 --- a/source/dnode/vnode/src/meta/metaEntry.c +++ b/source/dnode/vnode/src/meta/metaEntry.c @@ -31,21 +31,21 @@ int meteEncodeColCmprEntry(SEncoder *pCoder, const SMetaEntry *pME) { int meteDecodeColCmprEntry(SDecoder *pDecoder, SMetaEntry *pME) { SColCmprWrapper *pWrapper = &pME->colCmpr; if (tDecodeI32v(pDecoder, &pWrapper->nCols) < 0) return -1; + if (pWrapper->nCols == 0) { + return 0; + } + if (tDecodeI32v(pDecoder, &pWrapper->version) < 0) return -1; uDebug("dencode cols:%d", pWrapper->nCols); - pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr)); if (pWrapper->pColCmpr == NULL) return -1; for (int i = 0; i < pWrapper->nCols; i++) { SColCmpr *p = &pWrapper->pColCmpr[i]; - if (tDecodeI16v(pDecoder, &p->id) < 0) goto END; - if (tDecodeU32(pDecoder, &p->alg) < 0) goto END; + if (tDecodeI16v(pDecoder, &p->id) < 0) return -1; + if (tDecodeU32(pDecoder, &p->alg) < 0) return -1; } return 0; -END: - // taosMemoryFree(pWrapper->pColCmpr); - return -1; } static FORCE_INLINE void metatInitDefaultSColCmprWrapper(SDecoder *pDecoder, SColCmprWrapper *pCmpr, SSchemaWrapper *pSchema) { @@ -152,6 +152,10 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { if (pME->type == TSDB_SUPER_TABLE) { if (TABLE_IS_COL_COMPRESSED(pME->flags)) { if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1; + + if (pME->colCmpr.nCols == 0) { + metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow); + } } else { metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->stbEntry.schemaRow); TABLE_SET_COL_COMPRESSED(pME->flags); @@ -160,6 +164,9 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { if (!tDecodeIsEnd(pCoder)) { uDebug("set type: %d, tableName:%s", pME->type, pME->name); if (meteDecodeColCmprEntry(pCoder, pME) < 0) return -1; + if (pME->colCmpr.nCols == 0) { + metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow); + } } else { uDebug("set default type: %d, tableName:%s", pME->type, pME->name); metatInitDefaultSColCmprWrapper(pCoder, &pME->colCmpr, &pME->ntbEntry.schemaRow); diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index c9246b67f8..f89ed73ac9 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -281,10 +281,6 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { if (pReq->colCmpred) { TABLE_SET_COL_COMPRESSED(me.flags); me.colCmpr = pReq->colCmpr; - } else { - TABLE_SET_COL_COMPRESSED(me.flags); - // TODO(yihao) - // SETUP default compress algr } if (metaHandleEntry(pMeta, &me) < 0) goto _err; @@ -891,6 +887,8 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs bool sysTbl = (pReq->type == TSDB_CHILD_TABLE) && metaTbInFilterCache(pMeta, pReq->ctb.stbName, 1); + if (!sysTbl && ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0)) goto _err; + // build SMetaEntry SVnodeStats *pStats = &pMeta->pVnode->config.vndStats; me.version = ver; diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 567d61e27a..3d5f5bd64c 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -367,7 +367,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { } while (0); } - // 2. check re-balance status + // 2. check rebalance status if (pHandle->consumerId != consumerId) { tqError("ERROR tmq poll: consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64, @@ -485,7 +485,7 @@ int32_t tqProcessVgWalInfoReq(STQ* pTq, SRpcMsg* pMsg) { return -1; } - // 2. check re-balance status + // 2. check rebalance status if (pHandle->consumerId != consumerId) { tqDebug("ERROR consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64, consumerId, vgId, req.subKey, pHandle->consumerId); @@ -666,7 +666,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg req.vgId, req.subKey, req.newConsumerId, req.oldConsumerId); } if (req.newConsumerId == -1) { - tqError("vgId:%d, tq invalid re-balance request, new consumerId %" PRId64 "", req.vgId, req.newConsumerId); + tqError("vgId:%d, tq invalid rebalance request, new consumerId %" PRId64 "", req.vgId, req.newConsumerId); goto end; } STqHandle handle = {0}; diff --git a/source/dnode/vnode/src/tqCommon/tqCommon.c b/source/dnode/vnode/src/tqCommon/tqCommon.c index 4ce8579ea0..2352d3a555 100644 --- a/source/dnode/vnode/src/tqCommon/tqCommon.c +++ b/source/dnode/vnode/src/tqCommon/tqCommon.c @@ -161,6 +161,7 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM int32_t len = pMsg->contLen - sizeof(SMsgHead); SRpcMsg rsp = {.info = pMsg->info, .code = TSDB_CODE_SUCCESS}; int64_t st = taosGetTimestampMs(); + bool updated = false; SStreamTaskNodeUpdateMsg req = {0}; @@ -214,9 +215,10 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM return rsp.code; } - streamTaskUpdateEpsetInfo(pTask, req.pNodeList); + updated = streamTaskUpdateEpsetInfo(pTask, req.pNodeList); streamTaskResetStatus(pTask); - streamTaskCompleteCheck(&pTask->taskCheckInfo, pTask->id.idStr); + + streamTaskStopMonitorCheckRsp(&pTask->taskCheckInfo, pTask->id.idStr); SStreamTask** ppHTask = NULL; if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { @@ -229,21 +231,22 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM CLEAR_RELATED_FILLHISTORY_TASK(pTask); } else { tqDebug("s-task:%s fill-history task update nodeEp along with stream task", (*ppHTask)->id.idStr); - streamTaskUpdateEpsetInfo(*ppHTask, req.pNodeList); + bool updateEpSet = streamTaskUpdateEpsetInfo(*ppHTask, req.pNodeList); + if (!updated) { + updated = updateEpSet; + } + streamTaskResetStatus(*ppHTask); - streamTaskCompleteCheck(&(*ppHTask)->taskCheckInfo, (*ppHTask)->id.idStr); + streamTaskStopMonitorCheckRsp(&(*ppHTask)->taskCheckInfo, (*ppHTask)->id.idStr); } } - if (restored) { - tqDebug("s-task:%s vgId:%d start to save task", idstr, vgId); + if (updated) { + tqDebug("s-task:%s vgId:%d save task after update epset", idstr, vgId); streamMetaSaveTask(pMeta, pTask); if (ppHTask != NULL) { streamMetaSaveTask(pMeta, *ppHTask); } - - } else { - tqDebug("s-task:%s vgId:%d not save since restore not finish", idstr, vgId); } tqDebug("s-task:%s vgId:%d start to stop task after save task", idstr, vgId); @@ -252,15 +255,13 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM // keep the already updated info taosHashPut(pMeta->updateInfo.pTasks, &entry, sizeof(entry), NULL, 0); + int64_t now = taosGetTimestampMs(); if (ppHTask != NULL) { streamTaskStop(*ppHTask); - - int64_t now = taosGetTimestampMs(); tqDebug("s-task:%s vgId:%d task nodeEp update completed, streamTask/fill-history closed, elapsed:%" PRId64 " ms", idstr, vgId, now - st); taosHashPut(pMeta->updateInfo.pTasks, &(*ppHTask)->id, sizeof(pTask->id), NULL, 0); } else { - int64_t now = taosGetTimestampMs(); tqDebug("s-task:%s vgId:%d, task nodeEp update completed, streamTask closed, elapsed time:%" PRId64 "ms", idstr, vgId, now - st); } @@ -276,7 +277,6 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM if (updateTasks < numOfTasks) { tqDebug("vgId:%d closed tasks:%d, unclosed:%d, all tasks will be started when nodeEp update completed", vgId, updateTasks, (numOfTasks - updateTasks)); - streamMetaWUnLock(pMeta); } else { if (streamMetaCommit(pMeta) < 0) { // persist to disk @@ -285,7 +285,6 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM if (!restored) { tqDebug("vgId:%d vnode restore not completed, not start the tasks, clear the start after nodeUpdate flag", vgId); pMeta->startInfo.tasksWillRestart = 0; - streamMetaWUnLock(pMeta); } else { tqDebug("vgId:%d all %d task(s) nodeEp updated and closed, transId:%d", vgId, numOfTasks, req.transId); #if 0 @@ -294,10 +293,10 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM #endif tqStreamTaskStartAsync(pMeta, cb, true); - streamMetaWUnLock(pMeta); } } + streamMetaWUnLock(pMeta); taosArrayDestroy(req.pNodeList); return rsp.code; } @@ -990,7 +989,7 @@ int32_t tqStreamTaskProcessTaskPauseReq(SStreamMeta* pMeta, char* pMsg) { } tqDebug("s-task:%s receive pause msg from mnode", pTask->id.idStr); - streamTaskPause(pMeta, pTask); + streamTaskPause(pTask); SStreamTask* pHistoryTask = NULL; if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { @@ -1007,7 +1006,7 @@ int32_t tqStreamTaskProcessTaskPauseReq(SStreamMeta* pMeta, char* pMsg) { tqDebug("s-task:%s fill-history task handle paused along with related stream task", pHistoryTask->id.idStr); - streamTaskPause(pMeta, pHistoryTask); + streamTaskPause(pHistoryTask); streamMetaReleaseTask(pMeta, pHistoryTask); } diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 99f35717fe..76f98b33c1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -1637,8 +1637,8 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h); SLastCol lastCol = *pLastCol; - for (int8_t i = 0; i < lastCol.rowKey.numOfPKs; i++) { - reallocVarDataVal(&lastCol.rowKey.pks[i]); + for (int8_t j = 0; j < lastCol.rowKey.numOfPKs; j++) { + reallocVarDataVal(&lastCol.rowKey.pks[j]); } reallocVarData(&lastCol.colVal); taosArrayPush(pLastArray, &lastCol); @@ -1667,8 +1667,8 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h); SLastCol lastCol = *pLastCol; - for (int8_t i = 0; i < lastCol.rowKey.numOfPKs; i++) { - reallocVarDataVal(&lastCol.rowKey.pks[i]); + for (int8_t j = 0; j < lastCol.rowKey.numOfPKs; j++) { + reallocVarDataVal(&lastCol.rowKey.pks[j]); } reallocVarData(&lastCol.colVal); taosArraySet(pLastArray, idxKey->idx, &lastCol); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 1ea037b4e9..93099a9aa7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -1610,11 +1610,6 @@ static bool tryCopyDistinctRowFromSttBlock(TSDBROW* fRow, SSttBlockReader* pSttB doUnpinSttBlock(pSttBlockReader); if (hasVal) { SRowKey* pNext = getCurrentKeyInSttBlock(pSttBlockReader); - - if (IS_VAR_DATA_TYPE(pSttKey->pks[0].type)) { - tsdbInfo("current pk:%s, next pk:%s", pSttKey->pks[0].pData, pNext->pks[0].pData); - } - if (pkCompEx(pSttKey, pNext) != 0) { code = doAppendRowFromFileBlock(pReader->resBlockInfo.pResBlock, pReader, fRow->pBlockData, fRow->iRow); *copied = (code == TSDB_CODE_SUCCESS); diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index 2e0b44f5f8..45c63cb4f1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -553,10 +553,11 @@ _exit: } static int32_t tsdbMigrateDataFileS3(SRTNer *rtner, const STFileObj *fobj, int64_t size, int64_t chunksize) { - int32_t code = 0; - int32_t lino = 0; - STFileOp op = {0}; - int32_t lcn = (size - 1) / chunksize + 1; + int32_t code = 0; + int32_t lino = 0; + STFileOp op = {0}; + int32_t lcn = (size - 1) / chunksize + 1; + TdFilePtr fdFrom = NULL, fdTo = NULL; // remove old op = (STFileOp){ @@ -615,9 +616,8 @@ static int32_t tsdbMigrateDataFileS3(SRTNer *rtner, const STFileObj *fobj, int64 } // copy last chunk - TdFilePtr fdFrom = NULL, fdTo = NULL; - int64_t lc_offset = (int64_t)(lcn - 1) * chunksize; - int64_t lc_size = size - lc_offset; + int64_t lc_offset = (int64_t)(lcn - 1) * chunksize; + int64_t lc_size = size - lc_offset; dot = strchr(object_name, '.'); if (!dot) { diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 3036346230..425cff7ce9 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -486,21 +486,18 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC if (tsEnableMonitor && pVnode->monitor.insertCounter == NULL) { taos_counter_t *counter = NULL; - counter = taos_collector_registry_get_metric(VNODE_METRIC_SQL_COUNT); - if(counter == NULL){ - int32_t label_count = 7; - const char *sample_labels[] = {VNODE_METRIC_TAG_NAME_SQL_TYPE, VNODE_METRIC_TAG_NAME_CLUSTER_ID, - VNODE_METRIC_TAG_NAME_DNODE_ID, VNODE_METRIC_TAG_NAME_DNODE_EP, - VNODE_METRIC_TAG_NAME_VGROUP_ID, VNODE_METRIC_TAG_NAME_USERNAME, - VNODE_METRIC_TAG_NAME_RESULT}; - counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", - label_count, sample_labels); - vInfo("vgId:%d, new metric:%p",TD_VID(pVnode), counter); - if(taos_collector_registry_register_metric(counter) == 1){ - taos_counter_destroy(counter); - counter = taos_collector_registry_get_metric(VNODE_METRIC_SQL_COUNT); - vInfo("vgId:%d, get metric from registry:%p", TD_VID(pVnode), counter); - } + int32_t label_count = 7; + const char *sample_labels[] = {VNODE_METRIC_TAG_NAME_SQL_TYPE, VNODE_METRIC_TAG_NAME_CLUSTER_ID, + VNODE_METRIC_TAG_NAME_DNODE_ID, VNODE_METRIC_TAG_NAME_DNODE_EP, + VNODE_METRIC_TAG_NAME_VGROUP_ID, VNODE_METRIC_TAG_NAME_USERNAME, + VNODE_METRIC_TAG_NAME_RESULT}; + counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", + label_count, sample_labels); + vInfo("vgId:%d, new metric:%p",TD_VID(pVnode), counter); + if(taos_collector_registry_register_metric(counter) == 1){ + taos_counter_destroy(counter); + counter = taos_collector_registry_get_metric(VNODE_METRIC_SQL_COUNT); + vInfo("vgId:%d, get metric from registry:%p", TD_VID(pVnode), counter); } pVnode->monitor.insertCounter = counter; vInfo("vgId:%d, succeed to set metric:%p", TD_VID(pVnode), counter); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d1f12fc0c0..6d97c1cd79 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -1076,16 +1076,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, pCreateReq = req.pReqs + iReq; memset(&cRsp, 0, sizeof(cRsp)); - if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) { - rcode = -1; - goto _exit; - } - - if ((terrno = grantCheck(TSDB_GRANT_TABLE)) < 0) { - rcode = -1; - goto _exit; - } - if (tsEnableAudit && tsEnableAuditCreateTable) { char *str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); if (str == NULL) { @@ -1778,13 +1768,6 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in // create table if (pSubmitTbData->pCreateTbReq) { - // check (TODO: move check to create table) - code = grantCheck(TSDB_GRANT_TIMESERIES); - if (code) goto _exit; - - code = grantCheck(TSDB_GRANT_TABLE); - if (code) goto _exit; - // alloc if need if (pSubmitRsp->aCreateTbRsp == NULL && (pSubmitRsp->aCreateTbRsp = taosArrayInit(TARRAY_SIZE(pSubmitReq->aSubmitTbData), sizeof(SVCreateTbRsp))) == diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index bf901188dc..2902a19f06 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -18,10 +18,10 @@ #include "commandInt.h" #include "scheduler.h" #include "systable.h" +#include "taosdef.h" #include "tdatablock.h" #include "tglobal.h" #include "tgrant.h" -#include "taosdef.h" extern SConfig* tsCfg; @@ -126,7 +126,8 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock, pCol7 = taosArrayGet(pBlock->pDataBlock, 6); } - char buf[DESCRIBE_RESULT_FIELD_LEN] = {0}; + int32_t fillTagCol = 0; + char buf[DESCRIBE_RESULT_FIELD_LEN] = {0}; for (int32_t i = 0; i < numOfRows; ++i) { if (invisibleColumn(sysInfoUser, pMeta->tableType, pMeta->schema[i].flags)) { continue; @@ -140,6 +141,7 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock, if (TSDB_VIEW_TABLE != pMeta->tableType) { if (i >= pMeta->tableInfo.numOfColumns) { STR_TO_VARSTR(buf, "TAG"); + fillTagCol = 1; } else if (i == 1 && pMeta->schema[i].flags & COL_IS_KEY) { STR_TO_VARSTR(buf, "PRIMARY KEY") } else { @@ -158,15 +160,17 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock, STR_TO_VARSTR(buf, columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pMeta->schemaExt[i].compress))); colDataSetVal(pCol7, pBlock->info.rows, buf, false); } else { - STR_TO_VARSTR(buf, ""); + STR_TO_VARSTR(buf, fillTagCol == 0 ? "" : "disabled"); colDataSetVal(pCol5, pBlock->info.rows, buf, false); - STR_TO_VARSTR(buf, ""); + STR_TO_VARSTR(buf, fillTagCol == 0 ? "" : "disabled"); colDataSetVal(pCol6, pBlock->info.rows, buf, false); - STR_TO_VARSTR(buf, ""); + STR_TO_VARSTR(buf, fillTagCol == 0 ? "" : "disabled"); colDataSetVal(pCol7, pBlock->info.rows, buf, false); } } + fillTagCol = 0; + ++(pBlock->info.rows); } if (pMeta->tableType == TSDB_SUPER_TABLE && biMode != 0) { @@ -355,7 +359,7 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch break; } - char* retentions = buildRetension(pCfg->pRetensions); + char* retentions = buildRetension(pCfg->pRetensions); int32_t dbFNameLen = strlen(dbFName); int32_t hashPrefix = 0; if (pCfg->hashPrefix > 0) { @@ -367,17 +371,20 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch if (IS_SYS_DBNAME(dbName)) { len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName); } else { - len += sprintf( - buf2 + VARSTR_HEADER_SIZE, - "CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm " - "WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d " - "WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d " - "WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64 " KEEP_TIME_OFFSET %d ENCRYPT_ALGORITHM '%s' S3_CHUNKSIZE %d S3_KEEPLOCAL %dm S3_COMPACT %d", - dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, pCfg->daysPerFile, - pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, - pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups, - 1 == pCfg->numOfStables, hashPrefix, pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize, - pCfg->keepTimeOffset, encryptAlgorithmStr(pCfg->encryptAlgorithm), pCfg->s3ChunkSize, pCfg->s3KeepLocal, pCfg->s3Compact); + len += sprintf(buf2 + VARSTR_HEADER_SIZE, + "CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %dm " + "WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d " + "PRECISION '%s' REPLICA %d " + "WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d " + "WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64 + " KEEP_TIME_OFFSET %d ENCRYPT_ALGORITHM '%s' S3_CHUNKSIZE %d S3_KEEPLOCAL %dm S3_COMPACT %d", + dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, + pCfg->daysPerFile, pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, + pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, pCfg->pages, pCfg->pageSize, prec, + pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups, 1 == pCfg->numOfStables, hashPrefix, + pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize, + pCfg->keepTimeOffset, encryptAlgorithmStr(pCfg->encryptAlgorithm), pCfg->s3ChunkSize, + pCfg->s3KeepLocal, pCfg->s3Compact); if (retentions) { len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions); @@ -391,7 +398,9 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch colDataSetVal(pCol2, 0, buf2, false); } -#define CHECK_LEADER(n) (row[n] && (fields[n].type == TSDB_DATA_TYPE_VARCHAR && strncasecmp(row[n], "leader", varDataLen((char *)row[n] - VARSTR_HEADER_SIZE)) == 0)) +#define CHECK_LEADER(n) \ + (row[n] && (fields[n].type == TSDB_DATA_TYPE_VARCHAR && \ + strncasecmp(row[n], "leader", varDataLen((char*)row[n] - VARSTR_HEADER_SIZE)) == 0)) // on this row, if have leader return true else return false bool existLeaderRole(TAOS_ROW row, TAOS_FIELD* fields, int nFields) { // vgroup_id | db_name | tables | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status | v4_dnode | @@ -548,23 +557,25 @@ static int32_t buildCreateViewResultDataBlock(SSDataBlock** pOutput) { return code; } - - void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) { for (int32_t i = 0; i < pCfg->numOfColumns; ++i) { SSchema* pSchema = pCfg->pSchemas + i; char type[32 + 60]; // 60 byte for compress info sprintf(type, "%s", tDataTypes[pSchema->type].name); - if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) { + if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || + TSDB_DATA_TYPE_GEOMETRY == pSchema->type) { sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } if (useCompress(pCfg->tableType)) { - sprintf(type + strlen(type), " ENCODE \'%s\'", columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress))); - sprintf(type + strlen(type), " COMPRESS \'%s\'", columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress))); - sprintf(type + strlen(type), " LEVEL \'%s\'", columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress))); + sprintf(type + strlen(type), " ENCODE \'%s\'", + columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress))); + sprintf(type + strlen(type), " COMPRESS \'%s\'", + columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress))); + sprintf(type + strlen(type), " LEVEL \'%s\'", + columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress))); } if (!(pSchema->flags & COL_IS_KEY)) { *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); @@ -580,7 +591,8 @@ void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) { SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i; char type[32]; sprintf(type, "%s", tDataTypes[pSchema->type].name); - if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) { + if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || + TSDB_DATA_TYPE_GEOMETRY == pSchema->type) { sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); @@ -823,7 +835,8 @@ static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreate SViewMeta* pMeta = pStmt->pViewMeta; ASSERT(pMeta); - snprintf(varDataVal(buf2), SHOW_CREATE_VIEW_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE VIEW `%s`.`%s` AS %s", pStmt->dbName, pStmt->viewName, pMeta->querySql); + snprintf(varDataVal(buf2), SHOW_CREATE_VIEW_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE VIEW `%s`.`%s` AS %s", + pStmt->dbName, pStmt->viewName, pMeta->querySql); int32_t len = strlen(varDataVal(buf2)); varDataLen(buf2) = (len > 65535) ? 65535 : len; colDataSetVal(pCol2, 0, buf2, false); @@ -833,7 +846,6 @@ static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreate return TSDB_CODE_SUCCESS; } - static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) { SSDataBlock* pBlock = NULL; int32_t code = buildCreateTbResultDataBlock(&pBlock); diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index 723474adae..edfad8c872 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -944,6 +944,7 @@ int64_t getDeleteMark(SWindowPhysiNode* pWinPhyNode, int64_t interval); void resetUnCloseSessionWinInfo(SSHashObj* winMap); void setStreamOperatorCompleted(struct SOperatorInfo* pOperator); void reloadAggSupFromDownStream(struct SOperatorInfo* downstream, SStreamAggSupporter* pAggSup); +void destroyFlusedPos(void* pRes); int32_t encodeSSessionKey(void** buf, SSessionKey* key); void* decodeSSessionKey(void* buf, SSessionKey* key); diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index 115a61f647..b7159225e1 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -87,8 +87,11 @@ static void setColIdForCacheReadBlock(SSDataBlock* pBlock, SLastRowScanPhysiNode SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { int32_t code = TSDB_CODE_SUCCESS; + int32_t numOfCols = 0; + SNodeList* pScanCols = pScanNode->scan.pScanCols; SCacheRowsScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SCacheRowsScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; tableListDestroy(pTableListInfo); @@ -101,22 +104,32 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe SDataBlockDescNode* pDescNode = pScanNode->scan.node.pOutputDataBlockDesc; pInfo->pRes = createDataBlockFromDescNode(pDescNode); - int32_t numOfCols = 0; - code = - extractColMatchInfo(pScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); + code = extractColMatchInfo(pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); if (code != TSDB_CODE_SUCCESS) { goto _error; } - // todd: the pk information should comes from the physical plan - for(int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) { - SColMatchItem* pItem = taosArrayGet(pInfo->matchInfo.pList, i); - if (pItem->isPk) { - pInfo->numOfPks += 1; - pInfo->pkCol.type = pItem->dataType.type; // only record one primary key - pInfo->pkCol.bytes = pItem->dataType.bytes; // only record one primary key + // todo: the pk information should comes from the physical plan + // pk info may not in pScanCols, so extract primary key from pInfo->matchInfo may failed + SSchemaInfo* pSchemaInfo = taosArrayGet(pTaskInfo->schemaInfos, 0); + if (pSchemaInfo != NULL) { + if (pSchemaInfo->sw->pSchema[1].flags & COL_IS_KEY) { // is primary key + SSchema* pColSchema = &pSchemaInfo->sw->pSchema[1]; + pInfo->numOfPks = 1; + pInfo->pkCol.type = pColSchema->type; + pInfo->pkCol.bytes = pColSchema->bytes; pInfo->pkCol.pk = 1; } + } else { + for(int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) { + SColMatchItem* pItem = taosArrayGet(pInfo->matchInfo.pList, i); + if (pItem->isPk) { + pInfo->numOfPks += 1; + pInfo->pkCol.type = pItem->dataType.type; // only record one primary key + pInfo->pkCol.bytes = pItem->dataType.bytes; // only record one primary key + pInfo->pkCol.pk = 1; + } + } } SArray* pCidList = taosArrayInit(numOfCols, sizeof(int16_t)); @@ -204,6 +217,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { SCacheRowsScanInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; STableListInfo* pTableList = pInfo->pTableList; + SStoreCacheReader* pReaderFn = &pInfo->readHandle.api.cacheFn; uint64_t suid = tableListGetSuid(pTableList); int32_t size = tableListGetSize(pTableList); @@ -224,8 +238,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { blockDataCleanup(pInfo->pBufferedRes); taosArrayClear(pInfo->pUidList); - int32_t code = pInfo->readHandle.api.cacheFn.retrieveRows(pInfo->pLastrowReader, pInfo->pBufferedRes, - pInfo->pSlotIds, pInfo->pDstSlotIds, pInfo->pUidList); + int32_t code = pReaderFn->retrieveRows(pInfo->pLastrowReader, pInfo->pBufferedRes, pInfo->pSlotIds, + pInfo->pDstSlotIds, pInfo->pUidList); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); } @@ -294,10 +308,10 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { } if (NULL == pInfo->pLastrowReader) { - code = pInfo->readHandle.api.cacheFn.openReader( - pInfo->readHandle.vnode, pInfo->retrieveType, pList, num, taosArrayGetSize(pInfo->matchInfo.pList), - pInfo->pCidList, pInfo->pSlotIds, suid, &pInfo->pLastrowReader, pTaskInfo->id.str, pInfo->pFuncTypeList, - &pInfo->pkCol, pInfo->numOfPks); + code = pReaderFn->openReader(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num, + taosArrayGetSize(pInfo->matchInfo.pList), pInfo->pCidList, pInfo->pSlotIds, suid, + &pInfo->pLastrowReader, pTaskInfo->id.str, pInfo->pFuncTypeList, &pInfo->pkCol, + pInfo->numOfPks); if (code != TSDB_CODE_SUCCESS) { pInfo->currentGroupIndex += 1; @@ -305,13 +319,13 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { continue; } } else { - pInfo->readHandle.api.cacheFn.reuseReader(pInfo->pLastrowReader, pList, num); + pReaderFn->reuseReader(pInfo->pLastrowReader, pList, num); } taosArrayClear(pInfo->pUidList); - code = pInfo->readHandle.api.cacheFn.retrieveRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pDstSlotIds, - pInfo->pUidList); + code = pReaderFn->retrieveRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pDstSlotIds, + pInfo->pUidList); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); } @@ -344,7 +358,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { } } - pInfo->pLastrowReader = pInfo->readHandle.api.cacheFn.closeReader(pInfo->pLastrowReader); + pInfo->pLastrowReader = pReaderFn->closeReader(pInfo->pLastrowReader); setOperatorCompleted(pOperator); return NULL; } diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index be6fb2983c..d06beebd6b 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -287,7 +287,19 @@ int32_t prepareDataBlockBuf(SSDataBlock* pDataBlock, SColMatchInfo* pMatchInfo) EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) { SMetaReader* mr = (SMetaReader*)pContext; + bool isTagCol = false, isTbname = false; if (nodeType(*pNode) == QUERY_NODE_COLUMN) { + SColumnNode* pCol = (SColumnNode*)*pNode; + if (pCol->colType == COLUMN_TYPE_TBNAME) + isTbname = true; + else + isTagCol = true; + } else if (nodeType(*pNode) == QUERY_NODE_FUNCTION) { + SFunctionNode* pFunc = (SFunctionNode*)*pNode; + if (pFunc->funcType == FUNCTION_TYPE_TBNAME) + isTbname = true; + } + if (isTagCol) { SColumnNode* pSColumnNode = *(SColumnNode**)pNode; SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); @@ -316,24 +328,21 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) { } nodesDestroyNode(*pNode); *pNode = (SNode*)res; - } else if (nodeType(*pNode) == QUERY_NODE_FUNCTION) { - SFunctionNode* pFuncNode = *(SFunctionNode**)pNode; - if (pFuncNode->funcType == FUNCTION_TYPE_TBNAME) { - SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); - if (NULL == res) { - return DEAL_RES_ERROR; - } - - res->translate = true; - res->node.resType = pFuncNode->node.resType; - - int32_t len = strlen(mr->me.name); - res->datum.p = taosMemoryCalloc(len + VARSTR_HEADER_SIZE + 1, 1); - memcpy(varDataVal(res->datum.p), mr->me.name, len); - varDataSetLen(res->datum.p, len); - nodesDestroyNode(*pNode); - *pNode = (SNode*)res; + } else if (isTbname) { + SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + if (NULL == res) { + return DEAL_RES_ERROR; } + + res->translate = true; + res->node.resType = ((SExprNode*)(*pNode))->resType; + + int32_t len = strlen(mr->me.name); + res->datum.p = taosMemoryCalloc(len + VARSTR_HEADER_SIZE + 1, 1); + memcpy(varDataVal(res->datum.p), mr->me.name, len); + varDataSetLen(res->datum.p, len); + nodesDestroyNode(*pNode); + *pNode = (SNode*)res; } return DEAL_RES_CONTINUE; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 9dfe6230d9..c30059fffd 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1640,7 +1640,7 @@ static void getPreVersionDataBlock(uint64_t uid, TSKEY startTs, TSKEY endTs, int printDataBlock(pBlock, "new delete", taskIdStr); } -static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) { +static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType mode) { if (pSrcBlock->info.rows == 0) { return TSDB_CODE_SUCCESS; } @@ -1659,7 +1659,7 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr } int64_t ver = pSrcBlock->info.version - 1; - if (pInfo->partitionSup.needCalc && (startData[0] != endData[0] || hasPrimaryKey(pInfo))) { + if (pInfo->partitionSup.needCalc && ( startData[0] != endData[0] || (hasPrimaryKey(pInfo) && mode == STREAM_DELETE_DATA) )) { getPreVersionDataBlock(uidCol[0], startData[0], endData[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock); startData = (TSKEY*)pStartTsCol->pData; endData = (TSKEY*)pEndTsCol->pData; @@ -1736,7 +1736,7 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB } int64_t ver = pSrcBlock->info.version - 1; - if (pInfo->partitionSup.needCalc && (startData[0] != endData[0] || hasPrimaryKey(pInfo))) { + if (pInfo->partitionSup.needCalc && ( startData[0] != endData[0] || (hasPrimaryKey(pInfo) && mode == STREAM_DELETE_DATA) )) { getPreVersionDataBlock(uidCol[0], startData[0], endData[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock); startData = (TSKEY*)pStartTsCol->pData; endData = (TSKEY*)pEndTsCol->pData; @@ -1779,7 +1779,7 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB return TSDB_CODE_SUCCESS; } -static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) { +static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType mode) { blockDataCleanup(pDestBlock); if (pSrcBlock->info.rows == 0) { return TSDB_CODE_SUCCESS; @@ -1800,7 +1800,7 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData; int64_t ver = pSrcBlock->info.version - 1; - if (pInfo->partitionSup.needCalc && (srcStartTsCol[0] != srcEndTsCol[0] || hasPrimaryKey(pInfo))) { + if (pInfo->partitionSup.needCalc && ( srcStartTsCol[0] != srcEndTsCol[0] || (hasPrimaryKey(pInfo) && mode == STREAM_DELETE_DATA) )) { getPreVersionDataBlock(srcUidData[0], srcStartTsCol[0], srcEndTsCol[0], ver, GET_TASKID(pTaskInfo), pInfo, pSrcBlock); srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData; srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData; @@ -1959,9 +1959,9 @@ static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pS static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType type) { int32_t code = TSDB_CODE_SUCCESS; if (isIntervalWindow(pInfo)) { - code = generateIntervalScanRange(pInfo, pSrcBlock, pDestBlock); + code = generateIntervalScanRange(pInfo, pSrcBlock, pDestBlock, type); } else if (isSessionWindow(pInfo) || isStateWindow(pInfo)) { - code = generateSessionScanRange(pInfo, pSrcBlock, pDestBlock); + code = generateSessionScanRange(pInfo, pSrcBlock, pDestBlock, type); } else if (isCountWindow(pInfo)) { code = generateCountScanRange(pInfo, pSrcBlock, pDestBlock, type); } else { @@ -2660,7 +2660,7 @@ FETCH_NEXT_BLOCK: } } break; case STREAM_SCAN_FROM_DELETE_DATA: { - generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes, STREAM_DELETE_DATA); + generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes, STREAM_PARTITION_DELETE_DATA); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); diff --git a/source/libs/executor/src/streamcountwindowoperator.c b/source/libs/executor/src/streamcountwindowoperator.c index b66df120b4..9cef8f584e 100644 --- a/source/libs/executor/src/streamcountwindowoperator.c +++ b/source/libs/executor/src/streamcountwindowoperator.c @@ -50,12 +50,13 @@ void destroyStreamCountAggOperatorInfo(void* param) { destroyStreamAggSupporter(&pInfo->streamAggSup); cleanupExprSupp(&pInfo->scalarSupp); clearGroupResInfo(&pInfo->groupResInfo); + taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); + pInfo->pUpdated = NULL; colDataDestroy(&pInfo->twAggSup.timeWindowData); blockDataDestroy(pInfo->pDelRes); tSimpleHashCleanup(pInfo->pStUpdated); tSimpleHashCleanup(pInfo->pStDeleted); - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); cleanupGroupResInfo(&pInfo->groupResInfo); taosArrayDestroy(pInfo->historyWins); @@ -185,7 +186,7 @@ void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, ESt return; } pDelRange->win = tmpKey.win; - while (mode == STREAM_DELETE_DATA) { + while (mode == STREAM_DELETE_DATA || mode == STREAM_PARTITION_DELETE_DATA) { pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur); code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index 99b377e1d3..22c7f20658 100644 --- a/source/libs/executor/src/streameventwindowoperator.c +++ b/source/libs/executor/src/streameventwindowoperator.c @@ -46,6 +46,9 @@ void destroyStreamEventOperatorInfo(void* param) { cleanupBasicInfo(&pInfo->binfo); destroyStreamAggSupporter(&pInfo->streamAggSup); clearGroupResInfo(&pInfo->groupResInfo); + taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); + pInfo->pUpdated = NULL; + cleanupExprSupp(&pInfo->scalarSupp); if (pInfo->pChildren != NULL) { int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -60,7 +63,6 @@ void destroyStreamEventOperatorInfo(void* param) { tSimpleHashCleanup(pInfo->pSeUpdated); tSimpleHashCleanup(pInfo->pAllUpdated); tSimpleHashCleanup(pInfo->pSeDeleted); - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); cleanupGroupResInfo(&pInfo->groupResInfo); taosArrayDestroy(pInfo->historyWins); diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index 5c79ffa6de..0cab4b7951 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -262,7 +262,7 @@ static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDa if (chIds) { int32_t childId = getChildIndex(pBlock); if (pInvalidWins) { - qDebug("===stream===save mid delete window:%" PRId64 ",groupId:%" PRId64 ",chId:%d", winRes.ts, winRes.groupId, childId); + qDebug("===stream===save invalid delete window:%" PRId64 ",groupId:%" PRId64 ",chId:%d", winRes.ts, winRes.groupId, childId); taosHashPut(pInvalidWins, &winRes, sizeof(SWinKey), NULL, 0); } @@ -388,15 +388,20 @@ static void doBuildDeleteResult(SStreamIntervalOperatorInfo* pInfo, SArray* pWin } } +void destroyFlusedPos(void* pRes) { + SRowBuffPos* pPos = (SRowBuffPos*) pRes; + if (!pPos->needFree && !pPos->pRowBuff) { + taosMemoryFreeClear(pPos->pKey); + taosMemoryFree(pPos); + } +} + void clearGroupResInfo(SGroupResInfo* pGroupResInfo) { if (pGroupResInfo->freeItem) { int32_t size = taosArrayGetSize(pGroupResInfo->pRows); for (int32_t i = pGroupResInfo->index; i < size; i++) { - SRowBuffPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i); - if (!pPos->needFree && !pPos->pRowBuff) { - taosMemoryFreeClear(pPos->pKey); - taosMemoryFree(pPos); - } + void* pPos = taosArrayGetP(pGroupResInfo->pRows, i); + destroyFlusedPos(pPos); } pGroupResInfo->freeItem = false; } @@ -409,6 +414,8 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) { cleanupBasicInfo(&pInfo->binfo); cleanupAggSup(&pInfo->aggSup); clearGroupResInfo(&pInfo->groupResInfo); + taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); + pInfo->pUpdated = NULL; // it should be empty. void* pIte = NULL; @@ -437,7 +444,6 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) { cleanupExprSupp(&pInfo->scalarSupp); tSimpleHashCleanup(pInfo->pUpdatedMap); pInfo->pUpdatedMap = NULL; - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); tSimpleHashCleanup(pInfo->pDeletedMap); blockDataDestroy(pInfo->pCheckpointRes); @@ -654,11 +660,12 @@ static bool processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFina .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey}; // add pull data request - qDebug("===stream===prepare final retrive for delete window:%" PRId64 ",groupId%" PRId64 ", size:%d", winRes.ts, winRes.groupId, numOfCh); + qDebug("===stream===prepare final retrive for delete window:%" PRId64 ",groupId:%" PRId64 ", size:%d", winRes.ts, winRes.groupId, numOfCh); if (IS_MID_INTERVAL_OP(pOperator)) { SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperator->info; taosArrayPush(pInfo->pMidPullDatas, &winRes); } else if (savePullWindow(&pull, pPullWins) == TSDB_CODE_SUCCESS) { + taosArrayPush(pInfo->pDelWins, &winRes); addPullWindow(pMap, &winRes, numOfCh); if (pInfo->destHasPrimaryKey) { tSimpleHashPut(pInfo->pDeletedMap,&winRes, sizeof(SWinKey), NULL, 0); @@ -1328,7 +1335,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || pBlock->info.type == STREAM_CLEAR) { SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); - doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, NULL); + SHashObj* finalMap = IS_FINAL_INTERVAL_OP(pOperator) ? pInfo->pFinalPullDataMap : NULL; + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, finalMap); if (IS_FINAL_INTERVAL_OP(pOperator)) { int32_t chId = getChildIndex(pBlock); addRetriveWindow(delWins, pInfo, chId); @@ -1662,6 +1670,8 @@ void destroyStreamSessionAggOperatorInfo(void* param) { destroyStreamAggSupporter(&pInfo->streamAggSup); cleanupExprSupp(&pInfo->scalarSupp); clearGroupResInfo(&pInfo->groupResInfo); + taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); + pInfo->pUpdated = NULL; if (pInfo->pChildren != NULL) { int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -1677,7 +1687,6 @@ void destroyStreamSessionAggOperatorInfo(void* param) { blockDataDestroy(pInfo->pWinBlock); tSimpleHashCleanup(pInfo->pStUpdated); tSimpleHashCleanup(pInfo->pStDeleted); - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); cleanupGroupResInfo(&pInfo->groupResInfo); taosArrayDestroy(pInfo->historyWins); @@ -3248,6 +3257,9 @@ void destroyStreamStateOperatorInfo(void* param) { cleanupBasicInfo(&pInfo->binfo); destroyStreamAggSupporter(&pInfo->streamAggSup); clearGroupResInfo(&pInfo->groupResInfo); + taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); + pInfo->pUpdated = NULL; + cleanupExprSupp(&pInfo->scalarSupp); if (pInfo->pChildren != NULL) { int32_t size = taosArrayGetSize(pInfo->pChildren); @@ -3261,7 +3273,6 @@ void destroyStreamStateOperatorInfo(void* param) { blockDataDestroy(pInfo->pDelRes); tSimpleHashCleanup(pInfo->pSeUpdated); tSimpleHashCleanup(pInfo->pSeDeleted); - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); cleanupGroupResInfo(&pInfo->groupResInfo); taosArrayDestroy(pInfo->historyWins); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 394eecd542..bcd1ab5c18 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2517,7 +2517,7 @@ static int32_t translateMd5(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - pFunc->node.resType = (SDataType){.bytes = MD5_OUTPUT_LEN, .type = TSDB_DATA_TYPE_VARCHAR}; + pFunc->node.resType = (SDataType){.bytes = MD5_OUTPUT_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index de84246727..5f59fabec5 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -511,6 +511,7 @@ static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) { COPY_SCALAR_FIELD(seqWinGroup); COPY_SCALAR_FIELD(grpJoin); COPY_SCALAR_FIELD(hashJoinHint); + COPY_SCALAR_FIELD(batchScanHint); CLONE_NODE_FIELD(pLeftOnCond); CLONE_NODE_FIELD(pRightOnCond); COPY_SCALAR_FIELD(timeRangeTarget); diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 007dfbb8af..fa03780a6d 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -745,7 +745,6 @@ SNode* createTimeOffsetValueNode(SAstCreateContext* pCxt, const SToken* pLiteral return (SNode*)val; } - SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); if (NULL == pCxt->pQueryCxt->db) { @@ -965,7 +964,8 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok return (SNode*)tempTable; } -SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, EJoinSubType stype, SNode* pLeft, SNode* pRight, SNode* pJoinCond) { +SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, EJoinSubType stype, SNode* pLeft, SNode* pRight, + SNode* pJoinCond) { CHECK_PARSER_STATUS(pCxt); SJoinTableNode* joinTable = (SJoinTableNode*)nodesMakeNode(QUERY_NODE_JOIN_TABLE); CHECK_OUT_OF_MEM(joinTable); @@ -1264,7 +1264,6 @@ SNode* addFillClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pFill) { return pStmt; } - SNode* addJLimitClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pJLimit) { CHECK_PARSER_STATUS(pCxt); if (NULL == pJLimit) { @@ -1272,11 +1271,10 @@ SNode* addJLimitClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pJLimit) { } SJoinTableNode* pJoinNode = (SJoinTableNode*)pJoin; pJoinNode->pJLimit = pJLimit; - + return pJoin; } - SNode* addWindowOffsetClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pWinOffset) { CHECK_PARSER_STATUS(pCxt); if (NULL == pWinOffset) { @@ -1284,11 +1282,10 @@ SNode* addWindowOffsetClause(SAstCreateContext* pCxt, SNode* pJoin, SNode* pWinO } SJoinTableNode* pJoinNode = (SJoinTableNode*)pJoin; pJoinNode->pWindowOffset = pWinOffset; - + return pJoin; } - SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint) { CHECK_PARSER_STATUS(pCxt); @@ -1549,10 +1546,10 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED case DB_OPTION_KEEP_TIME_OFFSET: { pDbOptions->keepTimeOffset = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; - case DB_OPTION_ENCRYPT_ALGORITHM: - COPY_STRING_FORM_STR_TOKEN(pDbOptions->encryptAlgorithmStr, (SToken*)pVal); - pDbOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO; - break; + case DB_OPTION_ENCRYPT_ALGORITHM: + COPY_STRING_FORM_STR_TOKEN(pDbOptions->encryptAlgorithmStr, (SToken*)pVal); + pDbOptions->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO; + break; } default: break; @@ -1744,17 +1741,17 @@ SNode* setColumnOptions(SAstCreateContext* pCxt, SNode* pOptions, EColumnOptionT memset(((SColumnOptions*)pOptions)->compress, 0, TSDB_CL_COMPRESS_OPTION_LEN); COPY_STRING_FORM_STR_TOKEN(((SColumnOptions*)pOptions)->compress, (SToken*)pVal); if (0 == strlen(((SColumnOptions*)pOptions)->compress)) { - pCxt->errCode = TSDB_CODE_TSC_ENCODE_PARAM_ERROR; + pCxt->errCode = TSDB_CODE_TSC_COMPRESS_PARAM_ERROR; } break; case COLUMN_OPTION_LEVEL: memset(((SColumnOptions*)pOptions)->compressLevel, 0, TSDB_CL_COMPRESS_OPTION_LEN); COPY_STRING_FORM_STR_TOKEN(((SColumnOptions*)pOptions)->compressLevel, (SToken*)pVal); if (0 == strlen(((SColumnOptions*)pOptions)->compressLevel)) { - pCxt->errCode = TSDB_CODE_TSC_ENCODE_PARAM_ERROR; + pCxt->errCode = TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR; } break; - case COLUMN_OPTION_PRIMARYKEY: + case COLUMN_OPTION_PRIMARYKEY: ((SColumnOptions*)pOptions)->bPrimaryKey = true; break; default: @@ -1789,7 +1786,7 @@ SDataType createDataType(uint8_t type) { SDataType createVarLenDataType(uint8_t type, const SToken* pLen) { int32_t len = TSDB_MAX_BINARY_LEN - VARSTR_HEADER_SIZE; if (type == TSDB_DATA_TYPE_NCHAR) len /= TSDB_NCHAR_SIZE; - if(pLen) len = taosStr2Int32(pLen->z, NULL, 10); + if (pLen) len = taosStr2Int32(pLen->z, NULL, 10); SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = len}; return dt; } @@ -1895,8 +1892,8 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, return createAlterTableStmtFinalize(pRealTable, pStmt); } -SNode* createAlterTableAddModifyColOptions(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName, - SNode* pOptions) { +SNode* createAlterTableAddModifyColOptions(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, + SToken* pColName, SNode* pOptions) { CHECK_PARSER_STATUS(pCxt); if (!checkColumnName(pCxt, pColName)) { return NULL; @@ -2965,7 +2962,7 @@ SNode* createTSMAOptions(SAstCreateContext* pCxt, SNodeList* pFuncs) { CHECK_PARSER_STATUS(pCxt); STSMAOptions* pOptions = (STSMAOptions*)nodesMakeNode(QUERY_NODE_TSMA_OPTIONS); if (!pOptions) { - //nodesDestroyList(pTSMAFuncs); + // nodesDestroyList(pTSMAFuncs); pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "Out of memory"); return NULL; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index ccaf2131f4..60c7b30a47 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -735,7 +735,7 @@ static int32_t getTableTsmas(STranslateContext* pCxt, const SName* pName, SArray } static int32_t getTsma(STranslateContext* pCxt, const SName* pName, STableTSMAInfo** pTsma) { - int32_t code = 0; + int32_t code = 0; SParseContext* pParCxt = pCxt->pParseCxt; if (pParCxt->async) { code = getTsmaFromCache(pCxt->pMetaCache, pName, pTsma); @@ -3676,7 +3676,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo char buf[TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1]; for (int32_t i = 0; i < pRealTable->pTsmas->size; ++i) { STableTSMAInfo* pTsma = taosArrayGetP(pRealTable->pTsmas, i); - SName tsmaTargetTbName = {0}; + SName tsmaTargetTbName = {0}; toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName); int32_t len = snprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name, pRealTable->table.tableName); @@ -3684,7 +3684,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo strncpy(tsmaTargetTbName.tname, buf, MD5_OUTPUT_LEN); collectUseTable(&tsmaTargetTbName, pCxt->pTargetTables); SVgroupInfo vgInfo = {0}; - bool exists = false; + bool exists = false; code = catalogGetCachedTableHashVgroup(pCxt->pParseCxt->pCatalog, &tsmaTargetTbName, &vgInfo, &exists); if (TSDB_CODE_SUCCESS == code) { ASSERT(exists); @@ -5695,8 +5695,8 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* int32_t code = TSDB_CODE_SUCCESS; for (int i = 0; i < taosArrayGetSize(aTables); ++i) { SEqCondTbNameTableInfo* pInfo = taosArrayGet(aTables, i); - int32_t nTbls = taosArrayGetSize(pInfo->aTbnames); - int32_t numOfVgs = pInfo->pRealTable->pVgroupList->numOfVgroups; + int32_t nTbls = taosArrayGetSize(pInfo->aTbnames); + int32_t numOfVgs = pInfo->pRealTable->pVgroupList->numOfVgroups; SVgroupsInfo* vgsInfo = taosMemoryMalloc(sizeof(SVgroupsInfo) + nTbls * sizeof(SVgroupInfo)); findVgroupsFromEqualTbname(pCxt, pInfo->aTbnames, pInfo->pRealTable->table.dbName, numOfVgs, vgsInfo); @@ -5705,7 +5705,7 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* pInfo->pRealTable->pVgroupList = vgsInfo; } else { taosMemoryFree(vgsInfo); - } + } vgsInfo = NULL; if (pInfo->pRealTable->pTsmas) { @@ -5714,12 +5714,12 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* for (int32_t i = 0; i < pInfo->pRealTable->pTsmas->size; ++i) { STableTSMAInfo* pTsma = taosArrayGetP(pInfo->pRealTable->pTsmas, i); - SArray *pTbNames = taosArrayInit(pInfo->aTbnames->size, POINTER_BYTES); + SArray* pTbNames = taosArrayInit(pInfo->aTbnames->size, POINTER_BYTES); if (!pTbNames) return TSDB_CODE_OUT_OF_MEMORY; for (int32_t k = 0; k < pInfo->aTbnames->size; ++k) { const char* pTbName = taosArrayGetP(pInfo->aTbnames, k); - char* pNewTbName = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1); + char* pNewTbName = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1); if (!pNewTbName) { code = TSDB_CODE_OUT_OF_MEMORY; break; @@ -7225,9 +7225,9 @@ static int32_t checkColumnOptions(SNodeList* pList) { if (!checkColumnEncodeOrSetDefault(pCol->dataType.type, ((SColumnOptions*)pCol->pOptions)->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; if (!checkColumnCompressOrSetDefault(pCol->dataType.type, ((SColumnOptions*)pCol->pOptions)->compress)) - return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; + return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR; if (!checkColumnLevelOrSetDefault(pCol->dataType.type, ((SColumnOptions*)pCol->pOptions)->compressLevel)) - return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; + return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR; } return TSDB_CODE_SUCCESS; } @@ -7245,11 +7245,11 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calB FOREACH(pNode, pList) { SColumnDefNode* pCol = (SColumnDefNode*)pNode; SFieldWithOptions field = {.type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType)}; - if (calBytes) { + if (calBytes) { field.bytes = calcTypeBytes(pCol->dataType); } else { field.bytes = pCol->dataType.bytes; - } + } strcpy(field.name, pCol->colName); if (pCol->pOptions) { @@ -7742,7 +7742,7 @@ static int32_t addWdurationToSampleProjects(SNodeList* pProjectionList) { return nodesListAppend(pProjectionList, (SNode*)pFunc); } -static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList, int32_t *pProjectionTotalLen) { +static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList, int32_t* pProjectionTotalLen) { SNodeList* pProjectionList = pInfo->pFuncs; pInfo->pFuncs = NULL; @@ -8118,13 +8118,15 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt* TAOS_FIELD field = {0}; strcpy(field.name, pStmt->colName); if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - int8_t valid = + if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR; + if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR; + int32_t code = setColCompressByOption(pStmt->dataType.type, columnEncodeVal(pStmt->pColOptions->encode), columnCompressVal(pStmt->pColOptions->compress), columnLevelVal(pStmt->pColOptions->compressLevel), false, (uint32_t*)&field.bytes); - if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; + if (code != TSDB_CODE_SUCCESS) { + return code; + } taosArrayPush(pAlterReq->pFields, &field); break; } @@ -10708,8 +10710,8 @@ static int32_t compareTsmaFuncWithFuncAndColId(SNode* pNode1, SNode* pNode2) { // pFuncs are already sorted by funcId and colId static int32_t deduplicateTsmaFuncs(SNodeList* pFuncs) { - SNode* pLast = NULL; - SNode* pFunc = NULL; + SNode* pLast = NULL; + SNode* pFunc = NULL; SNodeList* pRes = NULL; FOREACH(pFunc, pFuncs) { if (pLast) { @@ -10726,7 +10728,8 @@ static int32_t deduplicateTsmaFuncs(SNodeList* pFuncs) { return TSDB_CODE_SUCCESS; } -static int32_t buildTSMAAstStreamSubTable(SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, const SNode* pTbname, SNode** pSubTable) { +static int32_t buildTSMAAstStreamSubTable(SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, const SNode* pTbname, + SNode** pSubTable) { int32_t code = 0; SFunctionNode* pMd5Func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); SFunctionNode* pConcatFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); @@ -10768,8 +10771,8 @@ _end: return code; } -static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, - const char* tbName, int32_t numOfTags, const SSchema* pTags) { +static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, const char* tbName, + int32_t numOfTags, const SSchema* pTags) { int32_t code = TSDB_CODE_SUCCESS; SSampleAstInfo info = {0}; info.createSmaIndex = true; @@ -10813,16 +10816,17 @@ static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMC if (!pTagCol) code = TSDB_CODE_OUT_OF_MEMORY; } if (code == TSDB_CODE_SUCCESS) { - code = buildTSMAAstStreamSubTable(pStmt, pReq, pStmt->pOptions->recursiveTsma ? pTagCol : (SNode*)pTbnameFunc, (SNode**)&pSubTable); + code = buildTSMAAstStreamSubTable(pStmt, pReq, pStmt->pOptions->recursiveTsma ? pTagCol : (SNode*)pTbnameFunc, + (SNode**)&pSubTable); info.pSubTable = (SNode*)pSubTable; } if (code == TSDB_CODE_SUCCESS) - code = nodesListMakeStrictAppend(&info.pTags, pStmt->pOptions->recursiveTsma ? pTagCol : nodesCloneNode((SNode*)pTbnameFunc)); + code = nodesListMakeStrictAppend( + &info.pTags, pStmt->pOptions->recursiveTsma ? pTagCol : nodesCloneNode((SNode*)pTbnameFunc)); } } - if (code == TSDB_CODE_SUCCESS && !pStmt->pOptions->recursiveTsma) - code = fmCreateStateFuncs(info.pFuncs); + if (code == TSDB_CODE_SUCCESS && !pStmt->pOptions->recursiveTsma) code = fmCreateStateFuncs(info.pFuncs); if (code == TSDB_CODE_SUCCESS) { int32_t pProjectionTotalLen = 0; @@ -10914,7 +10918,8 @@ static int32_t rewriteTSMAFuncs(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, return code; } -static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, SName* useTbName) { +static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, + SName* useTbName) { SName name; tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), pReq->name); memset(&name, 0, sizeof(SName)); @@ -10924,15 +10929,15 @@ static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStm pReq->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; pReq->intervalUnit = TIME_UNIT_MILLISECOND; -#define TSMA_MIN_INTERVAL_MS 1 // 1ms -#define TSMA_MAX_INTERVAL_MS (60 * 60 * 1000) // 1h +#define TSMA_MIN_INTERVAL_MS 1 // 1ms +#define TSMA_MAX_INTERVAL_MS (60 * 60 * 1000) // 1h if (pReq->interval > TSMA_MAX_INTERVAL_MS || pReq->interval < TSMA_MIN_INTERVAL_MS) { return TSDB_CODE_TSMA_INVALID_INTERVAL; } int32_t code = TSDB_CODE_SUCCESS; - STableMeta* pTableMeta = NULL; + STableMeta* pTableMeta = NULL; STableTSMAInfo* pRecursiveTsma = NULL; int32_t numOfCols = 0, numOfTags = 0; SSchema * pCols = NULL, *pTags = NULL; @@ -11022,7 +11027,7 @@ static int32_t translateCreateTSMA(STranslateContext* pCxt, SCreateTSMAStmt* pSt if (code == TSDB_CODE_SUCCESS) { code = buildCreateTSMAReq(pCxt, pStmt, pStmt->pReq, &useTbName); } - if ( TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code) { code = collectUseTable(&useTbName, pCxt->pTargetTables); } if (TSDB_CODE_SUCCESS == code) { @@ -11063,7 +11068,8 @@ int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSData if (TSDB_CODE_SUCCESS == code) { if (interval.interval > 0) { - pStmt->pReq->lastTs = taosTimeAdd(taosTimeTruncate(lastTs, &interval), interval.interval, interval.intervalUnit, interval.precision); + pStmt->pReq->lastTs = taosTimeAdd(taosTimeTruncate(lastTs, &interval), interval.interval, interval.intervalUnit, + interval.precision); } else { pStmt->pReq->lastTs = lastTs + 1; // start key of the next time window } @@ -11074,7 +11080,7 @@ int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSData code = setQuery(&cxt, pQuery); } - if ( TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code) { SName name = {0}; toName(pParseCxt->acctId, pStmt->dbName, pStmt->originalTbName, &name); code = collectUseTable(&name, cxt.pTargetTables); @@ -11090,7 +11096,7 @@ int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSData } static int32_t translateDropTSMA(STranslateContext* pCxt, SDropTSMAStmt* pStmt) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; SMDropSmaReq dropReq = {0}; SName name; tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), dropReq.name); @@ -12033,13 +12039,13 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* toSchema(pColDef, index + 1, pScheam); if (pColDef->pOptions) { req.colCmpr.pColCmpr[index].id = index + 1; - int8_t valid = setColCompressByOption( + int32_t code = setColCompressByOption( pScheam->type, columnEncodeVal(((SColumnOptions*)pColDef->pOptions)->encode), columnCompressVal(((SColumnOptions*)pColDef->pOptions)->compress), columnLevelVal(((SColumnOptions*)pColDef->pOptions)->compressLevel), true, &req.colCmpr.pColCmpr[index].alg); - if (!valid) { + if (code != TSDB_CODE_SUCCESS) { tdDestroySVCreateTbReq(&req); - return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; + return code; } } ++index; @@ -12499,7 +12505,6 @@ static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableCl goto over; } - SVgroupInfo info = {0}; if (TSDB_CODE_SUCCESS == code) { code = getTableHashVgroup(pCxt, pClause->dbName, pClause->tableName, &info); @@ -12586,7 +12591,7 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) { taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch); FOREACH(pNode, pStmt->pTables) { SDropTableClause* pClause = (SDropTableClause*)pNode; - SName name; + SName name; toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name); int32_t code = buildDropTableVgroupHashmap(pCxt, pClause, &name, &tableType, pVgroupHashmap); if (TSDB_CODE_SUCCESS != code) { @@ -12653,8 +12658,8 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) { static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, SVAlterTbReq* pReq) { - SName tbName = {0}; - SArray* pTsmas = NULL; + SName tbName = {0}; + SArray* pTsmas = NULL; int32_t code = TSDB_CODE_SUCCESS; if (pCxt->pMetaCache) { toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName); @@ -12679,9 +12684,9 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS pReq->colId = pSchema->colId; pReq->tagType = pSchema->type; - STag* pTag = NULL; - SToken token; - char tokenBuf[TSDB_MAX_TAGS_LEN]; + STag* pTag = NULL; + SToken token; + char tokenBuf[TSDB_MAX_TAGS_LEN]; const char* tagStr = pStmt->pVal->literal; NEXT_TOKEN_WITH_PREV(tagStr, token); if (TSDB_CODE_SUCCESS == code) { @@ -12879,14 +12884,12 @@ static int buildAlterTableColumnCompress(STranslateContext* pCxt, SAlterTableStm } if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - int8_t valid = setColCompressByOption(pSchema->type, columnEncodeVal(pStmt->pColOptions->encode), - columnCompressVal(pStmt->pColOptions->compress), - columnLevelVal(pStmt->pColOptions->compressLevel), true, &pReq->compress); - if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - - return TSDB_CODE_SUCCESS; + if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR; + if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR; + int8_t code = setColCompressByOption(pSchema->type, columnEncodeVal(pStmt->pColOptions->encode), + columnCompressVal(pStmt->pColOptions->compress), + columnLevelVal(pStmt->pColOptions->compressLevel), true, &pReq->compress); + return code; } static int32_t buildAlterTbReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index cceabcbf50..2e3e8f189b 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -582,6 +582,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect pJoin->node.inputTsOrder = ORDER_ASC; pJoin->node.groupAction = GROUP_ACTION_CLEAR; pJoin->hashJoinHint = getHashJoinOptHint(pSelect->pHint); + pJoin->batchScanHint = getBatchScanOptionFromHint(pSelect->pHint); pJoin->node.requireDataOrder = pJoin->hashJoinHint ? DATA_ORDER_LEVEL_NONE : DATA_ORDER_LEVEL_GLOBAL; pJoin->node.resultDataOrder = DATA_ORDER_LEVEL_NONE; pJoin->isLowLevelJoin = pJoinTable->isLowLevelJoin; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index ae37334762..da39228a62 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2751,16 +2751,20 @@ static bool partTagsIsOptimizableNode(SLogicNode* pNode) { if (!ret) return ret; switch (nodeType(pNode)) { case QUERY_NODE_LOGIC_PLAN_PARTITION: { - if (pNode->pParent && nodeType(pNode->pParent) == QUERY_NODE_LOGIC_PLAN_WINDOW) { - SWindowLogicNode* pWindow = (SWindowLogicNode*)pNode->pParent; - if (pWindow->winType == WINDOW_TYPE_INTERVAL) { - // if interval has slimit, we push down partition node to scan, and scan will set groupOrderScan to true - // we want to skip groups of blocks after slimit satisfied - // if interval only has limit, we do not push down partition node to scan - // we want to get grouped output from partition node and make use of limit - // if no slimit and no limit, we push down partition node and groupOrderScan is false, cause we do not need - // group ordered output - if (!pWindow->node.pSlimit && pWindow->node.pLimit) ret = false; + if (pNode->pParent) { + if (nodeType(pNode->pParent) == QUERY_NODE_LOGIC_PLAN_WINDOW) { + SWindowLogicNode* pWindow = (SWindowLogicNode*)pNode->pParent; + if (pWindow->winType == WINDOW_TYPE_INTERVAL) { + // if interval has slimit, we push down partition node to scan, and scan will set groupOrderScan to true + // we want to skip groups of blocks after slimit satisfied + // if interval only has limit, we do not push down partition node to scan + // we want to get grouped output from partition node and make use of limit + // if no slimit and no limit, we push down partition node and groupOrderScan is false, cause we do not need + // group ordered output + if (!pWindow->node.pSlimit && pWindow->node.pLimit) ret = false; + } + } else if (nodeType(pNode->pParent) == QUERY_NODE_LOGIC_PLAN_JOIN) { + ret = false; } } } break; @@ -5607,7 +5611,7 @@ static int32_t grpJoinOptPartByTags(SLogicNode* pNode) { static int32_t grpJoinOptRewriteGroupJoin(SOptimizeContext* pCxt, SLogicNode* pNode, SLogicSubplan* pLogicSubplan) { SJoinLogicNode* pJoin = (SJoinLogicNode*)pNode; - int32_t code = (pJoin->allEqTags && !pJoin->hasSubQuery) ? grpJoinOptPartByTags(pNode) : grpJoinOptInsertPartitionNode(pNode); + int32_t code = (pJoin->allEqTags && !pJoin->hasSubQuery && !pJoin->batchScanHint) ? grpJoinOptPartByTags(pNode) : grpJoinOptInsertPartitionNode(pNode); if (TSDB_CODE_SUCCESS == code) { pJoin->grpJoin = true; pCxt->optimized = true; @@ -6328,6 +6332,7 @@ static int32_t tsmaOptRewriteScan(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pNew if (code == TSDB_CODE_SUCCESS) { code = tsmaOptRewriteNodeList(pNewScan->pGroupTags, pTsmaOptCtx, pTsma, true, true); } + pTsmaOptCtx->pScan->dataRequired = FUNC_DATA_REQUIRED_DATA_LOAD; if (pTsmaOptCtx->pScan->pTsmaTargetTbVgInfo && pTsmaOptCtx->pScan->pTsmaTargetTbVgInfo->size > 0) { for (int32_t i = 0; i < taosArrayGetSize(pTsmaOptCtx->pScan->pTsmas); ++i) { STableTSMAInfo* pTsmaInfo = taosArrayGetP(pTsmaOptCtx->pScan->pTsmas, i); diff --git a/source/libs/stream/src/streamStart.c b/source/libs/stream/src/streamStart.c index b9b7c8ddfa..0b91359f48 100644 --- a/source/libs/stream/src/streamStart.c +++ b/source/libs/stream/src/streamStart.c @@ -184,15 +184,10 @@ void streamTaskCheckDownstream(SStreamTask* pTask) { ASSERT(pTask->status.downstreamReady == 0); - int32_t code = streamTaskStartCheckDownstream(&pTask->taskCheckInfo, pTask->id.idStr); - if (code != TSDB_CODE_SUCCESS) { - return; - } - - streamTaskInitTaskCheckInfo(&pTask->taskCheckInfo, &pTask->outputInfo, taosGetTimestampMs()); - // serialize streamProcessScanHistoryFinishRsp if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) { + streamTaskStartMonitorCheckRsp(pTask); + req.reqId = tGenIdPI64(); req.downstreamNodeId = pTask->outputInfo.fixedDispatcher.nodeId; req.downstreamTaskId = pTask->outputInfo.fixedDispatcher.taskId; @@ -200,14 +195,15 @@ void streamTaskCheckDownstream(SStreamTask* pTask) { streamTaskAddReqInfo(&pTask->taskCheckInfo, req.reqId, req.downstreamTaskId, pTask->id.idStr); stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " check single downstream task:0x%x(vgId:%d) ver:%" PRId64 "-%" PRId64 - " window:%" PRId64 "-%" PRId64 " req:0x%" PRIx64, + " window:%" PRId64 "-%" PRId64 " reqId:0x%" PRIx64, pTask->id.idStr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, pRange->range.minVer, pRange->range.maxVer, pWindow->skey, pWindow->ekey, req.reqId); streamSendCheckMsg(pTask, &req, pTask->outputInfo.fixedDispatcher.nodeId, &pTask->outputInfo.fixedDispatcher.epSet); - streamTaskStartMonitorCheckRsp(pTask); } else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) { + streamTaskStartMonitorCheckRsp(pTask); + SArray* vgInfo = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos; int32_t numOfVgs = taosArrayGetSize(vgInfo); @@ -222,15 +218,14 @@ void streamTaskCheckDownstream(SStreamTask* pTask) { streamTaskAddReqInfo(&pTask->taskCheckInfo, req.reqId, req.downstreamTaskId, pTask->id.idStr); - stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " check downstream task:0x%x (vgId:%d) (shuffle), idx:%d", - pTask->id.idStr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, i); + stDebug("s-task:%s (vgId:%d) stage:%" PRId64 + " check downstream task:0x%x (vgId:%d) (shuffle), idx:%d, reqId:0x%" PRIx64, + pTask->id.idStr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, i, req.reqId); streamSendCheckMsg(pTask, &req, pVgInfo->vgId, &pVgInfo->epSet); } - - streamTaskStartMonitorCheckRsp(pTask); } else { // for sink task, set it ready directly. stDebug("s-task:%s (vgId:%d) set downstream ready, since no downstream", pTask->id.idStr, pTask->info.nodeId); - streamTaskCompleteCheck(&pTask->taskCheckInfo, pTask->id.idStr); + streamTaskStopMonitorCheckRsp(&pTask->taskCheckInfo, pTask->id.idStr); doProcessDownstreamReadyRsp(pTask); } } @@ -401,17 +396,24 @@ int32_t streamProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRs } if (pRsp->status == TASK_DOWNSTREAM_READY) { - streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id); + int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id); + if (code != TSDB_CODE_SUCCESS) { + return TSDB_CODE_SUCCESS; + } if (left == 0) { doProcessDownstreamReadyRsp(pTask); // all downstream tasks are ready, set the complete check downstream flag - streamTaskCompleteCheck(pInfo, id); + streamTaskStopMonitorCheckRsp(pInfo, id); } else { stDebug("s-task:%s (vgId:%d) recv check rsp from task:0x%x (vgId:%d) status:%d, total:%d not ready:%d", id, pRsp->upstreamNodeId, pRsp->downstreamTaskId, pRsp->downstreamNodeId, pRsp->status, total, left); } } else { // not ready, wait for 100ms and retry - streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id); + int32_t code = streamTaskUpdateCheckInfo(pInfo, pRsp->downstreamTaskId, pRsp->status, now, pRsp->reqId, &left, id); + if (code != TSDB_CODE_SUCCESS) { + return TSDB_CODE_SUCCESS; // return success in any cases. + } + if (pRsp->status == TASK_UPSTREAM_NEW_STAGE || pRsp->status == TASK_DOWNSTREAM_NOT_LEADER) { if (pRsp->status == TASK_UPSTREAM_NEW_STAGE) { stError("s-task:%s vgId:%d self vnode-transfer/leader-change/restart detected, old stage:%" PRId64 diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 7dc93ceccf..2bc09c1c22 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -24,8 +24,8 @@ #define CHECK_NOT_RSP_DURATION 10*1000 // 10 sec static void streamTaskDestroyUpstreamInfo(SUpstreamInfo* pUpstreamInfo); -static void streamTaskUpdateUpstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet); -static void streamTaskUpdateDownstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet); +static void streamTaskUpdateUpstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet, bool* pUpdated); +static void streamTaskUpdateDownstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet, bool* pUpdate); static int32_t addToTaskset(SArray* pArray, SStreamTask* pTask) { int32_t childId = taosArrayGetSize(pArray); @@ -34,10 +34,14 @@ static int32_t addToTaskset(SArray* pArray, SStreamTask* pTask) { return 0; } -static int32_t doUpdateTaskEpset(SStreamTask* pTask, int32_t nodeId, SEpSet* pEpSet) { +static int32_t doUpdateTaskEpset(SStreamTask* pTask, int32_t nodeId, SEpSet* pEpSet, bool* pUpdated) { char buf[512] = {0}; if (pTask->info.nodeId == nodeId) { // execution task should be moved away + if (!(*pUpdated)) { + *pUpdated = isEpsetEqual(&pTask->info.epSet, pEpSet); + } + epsetAssign(&pTask->info.epSet, pEpSet); epsetToStr(pEpSet, buf, tListLen(buf)); stDebug("s-task:0x%x (vgId:%d) self node epset is updated %s", pTask->id.taskId, nodeId, buf); @@ -46,12 +50,12 @@ static int32_t doUpdateTaskEpset(SStreamTask* pTask, int32_t nodeId, SEpSet* pEp // check for the dispatch info and the upstream task info int32_t level = pTask->info.taskLevel; if (level == TASK_LEVEL__SOURCE) { - streamTaskUpdateDownstreamInfo(pTask, nodeId, pEpSet); + streamTaskUpdateDownstreamInfo(pTask, nodeId, pEpSet, pUpdated); } else if (level == TASK_LEVEL__AGG) { - streamTaskUpdateUpstreamInfo(pTask, nodeId, pEpSet); - streamTaskUpdateDownstreamInfo(pTask, nodeId, pEpSet); + streamTaskUpdateUpstreamInfo(pTask, nodeId, pEpSet, pUpdated); + streamTaskUpdateDownstreamInfo(pTask, nodeId, pEpSet, pUpdated); } else { // TASK_LEVEL__SINK - streamTaskUpdateUpstreamInfo(pTask, nodeId, pEpSet); + streamTaskUpdateUpstreamInfo(pTask, nodeId, pEpSet, pUpdated); } return 0; @@ -534,7 +538,8 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i pTask->msgInfo.pRetryList = taosArrayInit(4, sizeof(int32_t)); TdThreadMutexAttr attr = {0}; - int code = taosThreadMutexAttrInit(&attr); + + int code = taosThreadMutexAttrInit(&attr); if (code != 0) { stError("s-task:%s initElapsed mutex attr failed, code:%s", pTask->id.idStr, tstrerror(code)); return code; @@ -563,6 +568,14 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i streamTaskInitTokenBucket(pOutputInfo->pTokenBucket, 35, 35, tsSinkDataRate, pTask->id.idStr); pOutputInfo->pDownstreamUpdateList = taosArrayInit(4, sizeof(SDownstreamTaskEpset)); if (pOutputInfo->pDownstreamUpdateList == NULL) { + stError("s-task:%s failed to prepare downstreamUpdateList, code:%s", pTask->id.idStr, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + return TSDB_CODE_OUT_OF_MEMORY; + } + + pTask->taskCheckInfo.pList = taosArrayInit(4, sizeof(SDownstreamStatusInfo)); + if (pTask->taskCheckInfo.pList == NULL) { + stError("s-task:%s failed to prepare taskCheckInfo list, code:%s", pTask->id.idStr, + tstrerror(TSDB_CODE_OUT_OF_MEMORY)); return TSDB_CODE_OUT_OF_MEMORY; } @@ -599,7 +612,7 @@ int32_t streamTaskSetUpstreamInfo(SStreamTask* pTask, const SStreamTask* pUpstre return TSDB_CODE_SUCCESS; } -void streamTaskUpdateUpstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet) { +void streamTaskUpdateUpstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet, bool* pUpdated) { char buf[512] = {0}; epsetToStr(pEpSet, buf, tListLen(buf)); @@ -607,6 +620,10 @@ void streamTaskUpdateUpstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpS for (int32_t i = 0; i < numOfUpstream; ++i) { SStreamChildEpInfo* pInfo = taosArrayGetP(pTask->upstreamInfo.pList, i); if (pInfo->nodeId == nodeId) { + if (!(*pUpdated)) { + *pUpdated = isEpsetEqual(&pInfo->epSet, pEpSet); + } + epsetAssign(&pInfo->epSet, pEpSet); stDebug("s-task:0x%x update the upstreamInfo taskId:0x%x(nodeId:%d) newEpset:%s", pTask->id.taskId, pInfo->taskId, nodeId, buf); @@ -633,12 +650,14 @@ void streamTaskSetFixedDownstreamInfo(SStreamTask* pTask, const SStreamTask* pDo pTask->msgInfo.msgType = TDMT_STREAM_TASK_DISPATCH; } -void streamTaskUpdateDownstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet) { +void streamTaskUpdateDownstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet, bool *pUpdated) { char buf[512] = {0}; epsetToStr(pEpSet, buf, tListLen(buf)); - int32_t id = pTask->id.taskId; + *pUpdated = false; + + int32_t id = pTask->id.taskId; + int8_t type = pTask->outputInfo.type; - int8_t type = pTask->outputInfo.type; if (type == TASK_OUTPUT__SHUFFLE_DISPATCH) { SArray* pVgs = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos; @@ -647,18 +666,24 @@ void streamTaskUpdateDownstreamInfo(SStreamTask* pTask, int32_t nodeId, const SE SVgroupInfo* pVgInfo = taosArrayGet(pVgs, i); if (pVgInfo->vgId == nodeId) { + if (!(*pUpdated)) { + (*pUpdated) = isEpsetEqual(&pVgInfo->epSet, pEpSet); + } + epsetAssign(&pVgInfo->epSet, pEpSet); - stDebug("s-task:0x%x update the dispatch info, task:0x%x(nodeId:%d) newEpset:%s", id, pVgInfo->taskId, nodeId, - buf); + stDebug("s-task:0x%x update dispatch info, task:0x%x(nodeId:%d) newEpset:%s", id, pVgInfo->taskId, nodeId, buf); break; } } } else if (type == TASK_OUTPUT__FIXED_DISPATCH) { STaskDispatcherFixed* pDispatcher = &pTask->outputInfo.fixedDispatcher; if (pDispatcher->nodeId == nodeId) { + if (!(*pUpdated)) { + *pUpdated = isEpsetEqual(&pDispatcher->epSet, pEpSet); + } + epsetAssign(&pDispatcher->epSet, pEpSet); - stDebug("s-task:0x%x update the dispatch info, task:0x%x(nodeId:%d) newEpset:%s", id, pDispatcher->taskId, nodeId, - buf); + stDebug("s-task:0x%x update dispatch info, task:0x%x(nodeId:%d) newEpset:%s", id, pDispatcher->taskId, nodeId, buf); } } } @@ -681,7 +706,7 @@ int32_t streamTaskStop(SStreamTask* pTask) { return 0; } -int32_t streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList) { +bool streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList) { STaskExecStatisInfo* p = &pTask->execInfo; int32_t numOfNodes = taosArrayGetSize(pNodeList); @@ -692,11 +717,13 @@ int32_t streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList) { stDebug("s-task:0x%x update task nodeEp epset, updatedNodes:%d, updateCount:%d, prevTs:%" PRId64, pTask->id.taskId, numOfNodes, p->updateCount, prevTs); + bool updated = false; for (int32_t i = 0; i < taosArrayGetSize(pNodeList); ++i) { SNodeUpdateInfo* pInfo = taosArrayGet(pNodeList, i); - doUpdateTaskEpset(pTask, pInfo->nodeId, &pInfo->newEp); + doUpdateTaskEpset(pTask, pInfo->nodeId, &pInfo->newEp, &updated); } - return 0; + + return updated; } void streamTaskResetUpstreamStageInfo(SStreamTask* pTask) { @@ -885,7 +912,7 @@ static int32_t taskPauseCallback(SStreamTask* pTask, void* param) { return TSDB_CODE_SUCCESS; } -void streamTaskPause(SStreamMeta* pMeta, SStreamTask* pTask) { +void streamTaskPause(SStreamTask* pTask) { streamTaskHandleEventAsync(pTask->status.pSM, TASK_EVENT_PAUSE, taskPauseCallback, NULL); } @@ -942,14 +969,8 @@ int32_t streamTaskSendCheckpointReq(SStreamTask* pTask) { return 0; } -int32_t streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutputInfo, int64_t startTs) { - if (pInfo->pList == NULL) { - pInfo->pList = taosArrayInit(4, sizeof(SDownstreamStatusInfo)); - } else { - taosArrayClear(pInfo->pList); - } - - taosThreadMutexLock(&pInfo->checkInfoLock); +static int32_t streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOutputInfo, int64_t startTs) { + taosArrayClear(pInfo->pList); if (pOutputInfo->type == TASK_OUTPUT__FIXED_DISPATCH) { pInfo->notReadyTasks = 1; @@ -959,24 +980,30 @@ int32_t streamTaskInitTaskCheckInfo(STaskCheckInfo* pInfo, STaskOutputInfo* pOut } pInfo->startTs = startTs; - - taosThreadMutexUnlock(&pInfo->checkInfoLock); return TSDB_CODE_SUCCESS; } +static SDownstreamStatusInfo* findCheckRspStatus(STaskCheckInfo* pInfo, int32_t taskId) { + for (int32_t j = 0; j < taosArrayGetSize(pInfo->pList); ++j) { + SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, j); + if (p->taskId == taskId) { + return p; + } + } + + return NULL; +} + int32_t streamTaskAddReqInfo(STaskCheckInfo* pInfo, int64_t reqId, int32_t taskId, const char* id) { SDownstreamStatusInfo info = {.taskId = taskId, .status = -1, .reqId = reqId, .rspTs = 0}; taosThreadMutexLock(&pInfo->checkInfoLock); - for(int32_t i = 0; i < taosArrayGetSize(pInfo->pList); ++i) { - SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, i); - if (p->taskId == taskId) { - stDebug("s-task:%s check info to task:0x%x already sent", id, taskId); - - taosThreadMutexUnlock(&pInfo->checkInfoLock); - return TSDB_CODE_SUCCESS; - } + SDownstreamStatusInfo* p = findCheckRspStatus(pInfo, taskId); + if (p != NULL) { + stDebug("s-task:%s check info to task:0x%x already sent", id, taskId); + taosThreadMutexUnlock(&pInfo->checkInfoLock); + return TSDB_CODE_SUCCESS; } taosArrayPush(pInfo->pList, &info); @@ -989,64 +1016,64 @@ int32_t streamTaskUpdateCheckInfo(STaskCheckInfo* pInfo, int32_t taskId, int32_t int32_t* pNotReady, const char* id) { taosThreadMutexLock(&pInfo->checkInfoLock); - for(int32_t i = 0; i < taosArrayGetSize(pInfo->pList); ++i) { - SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, i); - if (p->taskId == taskId) { - ASSERT(reqId == p->reqId); - - // count down one, since it is ready now - if ((p->status != TASK_DOWNSTREAM_READY) && (status == TASK_DOWNSTREAM_READY)) { - *pNotReady = atomic_sub_fetch_32(&pInfo->notReadyTasks, 1); - } else { - *pNotReady = pInfo->notReadyTasks; - } - - p->status = status; - p->rspTs = rspTs; + SDownstreamStatusInfo* p = findCheckRspStatus(pInfo, taskId); + if (p != NULL) { + if (reqId != p->reqId) { + stError("s-task:%s reqId:%" PRIx64 " expected:%" PRIx64 + " expired check-rsp recv from downstream task:0x%x, discarded", + id, reqId, p->reqId, taskId); taosThreadMutexUnlock(&pInfo->checkInfoLock); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_FAILED; } - } - taosThreadMutexUnlock(&pInfo->checkInfoLock); - stError("s-task:%s unexpected check rsp msg, downstream task:0x%x, reqId:%"PRIx64, id, taskId, reqId); - return TSDB_CODE_FAILED; -} + // subtract one not-ready-task, since it is ready now + if ((p->status != TASK_DOWNSTREAM_READY) && (status == TASK_DOWNSTREAM_READY)) { + *pNotReady = atomic_sub_fetch_32(&pInfo->notReadyTasks, 1); + } else { + *pNotReady = pInfo->notReadyTasks; + } -int32_t streamTaskStartCheckDownstream(STaskCheckInfo* pInfo, const char* id) { - taosThreadMutexLock(&pInfo->checkInfoLock); - if (pInfo->inCheckProcess == 0) { - pInfo->inCheckProcess = 1; - } else { - ASSERT(pInfo->startTs > 0); - stError("s-task:%s already in check procedure, checkTs:%"PRId64, id, pInfo->startTs); + p->status = status; + p->rspTs = rspTs; - taosThreadMutexUnlock(&pInfo->checkInfoLock); - return TSDB_CODE_FAILED; - } - - taosThreadMutexUnlock(&pInfo->checkInfoLock); - stDebug("s-task:%s set the in-check-procedure flag", id); - return 0; -} - -int32_t streamTaskCompleteCheck(STaskCheckInfo* pInfo, const char* id) { - taosThreadMutexLock(&pInfo->checkInfoLock); - if (!pInfo->inCheckProcess) { taosThreadMutexUnlock(&pInfo->checkInfoLock); return TSDB_CODE_SUCCESS; } - int64_t el = taosGetTimestampMs() - pInfo->startTs; - stDebug("s-task:%s clear the in-check-procedure flag, elapsed time:%" PRId64 " ms", id, el); + taosThreadMutexUnlock(&pInfo->checkInfoLock); + stError("s-task:%s unexpected check rsp msg, invalid downstream task:0x%x, reqId:%" PRIx64 " discarded", id, taskId, + reqId); + return TSDB_CODE_FAILED; +} + +static int32_t streamTaskStartCheckDownstream(STaskCheckInfo* pInfo, const char* id) { + if (pInfo->inCheckProcess == 0) { + pInfo->inCheckProcess = 1; + } else { + ASSERT(pInfo->startTs > 0); + stError("s-task:%s already in check procedure, checkTs:%"PRId64", start monitor check rsp failed", id, pInfo->startTs); + return TSDB_CODE_FAILED; + } + + stDebug("s-task:%s set the in-check-procedure flag", id); + return 0; +} + +static int32_t streamTaskCompleteCheckRsp(STaskCheckInfo* pInfo, const char* id) { + if (!pInfo->inCheckProcess) { + stWarn("s-task:%s already not in-check-procedure", id); + } + + int64_t el = (pInfo->startTs != 0) ? (taosGetTimestampMs() - pInfo->startTs) : 0; + stDebug("s-task:%s clear the in-check-procedure flag, not in-check-procedure elapsed time:%" PRId64 " ms", id, el); pInfo->startTs = 0; - pInfo->inCheckProcess = 0; pInfo->notReadyTasks = 0; + pInfo->inCheckProcess = 0; + pInfo->stopCheckProcess = 0; taosArrayClear(pInfo->pList); - taosThreadMutexUnlock(&pInfo->checkInfoLock); return 0; } @@ -1064,7 +1091,7 @@ static void doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) { req.reqId = p->reqId; req.downstreamNodeId = pOutputInfo->fixedDispatcher.nodeId; req.downstreamTaskId = pOutputInfo->fixedDispatcher.taskId; - stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " re-send check downstream task:0x%x(vgId:%d) req:0x%" PRIx64, + stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " re-send check downstream task:0x%x(vgId:%d) reqId:0x%" PRIx64, pTask->id.idStr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, req.reqId); streamSendCheckMsg(pTask, &req, pOutputInfo->fixedDispatcher.nodeId, &pOutputInfo->fixedDispatcher.epSet); @@ -1080,8 +1107,10 @@ static void doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) { req.downstreamNodeId = pVgInfo->vgId; req.downstreamTaskId = pVgInfo->taskId; - stDebug("s-task:%s (vgId:%d) stage:%" PRId64 " re-send check downstream task:0x%x (vgId:%d) (shuffle), idx:%d", - pTask->id.idStr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, i); + stDebug("s-task:%s (vgId:%d) stage:%" PRId64 + " re-send check downstream task:0x%x(vgId:%d) (shuffle), idx:%d reqId:0x%" PRIx64, + pTask->id.idStr, pTask->info.nodeId, req.stage, req.downstreamTaskId, req.downstreamNodeId, i, + p->reqId); streamSendCheckMsg(pTask, &req, pVgInfo->vgId, &pVgInfo->epSet); break; } @@ -1091,6 +1120,31 @@ static void doSendCheckMsg(SStreamTask* pTask, SDownstreamStatusInfo* p) { } } +static void getCheckRspStatus(STaskCheckInfo* pInfo, int64_t el, int32_t* numOfReady, int32_t* numOfFault, + int32_t* numOfNotRsp, SArray* pTimeoutList, SArray* pNotReadyList, const char* id) { + for (int32_t i = 0; i < taosArrayGetSize(pInfo->pList); ++i) { + SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, i); + if (p->status == TASK_DOWNSTREAM_READY) { + (*numOfReady) += 1; + } else if (p->status == TASK_UPSTREAM_NEW_STAGE || p->status == TASK_DOWNSTREAM_NOT_LEADER) { + stDebug("s-task:%s recv status:NEW_STAGE/NOT_LEADER from downstream, task:0x%x, quit from check downstream", id, + p->taskId); + (*numOfFault) += 1; + } else { // TASK_DOWNSTREAM_NOT_READY + if (p->rspTs == 0) { // not response yet + ASSERT(p->status == -1); + if (el >= CHECK_NOT_RSP_DURATION) { // not receive info for 10 sec. + taosArrayPush(pTimeoutList, &p->taskId); + } else { // el < CHECK_NOT_RSP_DURATION + (*numOfNotRsp) += 1; // do nothing and continue waiting for their rsp + } + } else { + taosArrayPush(pNotReadyList, &p->taskId); + } + } + } +} + static void rspMonitorFn(void* param, void* tmrId) { SStreamTask* pTask = param; SStreamTaskState* pStat = streamTaskGetStatus(pTask); @@ -1099,25 +1153,38 @@ static void rspMonitorFn(void* param, void* tmrId) { int64_t now = taosGetTimestampMs(); int64_t el = now - pInfo->startTs; ETaskStatus state = pStat->state; + const char* id = pTask->id.idStr; int32_t numOfReady = 0; int32_t numOfFault = 0; - const char* id = pTask->id.idStr; + int32_t numOfNotRsp = 0; + int32_t numOfNotReady = 0; + int32_t numOfTimeout = 0; - stDebug("s-task:%s start to do check downstream rsp check", id); + stDebug("s-task:%s start to do check-downstream-rsp check in tmr", id); if (state == TASK_STATUS__STOP) { int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr, ref:%d", id, pStat->name, vgId, ref); - streamTaskCompleteCheck(pInfo, id); + + taosThreadMutexLock(&pInfo->checkInfoLock); + streamTaskCompleteCheckRsp(pInfo, id); + taosThreadMutexUnlock(&pInfo->checkInfoLock); streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, pInfo->startTs, now, false); + if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { + STaskId* pHId = &pTask->hTaskInfo.id; + streamMetaAddTaskLaunchResult(pTask->pMeta, pHId->streamId, pHId->taskId, pInfo->startTs, now, false); + } return; } - if (state == TASK_STATUS__DROPPING || state == TASK_STATUS__READY) { + if (state == TASK_STATUS__DROPPING || state == TASK_STATUS__READY || state == TASK_STATUS__PAUSE) { int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); stDebug("s-task:%s status:%s vgId:%d quit from monitor check-rsp tmr, ref:%d", id, pStat->name, vgId, ref); - streamTaskCompleteCheck(pInfo, id); + + taosThreadMutexLock(&pInfo->checkInfoLock); + streamTaskCompleteCheckRsp(pInfo, id); + taosThreadMutexUnlock(&pInfo->checkInfoLock); return; } @@ -1127,8 +1194,8 @@ static void rspMonitorFn(void* param, void* tmrId) { stDebug("s-task:%s status:%s vgId:%d all downstream ready, quit from monitor rsp tmr, ref:%d", id, pStat->name, vgId, ref); + streamTaskCompleteCheckRsp(pInfo, id); taosThreadMutexUnlock(&pInfo->checkInfoLock); - streamTaskCompleteCheck(pInfo, id); return; } @@ -1136,57 +1203,40 @@ static void rspMonitorFn(void* param, void* tmrId) { SArray* pTimeoutList = taosArrayInit(4, sizeof(int64_t)); if (pStat->state == TASK_STATUS__UNINIT) { - for (int32_t i = 0; i < taosArrayGetSize(pInfo->pList); ++i) { - SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, i); - if (p->status == TASK_DOWNSTREAM_READY) { - numOfReady += 1; - } else if (p->status == TASK_UPSTREAM_NEW_STAGE || p->status == TASK_DOWNSTREAM_NOT_LEADER) { - stDebug("s-task:%s recv status from downstream, task:0x%x, quit from check downstream tasks", id, p->taskId); - numOfFault += 1; - } else { // TASK_DOWNSTREAM_NOT_READY - if (p->rspTs == 0) { // not response yet - ASSERT(p->status == -1); - if (el >= CHECK_NOT_RSP_DURATION) { // not receive info for 10 sec. - taosArrayPush(pTimeoutList, &p->taskId); - } else { // el < CHECK_NOT_RSP_DURATION - // do nothing and continue waiting for their rsps - } - } else { - taosArrayPush(pNotReadyList, &p->taskId); - } - } - } + getCheckRspStatus(pInfo, el, &numOfReady, &numOfFault, &numOfNotRsp, pTimeoutList, pNotReadyList, id); } else { // unexpected status stError("s-task:%s unexpected task status:%s during waiting for check rsp", id, pStat->name); } - int32_t numOfNotReady = (int32_t)taosArrayGetSize(pNotReadyList); - int32_t numOfTimeout = (int32_t)taosArrayGetSize(pTimeoutList); + numOfNotReady = (int32_t)taosArrayGetSize(pNotReadyList); + numOfTimeout = (int32_t)taosArrayGetSize(pTimeoutList); // fault tasks detected, not try anymore - if (((numOfReady + numOfFault + numOfNotReady + numOfTimeout) == taosArrayGetSize(pInfo->pList)) && - (numOfFault > 0)) { + ASSERT((numOfReady + numOfFault + numOfNotReady + numOfTimeout + numOfNotRsp) == taosArrayGetSize(pInfo->pList)); + if (numOfFault > 0) { int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); stDebug( "s-task:%s status:%s vgId:%d all rsp. quit from monitor rsp tmr, since vnode-transfer/leader-change/restart " - "detected, notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d", - id, pStat->name, vgId, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); + "detected, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d ref:%d", + id, pStat->name, vgId, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); + streamTaskCompleteCheckRsp(pInfo, id); taosThreadMutexUnlock(&pInfo->checkInfoLock); + taosArrayDestroy(pNotReadyList); taosArrayDestroy(pTimeoutList); - - streamTaskCompleteCheck(pInfo, id); return; } // checking of downstream tasks has been stopped by other threads - if (pInfo->inCheckProcess == 0) { + if (pInfo->stopCheckProcess == 1) { int32_t ref = atomic_sub_fetch_32(&pTask->status.timerActive, 1); stDebug( - "s-task:%s status:%s vgId:%d stopped by other threads to check downstream process, notReady:%d, fault:%d, " - "timeout:%d, ready:%d ref:%d", - id, pStat->name, vgId, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); + "s-task:%s status:%s vgId:%d stopped by other threads to check downstream process, notRsp:%d, notReady:%d, " + "fault:%d, timeout:%d, ready:%d ref:%d", + id, pStat->name, vgId, numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady, ref); + + streamTaskCompleteCheckRsp(pInfo, id); taosThreadMutexUnlock(&pInfo->checkInfoLock); // add the not-ready tasks into the final task status result buf, along with related fill-history task if exists. @@ -1195,6 +1245,9 @@ static void rspMonitorFn(void* param, void* tmrId) { STaskId* pHId = &pTask->hTaskInfo.id; streamMetaAddTaskLaunchResult(pTask->pMeta, pHId->streamId, pHId->taskId, pInfo->startTs, now, false); } + + taosArrayDestroy(pNotReadyList); + taosArrayDestroy(pTimeoutList); return; } @@ -1205,13 +1258,11 @@ static void rspMonitorFn(void* param, void* tmrId) { for (int32_t i = 0; i < numOfNotReady; ++i) { int32_t taskId = *(int32_t*)taosArrayGet(pNotReadyList, i); - for (int32_t j = 0; j < taosArrayGetSize(pInfo->pList); ++j) { - SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, j); - if (p->taskId == taskId) { - p->rspTs = 0; - p->status = -1; - doSendCheckMsg(pTask, p); - } + SDownstreamStatusInfo* p = findCheckRspStatus(pInfo, taskId); + if (p != NULL) { + p->rspTs = 0; + p->status = -1; + doSendCheckMsg(pTask, p); } } @@ -1225,38 +1276,63 @@ static void rspMonitorFn(void* param, void* tmrId) { for (int32_t i = 0; i < numOfTimeout; ++i) { int32_t taskId = *(int32_t*)taosArrayGet(pTimeoutList, i); - for (int32_t j = 0; j < taosArrayGetSize(pInfo->pList); ++j) { - SDownstreamStatusInfo* p = taosArrayGet(pInfo->pList, j); - if (p->taskId == taskId) { - ASSERT(p->status == -1 && p->rspTs == 0); - doSendCheckMsg(pTask, p); - break; - } + SDownstreamStatusInfo* p = findCheckRspStatus(pInfo, taskId); + if (p != NULL) { + ASSERT(p->status == -1 && p->rspTs == 0); + doSendCheckMsg(pTask, p); } } stDebug("s-task:%s %d downstream tasks timeout, send check msg again, start ts:%" PRId64, id, numOfTimeout, now); } + taosTmrReset(rspMonitorFn, CHECK_RSP_INTERVAL, pTask, streamTimer, &pInfo->checkRspTmr); taosThreadMutexUnlock(&pInfo->checkInfoLock); - taosTmrReset(rspMonitorFn, CHECK_RSP_INTERVAL, pTask, streamTimer, &pInfo->checkRspTmr); - stDebug("s-task:%s continue checking rsp in 200ms, notReady:%d, fault:%d, timeout:%d, ready:%d", id, numOfNotReady, - numOfFault, numOfTimeout, numOfReady); + stDebug("s-task:%s continue checking rsp in 300ms, notRsp:%d, notReady:%d, fault:%d, timeout:%d, ready:%d", id, + numOfNotRsp, numOfNotReady, numOfFault, numOfTimeout, numOfReady); taosArrayDestroy(pNotReadyList); taosArrayDestroy(pTimeoutList); } int32_t streamTaskStartMonitorCheckRsp(SStreamTask* pTask) { - ASSERT(pTask->taskCheckInfo.checkRspTmr == NULL); + STaskCheckInfo* pInfo = &pTask->taskCheckInfo; + + taosThreadMutexLock(&pInfo->checkInfoLock); + int32_t code = streamTaskStartCheckDownstream(pInfo, pTask->id.idStr); + if (code != TSDB_CODE_SUCCESS) { + + taosThreadMutexUnlock(&pInfo->checkInfoLock); + return TSDB_CODE_FAILED; + } + + streamTaskInitTaskCheckInfo(pInfo, &pTask->outputInfo, taosGetTimestampMs()); int32_t ref = atomic_add_fetch_32(&pTask->status.timerActive, 1); stDebug("s-task:%s start check rsp monit, ref:%d ", pTask->id.idStr, ref); - pTask->taskCheckInfo.checkRspTmr = taosTmrStart(rspMonitorFn, CHECK_RSP_INTERVAL, pTask, streamTimer); + + if (pInfo->checkRspTmr == NULL) { + pInfo->checkRspTmr = taosTmrStart(rspMonitorFn, CHECK_RSP_INTERVAL, pTask, streamTimer); + } else { + taosTmrReset(rspMonitorFn, CHECK_RSP_INTERVAL, pTask, streamTimer, pInfo->checkRspTmr); + } + + taosThreadMutexUnlock(&pInfo->checkInfoLock); return 0; } +int32_t streamTaskStopMonitorCheckRsp(STaskCheckInfo* pInfo, const char* id) { + taosThreadMutexLock(&pInfo->checkInfoLock); + streamTaskCompleteCheckRsp(pInfo, id); + + pInfo->stopCheckProcess = 1; + taosThreadMutexUnlock(&pInfo->checkInfoLock); + + stDebug("s-task:%s set stop check rsp mon", id); + return TSDB_CODE_SUCCESS; +} + void streamTaskCleanCheckInfo(STaskCheckInfo* pInfo) { ASSERT(pInfo->inCheckProcess == 0); diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c index 8d83a70c11..3e5a86588d 100644 --- a/source/util/src/talgo.c +++ b/source/util/src/talgo.c @@ -153,6 +153,130 @@ void taosqsort(void *src, int64_t numOfElem, int64_t size, const void *param, __ taosMemoryFreeClear(buf); } +#define DOSWAP(a, b, size) \ + do { \ + size_t __size = (size); \ + char *__a = (a), *__b = (b); \ + do { \ + char __tmp = *__a; \ + *__a++ = *__b; \ + *__b++ = __tmp; \ + } while (--__size > 0); \ + } while (0) + +typedef struct { + char *lo; + char *hi; +} stack_node; + +#define STACK_SIZE (CHAR_BIT * sizeof(size_t)) +#define PUSH(low, high) ((void)((top->lo = (low)), (top->hi = (high)), ++top)) +#define POP(low, high) ((void)(--top, (low = top->lo), (high = top->hi))) +#define STACK_NOT_EMPTY (stack < top) + +void taosqsort_r(void *src, int64_t nelem, int64_t size, const void *arg, __ext_compar_fn_t cmp) { + const int32_t MAX_THRESH = 6; + char *base_ptr = (char *)src; + + const size_t max_thresh = MAX_THRESH * size; + + if (nelem == 0) return; + + if (nelem > MAX_THRESH) { + char *lo = base_ptr; + char *hi = &lo[size * (nelem - 1)]; + stack_node stack[STACK_SIZE]; + stack_node *top = stack; + + PUSH(NULL, NULL); + + while (STACK_NOT_EMPTY) { + char *left_ptr; + char *right_ptr; + + char *mid = lo + size * ((hi - lo) / size >> 1); + + if ((*cmp)((void *)mid, (void *)lo, arg) < 0) DOSWAP(mid, lo, size); + if ((*cmp)((void *)hi, (void *)mid, arg) < 0) + DOSWAP(mid, hi, size); + else + goto jump_over; + if ((*cmp)((void *)mid, (void *)lo, arg) < 0) DOSWAP(mid, lo, size); + jump_over:; + + left_ptr = lo + size; + right_ptr = hi - size; + do { + while ((*cmp)((void *)left_ptr, (void *)mid, arg) < 0) left_ptr += size; + + while ((*cmp)((void *)mid, (void *)right_ptr, arg) < 0) right_ptr -= size; + + if (left_ptr < right_ptr) { + DOSWAP(left_ptr, right_ptr, size); + if (mid == left_ptr) + mid = right_ptr; + else if (mid == right_ptr) + mid = left_ptr; + left_ptr += size; + right_ptr -= size; + } else if (left_ptr == right_ptr) { + left_ptr += size; + right_ptr -= size; + break; + } + } while (left_ptr <= right_ptr); + + if ((size_t)(right_ptr - lo) <= max_thresh) { + if ((size_t)(hi - left_ptr) <= max_thresh) + POP(lo, hi); + else + lo = left_ptr; + } else if ((size_t)(hi - left_ptr) <= max_thresh) + hi = right_ptr; + else if ((right_ptr - lo) > (hi - left_ptr)) { + PUSH(lo, right_ptr); + lo = left_ptr; + } else { + PUSH(left_ptr, hi); + hi = right_ptr; + } + } + } +#define min(x, y) ((x) < (y) ? (x) : (y)) + + { + char *const end_ptr = &base_ptr[size * (nelem - 1)]; + char *tmp_ptr = base_ptr; + char *thresh = min(end_ptr, base_ptr + max_thresh); + char *run_ptr; + + for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) + if ((*cmp)((void *)run_ptr, (void *)tmp_ptr, arg) < 0) tmp_ptr = run_ptr; + + if (tmp_ptr != base_ptr) DOSWAP(tmp_ptr, base_ptr, size); + + run_ptr = base_ptr + size; + while ((run_ptr += size) <= end_ptr) { + tmp_ptr = run_ptr - size; + while ((*cmp)((void *)run_ptr, (void *)tmp_ptr, arg) < 0) tmp_ptr -= size; + + tmp_ptr += size; + if (tmp_ptr != run_ptr) { + char *trav; + + trav = run_ptr + size; + while (--trav >= run_ptr) { + char c = *trav; + char *hi, *lo; + + for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) *hi = *lo; + *hi = c; + } + } + } + } +} + void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size, __compar_fn_t compar, int32_t flags) { uint8_t *p; int32_t lidx; @@ -275,7 +399,7 @@ void taosheapsort(void *base, int32_t size, int32_t len, const void *parcompar, } static void taosMerge(void *src, int32_t start, int32_t leftend, int32_t end, int64_t size, const void *param, - __ext_compar_fn_t comparFn, void *tmp) { + __ext_compar_fn_t comparFn, void *tmp) { int32_t leftSize = leftend - start + 1; int32_t rightSize = end - leftend; @@ -326,7 +450,7 @@ static int32_t taosMergeSortHelper(void *src, int64_t numOfElem, int64_t size, c if (numOfElem > THRESHOLD_SIZE) { int32_t currSize; - void *tmp = taosMemoryMalloc(numOfElem * size); + void *tmp = taosMemoryMalloc(numOfElem * size); if (tmp == NULL) return TSDB_CODE_OUT_OF_MEMORY; for (currSize = THRESHOLD_SIZE; currSize <= numOfElem - 1; currSize = 2 * currSize) { @@ -351,7 +475,6 @@ int32_t msortHelper(const void *p1, const void *p2, const void *param) { return comparFn(p1, p2); } - int32_t taosMergeSort(void *src, int64_t numOfElem, int64_t size, __compar_fn_t comparFn) { void *param = comparFn; return taosMergeSortHelper(src, numOfElem, size, param, msortHelper); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index ac61b288a4..ab5d3da781 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -151,8 +151,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_KILLED, "Query killed") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_EXEC_NODE, "No available execution node in current query policy configuration") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NOT_STABLE_ERROR, "Table is not a super table") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_CACHE_ERROR, "Stmt cache error") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ENCODE_PARAM_ERROR, "Invalid compress param") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ENCODE_PARAM_ERROR, "Invalid encode param") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ENCODE_PARAM_NULL, "Not found compress param") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_COMPRESS_PARAM_ERROR, "Invalid compress param") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR, "Invalid compress level param") + + TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INTERNAL_ERROR, "Internal error") // mnode-common @@ -221,7 +225,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_NOT_EXIST, "Column does not exist TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STB_OPTION, "Invalid stable options") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ROW_BYTES, "Invalid row bytes") TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_VALUE_OVERFLOW, "out of range and overflow") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_COMPRESS_ALREADY_EXIST, "Column compress already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_COLUMN_COMPRESS_ALREADY_EXIST, "Same with old param") // mnode-func @@ -397,7 +401,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_ALREADY_IS_VOTER, "Vnode already is a vo TAOS_DEFINE_ERROR(TSDB_CODE_VND_DIR_ALREADY_EXIST, "Vnode directory already exist") TAOS_DEFINE_ERROR(TSDB_CODE_VND_META_DATA_UNSAFE_DELETE, "Single replica vnode data will lost permanently after this operation, if you make sure this, please use drop dnode unsafe to execute") TAOS_DEFINE_ERROR(TSDB_CODE_VND_ARB_NOT_SYNCED, "Vgroup peer is not synced") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST,"Column compress already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_COLUMN_COMPRESS_ALREADY_EXIST,"Same with old param") // tsdb diff --git a/tests/army/community/query/test_join.py b/tests/army/community/query/test_join.py new file mode 100644 index 0000000000..ce5288bdb0 --- /dev/null +++ b/tests/army/community/query/test_join.py @@ -0,0 +1,3431 @@ +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame import * +from frame.eos import * +from datetime import datetime, timedelta + +class TDTestCase(TBase): + """Verify the join function + """ + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + # super table common name, will use db name as prefix, "_" as connector with table name as the whole table name + self.super_table_names = ["st1", "st2", "st_empty"] + # child table common name, will use db name as prefix, "_" as connector with super table name and child table name as the whole table name + self.child_table_names = ["ct1", "ct2", "ct_empty"] + # regular table common name, will use db name as prefix, "_" as connector with table name as the whole table name + self.regular_table_names = ["t1", "t2", "t_empty"] + self.total_sql_num = 0 + + def column_fields(self, pk_int32=False, pk_int64=False, pk_str=False): + """Column schema definition for all tables + """ + if pk_int32: + return "ts timestamp, v_int int primary key, v_ts timestamp, v_int_empty int, v_bigint bigint, v_bigint_empty bigint, \ + v_double double, v_double_empty double, v_binary binary(32), v_binary_empty binary(32), v_bool bool, v_bool_empty bool" + elif pk_int64: + return "ts timestamp, v_bigint bigint primary key, v_ts timestamp, v_int int, v_int_empty int, v_bigint_empty bigint, \ + v_double double, v_double_empty double, v_binary binary(32), v_binary_empty binary(32), v_bool bool, v_bool_empty bool" + elif pk_str: + return "ts timestamp, v_binary binary(32) primary key, v_ts timestamp, v_int int, v_int_empty int, v_bigint bigint, v_bigint_empty bigint, \ + v_double double, v_double_empty double, v_binary_empty binary(32), v_bool bool, v_bool_empty bool" + else: + return "ts timestamp, v_ts timestamp, v_int int, v_int_empty int, v_bigint bigint, v_bigint_empty bigint, \ + v_double double, v_double_empty double, v_binary binary(32), v_binary_empty binary(32), v_bool bool, v_bool_empty bool" + + def tag_fields(self): + """Tag schema definition for super table + """ + return "t_ts timestamp, t_int int, t_int_empty int, t_bigint bigint, t_bigint_empty bigint, \ + t_double double, t_double_empty double, t_binary binary(32), t_binary_empty binary(32), t_bool bool, t_bool_empty bool" + + def tag_values(self, mark_name): + """Tag values for 3 super tables + :param mark_name: tag values are marked with name for different test scenarios + """ + v_dic = { + "common": [ + "'2024-01-01 12:00:00', 1, NULL, 123456789, NULL, 1234.56789, NULL, 'test message', NULL, true, NULL", + "'2024-01-01 13:00:00', 2, NULL, 123456789, NULL, 2234.56789, NULL, 'test message', NULL, false, NULL", + "'2024-01-01 14:00:00', 2, NULL, 223456789, NULL, 2234.56789, NULL, 'test message', NULL, false, NULL" + ] + } + return v_dic[mark_name] + + def create_tables(self, db_list, precision_list, tag_mark="common"): + """Init the database and tables, the database number should keep same with table number + :param db_list: the database name list + :param precision_list: the precision each of the database, the precision can be "ms", "us", "ns" + :param tag_mark: the tag values mark, default is "common" + """ + for name, precision in zip(db_list, precision_list): + tdSql.execute(f"create database {name} precision '{precision}';") + tdSql.execute(f"use {name}") + if precision == "ms": + if name == "db_pk": + for st in self.super_table_names: + # primary key for int32 + tdSql.execute(f"create table {'_'.join([name, st, 'int32'])} ({self.column_fields(pk_int32=True)}) tags({self.tag_fields()});") + # primary key for int64 + tdSql.execute(f"create table {'_'.join([name, st, 'int64'])} ({self.column_fields(pk_int64=True)}) tags({self.tag_fields()});") + # primary key for binary + tdSql.execute(f"create table {'_'.join([name, st, 'str'])} ({self.column_fields(pk_str=True)}) tags({self.tag_fields()});") + if st != "st_empty": + tags = self.tag_values(tag_mark) + for index in range(len(self.child_table_names)): + tdSql.execute(f"create table {'_'.join([name, st, 'int32', self.child_table_names[index]])} using {'_'.join([name, st, 'int32'])} tags({tags[index]});") + tdSql.execute(f"create table {'_'.join([name, st, 'int64', self.child_table_names[index]])} using {'_'.join([name, st, 'int64'])} tags({tags[index]});") + tdSql.execute(f"create table {'_'.join([name, st, 'str', self.child_table_names[index]])} using {'_'.join([name, st, 'str'])} tags({tags[index]});") + else: + # only for scenarios without primary key + for st in self.super_table_names: + tdSql.execute(f"create table {'_'.join([name, st])} ({self.column_fields()}) tags({self.tag_fields()});") + if st != "st_empty": + tags = self.tag_values(tag_mark) + for index in range(len(self.child_table_names)): + tdSql.execute(f"create table {'_'.join([name, st, self.child_table_names[index]])} using {'_'.join([name, st])} tags({tags[index]});") + for rt in self.regular_table_names: + tdSql.execute(f"create table {'_'.join([name, rt])} ({self.column_fields()});") + else: + # only create regular tables for 'us' and 'ns' precision + tdSql.execute(f"create table {name}_t ({self.column_fields()});") + + def insert_data(self, db_name, table_name, data): + """Insert data into table of database + :param db_name: the database name + :param table_name: the table name + :param data: the data list + """ + tdSql.execute(f"use {db_name}") + sql = f"insert into {table_name} values" + for d in data: + sql += f"({d})" + sql += ";" + tdSql.execute(sql) + + def data(self, db_name_list, data_mark): + """Data generator for test cases, is marked by data_mark + :param db_name_list: the database name list, the data is same for different databases + :param data_mark: the data mark for different test scenarios + """ + data = { + "common_ms": { + "st1_ct1": [ + "'2024-01-01 12:00:00.000', '2024-01-01 12:00:00.000', -2, NULL, 123456780, NULL, 1234.56780, NULL, 'abc', NULL, true, NULL", + "'2024-01-01 12:00:00.200', '2024-01-01 12:00:00.200', 0, NULL, 123456792, NULL, 1234.56792, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.400', '2024-01-01 12:00:00.400', 2, NULL, 123456794, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.600', '2024-01-01 12:00:00.600', 4, NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.800', '2024-01-01 12:00:00.800', 16, NULL, 123456798, NULL, 1234.56798, NULL, 'abce', NULL, true, NULL" + ], + "st1_ct2": [ + "'2024-01-01 12:00:01.000', '2024-01-01 12:00:01.000', 8, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.200', '2024-01-01 12:00:01.200', 10, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.400', '2024-01-01 12:00:01.400', 12, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.600', '2024-01-01 12:00:01.600', 14, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.800', '2024-01-01 12:00:01.800', 16, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL" + ], + "st2_ct1": [ + "'2024-01-01 12:00:00.000', '2024-01-01 12:00:00.000', -3, NULL, 123456780, NULL, 1234.56780, NULL, 'abc', NULL, false, NULL", + "'2024-01-01 12:00:00.100', '2024-01-01 12:00:00.100', -1, NULL, 123456791, NULL, 1234.56791, NULL, 'abcf', NULL, true, NULL", + "'2024-01-01 12:00:00.200', '2024-01-01 12:00:00.200', 1, NULL, 123456793, NULL, 1234.56793, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:00.300', '2024-01-01 12:00:00.300', 4, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:00.400', '2024-01-01 12:00:00.400', 6, NULL, 123456797, NULL, 1234.56797, NULL, 'abcg', NULL, false, NULL" + ], + "st2_ct2": [ + "'2024-01-01 12:00:00.500', '2024-01-01 12:00:00.500', 7, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:01.600', '2024-01-01 12:00:00.600', 9, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:00.700', '2024-01-01 12:00:00.700', 12, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:00.800', '2024-01-01 12:00:00.800', 16, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:01.900', '2024-01-01 12:00:00.900', 14, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL" + ], + "t1": [ + "'2024-01-01 12:00:00.000', '2024-01-01 12:00:00.000', -2, NULL, 123456780, NULL, 1234.56780, NULL, 'abc', NULL, true, NULL", + "'2024-01-01 12:00:00.200', '2024-01-01 12:00:00.200', 0, NULL, 123456792, NULL, 1234.56792, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.400', '2024-01-01 12:00:00.400', 2, NULL, 123456794, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.600', '2024-01-01 12:00:00.600', 4, NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.800', '2024-01-01 12:00:00.800', 16, NULL, 123456798, NULL, 1234.56798, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.000', '2024-01-01 12:00:01.000', 8, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.200', '2024-01-01 12:00:01.200', 10, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.400', '2024-01-01 12:00:01.400', 12, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.600', '2024-01-01 12:00:01.600', 14, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.800', '2024-01-01 12:00:01.800', 16, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + ], + "t2": [ + "'2024-01-01 12:00:00.000', '2024-01-01 12:00:00.000', -3, NULL, 123456780, NULL, 1234.56780, NULL, 'abc', NULL, false, NULL", + "'2024-01-01 12:00:00.100', '2024-01-01 12:00:00.100', -1, NULL, 123456791, NULL, 1234.56791, NULL, 'abcf', NULL, true, NULL", + "'2024-01-01 12:00:00.200', '2024-01-01 12:00:00.200', 1, NULL, 123456793, NULL, 1234.56793, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:00.300', '2024-01-01 12:00:00.300', 4, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:00.400', '2024-01-01 12:00:00.400', 6, NULL, 123456797, NULL, 1234.56797, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:00.500', '2024-01-01 12:00:00.500', 7, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:01.600', '2024-01-01 12:00:00.600', 9, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:00.700', '2024-01-01 12:00:00.700', 12, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:00.800', '2024-01-01 12:00:00.800', 16, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:01.900', '2024-01-01 12:00:00.900', 14, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + ] + }, + "common_us": { + "t": [ + "'2024-01-01 12:00:00.000000', '2024-01-01 12:00:00.000', -2, NULL, 123456780, NULL, 1234.56780, NULL, 'abc', NULL, true, NULL", + "'2024-01-01 12:00:00.000200', '2024-01-01 12:00:00.200', 0, NULL, 123456792, NULL, 1234.56792, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.000400', '2024-01-01 12:00:00.400', 2, NULL, 123456794, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.000600', '2024-01-01 12:00:00.600', 4, NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.000800', '2024-01-01 12:00:00.800', 16, NULL, 123456798, NULL, 1234.56798, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.000000', '2024-01-01 12:00:01.000', 8, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.000200', '2024-01-01 12:00:01.200', 10, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.000400', '2024-01-01 12:00:01.400', 12, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.000600', '2024-01-01 12:00:01.600', 14, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.000800', '2024-01-01 12:00:01.800', 16, NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + ] + }, + "common_ns": { + "t": [ + "'2024-01-01 12:00:00.000000000', '2024-01-01 12:00:00.000', -3, NULL, 123456780, NULL, 1234.56780, NULL, 'abc', NULL, false, NULL", + "'2024-01-01 12:00:00.000000100', '2024-01-01 12:00:00.100', -1, NULL, 123456791, NULL, 1234.56791, NULL, 'abcf', NULL, true, NULL", + "'2024-01-01 12:00:00.000000200', '2024-01-01 12:00:00.200', 1, NULL, 123456793, NULL, 1234.56793, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:00.000000300', '2024-01-01 12:00:00.300', 4, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:00.000000400', '2024-01-01 12:00:00.400', 6, NULL, 123456797, NULL, 1234.56797, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:00.000000500', '2024-01-01 12:00:00.500', 7, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:01.000000600', '2024-01-01 12:00:00.600', 9, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:00.000000700', '2024-01-01 12:00:00.700', 12, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + "'2024-01-01 12:00:00.000000800', '2024-01-01 12:00:00.800', 16, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, false, NULL", + "'2024-01-01 12:00:01.000000900', '2024-01-01 12:00:00.900', 14, NULL, 123456795, NULL, 1234.56795, NULL, 'abcg', NULL, true, NULL", + ] + }, + "pk_int32_ms": { + "st1_int32_ct1": [ + "'2024-01-01 12:00:00.000', 0, '2024-01-01 12:00:00.000', NULL, 123456780, NULL, 1234.56780, NULL, 'abc', NULL, true, NULL", + "'2024-01-01 12:00:00.000', -2147483648, '2024-01-01 12:00:00.100', NULL, 123456781, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.000', 2147483647, '2024-01-01 12:00:00.200', NULL, 123456781, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.200', 0, '2024-01-01 12:00:00.200', NULL, 123456792, NULL, 1234.56792, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.200', 2147483647, '2024-01-01 12:00:00.200', NULL, 123456793, NULL, 1234.56793, NULL, 'abcde', NULL, true, NULL", + "'2024-01-01 12:00:00.400', 2147483647,'2024-01-01 12:00:00.400', NULL, 123456794, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.400', -2147483648,'2024-01-01 12:00:00.500', NULL, 123456794, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.600', 0,'2024-01-01 12:00:00.600', NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.600', -2147483648,'2024-01-01 12:00:00.600', NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.600', 2147483647,'2024-01-01 12:00:00.600', NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL" + ], + "st1_int32_ct2": [ + "'2024-01-01 12:00:01.000', 2147483647, '2024-01-01 12:00:01.000', NULL, 123456780, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:01.000', -2147483648, '2024-01-01 12:00:01.100', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.100', 0, '2024-01-01 12:00:01.200', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.100', 2147483647, '2024-01-01 12:00:01.200', NULL, 123456795, NULL, 1234.56795, NULL, 'abcde', NULL, false, NULL", + "'2024-01-01 12:00:01.100', -2147483648, '2024-01-01 12:00:01.200', NULL, 123456795, NULL, 1234.56796, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.400', 2147483647, '2024-01-01 12:00:01.400', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.400', -2147483648, '2024-01-01 12:00:01.600', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.500', 2147483647, '2024-01-01 12:00:01.800', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.800', 0, '2024-01-01 12:00:01.800', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.800', -2147483648,'2024-01-01 12:00:01.800', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL" + ], + "st2_int32_ct1": [ + "'2024-01-01 12:00:00.000', 0, '2024-01-01 12:00:00.000', NULL, 123456780, NULL, 1234.56780, NULL, 'abc', NULL, true, NULL", + "'2024-01-01 12:00:00.000', -2147483648, '2024-01-01 12:00:00.100', NULL, 123456781, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.000', 2147483647, '2024-01-01 12:00:00.200', NULL, 123456781, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.200', 0, '2024-01-01 12:00:00.200', NULL, 123456792, NULL, 1234.56792, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.200', 2147483647, '2024-01-01 12:00:00.200', NULL, 123456793, NULL, 1234.56793, NULL, 'abcde', NULL, true, NULL", + "'2024-01-01 12:00:00.400', 2147483647,'2024-01-01 12:00:00.400', NULL, 123456794, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.400', -2147483648,'2024-01-01 12:00:00.500', NULL, 123456794, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.600', 0,'2024-01-01 12:00:00.600', NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.600', -2147483648,'2024-01-01 12:00:00.600', NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.600', 2147483647,'2024-01-01 12:00:00.600', NULL, 123456796, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL" + ], + "st2_int32_ct2": [ + "'2024-01-01 12:00:01.000', 2147483647, '2024-01-01 12:00:01.000', NULL, 123456780, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:01.000', -2147483648, '2024-01-01 12:00:01.100', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.100', 0, '2024-01-01 12:00:01.200', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.100', 2147483647, '2024-01-01 12:00:01.200', NULL, 123456795, NULL, 1234.56795, NULL, 'abcde', NULL, false, NULL", + "'2024-01-01 12:00:01.100', -2147483648, '2024-01-01 12:00:01.200', NULL, 123456795, NULL, 1234.56796, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.400', 2147483647, '2024-01-01 12:00:01.400', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.400', -2147483648, '2024-01-01 12:00:01.600', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.500', 2147483647, '2024-01-01 12:00:01.800', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.800', 0, '2024-01-01 12:00:01.800', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.800', -2147483648,'2024-01-01 12:00:01.800', NULL, 123456795, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL" + ] + }, + "pk_int64_ms": { + "st1_int64_ct1": [ + "'2024-01-01 12:00:00.000', -9.2233720e+18, '2024-01-01 12:00:00.000', 2147483647, NULL, NULL, 1234.56780, NULL, 'abc', NULL, true, NULL", + "'2024-01-01 12:00:00.000', 0, '2024-01-01 12:00:00.100', 0, NULL, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.000', 9.2233720e+18, '2024-01-01 12:00:00.200', 2147483647, NULL, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.200', 0, '2024-01-01 12:00:00.200', 0, NULL, NULL, 1234.56792, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.200', 9.2233720e+18, '2024-01-01 12:00:00.200', 2147483647, NULL, NULL, 1234.56793, NULL, 'abcde', NULL, true, NULL", + "'2024-01-01 12:00:00.400', 9.2233720e+18,'2024-01-01 12:00:00.400', 2147483647, NULL, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.400', -9.2233720e+18,'2024-01-01 12:00:00.500', -2147483648, NULL, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.600', 0,'2024-01-01 12:00:00.600', 2147483647, NULL, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.600', -9.2233720e+18,'2024-01-01 12:00:00.600', -2147483648, NULL, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.600', 9.2233720e+18,'2024-01-01 12:00:00.600', 2147483647, NULL, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL" + ], + "st1_int64_ct2": [ + "'2024-01-01 12:00:01.000', 9.2233720e+18, '2024-01-01 12:00:01.000', -2147483648, NULL, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:01.000', -9.2233720e+18, '2024-01-01 12:00:01.100', -2147483648, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.100', 0, '2024-01-01 12:00:01.200', 0, NULL, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.100', 9.2233720e+18, '2024-01-01 12:00:01.200', 2147483647, NULL, NULL, 1234.56795, NULL, 'abcde', NULL, false, NULL", + "'2024-01-01 12:00:01.100', -9.2233720e+18, '2024-01-01 12:00:01.200', -2147483648, NULL, NULL, 1234.56796, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.400', 9.2233720e+18, '2024-01-01 12:00:01.400', 2147483647, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.400', -9.2233720e+18, '2024-01-01 12:00:01.600', -2147483648, NULL, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.500', 9.2233720e+18, '2024-01-01 12:00:01.800', 2147483647, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.800', 0, '2024-01-01 12:00:01.800', 0, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.800', -9.2233720e+18,'2024-01-01 12:00:01.800', -2147483648, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL" + ], + "st2_int64_ct1": [ + "'2024-01-01 12:00:00.000', -9.2233720e+18, '2024-01-01 12:00:00.000', 2147483647, NULL, NULL, 1234.56780, NULL, 'abc', NULL, true, NULL", + "'2024-01-01 12:00:00.000', 0, '2024-01-01 12:00:00.100', 0, NULL, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.000', 9.2233720e+18, '2024-01-01 12:00:00.200', 2147483647, NULL, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.200', 0, '2024-01-01 12:00:00.200', 0, NULL, NULL, 1234.56792, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:00.200', 9.2233720e+18, '2024-01-01 12:00:00.200', 2147483647, NULL, NULL, 1234.56793, NULL, 'abcde', NULL, true, NULL", + "'2024-01-01 12:00:00.400', 9.2233720e+18,'2024-01-01 12:00:00.400', 2147483647, NULL, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.400', -9.2233720e+18,'2024-01-01 12:00:00.500', -2147483648, NULL, NULL, 1234.56794, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:00.600', 0,'2024-01-01 12:00:00.600', 2147483647, NULL, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.600', -9.2233720e+18,'2024-01-01 12:00:00.600', -2147483648, NULL, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:00.600', 9.2233720e+18,'2024-01-01 12:00:00.600', 2147483647, NULL, NULL, 1234.56796, NULL, 'abce', NULL, false, NULL" + ], + "st2_int64_ct2": [ + "'2024-01-01 12:00:01.000', 9.2233720e+18, '2024-01-01 12:00:01.000', -2147483648, NULL, NULL, 1234.56781, NULL, 'abcd', NULL, false, NULL", + "'2024-01-01 12:00:01.000', -9.2233720e+18, '2024-01-01 12:00:01.100', -2147483648, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.100', 0, '2024-01-01 12:00:01.200', 0, NULL, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.100', 9.2233720e+18, '2024-01-01 12:00:01.200', 2147483647, NULL, NULL, 1234.56795, NULL, 'abcde', NULL, false, NULL", + "'2024-01-01 12:00:01.100', -9.2233720e+18, '2024-01-01 12:00:01.200', -2147483648, NULL, NULL, 1234.56796, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.400', 9.2233720e+18, '2024-01-01 12:00:01.400', 2147483647, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.400', -9.2233720e+18, '2024-01-01 12:00:01.600', -2147483648, NULL, NULL, 1234.56795, NULL, 'abce', NULL, true, NULL", + "'2024-01-01 12:00:01.500', 9.2233720e+18, '2024-01-01 12:00:01.800', 2147483647, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.800', 0, '2024-01-01 12:00:01.800', 0, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL", + "'2024-01-01 12:00:01.800', -9.2233720e+18,'2024-01-01 12:00:01.800', -2147483648, NULL, NULL, 1234.56795, NULL, 'abce', NULL, false, NULL" + ] + }, + "pk_str_ms": { + "st1_str_ct1": [ + "'2024-01-01 12:00:00.000', 'abc', '2024-01-01 12:00:00.000', 2147483647, NULL, -9.2233720e+18, NULL, 1234.56780, NULL, NULL, true, NULL", + "'2024-01-01 12:00:00.000', 'abcd', '2024-01-01 12:00:00.100', 0, NULL, 0, NULL, 1234.56781, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.000', 'abcde', '2024-01-01 12:00:00.200', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56781, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.200', 'abcd', '2024-01-01 12:00:00.200', 0, NULL, 0, NULL, 1234.56792, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.200', 'abcde', '2024-01-01 12:00:00.200', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56793, NULL, NULL, true, NULL", + "'2024-01-01 12:00:00.400', 'abcd','2024-01-01 12:00:00.400', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56794, NULL, NULL, true, NULL", + "'2024-01-01 12:00:00.400', 'abcde','2024-01-01 12:00:00.500', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56794, NULL, NULL, true, NULL", + "'2024-01-01 12:00:00.600', 'abc','2024-01-01 12:00:00.600', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56796, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.600', 'abcd','2024-01-01 12:00:00.600', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56796, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.600', 'abcde','2024-01-01 12:00:00.600', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56796, NULL, NULL, false, NULL" + ], + "st1_str_ct2": [ + "'2024-01-01 12:00:01.000', 'abcd', '2024-01-01 12:00:01.000', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56781, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.000', 'abc', '2024-01-01 12:00:01.100', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.100', 'abcd', '2024-01-01 12:00:01.200', 0, NULL, 0, NULL, 1234.56795, NULL, NULL, true, NULL", + "'2024-01-01 12:00:01.100', 'abc', '2024-01-01 12:00:01.200', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.100', 'abcde', '2024-01-01 12:00:01.200', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56796, NULL, NULL, true, NULL", + "'2024-01-01 12:00:01.400', 'abc', '2024-01-01 12:00:01.400', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.400', 'abcd', '2024-01-01 12:00:01.600', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56795, NULL, NULL, true, NULL", + "'2024-01-01 12:00:01.500', 'abcde', '2024-01-01 12:00:01.800', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.800', 'abc', '2024-01-01 12:00:01.800', 0, NULL, 0, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.800', 'abcd','2024-01-01 12:00:01.800', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL" + ], + "st2_str_ct1": [ + "'2024-01-01 12:00:00.000', 'abc', '2024-01-01 12:00:00.000', 2147483647, NULL, -9.2233720e+18, NULL, 1234.56780, NULL, NULL, true, NULL", + "'2024-01-01 12:00:00.000', 'abcd', '2024-01-01 12:00:00.100', 0, NULL, 0, NULL, 1234.56781, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.000', 'abcde', '2024-01-01 12:00:00.200', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56781, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.200', 'abcd', '2024-01-01 12:00:00.200', 0, NULL, 0, NULL, 1234.56792, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.200', 'abcde', '2024-01-01 12:00:00.200', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56793, NULL, NULL, true, NULL", + "'2024-01-01 12:00:00.400', 'abcd','2024-01-01 12:00:00.400', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56794, NULL, NULL, true, NULL", + "'2024-01-01 12:00:00.400', 'abcde','2024-01-01 12:00:00.500', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56794, NULL, NULL, true, NULL", + "'2024-01-01 12:00:00.600', 'abc','2024-01-01 12:00:00.600', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56796, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.600', 'abcd','2024-01-01 12:00:00.600', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56796, NULL, NULL, false, NULL", + "'2024-01-01 12:00:00.600', 'abcde','2024-01-01 12:00:00.600', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56796, NULL, NULL, false, NULL" + ], + "st2_str_ct2": [ + "'2024-01-01 12:00:01.000', 'abcd', '2024-01-01 12:00:01.000', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56781, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.000', 'abc', '2024-01-01 12:00:01.100', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.100', 'abcd', '2024-01-01 12:00:01.200', 0, NULL, 0, NULL, 1234.56795, NULL, NULL, true, NULL", + "'2024-01-01 12:00:01.100', 'abc', '2024-01-01 12:00:01.200', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.100', 'abcde', '2024-01-01 12:00:01.200', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56796, NULL, NULL, true, NULL", + "'2024-01-01 12:00:01.400', 'abc', '2024-01-01 12:00:01.400', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.400', 'abcd', '2024-01-01 12:00:01.600', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56795, NULL, NULL, true, NULL", + "'2024-01-01 12:00:01.500', 'abcde', '2024-01-01 12:00:01.800', 2147483647, NULL, 9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.800', 'abc', '2024-01-01 12:00:01.800', 0, NULL, 0, NULL, 1234.56795, NULL, NULL, false, NULL", + "'2024-01-01 12:00:01.800', 'abcd','2024-01-01 12:00:01.800', -2147483648, NULL, -9.2233720e+18, NULL, 1234.56795, NULL, NULL, false, NULL" + ] + }, + } + for db in db_name_list: + tdSql.execute(f"use {db}") + for k in data[data_mark].keys(): + self.insert_data(db, "_".join([db, k]), data[data_mark][k]) + + def sql_generator(self, join_type): + """Sql sets for different join types, for one check point, maybe have multiple sqls, note the query + result should be same with the expected result + :param join_type: the join type, can be "inner", "left-outer", "right-outer", "full", + "left-semi", "right-semi", "left-anti", "right-anti", "left-asof", "right-asof", “left-window", "right-window” + """ + # id indicates the join type, case number and check points + sql = { + "inner": [ + { + "id": "ij_c1_1", + "desc": "inner join for super table with master and other connection conditions", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int >= t2.v_int or t1.v_int <= t2.v_int) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int and t1.v_int_empty is null and t2.v_int_empty is null) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint = t2.v_bigint or t1.v_bigint != t2.v_bigint) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint >= t2.v_bigint or t1.v_bigint <= t2.v_bigint) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint = t2.v_bigint or t1.v_bigint != t2.v_bigint and t1.v_bigint_empty is null and t2.v_bigint_empty is null) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double >= t2.v_double or t1.v_double <= t2.v_double) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double and t1.v_double_empty is null and t2.v_double_empty is null) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary >= t2.v_binary or t1.v_binary != t2.v_binary) and t1.v_binary_empty is null and t2.v_binary_empty is null order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool >= t2.v_bool or t1.v_bool <= t2.v_bool) and t1.v_bool_empty is null and t2.v_bool_empty is null order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts = t2.t_ts or t1.t_ts != t2.t_ts) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts >= t2.t_ts or t1.t_ts <= t2.t_ts) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int >= t2.t_int or t1.t_int <= t2.t_int) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int and t1.t_int_empty is null and t2.t_int_empty is null) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint >= t2.t_bigint or t1.t_bigint <= t2.t_bigint) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint and t1.t_bigint_empty is null and t2.t_bigint_empty is null) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double >= t2.t_double or t1.t_double <= t2.t_double) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double and t1.t_double_empty is null and t2.t_double_empty is null) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[test]' or t1.t_binary nmatch '[test]') order by t1.v_int, t2.v_int;" + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary >= t2.t_binary or t1.t_binary != t2.t_binary) and t1.t_binary_empty is null and t2.t_binary_empty is null order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool >= t2.t_bool or t1.t_bool <= t2.t_bool) and t1.t_bool_empty is null and t2.t_bool_empty is null order by t1.v_int, t2.v_int;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,3)], [('2024-01-01 12:00:00.000'), (16)]] + } + } + }, + { + "id": "ij_c1_2_1", + "desc": "inner join for child table with contant and scalar function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and t1.ts between '2023-01-01 12:00:00.000' and '2024-03-01 12:00:00.300' order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and t1.ts >='2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_int >= 0 or t2.v_int < 0) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' and abs(t1.v_int) >= 0 and (acos(t2.v_int) > 0 or acos(t2.v_int) <= 0 or acos(t2.v_int) is null) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and (asin(t1.v_bigint) is null or asin(t1.v_int) >= 0 or asin(t1.v_int) < 0) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and (atan(t1.v_double) is null or atan(t1.v_double) > 0 or atan(t1.v_double) <= 0) order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and length(t1.v_binary) >= 0 and char_length(t2.v_binary) >= 0 order by t1.v_int, t2.v_int;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts, t2.ts, t1.v_binary;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts=t2.ts and cast(t1.t_ts as timestamp) <= now and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts, t1.v_binary;",], + "res": { + "total_rows": 3, + "value_check": { + "type": "contain", + "values": [[(0,0), (2,3)], [('2024-01-01 12:00:00.000'), (6)]] + } + } + }, + { + "id": "ij_c1_2_2", + "desc": "inner join for super table with contant and scalar function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and t1.v_int < 0 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and t1.v_bigint <= 123456780 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and t1.v_double <= 1234.56780 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary = 'abc' order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary = 'abc' and t1.v_bool = true and t2.v_bool = false order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and sin(t1.v_int) < 0 and ceil(t2.v_int) < 0 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and atan(t1.v_int) < 0 and round(t2.v_int) < 0 order by t1.ts;"], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0),(0,3)], [('2024-01-01 12:00:00.000'),(-3)]] + } + } + }, + { + "id": "ij_c1_3", + "desc": "inner join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct1 t1 join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_t_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 join db1_t_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is null and t2.v_int_empty is not null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_t_empty t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_t_empty t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts and t1.t_int_empty is null and t2.t_bigint_empty is not null and t1.v_binary_empty is null and t2.v_bool_empty is not null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st1 where ts >= now) t1, (select * from db1_st2 where ts >= now) t2 where t1.v_int = t2.v_int and t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select _wstart ts, sum(v_int) v_int from db1_st1 where ts >= now partition by tbname interval(1m) order by ts) t1, (select * from db1_st2 where ts >= now order by ts) t2 where t1.v_int = t2.v_int and t1.ts=t2.ts order by t1.ts;",], + "res": { + "total_rows": 0 + } + }, + { + "id": "ij_c1_4", + "desc": "inner join for subquery, especially for group scenario by timestamp", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from (select * from db1_st1) t1 join (select * from db1_st2) t2 on t1.ts=t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 order by ts desc) t1 join (select * from db1_st2) t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts between '2024-01-01 12:00:00.000' and '2024-01-01 12:00:02') t1 join (select * from db1_st2 where ts >= '2024-01-01 12:00:00.000') t2 on t1.ts=t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where v_int > 0 or v_int <= 0) t1 join (select * from db1_st2) t2 on t1.ts=t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 join (select * from db1_st2) t2 on t1.ts=t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where v_int > 0 or v_int <= 0) t1 join db1_st2 t2 on t1.ts=t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0),(4,1)], [('2024-01-01 12:00:00.000'),('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ij_c2_1", + "desc": "inner join with filter", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000';", + "select t1.ts, t2.ts from db1.db1_st1 t1, db2.db2_st2 t2 where t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts < now order by t2.ts;" + "select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts < now order by t2.ts limit 10;", + "select t1.ts, t2.ts from db1.db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts < '2024-01-01 12:00:02.600' and (t1.v_int is null or t2.t_int_empty is null) order by t2.ts, t1.v_binary_empty;", + "select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts < '2024-01-01 12:00:02.600' order by t2.ts, t1.v_binary_empty;", + "select t1.ts, t2.ts from db1.db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts and (t1.v_int > 0 or t1.v_int <= 0);", + "select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_bigint >= 123456780 or t2.v_bigint < 123456780);", + "select t1.ts, t2.ts from db1.db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts and (t1.v_int > 0 or t1.v_int <= 0) and t1.v_bool in (true, false);", + "select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_binary match '[abc]' or t2.v_binary nmatch '[abc]');"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(4,0)], [('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ij_c3_1", + "desc": "inner join with timetruncated function for ts", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a);", + "select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where timetruncate(t1.ts, 1a)=t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where t1.ts=timetruncate(t2.ts,1a);", + "select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts < '2024-01-01 12:00:02.600';", + "select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) and (t1.v_int > 0 or t1.v_int <= 0) and (t1.v_bool in (true, false));", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1, (select * from db1_st2 where ts <= now) t2 where timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) and (t1.v_bigint>t2.v_bigint or t1.v_bigint <= t2.v_bigint) order by t1.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1, (select * from db1_st2 where ts <= now) t2 where timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) and (t1.v_bigint=t2.v_bigint or t1.v_bigint != t2.v_bigint) order by t1.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1, (select * from db1_st2 where ts <= now) t2 where timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) and (t1.v_bool in (true, false)) and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) order by t1.ts;",], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,0)], [('2024-01-01 12:00:00.000'),('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ij_c4_1", + "desc": "inner join with nested query", + "is_ci": True, + "exception": False, + "sql": ["select count(*) from (select t1.ts, t2.ts from db1_st1 t1, db1_st2 t2 where t1.ts=t2.ts);", + "select count(*) from (select t1.ts, t2.ts from (select * from db1_st1) t1, (select * from db1_st2) t2 where t1.ts=t2.ts);", + "select count(*) from (select t1.ts, t2.ts from (select * from db1_st1) t1, (select * from db1_st2) t2 where t1.ts=t2.ts and (t1.v_int + t2.v_bigint > t2.v_int or t1.v_int + t2.v_bigint <= t2.v_int));", + "select count(*) from (select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1, (select * from db1_st2 where v_int > 0 or v_int <= 0) t2 where t1.ts = t2.ts and (t1.v_bool in (true, false)));", + "select count(*) from (select t1.ts, avg(t2.v_int) from (select * from db1_st1 where ts <= now) t1, (select * from db1_st2 where v_int > 0 or v_int <= 0) t2 where t1.ts = t2.ts and (t1.v_bool in (true, false)) group by t1.ts);", + "select count(*) from (select t1.ts, avg(t2.v_int) from (select * from db1_st1 where ts <= now) t1, (select * from db1_st2 where v_int > 0 or v_int <= 0) t2 where t1.ts = t2.ts and (t1.v_bool in (true, false)) group by t1.ts having avg(t2.v_int) >0 or sum(t2.v_bigint) > 0);", + "select count(*) from (select t1.ts, avg(t2.v_int) from (select * from db1_st1 where ts <= now) t1, (select * from db1_st2 where v_int > 0 or v_int <= 0) t2 where t1.ts = t2.ts and (t1.v_bool in (true, false)) group by t1.ts having avg(t2.v_int) >0 or sum(t2.v_bigint) > 0 order by t1.ts);"], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(5)]] + } + } + }, + { + "id": "ij_c5", + "desc": "inner join exception", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 join db1_st2 t2 on t1.v_ts=t2.v_ts;", + "select * from db1_st1_ct1 t1 join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 join db1_st2 t2 on t1.ts < t2.ts;", + "select * from db1_st1 t1 join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 join db1_st2 t2 on timetruncate(t1.ts, 1sa)=timetruncate(t2.ts, 1sa);", + "select diff(t1.v_int) from db1_st1 t1 join db1_st2 t2 on t1.ts = t2.ts and t1.t_int = t2.t_int;", + "select csum(t1.v_int) from db1_st1 t1 join db1_st2 t2 on t1.ts = t2.ts and t1.t_bigint = t2.t_bigint;", + "select derivative(t1.v_double, 1s, 0) from db1_st1 t1 join db1_st2 t2 on t1.ts = t2.ts and t1.t_binary = t2.t_binary;", + "select irate(t1.v_bigint) from db1_st1 t1 join db1_st2 t2 on t1.ts = t2.ts and t1.t_bool = t2.t_bool;", + "select mavg(t1.v_int, 2) from db1_st1 t1 join db1_st2 t2 on t1.ts = t2.ts and t1.t_ts = t2.t_ts;", + "select statecount(t1.v_int, 'eq', 1) from db1_st1 t1 join db1_st2 t2 on t1.ts = t2.ts and t1.t_int = t2.t_int;", + "select stateduration(t1.v_int, 'gt', 100, 1m) from db1_st1 t1 join db1_st2 t2 on t1.ts = t2.ts and t1.t_bigint = t2.t_bigint;", + "select twa(t1.v_int) from db1_st1 t1 join db1_st2 t2 on t1.ts = t2.ts and t1.t_double = t2.t_double;", + "select t1.ts, total from (select _wstart as ts, sum(v_int) total from db1_st1 partition by tbname interval(2s)) t1 join db1_st2 on t1.ts = t2.ts;"], + } + ], + "left-outer": [ + { + "id": "loj_c1_1", + "desc": "left outer join for super table with master and other connection condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts order by t1.ts", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t1.v_ts = t2.v_ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_ts >= t2.v_ts or t1.v_ts < t1.v_ts) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) and t1.v_int_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint >= t2.v_bigint or t1.v_bigint < t2.v_bigint) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint = t2.v_bigint or t1.v_bigint != t2.v_bigint) and t2.v_bigint_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double >= t2.v_double or t1.v_double <= t2.v_double) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) and t1.v_double_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') and t1.v_binary_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) and t1.v_bool_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts = t2.t_ts or t1.t_ts != t2.t_ts) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts >= t2.t_ts or t1.t_ts < t2.t_ts) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int >= t2.t_int or t1.t_int < t2.t_int) and t1.t_int_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint >= t2.t_bigint or t1.t_bigint < t2.t_bigint) and t2.t_bigint_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double >= t2.t_double or t1.t_double <= t2.t_double) and t1.t_double_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') and t1.t_binary_empty is null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) and t1.t_bool_empty is null order by t1.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,3), (9,2)], [('2024-01-01 12:00:00.000'), (16), (16)]] + } + } + }, + { + "id": "loj_c1_2", + "desc": "left outer join for super table with contionn of scalar function and constant", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2023-01-01 12:00:00.000' and '2024-03-01 12:00:00.300' order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1.db1_st1 t1 left join db2.db2_st2 t2 on t1.ts=t2.ts and t1.ts >='2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' and t2.v_int > 0 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1.db1_st1 t1 left join db2.db2_st2 t2 on t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' and t2.v_int = 9 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_int >= 0 or t2.v_int < 0) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1.db1_st1 t1 left join db2.db2_st2 t2 on t1.ts=t2.ts and t1.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' and abs(t1.v_int) >= 0 and (acos(t2.v_int) > 0 or acos(t2.v_int) <= 0 or acos(t2.v_int) is null) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and (asin(t1.v_bigint) is null or asin(t1.v_int) >= 0 or asin(t1.v_int) < 0) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1.db1_st1 t1 left join db2.db2_st2 t2 on t1.ts=t2.ts and (atan(t1.v_double) is null or atan(t1.v_double) > 0 or atan(t1.v_double) <= 0) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and length(t1.v_binary) >= 0 and char_length(t2.v_binary) >= 0 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1.db1_st1 t1 left join db2.db2_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and cast(t1.t_ts as timestamp) <= now and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (8,3)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), (9)]] + } + } + }, + { + "id": "loj_c1_3", + "desc": "left outer join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st_empty t2 on t1.ts=t2.ts and t1.ts <= now order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_t_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is null and t2.v_int_empty is not null order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_t_empty t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_t_empty t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t1.t_int_empty is null and t2.t_bigint_empty is not null and t1.v_binary_empty is null and t2.v_bool_empty is not null order by t1.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (1,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), (None)]] + } + } + }, + { + "id": "loj_c1_4", + "desc": "left outer join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 left join db1_st2 t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 left join db1_st1 t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 left join db1_st2 t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 left join db1_t_empty t2 on t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st1 where ts >= now) t1 left join (select * from db1_st2 where ts >= now) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t1.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select _wstart ts, sum(v_int) v_int from db1_st1 where ts >= now partition by tbname interval(1m) order by ts) t1 left join (select * from db1_st2 where ts >= now order by ts) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t1.ts;"], + "res": { + "total_rows": 0 + } + }, + { + "id": "loj_c2_1", + "desc": "left outer join for super table with filter condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400';", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t2.ts < now or t2.ts is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t2.ts < now or t2.ts is null) order by t1.ts limit 8;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.v_int * t2.v_int > 0 or t1.v_int * t2.v_int is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.v_bigint / t2.v_bigint > 0 or t1.v_bigint / t2.v_bigint is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is null) order by t1.ts;", + "select t1.ts, t2.ts, t1.v_bool, t2.v_bool from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.v_bool in (true, false) or t2.v_bool is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t2.v_int is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t2.v_bigint is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t2.v_double is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.v_binary is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool or t1.t_bool in (true, false) or t2.t_bool is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.400' and (t1.t_int * t2.v_int_empty is null or t1.t_int * t2.v_int_empty is not null) order by t1.ts;"], + "res": { + "total_rows": 8, + "value_check": { + "type": "contain", + "values": [[(0,0), (7,0), (6,1), (7,1)], [('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600'), (None)]] + } + } + }, + { + "id": "loj_c3_1", + "desc": "left outer join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a);", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on timetruncate(t1.ts, 1a)=t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on t1.ts=timetruncate(t2.ts,1a);", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where t1.ts >= '2024-01-01 12:00:00.000' and (t2.ts < '2024-01-01 12:00:02.600' or t2.ts is null) order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t1.v_int > 0 or t1.v_int <= 0) and (t1.v_bool in (true, false)) order by t1.ts limit 11;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t1.v_bigint>t2.v_bigint or t1.v_bigint <= t2.v_bigint or t2.v_bigint is null) order by t1.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t1.v_bigint=t2.v_bigint or t1.v_bigint != t2.v_bigint or t2.v_bigint is null) order by t1.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t1.v_bool in (true, false)) and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary or t2.v_binary is null) order by t1.ts;",], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (8,1),(9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600'), (None)]] + } + } + }, + { + "id": "loj_c4_1", + "desc": "left outer join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.v_int > 0 or t1.v_int <= 0)) group by tbname order by tbname limit 2;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.v_bigint > 0 or t1.v_bigint <= 0 or t2.v_bigint is null)) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.v_double > 0 or t1.v_double <= 0 or t2.v_double is null)) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%')) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t2.v_int is null)) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t2.v_bigint is null)) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t2.v_double is null)) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.t_binary is null)) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now) group by tbname having(sum(v_int)) > 0 order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now where t1.ts <= now) group by tbname order by tbname limit 2;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.v_int > 0 or t1.v_int <= 0 or t2.v_int is null) where t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is null) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.v_bigint > 0 or t1.v_bigint <= 0 or t2.v_bigint is null) where t1.v_bigint * t2.v_bigint > 0 or t1.v_bigint * t2.v_bigint is null) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.v_double > 0 or t1.v_double <= 0 or t2.v_double is null) where t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is null) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') where t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t2.v_int is null) where t1.t_int = t2.t_int or t1.t_int != t2.t_int or t2.v_int is null) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t2.v_bigint is null) where t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t2.v_bigint is null) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t2.v_double is null) where t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t2.v_double is null) group by tbname order by tbname;", + "select first(ts1), tbname, avg(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t1.tbname from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.t_binary is null) where t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.t_binary is null) group by tbname order by tbname;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,0), (1,0), (0,2), (1,2)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.000'), (5), (9)]] + } + } + }, + { + "id": "loj_c5_1", + "desc": "left outer join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 left join db1_st2 t2 on t1.v_ts=t2.v_ts;", + "select * from db1_st1_ct1 t1 left join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 left join db1_st2 t2 on t1.ts < t2.ts;", + "select * from db1_st1 t1 left join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 left join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 left join db1_st2 t2 on timetruncate(t1.ts, 1sa)=timetruncate(t2.ts, 1sa);", + "select t1.ts, total from (select _wstart as ts, sum(v_int) total from db1_st1 partition by tbname interval(2s)) t1 left join db1_st2 on t1.ts = t2.ts;"], + } + ], + "right-outer": [ + { + "id": "roj_c1_1", + "desc": "right outer join for super table with master and other connection condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_ts = t2.v_ts or t1.v_ts != t2.v_ts) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1.db1_st1 t1 right join db2.db2_st2 t2 on t1.ts=t2.ts and (t1.v_ts >= t2.v_ts or t1.v_ts < t1.v_ts) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1.db1_st1 t1 right join db2.db2_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1.db1_st1 t1 right join db2.db2_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) and t1.v_int_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint >= t2.v_bigint or t1.v_bigint < t2.v_bigint) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint = t2.v_bigint or t1.v_bigint != t2.v_bigint) and t2.v_bigint_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1.db1_st1 t1 right join db2.db2_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double >= t2.v_double or t1.v_double <= t2.v_double) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) and t1.v_double_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') and t1.v_binary_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) and t1.v_bool_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts = t2.t_ts or t1.t_ts != t2.t_ts) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts >= t2.t_ts or t1.t_ts < t2.t_ts) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int >= t2.t_int or t1.t_int < t2.t_int) and t1.t_int_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint >= t2.t_bigint or t1.t_bigint < t2.t_bigint) and t2.t_bigint_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double >= t2.t_double or t1.t_double <= t2.t_double) and t1.t_double_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') and t1.t_binary_empty is null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) and t1.t_bool_empty is null order by t2.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,1), (9,0), (9,3)], [('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:00.900')]] + } + } + }, + { + "id": "roj_c1_2", + "desc": "right outer join for super table with contionn of scalar function and constant", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts between '2023-01-01 12:00:00.000' and '2024-03-01 12:00:00.300' order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts >='2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int > 0 or t2.v_int <= 0) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int = 9 or t2.v_int != 9) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and t2.ts <= now and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_int >= 0 or t2.v_int < 0) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-03-01 12:00:00.300' and abs(t1.v_int) >= 0 and (acos(t2.v_int) > 0 or acos(t2.v_int) <= 0 or acos(t2.v_int) is null) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (asin(t1.v_bigint) is null or asin(t1.v_int) >= 0 or asin(t1.v_int) < 0) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (atan(t1.v_double) is null or atan(t1.v_double) > 0 or atan(t1.v_double) <= 0) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and length(t1.v_binary) >= 0 and char_length(t2.v_binary) >= 0 order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and cast(t1.t_ts as timestamp) <= now and (t2.v_int > 0 or t2.v_int <= 0) order by t2.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (8,2)], [('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "roj_c1_3", + "desc": "right outer join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right join db1_st1 t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right join db1_st1 t2 on t1.ts=t2.ts and t2.ts <= now order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 right join db1_st1 t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 right join db1_st1 t2 on t1.ts=t2.ts and t1.v_int_empty is null and t2.v_int_empty is not null order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 right join db1_st1 t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 right join db1_st1 t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 right join db1_st1 t2 on t1.ts=t2.ts and t1.t_int_empty is null and t2.t_bigint_empty is not null and t1.v_binary_empty is null and t2.v_bool_empty is not null order by t2.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.800')]] + } + } + }, + { + "id": "roj_c1_4", + "desc": "right outer join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st2 t1 right join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 right join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st2 t1 right join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 right join db1_t_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now) t1 right join (select * from db1_st1 where ts >= now) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now order by ts) t1 right join (select _wstart ts, sum(v_int) v_int from db1_st1 where ts >= now partition by tbname interval(1m) order by ts) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;"], + "res": { + "total_rows": 0 + } + }, + { + "id": "roj_c2_1", + "desc": "right outer join for super table with filter condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400';", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.ts < now or t1.ts is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.ts < now or t1.ts is null) order by t2.ts limit 6;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.v_int * t2.v_int > 0 or t1.v_int * t2.v_int is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.v_bigint / t2.v_bigint > 0 or t1.v_bigint / t2.v_bigint is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is null) order by t2.ts;", + "select t1.ts, t2.ts, t1.v_bool, t2.v_bool from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t2.v_bool in (true, false) or t1.v_bool is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t1.v_double is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t1.v_binary is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool or t1.t_bool in (true, false) or t1.t_bool is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.400' and (t1.t_int * t2.v_int_empty is null or t1.t_int * t2.v_int_empty is not null) order by t2.ts;"], + "res": { + "total_rows": 6, + "value_check": { + "type": "contain", + "values": [[(0,0), (5,0), (5,1)], [('2024-01-01 12:00:00.400'), (None), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "roj_c3_1", + "desc": "right outer join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a);", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on timetruncate(t1.ts, 1a)=t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on t1.ts=timetruncate(t2.ts,1a);", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where t2.ts >= '2024-01-01 12:00:00.000' and (t1.ts < '2024-01-01 12:00:02.600' or t1.ts is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_int > 0 or t2.v_int <= 0) and (t2.v_bool in (true, false)) order by t2.ts limit 11;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint>t1.v_bigint or t2.v_bigint <= t1.v_bigint or t1.v_bigint is null) order by t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint=t1.v_bigint or t2.v_bigint != t1.v_bigint or t1.v_bigint is null) order by t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bool in (true, false)) and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary or t1.v_binary is null) order by t2.ts;",], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (8,1),(9,1)], [('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.600'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "roj_c4_1", + "desc": "right outer join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_int > 0 or t2.v_int <= 0)) group by tbname order by tbname limit 2;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_bigint > 0 or t2.v_bigint <= 0 or t1.v_bigint is null)) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_double > 0 or t2.v_double <= 0 or t1.v_double is null)) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%')) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null)) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is null)) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is null)) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null)) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now) group by tbname having(sum(v_int)) > 0 order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now where t2.ts <= now) group by tbname order by tbname limit 2;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_int > 0 or t1.v_int <= 0 or t2.v_int is null) where t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is null) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_bigint > 0 or t1.v_bigint <= 0 or t2.v_bigint is null) where t1.v_bigint * t2.v_bigint > 0 or t1.v_bigint * t2.v_bigint is null) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_double > 0 or t1.v_double <= 0 or t2.v_double is null) where t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is null) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') where t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) where t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is null) where t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is null) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is null) where t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t1.t_double <= t2.t_double or t1.v_double is null) group by tbname order by tbname;", + "select first(ts2), tbname, sum(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.t_binary is null) where t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null) group by tbname order by tbname;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,0), (1,0), (0,2), (1,2)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.500'), (7), (58)]] + } + } + }, + { + "id": "roj_c5_1", + "desc": "right outer join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 right join db1_st2 t2 on t1.v_ts=t2.v_ts;", + "select * from db1_st1_ct1 t1 right join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 right join db1_st2 t2 on t1.ts < t2.ts;", + "select * from db1_st1 t1 right join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 right join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 right join db1_st2 t2 on timetruncate(t1.ts, 1sa)=timetruncate(t2.ts, 1sa);", + "select t1.ts, total from (select _wstart as ts, sum(v_int) total from db1_st1 partition by tbname interval(2s)) t1 right join db1_st2 on t1.ts = t2.ts;"], + } + ], + "full": [ + { + "id": "fj_c1_1", + "desc": "full join for super table with master and other connection condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts order by t1.ts, t2.ts", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_ts = t2.v_ts or t1.v_ts != t2.v_ts or t1.v_ts is null or t2.v_ts is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_ts >= t2.v_ts or t1.v_ts < t1.v_ts) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) and t1.v_int_empty is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint >= t2.v_bigint or t1.v_bigint < t2.v_bigint) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint = t2.v_bigint or t1.v_bigint != t2.v_bigint) and t2.v_bigint_empty is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double >= t2.v_double or t1.v_double <= t2.v_double) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) and t1.v_double_empty is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') and t1.v_binary_empty is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) and t1.v_bool_empty is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts = t2.t_ts or t1.t_ts != t2.t_ts) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts >= t2.t_ts or t1.t_ts < t2.t_ts) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int >= t2.t_int or t1.t_int < t2.t_int) and t1.t_int_empty is null order by t1.ts, t2.ts", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint >= t2.t_bigint or t1.t_bigint < t2.t_bigint) and t2.t_bigint_empty is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double >= t2.t_double or t1.t_double <= t2.t_double) and t1.t_double_empty is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') and t1.t_binary_empty is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) and t1.t_bool_empty is null order by t1.ts, t2.ts;"], + "res": { + "total_rows": 15, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (14,0), (13,1), (4,3), (14,3)], [(None), ('2024-01-01 12:00:00.100'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600'), (14), (None)]] + } + } + }, + { + "id": "fj_c1_2", + "desc": "full outer join for super table with contionn of scalar function and constant", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2023-01-01 12:00:00.000' and '2024-03-01 12:00:00.300' and t2.ts > '2024-01-01 12:00:00.300' and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts >='2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int = 9 or t2.v_int != 9) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= now and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_int >= 0 or t2.v_int < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= '2024-03-01 12:00:00.300' and abs(t1.v_int) >= 0 and (acos(t2.v_int) > 0 or acos(t2.v_int) <= 0 or acos(t2.v_int) is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (asin(t1.v_bigint) is null or asin(t1.v_int) >= 0 or asin(t1.v_int) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (atan(t1.v_double) is null or atan(t1.v_double) > 0 or atan(t1.v_double) <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and length(t1.v_binary) >= 0 and char_length(t2.v_binary) >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and cast(t1.t_ts as timestamp) <= now and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 17, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (16,0), (15,1), (7,3), (15,3)], [(None), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600'), (None), ('2024-01-01 12:00:00.600')]] + } + } + }, + { + "id": "fj_c1_3", + "desc": "full outer join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 full join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 full join db1_st1 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 full join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 full join db1_st1 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t2.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 full join db1_st1 t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 full join db1_st1 t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 full join db1_st1 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t2.ts is not null order by t1.ts, t2.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.800')]] + } + } + }, + { + "id": "fj_c1_4", + "desc": "full outer join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st_empty t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_t_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_t_empty t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_t_empty t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t1.ts is not null order by t1.ts, t2.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), (None)]] + } + } + }, + { + "id": "fj_c1_5", + "desc": "full outer join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 full join db1_st_empty t2 on t1.ts=t2.ts and t1.ts > now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct_empty t1 full join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 full join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 full join db1_t_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now) t1 full join (select * from db1_st1 where ts >= now) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now order by ts) t1 full join (select _wstart ts, sum(v_int) v_int from db1_st1 where ts >= now partition by tbname interval(1m) order by ts) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;"], + "res": { + "total_rows": 0 + } + }, + { + "id": "fj_c2_1", + "desc": "full outer join for super table with filter condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.ts < now where t1.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-01-02 12:00:00.400' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_int) >= 0 where t1.ts between '2023-12-31 12:00:00.400' and now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.v_bigint >= 123456780 where (t2.ts < now or t1.ts is not null) order by t1.ts, t2.ts limit 5;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_bigint - t2.v_bigint) >= 0 where (t2.ts < now or t1.ts is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2024-01-01 12:00:00.000' and now where (t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and abs(ceil(t1.v_double)) >= 0 where (t1.v_int * t2.v_int > 0 or t1.v_int * t2.v_int is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2024-01-01 12:00:00.000' and now where (t1.v_bigint / t2.v_bigint > 0 or t1.v_bigint / t2.v_bigint is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool is null or t1.v_bool is not null) where (t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t1.v_int in (-2, 0, 2, 14, 16) where (t2.v_bool in (true, false) or t1.v_bool is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') and t1.v_binary is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t1.v_double is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t1.v_binary is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool or t1.t_bool in (true, false) or t1.t_bool is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_int * t2.v_int_empty is null and t1.t_int is not null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "fj_c3_1", + "desc": "full outer join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on timetruncate(t1.ts, 1a)=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.ts >= '2024-01-01 12:00:00.000' or t2.ts is null) or (t1.ts < '2024-01-01 12:00:02.600' or t1.ts is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 full join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_int > 0 or t2.v_int <= 0 or t2.v_int is null) and (t2.v_bool in (true, false) or t2.v_bool is null) order by t1.ts, t2.ts limit 15;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 full join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint>t1.v_bigint or t2.v_bigint <= t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 full join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint=t1.v_bigint or t2.v_bigint != t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 full join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bool in (true, false) or t2.v_bool is null) and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary or t1.v_binary is null or t2.v_binary is null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 15, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (14,0),(14,1)], [(None), ('2024-01-01 12:00:00.100'), ('2024-01-01 12:00:01.800'), (None)]] + } + } + }, + { + "id": "fj_c4_1", + "desc": "full outer join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t1.v_int != t2.v_int) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.v_int > t2.v_int or t1.v_int < t2.v_int)) group by tbname order by tbname limit 2;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_bigint > 0 or t2.v_bigint <= 0 or t1.v_bigint is null or t2.v_bigint is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_double > 0 or t2.v_double <= 0 or t1.v_double is null or t2.v_double is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%')) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now) group by tbname having(sum(v_bigint)) > 0 order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now where t2.ts <= now) group by tbname order by tbname limit 2;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_int > 0 or t1.v_int <= 0 or t2.v_int is null) where t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_bigint > 0 or t1.v_bigint <= 0 or t2.v_bigint is null) where t1.v_bigint * t2.v_bigint > 0 or t1.v_bigint * t2.v_bigint is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_double > 0 or t1.v_double <= 0 or t2.v_double is null) where t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') where t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) where t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is not null) where t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is not null) where t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t1.t_double <= t2.t_double or t1.v_double is null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.t_binary is not null) where t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null) group by tbname order by tbname;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,1), (1,1)], [(17), (0)]] + } + } + }, + { + "id": "fj_c4_2", + "desc": "full outer join for union or union all operator", + "is_ci": True, + "exception": False, + "sql": ["select count(*) from (select ts from (select t1.ts from db1_st1_ct1 t1 full join db1_st2_ct1 t2 on t1.ts = t2.ts) union all (select t2.ts from db1_st1_ct2 t1 full join db1_st2_ct2 t2 on t1.ts = t2.ts));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts = t2.ts) union (select t2.ts from db1_st1 t1 full join db1_st2 t2 on t1.ts = t2.ts));",], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(16)]] + } + } + }, + { + "id": "fj_c5_1", + "desc": "full outer join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 full join db1_st2 t2 on t1.v_ts=t2.v_ts;", + "select * from db1_st1_ct1 t1 full join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 full join db1_st2 t2 on t1.ts < t2.ts;", + "select * from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 full join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 full join db1_st2 t2 on timetruncate(t1.ts, 1sa)=timetruncate(t2.ts, 1sa);", + "select first(ts2), tbname, count(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts) group by tbname order by tbname;", + "select last(ts2), tbname, count(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts) group by tbname order by tbname;", + "select diff(ts2), tbname, count(v_int) from (select t1.ts ts1, t2.ts ts2, t2.v_int, t2.tbname from db1_st1 t1 full join db1_st2 t2 on t1.ts=t2.ts) group by tbname order by tbname;", + "select t1.ts, total from (select _wstart as ts, sum(v_int) total from db1_st1 partition by tbname interval(2s)) t1 full join db1_st2 on t1.ts = t2.ts;"], + } + ], + "left-semi": [ + { + "id": "ls_c1_1", + "desc": "left semi join for super table with master and other connection condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts > '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_ts between '2024-01-01 12:00:00.100' and '2024-01-01 12:00:01.600' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_ts >= t2.v_ts and t1.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) and t2.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is null and t2.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint >= t2.v_bigint or t1.v_bigint < t2.v_bigint) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.v_bigint_empty is null and t2.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double >= t2.v_double or t1.v_double <= t2.v_double) and t2.v_double != 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_double_empty is null and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary_empty is null and t1.v_binary != t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) and t1.v_binary != t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_bool_empty is null and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts = t2.t_ts or t1.t_ts != t2.t_ts) and t1.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts >= t2.t_ts or t1.t_ts < t2.t_ts) and t2.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_int_empty is null and t2.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.t_bigint_empty is null and t2.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_double_empty is null and t2.v_double != 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary) and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_binary_empty is null and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_bool_empty is null and t1.v_bigint > 123456780 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 4, + "value_check": { + "type": "contain", + "values": [[(0,0), (3,0)], [('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ls_c1_2", + "desc": "left semi join for super table with contionn of scalar function and constant", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2023-01-01 12:00:00.000' and '2024-03-01 12:00:00.300' and t2.ts > '2024-01-01 12:00:00.300' and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts >='2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int = 9 or t2.v_int != 9) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= now and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_int >= 0 or t2.v_int < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= '2024-03-01 12:00:00.300' and abs(t1.v_int) >= 0 and (acos(t2.v_int) > 0 or acos(t2.v_int) <= 0 or acos(t2.v_int) is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (asin(t1.v_bigint) is null or asin(t1.v_int) >= 0 or asin(t1.v_int) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (atan(t1.v_double) is null or atan(t1.v_double) > 0 or atan(t1.v_double) <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and length(t1.v_binary) >= 0 and char_length(t2.v_binary) >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and cast(t1.t_ts as timestamp) <= now and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 3, + "value_check": { + "type": "contain", + "values": [[(0,0), (1,0), (2,0)], [('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:00.800'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ls_c1_3", + "desc": "left semi join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left semi join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left semi join db1_st1 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 left semi join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 left semi join db1_st1 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t2.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 left semi join db1_st1 t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 left semi join db1_st1 t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 left semi join db1_st1 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t2.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left semi join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left semi join db1_st_empty t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left semi join db1_t_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left semi join db1_t_empty t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left semi join db1_t_empty t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 left semi join db1_st_empty t2 on t1.ts=t2.ts and t1.ts > now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct_empty t1 left semi join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 left semi join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 left semi join db1_t_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now) t1 left semi join (select * from db1_st1 where ts >= now) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now order by ts) t1 left semi join (select _wstart ts, sum(v_int) v_int from db1_st1 where ts >= now partition by tbname interval(1m) order by ts) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;"], + "res": { + "total_rows": 0 + } + }, + { + "id": "ls_c2_1", + "desc": "left semi join for super table with filter condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts < now where t1.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-01-02 12:00:00.400' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_int) >= 0 where t1.ts between '2023-12-31 12:00:00.400' and now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_bigint >= 123456780 where (t2.ts < now or t1.ts is not null) order by t1.ts, t2.ts limit 5;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_bigint - t2.v_bigint) >= 0 where (t2.ts < now or t1.ts is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2024-01-01 12:00:00.000' and now where (t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and abs(ceil(t1.v_double)) >= 0 where (t1.v_int * t2.v_int > 0 or t1.v_int * t2.v_int is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2024-01-01 12:00:00.000' and now where (t1.v_bigint / t2.v_bigint > 0 or t1.v_bigint / t2.v_bigint is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool is null or t1.v_bool is not null) where (t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_int in (-2, 0, 2, 14, 16) where (t2.v_bool in (true, false) or t1.v_bool is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') and t1.v_binary is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t1.v_double is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t1.v_binary is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool or t1.t_bool in (true, false) or t1.t_bool is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_int * t2.v_int_empty is null and t1.t_int is not null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ls_c3_1", + "desc": "left semi join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on timetruncate(t1.ts, 1a)=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.ts >= '2024-01-01 12:00:00.000' or t2.ts is null) or (t1.ts < '2024-01-01 12:00:02.600' or t1.ts is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left semi join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_int > 0 or t2.v_int <= 0 or t2.v_int is null) and (t2.v_bool in (true, false) or t2.v_bool is null) order by t1.ts, t2.ts limit 15;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left semi join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint>t1.v_bigint or t2.v_bigint <= t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left semi join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint=t1.v_bigint or t2.v_bigint != t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left semi join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bool in (true, false) or t2.v_bool is null) and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary or t1.v_binary is null or t2.v_binary is null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,0)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ls_c4_1", + "desc": "left semi join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t1.v_int != t2.v_int) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.v_int > t2.v_int or t1.v_int < t2.v_int)) group by tbname order by tbname limit 2;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_bigint > 0 or t2.v_bigint <= 0 or t1.v_bigint is null or t2.v_bigint is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_double > 0 or t2.v_double <= 0 or t1.v_double is null or t2.v_double is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%')) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now) group by tbname having(sum(v_bigint)) > 0 order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now where t2.ts <= now) group by tbname order by tbname limit 2;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_int > 0 or t1.v_int <= 0 or t2.v_int is null) where t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_bigint > 0 or t1.v_bigint <= 0 or t2.v_bigint is null) where t1.v_bigint * t2.v_bigint > 0 or t1.v_bigint * t2.v_bigint is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_double > 0 or t1.v_double <= 0 or t2.v_double is null) where t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') where t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) where t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is not null) where t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is not null) where t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t1.t_double <= t2.t_double or t1.v_double is null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.t_binary is not null) where t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null) group by tbname order by tbname;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,1), (1,1)], [(17), (0)]] + } + } + }, + { + "id": "ls_c4_2", + "desc": "left semi join for union or union all operator", + "is_ci": True, + "exception": False, + "sql": ["select count(*) from (select ts from (select t1.ts from db1_st1_ct1 t1 left semi join db1_st2_ct1 t2 on t1.ts = t2.ts) union all (select t2.ts from db1_st1_ct2 t1 left semi join db1_st2_ct2 t2 on t1.ts = t2.ts));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts = t2.ts where t1.ts != '2024-01-01 12:00:00.800') union (select t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts = t2.ts where t2.ts != '2024-01-01 12:00:00.800'));",], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(4)]] + } + } + }, + { + "id": "ls_c5_1", + "desc": "left semi join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 left semi join db1_st2 t2 on t1.v_ts=t2.v_ts;", + "select * from db1_st1_ct1 t1 left semi join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 left semi join db1_st2 t2 on t1.ts < t2.ts;", + "select * from db1_st1 t1 left semi join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 left semi join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 left semi join db1_st2 t2 on timetruncate(t1.ts, 1sa)=timetruncate(t2.ts, 1sa);", + "select t1.ts, total from (select _wstart as ts, sum(v_int) total from db1_st1 partition by tbname interval(2s)) t1 left semi join db1_st2 on t1.ts = t2.ts;"] + } + ], + "right-semi": [ + { + "id": "rs_c1_1", + "desc": "right semi join for super table with master and other connection condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts > '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_ts between '2024-01-01 12:00:00.100' and '2024-01-01 12:00:01.600' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_ts >= t2.v_ts and t1.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) and t2.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is null and t2.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint >= t2.v_bigint or t1.v_bigint < t2.v_bigint) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.v_bigint_empty is null and t2.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double >= t2.v_double or t1.v_double <= t2.v_double) and t2.v_double != 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_double_empty is null and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary_empty is null and t1.v_binary != t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) and t1.v_binary != t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_bool_empty is null and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts = t2.t_ts or t1.t_ts != t2.t_ts) and t1.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts >= t2.t_ts or t1.t_ts < t2.t_ts) and t2.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_int_empty is null and t2.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.t_bigint_empty is null and t2.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_double_empty is null and t2.v_double != 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary) and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_binary_empty is null and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_bool_empty is null and t1.v_bigint > 123456780 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 4, + "value_check": { + "type": "contain", + "values": [[(0,0), (3,0)], [('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "rs_c1_2", + "desc": "right semi join for super table with contionn of scalar function and constant", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2023-01-01 12:00:00.000' and '2024-03-01 12:00:00.300' and t2.ts > '2024-01-01 12:00:00.300' and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts >='2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int = 9 or t2.v_int != 9) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= now and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_int >= 0 or t2.v_int < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= '2024-03-01 12:00:00.300' and abs(t1.v_int) >= 0 and (acos(t2.v_int) > 0 or acos(t2.v_int) <= 0 or acos(t2.v_int) is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (asin(t1.v_bigint) is null or asin(t1.v_int) >= 0 or asin(t1.v_int) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (atan(t1.v_double) is null or atan(t1.v_double) > 0 or atan(t1.v_double) <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and length(t1.v_binary) >= 0 and char_length(t2.v_binary) >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and cast(t1.t_ts as timestamp) <= now and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 3, + "value_check": { + "type": "contain", + "values": [[(0,0), (1,0), (2,0)], [('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:00.800'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "rs_c1_3", + "desc": "right semi join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right semi join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right semi join db1_st1 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 right semi join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 right semi join db1_st1 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t2.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 right semi join db1_st1 t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 right semi join db1_st1 t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 right semi join db1_st1 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t2.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right semi join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right semi join db1_st_empty t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right semi join db1_t_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right semi join db1_t_empty t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right semi join db1_t_empty t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 right semi join db1_st_empty t2 on t1.ts=t2.ts and t1.ts > now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct_empty t1 right semi join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 right semi join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 right semi join db1_t_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now) t1 right semi join (select * from db1_st1 where ts >= now) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now order by ts) t1 right semi join (select _wstart ts, sum(v_int) v_int from db1_st1 where ts >= now partition by tbname interval(1m) order by ts) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;"], + "res": { + "total_rows": 0 + } + }, + { + "id": "rs_c2_1", + "desc": "right semi join for super table with filter condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts < now where t1.ts >= '2024-01-01 12:00:00.000' and t2.ts <= '2024-01-02 12:00:00.400' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_int) >= 0 where t1.ts between '2023-12-31 12:00:00.400' and now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_bigint >= 123456780 where (t2.ts < now or t1.ts is not null) order by t1.ts, t2.ts limit 5;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_bigint - t2.v_bigint) >= 0 where (t2.ts < now or t1.ts is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2024-01-01 12:00:00.000' and now where (t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and abs(ceil(t1.v_double)) >= 0 where (t1.v_int * t2.v_int > 0 or t1.v_int * t2.v_int is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2024-01-01 12:00:00.000' and now where (t1.v_bigint / t2.v_bigint > 0 or t1.v_bigint / t2.v_bigint is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool is null or t1.v_bool is not null) where (t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_int in (-2, 0, 2, 14, 16) where (t2.v_bool in (true, false) or t1.v_bool is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') and t1.v_binary is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t1.v_double is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t1.v_binary is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool or t1.t_bool in (true, false) or t1.t_bool is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_int * t2.v_int_empty is null and t1.t_int is not null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "rs_c3_1", + "desc": "right semi join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on timetruncate(t1.ts, 1a)=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.ts >= '2024-01-01 12:00:00.000' or t2.ts is null) or (t1.ts < '2024-01-01 12:00:02.600' or t1.ts is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_int > 0 or t2.v_int <= 0 or t2.v_int is null) and (t2.v_bool in (true, false) or t2.v_bool is null) order by t1.ts, t2.ts limit 15;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right semi join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint>t1.v_bigint or t2.v_bigint <= t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right semi join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint=t1.v_bigint or t2.v_bigint != t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right semi join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bool in (true, false) or t2.v_bool is null) and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary or t1.v_binary is null or t2.v_binary is null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,0)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "rs_c4_1", + "desc": "right semi join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t1.v_int != t2.v_int) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.v_int > t2.v_int or t1.v_int < t2.v_int)) group by tbname order by tbname limit 2;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_bigint > 0 or t2.v_bigint <= 0 or t1.v_bigint is null or t2.v_bigint is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_double > 0 or t2.v_double <= 0 or t1.v_double is null or t2.v_double is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%')) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null)) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now) group by tbname having(sum(v_bigint)) > 0 order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now where t2.ts <= now) group by tbname order by tbname limit 2;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_int > 0 or t1.v_int <= 0 or t2.v_int is null) where t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_bigint > 0 or t1.v_bigint <= 0 or t2.v_bigint is null) where t1.v_bigint * t2.v_bigint > 0 or t1.v_bigint * t2.v_bigint is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_double > 0 or t1.v_double <= 0 or t2.v_double is null) where t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') where t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) where t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is not null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is not null) where t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is not null) where t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t1.t_double <= t2.t_double or t1.v_double is null) group by tbname order by tbname;", + "select tbname, spread(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.t_binary is not null) where t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null) group by tbname order by tbname;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,1), (1,1)], [(17), (0)]] + } + } + }, + { + "id": "rs_c4_2", + "desc": "right semi join for union or union all operator", + "is_ci": True, + "exception": False, + "sql": ["select count(*) from (select ts from (select t1.ts from db1_st1_ct1 t1 right semi join db1_st2_ct1 t2 on t1.ts = t2.ts) union all (select t2.ts from db1_st1_ct2 t1 left semi join db1_st2_ct2 t2 on t1.ts = t2.ts));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts = t2.ts where t1.ts != '2024-01-01 12:00:00.800') union (select t2.ts from db1_st1 t1 left semi join db1_st2 t2 on t1.ts = t2.ts where t2.ts != '2024-01-01 12:00:00.800'));",], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(4)]] + } + } + }, + { + "id": "rs_c5_1", + "desc": "right semi join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 right semi join db1_st2 t2 on t1.v_ts=t2.v_ts;", + "select * from db1_st1_ct1 t1 right semi join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 right semi join db1_st2 t2 on t1.ts < t2.ts;", + "select * from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 right semi join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 right semi join db1_st2 t2 on timetruncate(t1.ts, 1sa)=timetruncate(t2.ts, 1sa);", + "select t1.ts, total from (select _wstart as ts, sum(v_int) total from db1_st1 partition by tbname interval(2s)) t1 right semi join db1_st2 on t1.ts = t2.ts;"] + } + ], + "left-anti": [ + { + "id": "la_c1_1", + "desc": "left anti join for super table with master and other connection condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts > '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_ts between '2024-01-01 12:00:00.100' and '2024-01-01 12:00:01.600' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_ts >= t2.v_ts and t1.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is null and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.v_bigint_empty is null and t1.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double >= t2.v_double or t1.v_double <= t2.v_double) and t2.v_double != 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_double_empty is null and t1.ts > '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') and t1.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary_empty is null and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) and t1.v_binary != t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_bool_empty is null and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts = t2.t_ts or t1.t_ts != t2.t_ts) and t1.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts >= t2.t_ts or t1.t_ts < t2.t_ts) and t2.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.t_int_empty is null and t2.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.t_bigint_empty is null and t2.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.t_double_empty is null and t2.v_double != 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary) and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.t_binary_empty is null and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.t_bool_empty is null and t1.v_bigint > 123456780 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 6, + "value_check": { + "type": "contain", + "values": [[(0,0), (5,0)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800')]] + } + } + }, + { + "id": "la_c1_2", + "desc": "left anti join for super table with contionn of scalar function and constant", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2023-01-01 12:00:00.000' and '2024-03-01 12:00:00.300' and t2.ts > '2024-01-01 12:00:00.300' and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts >='2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int = 9 or t2.v_int != 9) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= now and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_int >= 0 or t2.v_int < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= '2024-03-01 12:00:00.300' and abs(t1.v_int) >= 0 and (acos(t2.v_int) > 0 or acos(t2.v_int) <= 0 or acos(t2.v_int) is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (asin(t1.v_bigint) is null or asin(t1.v_int) >= 0 or asin(t1.v_int) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (atan(t1.v_double) is null or atan(t1.v_double) > 0 or atan(t1.v_double) <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and length(t1.v_binary) >= 0 and char_length(t2.v_binary) >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and cast(t1.t_ts as timestamp) <= now and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 7, + "value_check": { + "type": "contain", + "values": [[(0,0), (6,0)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800')]] + } + } + }, + { + "id": "la_c1_3", + "desc": "left anti join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left anti join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left anti join db1_st1 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 left anti join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 left anti join db1_st1 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t2.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 left anti join db1_st1 t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_t_empty t1 left anti join db1_st1 t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 left anti join db1_st1 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t2.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from (select * from db1_st1 where ts > now) t1 left anti join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from (select * from db1_st1 where ts > '2024-02-01 01:00:00.000') t1 left anti join db1_st1 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from (select * from db1_st1 where v_int > 738437) t1 left anti join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from (select * from db1_st1 where v_bigint = 99999) t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from (select * from db1_st1 where v_bool is null) t1 left anti join db1_st1 t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from (select * from db1_st1 where v_binary = 'test') t1 left anti join db1_st1 t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from (select * from db1_st1 where v_int_empty is not null) t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 left anti join db1_st_empty t2 on t1.ts=t2.ts and t1.ts > now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct_empty t1 left anti join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 left anti join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 left anti join db1_t_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now) t1 left anti join (select * from db1_st1 where ts >= now) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now order by ts) t1 left anti join (select _wstart ts, sum(v_int) v_int from db1_st1 where ts >= now partition by tbname interval(1m) order by ts) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;"], + "res": { + "total_rows": 0 + } + }, + { + "id": "la_c2_1", + "desc": "left anti join for super table with filter condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now where t1.ts >= '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_int) >= 0 where t1.ts between '2023-12-31 12:00:00.400' and now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_bigint >= 123456780 where (t2.ts < now or t1.ts is not null) order by t1.ts, t2.ts limit 5;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_bigint - t2.v_bigint) >= 0 where (t2.ts < now or t1.ts is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2024-01-01 12:00:00.000' and now where (t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or t1.v_int + t2.v_int is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and abs(ceil(t1.v_double)) >= 0 where (t1.v_int * t2.v_int > 0 or t1.v_int * t2.v_int is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2024-01-01 12:00:00.000' and now where (t1.v_bigint / t2.v_bigint > 0 or t1.v_bigint / t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool is null or t1.v_bool is not null) where (t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.v_int in (-2, 0, 2, 14, 16) where (t1.v_bool in (true, false) or t2.v_bool is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') and t2.v_binary is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t2.v_bigint is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t2.v_double is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.v_binary is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool or t1.t_bool in (true, false) or t1.t_bool is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts >= '2024-01-01 12:00:00.000' and (t1.t_int * t2.v_int_empty is null and t1.t_int is not null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,0)], [('2024-01-01 12:00:00.600'), ('2024-01-01 12:00:01.800')]] + } + } + }, + { + "id": "la_c3_1", + "desc": "left anti join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on timetruncate(t1.ts, 1a)=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.ts >= '2024-01-01 12:00:00.000' or t2.ts is null) or (t1.ts < '2024-01-01 12:00:02.600' or t1.ts is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left anti join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_int > 0 or t2.v_int <= 0 or t2.v_int is null) and (t2.v_bool in (true, false) or t2.v_bool is null) order by t1.ts, t2.ts limit 15;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left anti join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint>t1.v_bigint or t2.v_bigint <= t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left anti join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint=t1.v_bigint or t2.v_bigint != t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 left anti join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bool in (true, false) or t2.v_bool is null) and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary or t1.v_binary is null or t2.v_binary is null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,0)], [('2024-01-01 12:00:00.600'), ('2024-01-01 12:00:01.800')]] + } + } + }, + { + "id": "la_c4_1", + "desc": "left anti join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.v_int > 0) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t2.v_bigint > 0 or t2.v_bigint <= 0 or t1.v_bigint is null or t2.v_bigint is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t2.v_double > 0 or t2.v_double <= 0 or t1.v_double is null or t2.v_double is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.v_int > t2.v_int or t1.v_int < t2.v_int or t2.v_int is null)) group by tbname order by tbname limit 2;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%' or t2.v_binary is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t2.v_int is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t2.v_bigint is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t2.v_double is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t2.t_binary is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts where t1.ts <= now) group by tbname having(sum(v_bigint)) > 0 order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now where t1.t_ts <= now) group by tbname order by tbname limit 2;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and (t1.v_int > 0 or t1.v_int <= 0 or t2.v_int is null) where t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and (t2.v_bigint > 0 or t1.v_bigint <= 0 or t2.v_bigint is null) where t1.v_bigint * t2.v_bigint > 0 or t1.v_bigint * t2.v_bigint is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and (t2.v_double > 0 or t1.v_double <= 0 or t2.v_double is null) where t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') where t2.v_binary like '%abc%' or t2.v_binary not like '%abc%' or t2.v_binary is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) where t1.t_int = t2.t_int or t1.t_int != t2.t_int or t2.v_int is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t2.v_bigint is null) where t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t1.t_bigint <= t2.t_bigint or t2.v_bigint is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t2.v_double is null) where t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t1.t_double <= t2.t_double or t2.v_double is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint, t1.tbname from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t2.t_binary is null) where t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t2.t_binary is null) group by tbname order by tbname;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,1), (1,1)], [(123456796), (493827180)]] + } + } + }, + { + "id": "la_c4_2", + "desc": "left anti join for union or union all operator", + "is_ci": True, + "exception": False, + "sql": ["select count(*) from (select ts from (select t1.ts from db1_st1_ct1 t1 left anti join db1_st2_ct1 t2 on t1.ts = t2.ts) union all (select t1.ts from db1_st1_ct2 t1 left anti join db1_st2_ct2 t2 on t1.ts = t2.ts));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts = t2.ts where t1.ts >= '2024-01-01 12:00:00.000') union (select t2.ts from db1_st1 t1 left anti join db1_st2 t2 on t1.ts = t2.ts where t1.ts between '2024-01-01 12:00:00.000' and '2024-01-01 12:00:01.000'));",], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(6)]] + } + } + }, + { + "id": "la_c5_1", + "desc": "left anti join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 left anti join db1_st2 t2 on t1.v_ts=t2.v_ts;", + "select * from db1_st1_ct1 t1 left anti join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 left anti join db1_st2 t2 on t1.ts < t2.ts;", + "select * from db1_st1 t1 left anti join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 left anti join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 left anti join db1_st2 t2 on timetruncate(t1.ts, 1sa)=timetruncate(t2.ts, 1sa);", + "select t1.ts, total from (select _wstart as ts, sum(v_int) total from db1_st1 partition by tbname interval(2s)) t1 left anti join db1_st2 on t1.ts = t2.ts;"] + } + ], + "right-anti": [ + { + "id": "ra_c1_1", + "desc": "right anti join for super table with master and other connection condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.v_ts between '2024-01-01 12:00:00.100' and '2024-01-01 12:00:01.600' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_ts >= t2.v_ts and t1.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int = t2.v_int or t1.v_int != t2.v_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_int > t2.v_int or t1.v_int <= t2.v_int) and t2.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_int_empty is null and t2.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bigint >= t2.v_bigint or t1.v_bigint < t2.v_bigint) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.v_bigint_empty is null and t2.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double = t2.v_double or t1.v_double != t2.v_double) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_double >= t2.v_double or t1.v_double <= t2.v_double) and t2.v_double != 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_double_empty is null and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary) and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_binary_empty is null and t1.v_binary != t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.v_bool = t2.v_bool or t1.v_bool != t2.v_bool) and t1.v_binary != t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.v_bool_empty is null and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts = t2.t_ts or t1.t_ts != t2.t_ts) and t1.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_ts >= t2.t_ts or t1.t_ts < t2.t_ts) and t2.ts != '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_int = t2.t_int or t1.t_int != t2.t_int) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_int_empty is null and t2.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t2.t_bigint_empty is null and t2.v_bigint != 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_double = t2.t_double or t1.t_double != t2.t_double) and t1.v_double > 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_double_empty is null and t2.v_double != 1234.567800000000034 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary) and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_binary match '[abc]' or t1.t_binary nmatch '[abc]') and t2.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_binary_empty is null and t1.v_binary != 'abc' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool) and t1.v_bigint > 123456780 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right semi join db1_st2 t2 on t1.ts=t2.ts and t1.t_bool_empty is null and t1.v_bigint > 123456780 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 4, + "value_check": { + "type": "contain", + "values": [[(0,0), (3,0)], [('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ra_c1_2", + "desc": "right anti join for super table with contionn of scalar function and constant", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts between '2023-01-01 12:00:00.000' and '2024-03-01 12:00:00.300' and t2.ts > '2024-01-01 12:00:00.300' and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts >='2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t2.ts <= '2024-03-01 12:00:00.300' and (t2.v_int = 9 or t2.v_int != 9) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= now and (t1.v_int > 0 or t1.v_int <= 0) and (t2.v_int >= 0 or t2.v_int < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and t1.ts <= '2024-03-01 12:00:00.300' and abs(t1.v_int) >= 0 and (acos(t2.v_int) > 0 or acos(t2.v_int) <= 0 or acos(t2.v_int) is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (asin(t1.v_bigint) is null or asin(t1.v_int) >= 0 or asin(t1.v_int) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (atan(t1.v_double) is null or atan(t1.v_double) > 0 or atan(t1.v_double) <= 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and length(t1.v_binary) >= 0 and char_length(t2.v_binary) >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and (t1.v_binary like '%abc%' or t1.v_binary not like '%abc%') order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts >= '2024-01-01 12:00:00.300' and cast(t1.t_ts as timestamp) <= now and (t2.v_int > 0 or t2.v_int <= 0) order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 7, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (6,1)], [(None), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "ra_c1_3", + "desc": "right anti join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join db1_st_empty t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join db1_t_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 right anti join db1_st1 t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join db1_t_empty t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join db1_t_empty t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 right anti join db1_st1 t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join (select * from db1_st1 where ts > now) t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join (select * from db1_st1 where ts > '2024-02-01 01:00:00.000') t2 on t1.ts=t2.ts and t1.ts <= now and t2.ts <= now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join (select * from db1_st1 where v_int > 738437) t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 right anti join (select * from db1_st1 where v_bigint = 99999) t2 on t1.ts=t2.ts and t1.v_int_empty is not null and t2.v_int_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join (select * from db1_st1 where v_bool is null) t2 on t1.ts=t2.ts and abs(t1.v_int+t2.v_int) = 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right anti join (select * from db1_st1 where v_binary = 'test') t2 on t1.ts=t2.ts and tan(t1.v_int_empty) = 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st2 t1 right anti join (select * from db1_st1 where v_int_empty is not null) t2 on t1.ts=t2.ts and t1.v_binary_empty is not null and t2.v_bool_empty is not null where t1.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st_empty t1 right anti join db1_st_empty t2 on t1.ts=t2.ts and t1.ts > now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_st1_ct_empty t1 right anti join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 right anti join db1_st_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from db1_t_empty t1 right anti join db1_t_empty t2 on t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now) t1 right anti join (select * from db1_st1 where ts >= now) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;", + "select t1.ts, t2.ts, t1.v_int, t2.v_int from (select * from db1_st2 where ts >= now order by ts) t1 right anti join (select _wstart ts, sum(v_int) v_int from db1_st1 where ts >= now partition by tbname interval(1m) order by ts) t2 on t1.v_int = t2.v_int and t1.ts=t2.ts order by t2.ts;"], + "res": { + "total_rows": 0 + } + }, + { + "id": "ra_c2_1", + "desc": "right anti join for super table with filter condition", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now where t2.ts >= '2024-01-01 12:00:00.000' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and abs(t2.v_int) >= 0 where t2.ts between '2023-12-31 12:00:00.400' and now order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.v_bigint >= 123456780 where (t1.ts < now or t2.ts is not null) order by t1.ts, t2.ts limit 5;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and abs(t1.v_bigint - t2.v_bigint) >= 0 where (t1.ts < now or t2.ts is not null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts between '2024-01-01 12:00:00.000' and now where (t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or t1.v_int + t2.v_int is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and abs(ceil(t2.v_double)) >= 0 where (t1.v_int * t2.v_int > 0 or t1.v_int * t2.v_int is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts between '2024-01-01 12:00:00.000' and now where (t1.v_bigint / t2.v_bigint > 0 or t1.v_bigint / t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and (t2.v_bool is null or t2.v_bool is not null) where (t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.v_int not in (-1, 4, 7, 12, 14) where (t2.v_bool in (true, false) or t1.v_bool is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') and t1.v_binary is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t2.v_int is not null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t1.t_bigint > t2.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t1.t_double > t2.t_double or t1.t_double <= t2.t_double or t1.v_double is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t1.v_binary is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_bool = t2.t_bool or t1.t_bool != t2.t_bool or t2.t_bool in (true, false) or t2.t_bool is null) order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts >= '2024-01-01 12:00:00.000' and (t1.t_int * t2.v_int_empty is null and t2.t_int is not null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,1), (4,1)], [('2024-01-01 12:00:00.100'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "ra_c3_1", + "desc": "right anti join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on timetruncate(t1.ts, 1a)=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.ts >= '2024-01-01 12:00:00.000' or t2.ts is null) or (t1.ts < '2024-01-01 12:00:02.600' or t1.ts is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right anti join db1_st2 t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_int > 0 or t2.v_int <= 0 or t2.v_int is null) and (t2.v_bool in (true, false) or t2.v_bool is null) order by t1.ts, t2.ts limit 15;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right anti join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint>t1.v_bigint or t2.v_bigint <= t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right anti join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bigint=t1.v_bigint or t2.v_bigint != t1.v_bigint or t1.v_bigint is null or t2.v_bigint is null) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from (select * from db1_st1 where ts <= now) t1 right anti join (select * from db1_st2 where ts <= now) t2 on timetruncate(t1.ts, 1a)=timetruncate(t2.ts,1a) where (t2.v_bool in (true, false) or t2.v_bool is null) and (t1.v_binary = t2.v_binary or t1.v_binary != t2.v_binary or t1.v_binary is null or t2.v_binary is null) order by t1.ts, t2.ts;"], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,1), (4,1)], [('2024-01-01 12:00:00.100'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "ra_c4_1", + "desc": "right anti join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.v_int > 0 or t2.v_int <= 0) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_bigint > 0 or t2.v_bigint <= 0)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.v_double > 0 or t1.v_double <= 0 or t2.v_double is null or t1.v_double is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.v_int > t2.v_int or t1.v_int < t2.v_int or t1.v_int is null)) group by tbname order by tbname limit 2;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%' or t1.v_binary is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null)) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts where t2.ts <= now) group by tbname having(sum(v_bigint)) > 0 order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now where t2.t_ts <= now) group by tbname order by tbname limit 2;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.v_int > 0 or t1.v_int <= 0 or t1.v_int is null) where t1.v_int + t2.v_int > 0 or t1.v_int + t2.v_int <= 0 or (t1.v_int + t2.v_int) is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_bigint > 0 or t1.v_bigint <= 0 or t1.v_bigint is null) where t1.v_bigint * t2.v_bigint > 0 or t1.v_bigint * t2.v_bigint is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_double > 0 or t1.v_double <= 0 or t1.v_double is null) where t1.v_double - t2.v_double != 0 or t1.v_double - t2.v_double = 0 or t1.v_double - t2.v_double is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t2.v_binary like '%abc%' or t2.v_binary not like '%abc%') where t2.v_binary like '%abc%' or t2.v_binary not like '%abc%' or t1.v_binary is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) where t1.t_int = t2.t_int or t1.t_int != t2.t_int or t1.v_int is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t2.t_bigint <= t1.t_bigint or t1.v_bigint is null) where t1.t_bigint = t2.t_bigint or t1.t_bigint != t2.t_bigint or t2.t_bigint > t1.t_bigint or t1.t_bigint <= t2.t_bigint or t1.v_bigint is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t2.t_double <= t1.t_double or t1.v_double is null) where t1.t_double = t2.t_double or t1.t_double != t2.t_double or t2.t_double > t1.t_double or t1.t_double <= t2.t_double or t1.v_double is null) group by tbname order by tbname;", + "select tbname, sum(v_bigint) from (select t1.ts ts1, t2.ts ts2, t2.v_bigint, t2.tbname from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts and t2.ts <= now and (t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t1.t_binary like '%abc%' or t1.t_binary not like '%abc%' or t1.t_binary is null) where t1.t_binary = t2.t_binary or t1.t_binary != t2.t_binary or t2.t_binary like '%abc%' or t2.t_binary not like '%abc%' or t1.t_binary is null) group by tbname order by tbname;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,1), (1,1)], [(246913586), (370370385)]] + } + } + }, + { + "id": "ra_c4_2", + "desc": "right anti join for union or union all operator", + "is_ci": True, + "exception": False, + "sql": ["select count(*) from (select ts from (select t2.ts from db1_st1_ct1 t1 right anti join db1_st2_ct1 t2 on t1.ts = t2.ts) union all (select t2.ts from db1_st1_ct2 t1 right anti join db1_st2_ct2 t2 on t1.ts = t2.ts));", + "select count(*) from (select ts from (select t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts = t2.ts where t2.ts >= '2024-01-01 12:00:00.000') union (select t2.ts from db1_st1 t1 right anti join db1_st2 t2 on t1.ts = t2.ts and t1.ts != '2024-01-01 12:00:00.800' where t2.ts between '2024-01-01 12:00:00.000' and '2024-01-01 12:00:01.000'));",], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(6)]] + } + } + }, + { + "id": "ra_c5_1", + "desc": "right anti join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 right anti join db1_st2 t2 on t1.v_ts=t2.v_ts;", + "select * from db1_st1_ct1 t1 right anti join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 right anti join db1_st2 t2 on t1.ts < t2.ts;", + "select * from db1_st1 t1 right anti join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 right anti join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 right anti join db1_st2 t2 on timetruncate(t1.ts, 1sa)=timetruncate(t2.ts, 1sa);", + "select t1.ts, total from (select _wstart as ts, sum(v_int) total from db1_st1 partition by tbname interval(2s)) t1 right anti join db1_st2 on t1.ts = t2.ts;"] + } + ], + "left-asof": [ + { + "id": "las_c1_1", + "desc": "left asof join for super table with master connection condition by >=、<=", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts >= t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts >= t2.ts jlimit 1 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 jlimit 1 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t2.ts <= t1.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t2.ts <= t1.ts jlimit 1 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "las_c1_2", + "desc": "left asof join for super table with master connection condition >、<", + "is_ci": True, + "exception": False, + "sql": [ + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts > t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts > t2.ts jlimit 1 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t2.ts < t1.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t2.ts < t1.ts jlimit 1 order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "las_c1_3", + "desc": "left asof join for super table with master connection condition =", + "is_ci": True, + "exception": False, + "sql": [ + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t2.ts = t1.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t2.ts = t1.ts jlimit 1 order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (3,0), (3,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.600'), (None), ('2024-01-01 12:00:01.800'), (None)]] + } + } + }, + { + "id": "las_c1_4", + "desc": "left asof join for super table with master and other connection conditions", + "is_ci": True, + "exception": False, + "sql": [ + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.v_int = t2.v_int order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.v_bigint = t2.v_bigint order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.v_ts = t2.v_ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.v_double = t2.v_double order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.v_binary = t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.v_bool = t2.v_bool order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.t_ts = t2.t_ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.t_int = t2.t_int order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.t_bigint = t2.t_bigint order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.t_double = t2.t_double order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.t_binary = t2.t_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.t_bool = t2.t_bool order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st1 t2 on t1.v_ts = t2.v_ts and t1.v_int = t2.v_int and t1.v_bigint = t2.v_bigint and t1.v_double = t2.v_double and t1.v_bool = t2.v_bool and t1.v_binary = t2.v_binary and t1.t_ts = t2.t_ts and t1.t_int = t2.t_int and t1.t_bigint = t2.t_bigint and t1.t_double = t2.t_double and t1.t_bool = t2.t_bool and t1.t_binary = t2.t_binary order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800')]] + } + } + }, + { + "id": "las_c1_5", + "desc": "left asof join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 on t1.ts>=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 on t1.ts>t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 on t1.ts<=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 on t1.ts=t2.ts jlimit 2 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 on t1.ts>t2.ts jlimit 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 on t1.ts<=t2.ts jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 left asof join db1_st1 t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left asof join db1_st_empty t2 on t1.ts>t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left asof join db1_st_empty t2 on t1.ts<=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left asof join db1_st_empty t2 on t1.ts=t2.ts jlimit 2 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left asof join db1_st_empty t2 on t1.ts>t2.ts jlimit 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left asof join db1_st_empty t2 on t1.ts<=t2.ts jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 left asof join db1_st_empty t2 on t1.ts 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and t1.ts >= t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_bigint > 123456792 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t2.v_bigint > 123456793 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_binary like '%abce%' order by t1.ts, t2.ts limit 8;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_bigint > 123456792 and t2.v_binary like '%abcg%' order by t1.ts, t2.ts limit 9;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_binary like '%abce%' and t1.ts between '2024-01-01 00:00:00.000' and now order by t1.ts, t2.ts limit 8;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_bool in (true, false) and t1.v_int > 0 and (t2.v_bool = true or t2.v_bool = false) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_double in (1234.567939999999908, 1234.567960000000085, 1234.567980000000034, 1234.567950000000110) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t2.v_double in (1234.567970000000059, 1234.567950000000110) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.t_int >= 1 and t2.ts > '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.t_bigint >= 123456789 and t2.ts > '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.t_double >= 1234.567890000000034 and t1.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.t_binary = 'test message' and t1.t_bool in (true, false) and t1.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.t_bool in (true, false) and t1.t_int >= 1 and t1.t_bigint >= 123456789 and t1.t_double >= 1234.567890000000034 and t1.t_binary = 'test message' and t1.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t2.t_int >= 1 and t2.ts > '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t2.t_bigint >= 123456789 and t2.ts > '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t2.t_double >= 1234.567890000000034 and t1.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t2.t_binary = 'test message' and t1.t_bool in (true, false) and t1.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t2.t_bool in (true, false) and t1.t_int >= 1 and t1.t_bigint >= 123456789 and t1.t_double >= 1234.567890000000034 and t1.t_binary = 'test message' and t1.v_int > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and length(t1.v_binary) > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and (sin(t2.v_bigint) >= 0 or sin(t2.v_bigint) < 0)order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and (cos(t2.v_double) >= 0 or cos(t2.v_double) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and (tan(t2.v_int) >= 0 or tan(t2.v_int) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and length(t2.t_binary) > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and (sin(t2.t_bigint) >= 0 or sin(t2.t_bigint) < 0)order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and (cos(t2.t_double) >= 0 or cos(t2.t_double) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and (tan(t2.t_int) >= 0 or tan(t2.t_int) < 0) order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 8, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (7,0), (7,1)], [('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "las_c3_1", + "desc": "left asof join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on timetruncate(t1.ts, 1a) >= timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on timetruncate(t1.ts, 1a) >= t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts >= timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on timetruncate(t1.ts, 1a) >= timetruncate(t2.ts,1a) where t1.ts < '2024-01-01 12:00:02.600' or t2.ts is null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on timetruncate(t2.ts,1a) <= timetruncate(t1.ts, 1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t2.ts <= timetruncate(t1.ts, 1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on timetruncate(t2.ts,1a) <= t1.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on timetruncate(t2.ts,1a) <= timetruncate(t1.ts, 1a) where t1.ts < '2024-01-01 12:00:02.600' or t2.ts is null order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "las_c4_1", + "desc": "left asof join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 on t1.ts > t2.ts order by ts1 desc) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 on t1.ts >= t2.ts order by ts1) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 on t2.ts < t1.ts order by ts2) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 on t2.ts <= t1.ts order by ts2 desc) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 where t1.ts <= now and t2.ts <= now) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int > 0 and t2.v_bigint > 0) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 where t1.v_binary like '%abc%' and t2.v_bool in (true, false)) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 where t1.t_ts <= now and t2.t_ts <= now) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 where t1.t_int > 0 and t2.t_bigint > 0) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left asof join db1_st2 t2 where t1.t_binary like '%test message%' and t2.t_bool in (true, false)) order by ts1 desc limit 1;" + ], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1)], [('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "las_c4_2", + "desc": "left asof join for aggregate and window query", + "is_ci": True, + "exception": False, + "sql": ["select _wstart ts, count(ts2) from (select t1.ts ts1, t2.ts ts2, t1.tbname from db1_st1 t1 left asof join db1_st2 t2) partition by tbname interval(1s) order by ts;", + "select first(ts1) ts, count(v_int2) from (select t1.ts ts1, t2.v_int v_int2, t1.tbname from db1_st1 t1 left asof join db1_st2 t2 on t1.ts >= t2.ts jlimit 1) group by tbname order by ts;", + "select _wstart ts, count(t_bool2) from (select t1.ts ts1, t2.t_bool t_bool2, t1.tbname from db1_st1 t1 left asof join db1_st2 t2 on t2.ts <= t1.ts) partition by tbname interval(1s) order by ts;", + "select first(ts1) ts, count(v_binary2) from (select t1.ts ts1, t2.v_binary v_binary2, t1.tbname from db1_st1 t1 left asof join db1_st2 t2 where t1.v_int = t2.v_int or t1.v_int != t2.v_int order by ts1 desc) group by tbname order by ts;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (1,0), (1,1)], [('2024-01-01 12:00:00.000'), (5), ('2024-01-01 12:00:01.000'), (5)]] + } + } + }, + { + "id": "las_c4_3", + "desc": "left asof join for union or union all operator", + "is_ci": True, + "exception": False, + "sql": ["select count(*) from (select ts from (select t1.ts from db1_st1_ct1 t1 left asof join db1_st2_ct1 t2) union all (select t1.ts from db1_st1_ct2 t1 left asof join db1_st2_ct2 t2));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 left asof join db1_st2 t2) union (select t2.ts from db1_st1 t1 left asof join db1_st2 t2 where t2.ts != '2024-01-01 12:00:00.500'));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts <= t2.ts where t1.ts > '2024-01-01 12:00:00.600') union (select t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts > t2.ts where t2.ts is not null));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts >= t2.ts where t1.ts < '2024-01-01 12:00:00.700') union all (select t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.ts <= t2.ts where t2.ts is not null and t2.ts != '2024-01-01 12:00:01.600'));", + ], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(10)]] + } + } + }, + { + "id": "las_c5_1", + "desc": "left asof join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 left asof join db1_st2 t2 on t1.ts = t2.ts and t1.v_int > 0;", + "select * from db1_st1 t1 left asof join db1_st2 t2 on t1.ts = t2.ts and t1.ts <= now;", + "select * from db1_st1 t1 left asof join db1_st2 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 left asof join db1_st2 t2 on t1.v_ts > t2.v_ts;", + "select * from db1_st1 t1 left asof join db1_st2 t2 jlimit -1;", + "select * from db1_st1 t1 left asof join db1_st2 t2 jlimit 1025;", + "select * from db1_st1_ct1 t1 left asof join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left asof join db1_st2 t2 on t1.t_int > t2.t_int jlimit 2 order by t1.ts, t2.ts;", + "select * from db1_st1 t1 left asof join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 left asof join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 left asof join (select * from db1_st2) t2;", + ] + } + ], + "right-asof": [ + { + "id": "ras_c1_1", + "desc": "right asof join for super table with master connection condition by >=、<=", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t2.ts >= t1.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t2.ts >= t1.ts jlimit 1 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 jlimit 1 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t1.ts <= t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t1.ts <= t2.ts jlimit 1 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "ras_c1_2", + "desc": "right asof join for super table with master connection condition >、<", + "is_ci": True, + "exception": False, + "sql": [ + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t2.ts > t1.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t2.ts > t1.ts jlimit 1 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t1.ts < t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t1.ts < t2.ts jlimit 1 order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (9,0), (9,1)], [(None), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "ras_c1_3", + "desc": "right asof join for super table with master connection condition =", + "is_ci": True, + "exception": False, + "sql": [ + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t2.ts = t1.ts order by t2.ts,t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t2.ts = t1.ts jlimit 1 order by t2.ts,t1.ts;", + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (3,0), (3,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:00.300'), (None), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "ras_c1_4", + "desc": "right asof join for super table with master and other connection conditions", + "is_ci": True, + "exception": False, + "sql": [ + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.v_int = t2.v_int order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.v_bigint = t2.v_bigint order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.v_ts = t2.v_ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.v_double = t2.v_double order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.v_binary = t2.v_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.v_bool = t2.v_bool order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.t_ts = t2.t_ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.t_int = t2.t_int order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.t_bigint = t2.t_bigint order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.t_double = t2.t_double order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.t_binary = t2.t_binary order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.t_bool = t2.t_bool order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st1 t2 on t1.v_ts = t2.v_ts and t1.v_int = t2.v_int and t1.v_bigint = t2.v_bigint and t1.v_double = t2.v_double and t1.v_bool = t2.v_bool and t1.v_binary = t2.v_binary and t1.t_ts = t2.t_ts and t1.t_int = t2.t_int and t1.t_bigint = t2.t_bigint and t1.t_double = t2.t_double and t1.t_bool = t2.t_bool and t1.t_binary = t2.t_binary order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800')]] + } + } + }, + { + "id": "ras_c1_5", + "desc": "right asof join for blank table with condition of blank table、column and tag", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 on t1.ts>=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 on t1.ts>t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 on t1.ts<=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 on t1.ts=t2.ts jlimit 2 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 on t1.ts>t2.ts jlimit 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 on t1.ts<=t2.ts jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st1 t1 right asof join db1_st_empty t2 on t1.ts=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right asof join db1_st1 t2 on t1.ts>t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right asof join db1_st1 t2 on t1.ts<=t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right asof join db1_st1 t2 on t1.ts=t2.ts jlimit 2 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right asof join db1_st1 t2 on t1.ts>t2.ts jlimit 100 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right asof join db1_st1 t2 on t1.ts<=t2.ts jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts, t1.v_ts, t2.v_ts from db1_st_empty t1 right asof join db1_st1 t2 on t1.ts 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.v_int > 0 and t2.ts >= t1.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.v_bigint > 123456792 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_bigint >= 123456792 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.v_binary like '%abcg%' order by t1.ts, t2.ts limit 8;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_bigint >= 123456792 and t2.v_binary like '%abcg%' order by t1.ts, t2.ts limit 9;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.v_binary like '%abcg%' and t1.ts between '2024-01-01 00:00:00.000' and now order by t1.ts, t2.ts limit 8;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.v_bool in (true, false) and t2.v_int > 0 and (t1.v_bool = true or t1.v_bool = false) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.v_double in (1234.567929999999933, 1234.567970000000059, 1234.567950000000110) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_double in ( 1234.567919999999958, 1234.567939999999908, 1234.567960000000085, 1234.567980000000034, 1234.567950000000110) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.t_int >= 1 and t1.ts >= '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.t_bigint >= 123456789 and t2.ts >= '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.t_double >= 1234.567890000000034 and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.t_binary = 'test message' and t1.t_bool in (true, false) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.t_bool in (true, false) and t2.t_int >= 0 and t2.t_bigint >= 123456789 and t2.t_double >= 1234.567890000000034 and t2.t_binary = 'test message' and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.t_int >= 1 and t2.ts >= '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.t_bigint >= 123456789 and t2.ts >= '2024-01-01 12:00:00.200' order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.t_double >= 1234.567890000000034 and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.t_binary = 'test message' and t1.t_bool in (true, false) and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.t_bool in (true, false) and t1.t_int >= 1 and t1.t_bigint >= 123456789 and t1.t_double >= 1234.567890000000034 and t1.t_binary = 'test message' and t1.v_int >= 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int >= 0 and length(t1.v_binary) > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int >= 0 and (sin(t2.v_bigint) >= 0 or sin(t2.v_bigint) < 0)order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int >= 0 and (cos(t2.v_double) >= 0 or cos(t2.v_double) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int >= 0 and (tan(t2.v_int) >= 0 or tan(t2.v_int) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int >= 0 and length(t2.t_binary) > 0 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int >= 0 and (sin(t2.t_bigint) >= 0 or sin(t2.t_bigint) < 0)order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int >= 0 and (cos(t2.t_double) >= 0 or cos(t2.t_double) < 0) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int >= 0 and (tan(t2.t_int) >= 0 or tan(t2.t_int) < 0) order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 8, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (7,0), (7,1)], [('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "ras_c3_1", + "desc": "right asof join for super table with timetruncate function", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on timetruncate(t1.ts, 1a) >= timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on timetruncate(t1.ts, 1a) >= t2.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t1.ts >= timetruncate(t2.ts,1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on timetruncate(t1.ts, 1a) >= timetruncate(t2.ts,1a) where t1.ts < '2024-01-01 12:00:02.600' or t2.ts is not null order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on timetruncate(t2.ts,1a) <= timetruncate(t1.ts, 1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t2.ts <= timetruncate(t1.ts, 1a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on timetruncate(t2.ts,1a) <= t1.ts order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on timetruncate(t2.ts,1a) <= timetruncate(t1.ts, 1a) where t2.ts < '2024-01-01 12:00:02.600' or t1.ts is null order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (9,0), (9,1)], [(None), ('2024-01-01 12:00:01.900'), ('2024-01-01 12:00:01.600'), ('2024-01-01 12:00:01.600')]] + } + } + }, + { + "id": "ras_c4_1", + "desc": "right asof join for super table with nested query", + "is_ci": True, + "exception": False, + "sql": ["select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 on t2.ts > t1.ts order by ts1 desc) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 on t2.ts >= t1.ts order by ts1) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 on t2.ts > t1.ts order by ts2) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 on t2.ts >= t1.ts order by ts2 desc) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 where t1.ts <= now and t2.ts <= now) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 where t1.v_int > 0 and t2.v_bigint > 0) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 where t1.v_binary like '%abc%' and t2.v_bool in (true, false)) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 where t1.t_ts <= now and t2.t_ts <= now) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 where t1.t_int > 0 and t2.t_bigint > 0) order by ts1 desc limit 1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right asof join db1_st2 t2 where t1.t_binary like '%test message%' and t2.t_bool in (true, false)) order by ts1 desc limit 1;" + ], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1)], [('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "ras_c4_2", + "desc": "right asof join for aggregate and window query", + "is_ci": True, + "exception": False, + "sql": ["select _wstart ts, count(ts1) from (select t1.ts ts1, t2.ts ts2, t2.tbname from db1_st1 t1 right asof join db1_st2 t2) partition by tbname interval(1s) order by ts;", + "select _wstart ts, count(t_bool1) from (select t2.ts ts2, t1.t_bool t_bool1, t2.tbname from db1_st1 t1 right asof join db1_st2 t2 on t1.ts <= t2.ts) partition by tbname interval(1s) order by ts;", + ], + "res": { + "total_rows": 3, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (1,0), (1,1), (2,0), (2,1)], [('2024-01-01 12:00:00.000'), (5), ('2024-01-01 12:00:00.000'), (3), ('2024-01-01 12:00:01.000'), (2)]] + } + } + }, + { + "id": "ras_c4_3", + "desc": "right asof join for union or union all operator", + "is_ci": True, + "exception": False, + "sql": ["select count(*) from (select ts from (select t1.ts from db1_st1_ct1 t1 right asof join db1_st2_ct1 t2) union all (select t1.ts from db1_st1_ct2 t1 right asof join db1_st2_ct2 t2));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 right asof join db1_st2 t2) union (select t2.ts from db1_st1 t1 right asof join db1_st2 t2 where t2.ts not in ('2024-01-01 12:00:00.500', '2024-01-01 12:00:00.700')));", + "select count(*) from (select ts from (select t1.ts from db1_st1 t1 right asof join db1_st2 t2 on t2.ts <= t1.ts where t1.ts > '2024-01-01 12:00:00.600') union (select t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t1.ts > t2.ts where t2.ts is not null));", + ], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(10)]] + } + } + }, + { + "id": "ras_c5_1", + "desc": "right asof join exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 right asof join db1_st2 t2 on t1.ts = t2.ts and t1.v_int > 0;", + "select * from db1_st1 t1 right asof join db1_st2 t2 on t1.ts = t2.ts and t1.ts <= now;", + "select * from db1_st1 t1 right asof join db1_st2 t2 on t1.ts != t2.ts;", + "select * from db1_st1 t1 right asof join db1_st2 t2 on t1.v_ts > t2.v_ts;", + "select * from db1_st1 t1 right asof join db1_st2 t2 jlimit -1;", + "select * from db1_st1 t1 right asof join db1_st2 t2 jlimit 1025;", + "select * from db1_st1_ct1 t1 right asof join db1_st2_ct1 t2 on t1.ts != t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right asof join db1_st2 t2 on t1.t_int > t2.t_int jlimit 2 order by t1.ts, t2.ts;", + "select * from db1_st1 t1 right asof join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int;", + "select * from db1_st1 t1 right asof join db1_st2 t2 on timediff(now, t1.ts) = timediff(now, t2.ts);", + "select * from db1_st1 t1 right asof join (select * from db1_st2) t2;", + "select _wstart ts, count(t_bool1) from (select t1.ts ts1, t1.t_bool t_bool1, t2.tbname from db1_st1 t1 right asof join db1_st2 t2 on t1.ts <= t2.ts) partition by tbname interval(1s) order by ts;" + ] + } + ], + "left-window": [ + { + "id": "lw_c1_1", + "desc": "left window join for super table with window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1.db1_st1 t1 left window join db2.db2_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts;", + ], + "res": { + "total_rows": 17, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (14,0), (14,1), (16,0), (16,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.400'), (None), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "lw_c1_2", + "desc": "left window join for super table with window by different time unit", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100w, 100w) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100d, 100d) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100h, 100h) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100m, 100m) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100s, 100s) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100000a, 100000a) jlimit 1024 order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 100, + "value_check": { + "type": "contain", + "values": [[(0,0), (99,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "lw_c1_3", + "desc": "left window join for super table with int column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.v_int = t2.v_int window_offset(-100a, 100a) jlimit 1024 order by t2.ts desc limit 1;"], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1)], [('2024-01-01 12:00:00.800'), ('2024-01-01 12:00:00.800')]] + } + } + }, + { + "id": "lw_c1_4", + "desc": "left window join for super table with bigint, double column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.v_bigint = t2.v_bigint window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.v_double = t2.v_double window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (7,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "lw_c1_5", + "desc": "left window join for super table with binary column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.v_binary = t2.v_binary window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (7,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.800'), (None)]] + } + } + }, + { + "id": "lw_c1_6", + "desc": "left window join for super table with bool column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.v_bool = t2.v_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;"], + "res": { + "total_rows": 11, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (7,1), (5,0), (5,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.100'), (None), ('2024-01-01 12:00:00.800'), ('2024-01-01 12:00:00.700')]] + } + } + }, + { + "id": "lw_c1_7", + "desc": "left window join for super table with timestamp column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.v_ts = t2.v_ts window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (3,1), (4,0), (4,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:00.800'), ('2024-01-01 12:00:00.800')]] + } + } + }, + { + "id": "lw_c1_8", + "desc": "left window join for super table with timestamp, int, bigint, double, binary, bool tag connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.t_ts = t2.t_ts window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.t_int = t2.t_int window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.t_bigint = t2.t_bigint window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts limit 14;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.t_double = t2.t_double window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.t_binary = t2.t_binary window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts limit 14;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on t1.t_bool = t2.t_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 14, + "value_check": { + "type": "contain", + "values": [[(2,0), (2,1), (3,1), (4,1)], [('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:00.100'), ('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:00.300')]] + } + } + }, + { + "id": "lw_c1_9", + "desc": "left window join for empty master table", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.v_ts = t2.v_ts window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.v_int = t2.v_int window_offset(-1000a, 1000a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.v_bigint = t2.v_bigint window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.v_double = t2.v_double window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.v_binary = t2.v_binary window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.v_bool = t2.v_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.t_ts = t2.t_ts window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.t_int = t2.t_int window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.t_bigint = t2.t_bigint window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.t_double = t2.t_double window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.t_binary = t2.t_binary window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 left window join db1_st2 t2 on t1.t_bool = t2.t_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 0 + } + }, + { + "id": "lw_c1_10", + "desc": "left window join for empty table-drive", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.v_ts = t2.v_ts window_offset(-100a, 100a) jlimit 10 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.v_int = t2.v_int window_offset(-1000a, 1000a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.v_bigint = t2.v_bigint window_offset(-100a, 100a) jlimit 1 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.v_double = t2.v_double window_offset(-100a, 100a) jlimit 102 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.v_binary = t2.v_binary window_offset(-100a, 100a) jlimit 104 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.v_bool = t2.v_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.t_ts = t2.t_ts window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.t_int = t2.t_int window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.t_bigint = t2.t_bigint window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.t_double = t2.t_double window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.t_binary = t2.t_binary window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st_empty t2 on t1.t_bool = t2.t_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (0,1), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), (None), (None)]] + } + } + }, + { + "id": "lw_c1_11", + "desc": "left window join for window query", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 having(count(t2.v_int) >= 0) order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty and t1.v_binary_empty = t2.v_binary_empty window_offset(-100a, 100a) jlimit 10 where t1.v_bigint_empty is null order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty and t1.v_binary_empty = t2.v_binary_empty window_offset(-100a, 100a) jlimit 10 where t1.v_bigint_empty is null having(count(t2.v_int) >= 0) order by t1.ts;", + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (7,1), (0,1), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), (0), (2), (1)]] + } + } + }, + { + "id": "lw_c2_1", + "desc": "left window join for window query with scalar filter", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_int > 0 and t2.v_int > 4 order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_bigint + t2.v_bigint > 0 and t1.ts between '2024-01-01 12:00:00.400' and now and t2.ts != '2024-01-01 12:00:00.300' order by t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_double * t2.v_double > 0 and t2.ts >= '2024-01-01 12:00:00.400' order by t1.ts;", + "select t1.ts, t2.ts from db1.db1_st1 t1 left window join db2.db2_st2 t2 window_offset(-100a, 100a) jlimit 10 where length(t2.v_binary) > 0 and t1.v_binary like '%abc%' and t1.ts >= '2024-01-01 12:00:00.400' and t2.ts >= '2024-01-01 12:00:00.400' order by t1.ts;", + "select t1.ts, t2.ts from db1.db1_st1 t1 left window join db2.db2_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 where t1.v_bool in (true, false) and t2.ts is not null and t2.ts >= '2024-01-01 12:00:00.400' order by t1.ts;", + "select t1.ts, t2.ts from db1.db1_st1 t1 left window join db2.db2_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 where t1.t_ts >= '2024-01-01 12:00:00.000' and t1.t_int + t2.t_int > 1 and t2.ts >= '2024-01-01 12:00:00.400' order by t1.ts;", + ], + "res": { + "total_rows": 8, + "value_check": { + "type": "contain", + "values": [[(0,0), (7,0), (7,1)], [('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "lw_c2_2", + "desc": "left window join for window query with aggregate filter", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_int > 0 and t2.v_int > 4 order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_bigint + t2.v_bigint > 0 and t1.ts between '2024-01-01 12:00:00.400' and now and t2.ts != '2024-01-01 12:00:00.300' having(sum(t1.v_int + t2.v_int) >= 0) order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_double * t2.v_double > 0 and t2.ts >= '2024-01-01 12:00:00.400' having(avg(abs(t1.v_double + t2.v_double)) > 0) order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where length(t2.v_binary) > 0 and t1.v_binary like '%abc%' and t1.ts >= '2024-01-01 12:00:00.400' and t2.ts >= '2024-01-01 12:00:00.400' having(avg(length(t2.v_binary) + length(t2.v_binary)) > 1) order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 where t1.v_bool in (true, false) and t2.ts is not null and t2.ts >= '2024-01-01 12:00:00.400' having(apercentile((t1.v_double + t2.v_double), 100) > 0) order by t1.ts;", + "select t1.ts, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 where t1.t_ts >= '2024-01-01 12:00:00.000' and t1.t_int + t2.t_int > 1 and t2.ts >= '2024-01-01 12:00:00.400' having(hyperloglog(t2.v_bigint) >= 0) order by t1.ts;", + ], + "res": { + "total_rows": 5, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,0), (4,1)], [('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:01.800'), (1)]] + } + } + }, + { + "id": "lw_c3_1", + "desc": "left window join for window query with nested query", + "is_ci": True, + "exception": False, + "sql": ["select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.tbname from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_int > 0 and t2.v_int > 4 order by t1.ts desc) partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.tbname from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_bigint + t2.v_bigint > 0 and t1.ts between '2024-01-01 12:00:00.400' and now and t2.ts != '2024-01-01 12:00:00.300' order by t1.ts desc) partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.tbname from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_double * t2.v_double > 0 and t2.ts >= '2024-01-01 12:00:00.400' order by t1.ts desc) where ts2 is not null partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.v_int v_int1, t2.v_int v_int2, t1.tbname from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts) where v_int1 > 0 and v_int2 > 4 partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint v_bigint1, t2.v_bigint v_bigint2, t1.tbname from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts) where v_bigint1 + v_bigint2 > 0 and ts1 between '2024-01-01 12:00:00.400' and now and ts2 != '2024-01-01 12:00:00.300' partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.v_double v_double1, t2.v_double v_double2, t1.tbname from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts) where v_double1 * v_double2 > 0 and ts2 >= '2024-01-01 12:00:00.400' partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, length(t2.v_binary) len, t1.v_binary v_binary1, t1.tbname from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts) where len > 0 and v_binary1 like '%abc%' and ts1 >= '2024-01-01 12:00:00.400' and ts2 >= '2024-01-01 12:00:00.400' partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.v_bool v_bool1, t2.v_bool v_bool2, t1.tbname from db1_st1 t1 left window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 order by t1.ts) where v_bool1 in (true, false) and ts2 is not null and ts2 >= '2024-01-01 12:00:00.400' partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.t_ts t_ts1, t2.t_ts t_ts2, t1.t_int t_int1, t2.t_int t_int2, t1.tbname from db1_st1 t1 left window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 order by t1.ts) where t_ts1 >= '2024-01-01 12:00:00.000' and t_int1 + t_int2 > 1 and ts2 >= '2024-01-01 12:00:00.400' partition by tbname interval(1s) order by _wend;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (1,0), (1,1)], [('2024-01-01 12:00:01.000'), (6), ('2024-01-01 12:00:02.000'), (2)]] + } + } + }, + { + "id": "lw_c3_2", + "desc": "left window join for union query", + "is_ci": True, + "exception": False, + "sql": ["select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1 where t1.tbname = 'db1_st1_ct1') union all (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1 where t1.tbname = 'db1_st1_ct2') order by ts1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1 where t1.tbname = 'db1_st1_ct1') union all (select t1.ts ts1, t2.ts ts2 from db1.db1_st1 t1 left window join db2.db2_st2 t2 window_offset(-100a, 100a) jlimit 1 where t1.tbname = 'db1_st1_ct2') order by ts1;" + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1) union (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1) order by ts1;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 left window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1) union (select t1.ts ts1, t2.ts ts2 from db1.db1_st1 t1 left window join db2.db2_st2 t2 window_offset(-100a, 100a) jlimit 1) order by ts1;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (6,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "lw_c4_1", + "desc": "left window join for super table with exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 t1 left window join db1_st2 t2 on t1.v_int > 0 window_offset(-1a, 1a);", + "select * from db1_st1 t1 left window join db1_st2 t2 on t1.ts <= now window_offset(-1a, 1a);", + "select * from db1_st1 t1 left window join db1_st2 t2 on t1.ts != t2.ts window_offset(-1a, 1a);", + "select * from db1_st1 t1 left window join db1_st2 t2 on t1.v_ts > t2.v_ts window_offset(-1a, 1a);", + "select * from db1_st1 t1 left window join db1_st2 t2 window_offset(-1a, 1a) jlimit -1;", + "select * from db1_st1 t1 left window join db1_st2 t2 window_offset(-1a, 1a) jlimit 1025;", + "select * from db1_st1_ct1 t1 left window join db1_st2_ct1 t2 on t1.v_int = t2.v_int or t1.v_bigint = t2.v_bigint window_offset(-1a, 1a);", + "select t1.ts, t2.ts from db1_st1 t1 left window join db1_st2 t2 on abs(t1.t_int) > t2.t_int window_offset(-1a, 1a) jlimit 2 order by t1.ts, t2.ts;", + "select * from db1_st1 t1 left window join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int window_offset(-1a, 1a);", + "select * from db1_st1 t1 left window join (select * from db1_st2) t2 window_offset(-1a, 1a);", + "select first(t1.ts), count(t2.*) from db1_st1 t1 left window join db1_st2 t2 window_offset(-1a, 1a) group by t1.tbname;", + "select _wstart, count(t2.*) from db1_st1 t1 left window join db1_st2 t2 window_offset(-1a, 1a) partition by t1.tbname;", + "select first(t1.ts), count(t2.*) from db1_st1 t1 left window join db1_st2 t2 on t1.v_int = t2.v_int window_offset(-1a, 1a) slimit 1;", + "select * from db1_st1 t1 left window join db1_st2 t2 window_offset(-1y, 1y);", + "select * from db1.db1_st1 t1 left window join db_us.db_us_t t2 window_offset(-100a, 100a);", + "select * from db1.db1_st1 t1 left window join db_ns.db_ns_t t2 window_offset(-100a, 100a);", + ] + } + ], + "right-window": [ + { + "id": "rw_c1_1", + "desc": "right window join for super table with window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 14 order by t1.ts, t2.ts limit 14;" + ], + "res": { + "total_rows": 14, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (13,0), (13,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "rw_c1_2", + "desc": "right window join for super table with window by different time unit", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100w, 100w) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100d, 100d) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100h, 100h) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100m, 100m) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100s, 100s) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100000a, 100000a) jlimit 1024 order by t1.ts, t2.ts;", + ], + "res": { + "total_rows": 100, + "value_check": { + "type": "contain", + "values": [[(0,0), (99,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "rw_c1_3", + "desc": "right window join for super table with int column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.v_int = t2.v_int window_offset(-100a, 100a) jlimit 1024 order by t1.ts desc limit 1;"], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1)], [('2024-01-01 12:00:00.800'), ('2024-01-01 12:00:00.800')]] + } + } + }, + { + "id": "rw_c1_4", + "desc": "right window join for super table with bigint, double column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.v_bigint = t2.v_bigint window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.v_double = t2.v_double window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (7,0), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "rw_c1_5", + "desc": "right window join for super table with binary column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.v_binary = t2.v_binary window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (7,0), (9,1), (9,0)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:01.900'), (None)]] + } + } + }, + { + "id": "rw_c1_6", + "desc": "right window join for super table with bool column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.v_bool = t2.v_bool window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(1,0), (1,1), (7,0), (5,0), (5,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.100'), (None), ('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:00.500')]] + } + } + }, + { + "id": "rw_c1_7", + "desc": "right window join for super table with timestamp column connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.v_ts = t2.v_ts window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;"], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (3,0), (4,0), (4,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), (None), ('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:00.400')]] + } + } + }, + { + "id": "rw_c1_8", + "desc": "right window join for super table with timestamp, int, bigint, double, binary, bool tag connection condition window", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.t_ts = t2.t_ts window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.t_int = t2.t_int window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.t_bigint = t2.t_bigint and t1.t_int = t2.t_int window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts limit 12;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.t_double = t2.t_double window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.t_binary = t2.t_binary and t1.t_double = t2.t_double window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts limit 12;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on t1.t_bool = t2.t_bool window_offset(-100a, 100a) jlimit 1024 order by t2.ts, t1.ts;", + ], + "res": { + "total_rows": 12, + "value_check": { + "type": "contain", + "values": [[(2,0), (2,1), (3,1), (4,1)], [('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:00.100'), ('2024-01-01 12:00:00.200'), ('2024-01-01 12:00:00.300')]] + } + } + }, + { + "id": "rw_c1_9", + "desc": "right window join for empty master table", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.v_ts = t2.v_ts window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.v_int = t2.v_int window_offset(-1000a, 1000a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.v_bigint = t2.v_bigint window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.v_double = t2.v_double window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.v_binary = t2.v_binary window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.v_bool = t2.v_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.t_ts = t2.t_ts window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.t_int = t2.t_int window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.t_bigint = t2.t_bigint window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.t_double = t2.t_double window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.t_binary = t2.t_binary window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st2 t1 right window join db1_st_empty t2 on t1.t_bool = t2.t_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 0 + } + }, + { + "id": "rw_c1_10", + "desc": "right window join for empty table-drive", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.v_ts = t2.v_ts window_offset(-100a, 100a) jlimit 10 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.v_int = t2.v_int window_offset(-1000a, 1000a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.v_bigint = t2.v_bigint window_offset(-100a, 100a) jlimit 1 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.v_double = t2.v_double window_offset(-100a, 100a) jlimit 102 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.v_binary = t2.v_binary window_offset(-100a, 100a) jlimit 104 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.v_bool = t2.v_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.t_ts = t2.t_ts window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.t_int = t2.t_int window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.t_bigint = t2.t_bigint window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.t_double = t2.t_double window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.t_binary = t2.t_binary window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;", + "select t1.ts, t2.ts from db1_st_empty t1 right window join db1_st1 t2 on t1.t_bool = t2.t_bool window_offset(-100a, 100a) jlimit 1024 order by t1.ts, t2.ts;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,1), (9,1), (0,0), (9,0)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), (None), (None)]] + } + } + }, + { + "id": "rw_c1_11", + "desc": "right window join for window query", + "is_ci": True, + "exception": False, + "sql": ["select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 having(count(t1.v_int) >= 0) order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty and t1.v_binary_empty = t2.v_binary_empty window_offset(-100a, 100a) jlimit 10 where t1.v_bigint_empty is null order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty and t1.v_binary_empty = t2.v_binary_empty window_offset(-100a, 100a) jlimit 10 where t1.v_bigint_empty is null having(count(t1.v_int) >= 0) order by t2.ts;", + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (9,0), (7,1), (0,1), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.900'), (1), (1), (1)]] + } + } + }, + { + "id": "rw_c2_1", + "desc": "right window join for window query with scalar filter", + "is_ci": True, + "exception": False, + "sql": ["select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_int > 0 and t2.v_int > 4 order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_bigint + t2.v_bigint > 0 and t1.ts between '2024-01-01 12:00:00.400' and now and t2.ts != '2024-01-01 12:00:00.300' order by t2.ts;", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_double * t2.v_double > 0 and t2.ts >= '2024-01-01 12:00:00.400' order by t2.ts;", + "select t1.ts, t2.ts from db1.db1_st1 t1 right window join db2.db2_st2 t2 window_offset(-100a, 100a) jlimit 10 where length(t2.v_binary) > 0 and t1.v_binary like '%abc%' and t1.ts >= '2024-01-01 12:00:00.400' and t2.ts >= '2024-01-01 12:00:00.400' order by t2.ts;", + "select t1.ts, t2.ts from db1.db1_st1 t1 right window join db2.db2_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 where t1.v_bool in (true, false) and t2.ts is not null and t2.ts >= '2024-01-01 12:00:00.400' order by t2.ts;", + "select t1.ts, t2.ts from db1.db1_st1 t1 right window join db2.db2_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 where t1.t_ts >= '2024-01-01 12:00:00.000' and t1.t_int + t2.t_int > 1 and t2.ts >= '2024-01-01 12:00:00.400' order by t2.ts;", + ], + "res": { + "total_rows": 8, + "value_check": { + "type": "contain", + "values": [[(0,0), (7,0), (7,1)], [('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "rw_c2_2", + "desc": "right window join for window query with aggregate filter", + "is_ci": True, + "exception": False, + "sql": ["select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_int > 0 and t2.v_int > 4 order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_bigint + t2.v_bigint > 0 and t1.ts between '2024-01-01 12:00:00.400' and now and t2.ts != '2024-01-01 12:00:00.300' having(sum(t1.v_int + t2.v_int) >= 0) order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_double * t2.v_double > 0 and t2.ts >= '2024-01-01 12:00:00.400' having(avg(abs(t1.v_double + t2.v_double)) > 0) order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where length(t2.v_binary) > 0 and t1.v_binary like '%abc%' and t1.ts >= '2024-01-01 12:00:00.400' and t2.ts >= '2024-01-01 12:00:00.400' having(avg(length(t2.v_binary) + length(t2.v_binary)) > 1) order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 where t1.v_bool in (true, false) and t2.ts is not null and t2.ts >= '2024-01-01 12:00:00.400' having(apercentile((t1.v_double + t2.v_double), 100) > 0) order by t2.ts;", + "select t2.ts, count(t1.*) from db1_st1 t1 right window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 where t1.t_ts >= '2024-01-01 12:00:00.000' and t1.t_int + t2.t_int > 1 and t2.ts >= '2024-01-01 12:00:00.400' having(hyperloglog(t2.v_bigint) >= 0) order by t2.ts;", + ], + "res": { + "total_rows": 6, + "value_check": { + "type": "contain", + "values": [[(0,0), (4,0), (4,1)], [('2024-01-01 12:00:00.400'), ('2024-01-01 12:00:01.600'), (1)]] + } + } + }, + { + "id": "rw_c3_1", + "desc": "right window join for window query with nested query", + "is_ci": True, + "exception": False, + "sql": ["select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.tbname from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_int > 0 and t2.v_int > 4 order by t1.ts desc) partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.tbname from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_bigint + t2.v_bigint > 0 and t1.ts between '2024-01-01 12:00:00.400' and now and t2.ts != '2024-01-01 12:00:00.300' order by t1.ts desc) partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.tbname from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 where t1.v_double * t2.v_double > 0 and t2.ts >= '2024-01-01 12:00:00.400' order by t1.ts desc) where ts2 is not null partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.v_int v_int1, t2.v_int v_int2, t1.tbname from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts) where v_int1 > 0 and v_int2 > 4 partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.v_bigint v_bigint1, t2.v_bigint v_bigint2, t1.tbname from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts) where v_bigint1 + v_bigint2 > 0 and ts1 between '2024-01-01 12:00:00.400' and now and ts2 != '2024-01-01 12:00:00.300' partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.v_double v_double1, t2.v_double v_double2, t1.tbname from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts) where v_double1 * v_double2 > 0 and ts2 >= '2024-01-01 12:00:00.400' partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, length(t2.v_binary) len, t1.v_binary v_binary1, t1.tbname from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 10 order by t1.ts) where len > 0 and v_binary1 like '%abc%' and ts1 >= '2024-01-01 12:00:00.400' and ts2 >= '2024-01-01 12:00:00.400' partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.v_bool v_bool1, t2.v_bool v_bool2, t1.tbname from db1_st1 t1 right window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 order by t1.ts) where v_bool1 in (true, false) and ts2 is not null and ts2 >= '2024-01-01 12:00:00.400' partition by tbname interval(1s) order by _wend;", + "select _wend, count(*) from (select t1.ts ts1, t2.ts ts2, t1.t_ts t_ts1, t2.t_ts t_ts2, t1.t_int t_int1, t2.t_int t_int2, t1.tbname from db1_st1 t1 right window join db1_st2 t2 on t1.v_int_empty = t2.v_int_empty window_offset(-100a, 100a) jlimit 10 order by t1.ts) where t_ts1 >= '2024-01-01 12:00:00.000' and t_int1 + t_int2 > 1 and ts2 >= '2024-01-01 12:00:00.400' partition by tbname interval(1s) order by _wend;", + ], + "res": { + "total_rows": 2, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (1,0), (1,1)], [('2024-01-01 12:00:01.000'), (6), ('2024-01-01 12:00:02.000'), (2)]] + } + } + }, + { + "id": "rw_c3_2", + "desc": "right window join for union query", + "is_ci": True, + "exception": False, + "sql": ["select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1 where t1.tbname = 'db1_st1_ct1') union all (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1 where t1.tbname = 'db1_st1_ct2') order by ts1, ts2;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1 where t1.tbname = 'db1_st1_ct1') union all (select t1.ts ts1, t2.ts ts2 from db1.db1_st1 t1 right window join db2.db2_st2 t2 window_offset(-100a, 100a) jlimit 1 where t1.tbname = 'db1_st1_ct2') order by ts1, ts2;" + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1) union (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1) order by ts1, ts2;", + "select ts1, ts2 from (select t1.ts ts1, t2.ts ts2 from db1_st1 t1 right window join db1_st2 t2 window_offset(-100a, 100a) jlimit 1) union (select t1.ts ts1, t2.ts ts2 from db1.db1_st1 t1 right window join db2.db2_st2 t2 window_offset(-100a, 100a) jlimit 1) order by ts1, ts2;" + ], + "res": { + "total_rows": 10, + "value_check": { + "type": "contain", + "values": [[(0,0), (0,1), (9,0), (9,1)], [('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:00.000'), ('2024-01-01 12:00:01.800'), ('2024-01-01 12:00:01.900')]] + } + } + }, + { + "id": "rw_c4_1", + "desc": "right window join for super table with exceptions", + "is_ci": True, + "exception": True, + "sql": ["select * from db1_st1 right window join db1_st2 t2 on t1.v_int > 0 window_offset(-1a, 1a);", + "select * from db1_st1 right window join db1_st2 t2 on t1.ts <= now window_offset(-1a, 1a);", + "select * from db1_st1 right window join db1_st2 t2 on t1.ts != t2.ts window_offset(-1a, 1a);", + "select * from db1_st1 right window join db1_st2 t2 on t1.v_ts > t2.v_ts window_offset(-1a, 1a);", + "select * from db1_st1 right window join db1_st2 t2 window_offset(-1a, 1a) jlimit -1;", + "select * from db1_st1 right window join db1_st2 t2 window_offset(-1a, 1a) jlimit 1025;", + "select * from db1_st1_ct1 t1 right window join db1_st2_ct1 t2 on t1.v_int = t2.v_int or t1.v_bigint = t2.v_bigint window_offset(-1a, 1a);", + "select t1.ts, t2.ts from db1_st1 t1 right window join db1_st2 t2 on abs(t1.t_int) > t2.t_int window_offset(-1a, 1a) jlimit 2 order by t1.ts, t2.ts;", + "select * from db1_st1 t1 right window join db1_st2 t2 on t1.ts=t2.ts or t2.v_int=t1.v_int window_offset(-1a, 1a);", + "select * from db1_st1 t1 right window join (select * from db1_st2) t2 window_offset(-1a, 1a);", + "select first(t1.ts), count(t2.*) from db1_st1 t1 right window join db1_st2 t2 window_offset(-1a, 1a) group by t1.tbname;", + "select _wstart, count(t2.*) from db1_st1 t1 right window join db1_st2 t2 window_offset(-1a, 1a) partition by t1.tbname;", + "select first(t1.ts), count(t2.*) from db1_st1 t1 right window join db1_st2 t2 on t1.v_int = t2.v_int window_offset(-1a, 1a) slimit 1;", + "select * from db1_st1 t1 right window join db1_st2 t2 window_offset(-1y, 1y);", + "select * from db1.db1_st1 t1 right window join db_us.db_us_t t2 window_offset(-100a, 100a);", + "select * from db1.db1_st1 t1 right window join db_ns.db_ns_t t2 window_offset(-100a, 100a);", + ] + } + ], + "pk_int32": [ + { + "id": "pk32_c1", + "desc": "all join functions with int32 primary key", + "is_ci": True, + "exception": False, + "sql": ["select count(ts1) from (select t1.ts ts1 from db_pk_st1_int32 t1 inner join db_pk_st2_int32 t2 on t1.ts = t2.ts where t1.v_int = 2147483647 and t2.v_int = 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int32 t1 left join db_pk_st2_int32 t2 on t1.ts = t2.ts where t1.v_int <= -2147483648 and t2.v_int = 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int32 t1 right join db_pk_st2_int32 t2 on t1.ts = t2.ts where t1.v_int >= 2147483647 and t2.v_int = 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int32 t1 full join db_pk_st2_int32 t2 on t1.ts = t2.ts where t1.v_int < 0 and t2.v_int = 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int32 t1 left semi join db_pk_st2_int32 t2 on t1.ts = t2.ts where t1.v_int = 0 and t2.v_int != 0);", + "select count(ts2) from (select t2.ts ts2 from db_pk_st1_int32 t1 right semi join db_pk_st2_int32 t2 on t1.ts = t2.ts where t2.v_int = 0 and t1.v_int != 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int32_ct1 t1 left anti join db_pk_st1_int32_ct2 t2 on t1.ts = t2.ts where t1.ts between '2024-01-01 12:00:00.100' and '2024-01-01 12:00:00.500');", + "select count(ts2) from (select t2.ts ts2 from db1.db1_st1 t1 right anti join db_pk_st1_int32 t2 on t1.ts = t2.ts);", + "select count(ts1) from (select t1.ts ts1, t2.ts from db_pk_st1_int32 t1 left asof join db_pk_st2_int32 t2 on t1.ts >= t2.ts jlimit 2 where t1.v_int >=0 and t2.v_int > 0 and t1.ts >= '2024-01-01 12:00:01.000');", + "select count(ts2) from (select t1.ts, t2.ts ts2 from db_pk_st1_int32 t1 right asof join db_pk_st2_int32 t2 on t1.ts >= t2.ts and t1.v_int = t2.v_int jlimit 2 where t2.v_int = 0 and t2.ts <= '2024-01-01 12:00:00.200');", + "select count(ts1) from (select t1.ts ts1, t2.ts, t1.v_int, t2.v_int from db_pk_st1_int32 t1 left window join db_pk_st2_int32 t2 on t1.v_int = t2.v_int window_offset(-100a, 100a) jlimit 1 where t1.v_int < 0 and t1.ts >= '2024-01-01 12:00:01.000');", + "select count(ts2) from (select t2.ts ts2, t1.ts, t1.v_int, t2.v_int from db_pk_st1_int32 t1 right window join db_pk_st2_int32 t2 on t1.v_int = t2.v_int window_offset(-100a, 100a) where t2.v_int = 0 and t2.ts > '2024-01-01 12:00:00.000');", + ], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(4)]] + } + } + } + ], + "pk_int64": [ + { + "id": "pk64_c1", + "desc": "all join functions with int64 primary key", + "is_ci": True, + "exception": False, + "sql": ["select count(ts1) from (select t1.ts ts1 from db_pk_st1_int64 t1 inner join db_pk_st2_int64 t2 on t1.ts = t2.ts where t1.v_bigint = 9223372000000000000 and t2.v_bigint = 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int64 t1 left join db_pk_st2_int64 t2 on t1.ts = t2.ts where t1.v_bigint > 0 and t2.v_bigint = 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int64 t1 right join db_pk_st2_int64 t2 on t1.ts = t2.ts where t1.v_bigint = 9223372000000000000 and t2.v_bigint = 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int64 t1 full join db_pk_st2_int64 t2 on t1.ts = t2.ts where t1.v_bigint < 0 and t2.v_bigint = 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int64 t1 left semi join db_pk_st2_int64 t2 on t1.ts = t2.ts where t1.v_bigint = 0 and t2.v_bigint != 0);", + "select count(ts2) from (select t2.ts ts2 from db_pk_st1_int64 t1 right semi join db_pk_st2_int64 t2 on t1.ts = t2.ts where t2.v_bigint = 0 and t1.v_bigint != 0);", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_int64_ct1 t1 left anti join db_pk_st1_int64_ct2 t2 on t1.ts = t2.ts where t1.ts between '2024-01-01 12:00:00.100' and '2024-01-01 12:00:00.500');", + "select count(ts2) from (select t2.ts ts2 from db1.db1_st1 t1 right anti join db_pk_st1_int64 t2 on t1.ts = t2.ts);", + "select count(ts1) from (select t1.ts ts1, t2.ts from db_pk_st1_int64 t1 left asof join db_pk_st2_int64 t2 on t1.ts >= t2.ts jlimit 2 where t1.v_bigint >=0 and t2.v_bigint > 0 and t1.ts >= '2024-01-01 12:00:01.000');", + "select count(ts2) from (select t1.ts, t2.ts ts2 from db_pk_st1_int64 t1 right asof join db_pk_st2_int64 t2 on t1.ts >= t2.ts and t1.v_int = t2.v_int jlimit 2 where t2.v_bigint = 0 and t2.ts <= '2024-01-01 12:00:00.200');", + "select count(ts1) from (select t1.ts ts1, t2.ts, t1.v_int, t2.v_int from db_pk_st1_int64 t1 left window join db_pk_st2_int64 t2 on t1.v_int = t2.v_int window_offset(-100a, 100a) jlimit 1 where t1.v_bigint < 0 and t1.ts >= '2024-01-01 12:00:01.000');", + "select count(ts2) from (select t2.ts ts2, t1.ts, t1.v_int, t2.v_int from db_pk_st1_int64 t1 right window join db_pk_st2_int64 t2 on t1.v_int = t2.v_int window_offset(-100a, 100a) where t2.v_bigint = 0 and t2.ts > '2024-01-01 12:00:00.200');", + ], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(4)]] + } + } + }, + ], + "pk_str": [ + { + "id": "pkstr_c1", + "desc": "all join functions with str primary key", + "is_ci": True, + "exception": False, + "sql": ["select count(ts1) from (select t1.ts ts1 from db_pk_st1_str t1 inner join db_pk_st2_str t2 on t1.ts = t2.ts where t1.v_binary like '%abcd%' and t1.ts >= '2024-01-01 12:00:01.000' and t2.v_binary != 'abcde');", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_str t1 left join db_pk_st2_str t2 on t1.ts = t2.ts where t1.v_binary like '%abcd%e' and t2.v_binary not in ('abc') and t1.ts < '2024-01-01 12:00:01.500');", + "select count(ts2) from (select t2.ts ts2 from db_pk_st1_str t1 right join db_pk_st2_str t2 on t1.ts = t2.ts where t2.v_binary match '[e]' and t2.ts between '2024-01-01 12:00:00.200' and now and t1.ts < '2024-01-01 12:00:01.500');", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_str t1 full join db_pk_st2_str t2 on t1.ts = t2.ts where length(t2.v_binary) > 4 and length(t1.v_binary) > 3 and t2.ts < '2024-01-01 12:00:01.500');", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_str t1 left semi join db_pk_st2_str t2 on t1.ts = t2.ts where t1.v_binary > t2.v_binary and t2.ts < '2024-01-01 12:00:01.500');", + "select count(ts2) from (select t2.ts ts2 from db_pk_st1_str t1 right semi join db_pk_st2_str t2 on t1.ts = t2.ts where t2.v_bigint >= 0 and t2.ts > '2024-01-01 12:00:00.000');", + "select count(ts1) from (select t1.ts ts1 from db_pk_st1_str_ct1 t1 left anti join db_pk_st1_str_ct2 t2 on t1.ts = t2.ts);", + "select count(ts2) from (select t2.ts ts2 from db_pk_st1_str_ct1 t1 right anti join db_pk_st1_str t2 on t1.ts = t2.ts);", + "select count(ts1) from (select t1.ts ts1, t2.ts from db_pk_st1_str t1 left asof join db_pk_st2_str t2 on t1.ts >= t2.ts jlimit 2 where t1.v_bigint >=0 and t2.v_bigint <= 0 and t2.ts <= '2024-01-01 12:00:01.300' and t1.ts != '2024-01-01 12:00:00.400');", + "select count(ts2) from (select t1.ts, t2.ts ts2, t2.v_bigint from db_pk_st1_str t1 right asof join db_pk_st2_str t2 on t1.ts >= t2.ts and t1.v_int = t2.v_int jlimit 2 where t2.v_bigint > 0 and t2.ts < '2024-01-01 12:00:01.100');", + "select count(ts1) from (select t1.ts ts1, t2.ts,t1.v_binary, t2.v_binary, t1.v_int, t2.v_int from db_pk_st1_str t1 left window join db_pk_st2_str t2 on t1.v_int = t2.v_int window_offset(-100a, 100a) jlimit 1 where t1.v_int >= 0 and t1.ts >= '2024-01-01 12:00:00.100');", + "select count(ts2) from (select t2.ts ts2, t1.ts, t1.v_int, t2.v_int from db_pk_st1_str t1 right window join db_pk_st2_str t2 on t1.v_int = t2.v_int window_offset(-100a, 100a) where t2.v_binary match '[e]' and t1.ts < '2024-01-01 12:00:01.500');", + ], + "res": { + "total_rows": 1, + "value_check": { + "type": "contain", + "values": [[(0,0)], [(10)]] + } + } + } + ] + } + return sql[join_type] + + def result_validator(self, query_result, expected_result): + """Query results validator + :param query_result: the query result + :param expected_result: the expected result defined in sql_generator + """ + if expected_result: + tdSql.checkEqual(len(query_result), expected_result["total_rows"]) + if "value_check" in expected_result.keys(): + if expected_result["value_check"]["type"] == "equal": + tdSql.checkEqual(tdSql.res, expected_result) + elif expected_result["value_check"]["type"] == "contain": + for index in range(len(expected_result["value_check"]["values"][0])): + item = expected_result["value_check"]["values"][0][index] + tdLog.debug(item) + value = expected_result["value_check"]["values"][1][index] + if type(tdSql.res[item[0]][item[1]]) is datetime and value: + # millisecond + if len(value.split(".")[1]) == 3: + timestamp_res = tdSql.res[item[0]][item[1]].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + # microsecond + elif len(value.split(".")[1]) == 6: + timestamp_res = tdSql.res[item[0]][item[1]].strftime('%Y-%m-%d %H:%M:%S.%f') + # nanosecond + elif len(value.split(".")[1]) == 9: + timestamp_res = tdSql.res[item[0]][item[1]].strftime('%Y-%m-%d %H:%M:%S.%3N') + tdSql.checkEqual(timestamp_res, value) + else: + tdSql.checkEqual(tdSql.res[item[0]][item[1]], value) + else: + tdLog.error("Unsupported value check type: %s" % expected_result["value_check"]["type"]) + + def test_join(self, join_type, pk=False): + """Verify the join operation + :param join_type: the join type, can be "inner", "left-outer", "right-outer", "full" + """ + # common check points + tdSql.query("show databases;") + if 'db1' not in [item[0] for item in tdSql.res]: + self.create_tables(["db1", "db2", "db_us", 'db_ns', 'db_pk'], ['ms', 'ms', 'us', 'ns', 'ms']) + self.data(["db1", "db2"], "common_ms") + # precision 'us' + self.data(["db_us"], "common_us") + # precision 'ns' + self.data(["db_ns"], "common_ns") + # primary key + self.data(["db_pk"], "pk_int32_ms") + self.data(["db_pk"], "pk_int64_ms") + self.data(["db_pk"], "pk_str_ms") + if pk: + tdSql.execute("use db_pk;") + else: + tdSql.execute("use db1;") + sql_list = self.sql_generator(join_type) + sql_num = 0 + for sql in sql_list: + tdLog.debug("Start the check point: %s" % sql["id"]) + tdLog.debug("Check point description: %s" % sql["desc"]) + if sql["is_ci"]: + if sql["exception"]: + for q in sql["sql"]: + tdSql.error(q) + sql_num += 1 + else: + # make sure the query result is same with the expected result + for q in sql["sql"]: + tdSql.query(q) + tdLog.debug(tdSql.res) + self.result_validator(tdSql.res, sql["res"]) + sql_num += 1 + tdLog.debug("Execute %d SQLs for %s join" % (sql_num, join_type)) + self.total_sql_num += sql_num + + def run(self): + # common check points for all join types with common data + self.test_join("inner") + self.test_join("left-outer") + self.test_join("right-outer") + self.test_join("full") + self.test_join("left-semi") + self.test_join("right-semi") + self.test_join("left-anti") + self.test_join("right-anti") + self.test_join("left-asof") + self.test_join("right-asof") + self.test_join("left-window") + self.test_join("right-window") + + # composite primary key + self.test_join("pk_int32", pk=True) + self.test_join("pk_int64", pk=True) + self.test_join("pk_str", pk=True) + + tdLog.success(f"{self.total_sql_num} for join verification SQLs are executed successfully") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/army/community/storage/compressBasic.py b/tests/army/community/storage/compressBasic.py index 2fe19abbd4..c0975c6d75 100644 --- a/tests/army/community/storage/compressBasic.py +++ b/tests/army/community/storage/compressBasic.py @@ -141,6 +141,13 @@ class TDTestCase(TBase): tdSql.checkData(i, 5, self.defCompress) tdSql.checkData(i, 6, self.defLevel) + # geometry encode is disabled + sql = f"create table {self.db}.ta(ts timestamp, pos geometry(64)) " + tdSql.execute(sql) + sql = f"describe {self.db}.ta" + tdSql.query(sql) + tdSql.checkData(1, 4, "disabled") + tdLog.info("check default encode compress and level successfully.") def checkDataDesc(self, tbname, row, col, value): diff --git a/tests/army/enterprise/s3/s3_basic.json b/tests/army/enterprise/s3/s3Basic.json similarity index 81% rename from tests/army/enterprise/s3/s3_basic.json rename to tests/army/enterprise/s3/s3Basic.json index 747ac7c8ec..4a2f4496f9 100644 --- a/tests/army/enterprise/s3/s3_basic.json +++ b/tests/army/enterprise/s3/s3Basic.json @@ -7,8 +7,8 @@ "password": "taosdata", "connection_pool_size": 8, "num_of_records_per_req": 4000, - "prepared_rand": 1000, - "thread_count": 2, + "prepared_rand": 500, + "thread_count": 4, "create_table_thread_count": 1, "confirm_parameter_prompt": "no", "databases": [ @@ -18,20 +18,26 @@ "drop": "yes", "vgroups": 2, "replica": 1, - "duration":"15d", - "flush_each_batch":"yes", - "keep": "60d,100d,200d" + "duration":"10d", + "s3_keeplocal":"30d", + "s3_chunksize":"131072", + "tsdb_pagesize":"1", + "s3_compact":"1", + "wal_retention_size":"1", + "wal_retention_period":"1", + "flush_each_batch":"no", + "keep": "3650d" }, "super_tables": [ { "name": "stb", "child_table_exists": "no", - "childtable_count": 2, + "childtable_count": 10, "insert_rows": 2000000, "childtable_prefix": "d", "insert_mode": "taosc", "timestamp_step": 1000, - "start_timestamp":"now-90d", + "start_timestamp": 1600000000000, "columns": [ { "type": "bool", "name": "bc"}, { "type": "float", "name": "fc" }, diff --git a/tests/army/enterprise/s3/s3Basic.py b/tests/army/enterprise/s3/s3Basic.py new file mode 100644 index 0000000000..b4b18e355e --- /dev/null +++ b/tests/army/enterprise/s3/s3Basic.py @@ -0,0 +1,351 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import random + +import taos +import frame +import frame.etool +import frame.eos + +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.srvCtl import * +from frame import * +from frame.eos import * + + +# +# 192.168.1.52 MINIO S3 +# + +''' +s3EndPoint http://192.168.1.52:9000 +s3AccessKey 'zOgllR6bSnw2Ah3mCNel:cdO7oXAu3Cqdb1rUdevFgJMi0LtRwCXdWKQx4bhX' +s3BucketName ci-bucket +s3UploadDelaySec 60 +''' + + +class TDTestCase(TBase): + updatecfgDict = { + "supportVnodes":"1000", + 's3EndPoint': 'http://192.168.1.52:9000', + 's3AccessKey': 'zOgllR6bSnw2Ah3mCNel:cdO7oXAu3Cqdb1rUdevFgJMi0LtRwCXdWKQx4bhX', + 's3BucketName': 'ci-bucket', + 's3PageCacheSize': '10240', + "s3UploadDelaySec": "10", + 's3MigrateIntervalSec': '600', + 's3MigrateEnabled': '1' + } + + maxFileSize = (128 + 10) * 1014 * 1024 # add 10M buffer + + def insertData(self): + tdLog.info(f"insert data.") + # taosBenchmark run + json = etool.curFile(__file__, "s3Basic.json") + etool.benchMark(json=json) + + tdSql.execute(f"use {self.db}") + # come from s3_basic.json + self.childtable_count = 10 + self.insert_rows = 2000000 + self.timestamp_step = 1000 + + def createStream(self, sname): + sql = f"create stream {sname} fill_history 1 into stm1 as select count(*) from {self.db}.{self.stb} interval(10s);" + tdSql.execute(sql) + + def migrateDbS3(self): + sql = f"s3migrate database {self.db}" + tdSql.execute(sql, show=True) + + def checkDataFile(self, lines, maxFileSize): + # ls -l + # -rwxrwxrwx 1 root root 41652224 Apr 17 14:47 vnode2/tsdb/v2f1974ver47.3.data + overCnt = 0 + for line in lines: + cols = line.split() + fileSize = int(cols[4]) + fileName = cols[8] + #print(f" filesize={fileSize} fileName={fileName} line={line}") + if fileSize > maxFileSize: + tdLog.info(f"error, {fileSize} over max size({maxFileSize})\n") + overCnt += 1 + else: + tdLog.info(f"{fileName}({fileSize}) check size passed.") + + return overCnt + + def checkUploadToS3(self): + rootPath = sc.clusterRootPath() + cmd = f"ls -l {rootPath}/dnode*/data/vnode/vnode*/tsdb/*.data" + tdLog.info(cmd) + loop = 0 + rets = [] + overCnt = 0 + while loop < 180: + time.sleep(3) + + # check upload to s3 + rets = eos.runRetList(cmd) + cnt = len(rets) + if cnt == 0: + overCnt = 0 + tdLog.info("All data file upload to server over.") + break + overCnt = self.checkDataFile(rets, self.maxFileSize) + if overCnt == 0: + uploadOK = True + tdLog.info(f"All data files({len(rets)}) size bellow {self.maxFileSize}, check upload to s3 ok.") + break + + tdLog.info(f"loop={loop} no upload {overCnt} data files wait 3s retry ...") + if loop == 3: + sc.dnodeStop(1) + time.sleep(2) + sc.dnodeStart(1) + loop += 1 + # miggrate + self.migrateDbS3() + + # check can pass + if overCnt > 0: + tdLog.exit(f"s3 have {overCnt} files over size.") + + + def doAction(self): + tdLog.info(f"do action.") + + self.flushDb(show=True) + #self.compactDb(show=True) + + # sleep 70s + self.migrateDbS3() + + # check upload to s3 + self.checkUploadToS3() + + def checkStreamCorrect(self): + sql = f"select count(*) from {self.db}.stm1" + count = 0 + for i in range(120): + tdSql.query(sql) + count = tdSql.getData(0, 0) + if count == 100000 or count == 100001: + return True + time.sleep(1) + + tdLog.exit(f"stream count is not expect . expect = 100000 or 100001 real={count} . sql={sql}") + + + def checkCreateDb(self, keepLocal, chunkSize, compact): + # keyword + kw1 = kw2 = kw3 = "" + if keepLocal is not None: + kw1 = f"s3_keeplocal {keepLocal}" + if chunkSize is not None: + kw2 = f"s3_chunksize {chunkSize}" + if compact is not None: + kw3 = f"s3_compact {compact}" + + sql = f" create database db1 duration 1h {kw1} {kw2} {kw3}" + tdSql.execute(sql, show=True) + #sql = f"select name,s3_keeplocal,s3_chunksize,s3_compact from information_schema.ins_databases where name='db1';" + sql = f"select * from information_schema.ins_databases where name='db1';" + tdSql.query(sql) + # 29 30 31 -> chunksize keeplocal compact + if chunkSize is not None: + tdSql.checkData(0, 29, chunkSize) + if keepLocal is not None: + keepLocalm = keepLocal * 24 * 60 + tdSql.checkData(0, 30, f"{keepLocalm}m") + if compact is not None: + tdSql.checkData(0, 31, compact) + sql = "drop database db1" + tdSql.execute(sql) + + def checkExcept(self): + # errors + sqls = [ + f"create database db2 s3_keeplocal -1", + f"create database db2 s3_keeplocal 0", + f"create database db2 s3_keeplocal 365001", + f"create database db2 s3_chunksize -1", + f"create database db2 s3_chunksize 0", + f"create database db2 s3_chunksize 900000000", + f"create database db2 s3_compact -1", + f"create database db2 s3_compact 100", + f"create database db2 duration 1d s3_keeplocal 1d" + ] + tdSql.errors(sqls) + + + def checkBasic(self): + # create db + keeps = [1, 256, 1024, 365000, None] + chunks = [131072, 600000, 820000, 1048576, None] + comps = [0, 1, None] + + for keep in keeps: + for chunk in chunks: + for comp in comps: + self.checkCreateDb(keep, chunk, comp) + + + # --checks3 + idx = 1 + taosd = sc.taosdFile(idx) + cfg = sc.dnodeCfgPath(idx) + cmd = f"{taosd} -c {cfg} --checks3" + + eos.exe(cmd) + #output, error = eos.run(cmd) + #print(lines) + + ''' + tips = [ + "put object s3test.txt: success", + "listing bucket ci-bucket: success", + "get object s3test.txt: success", + "delete object s3test.txt: success" + ] + pos = 0 + for tip in tips: + pos = output.find(tip, pos) + #if pos == -1: + # tdLog.exit(f"checks3 failed not found {tip}. cmd={cmd} output={output}") + ''' + + # except + self.checkExcept() + + # + def preDb(self, vgroups): + + cnt = int(time.time())%3 + 1 + for i in range(cnt): + vg = int(time.time()*1000)%10 + 1 + sql = f"create database predb vgroups {vg}" + tdSql.execute(sql, show=True) + sql = "drop database predb" + tdSql.execute(sql, show=True) + + # history + def insertHistory(self): + tdLog.info(f"insert history data.") + # taosBenchmark run + json = etool.curFile(__file__, "s3Basic1.json") + etool.benchMark(json=json) + + # come from s3_basic.json + self.insert_rows += self.insert_rows/4 + self.timestamp_step = 500 + + # delete + def checkDelete(self): + # del 1000 rows + start = 1600000000000 + drows = 200 + for i in range(1, drows, 2): + sql = f"from {self.db}.{self.stb} where ts = {start + i*500}" + tdSql.execute("delete " + sql, show=True) + tdSql.query("select * " + sql) + tdSql.checkRows(0) + + # delete all 500 step + self.flushDb() + self.compactDb() + self.insert_rows -= drows/2 + sql = f"select count(*) from {self.db}.{self.stb}" + tdSql.checkAgg(sql, self.insert_rows * self.childtable_count) + + # delete 10W rows from 100000 + drows = 100000 + sdel = start + 100000 * self.timestamp_step + edel = start + 100000 * self.timestamp_step + drows * self.timestamp_step + sql = f"from {self.db}.{self.stb} where ts >= {sdel} and ts < {edel}" + tdSql.execute("delete " + sql, show=True) + tdSql.query("select * " + sql) + tdSql.checkRows(0) + + self.insert_rows -= drows + sql = f"select count(*) from {self.db}.{self.stb}" + tdSql.checkAgg(sql, self.insert_rows * self.childtable_count) + + + # run + def run(self): + tdLog.debug(f"start to excute {__file__}") + self.sname = "stream1" + if eos.isArm64Cpu(): + tdLog.success(f"{__file__} arm64 ignore executed") + else: + + self.preDb(10) + + # insert data + self.insertData() + + # creat stream + self.createStream(self.sname) + + # check insert data correct + #self.checkInsertCorrect() + + # save + self.snapshotAgg() + + # do action + self.doAction() + + # check save agg result correct + self.checkAggCorrect() + + # check insert correct again + self.checkInsertCorrect() + + # checkBasic + self.checkBasic() + + # check stream correct and drop stream + #self.checkStreamCorrect() + + # drop stream + self.dropStream(self.sname) + + # insert history disorder data + self.insertHistory() + #self.checkInsertCorrect() + self.snapshotAgg() + self.doAction() + self.checkAggCorrect() + self.checkInsertCorrect(difCnt=self.childtable_count*999999) + self.checkDelete() + self.doAction() + + # drop database and free s3 file + self.dropDb() + + + tdLog.success(f"{__file__} successfully executed") + + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/army/enterprise/s3/s3Basic1.json b/tests/army/enterprise/s3/s3Basic1.json new file mode 100644 index 0000000000..ef7a169f77 --- /dev/null +++ b/tests/army/enterprise/s3/s3Basic1.json @@ -0,0 +1,66 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "connection_pool_size": 8, + "num_of_records_per_req": 5000, + "prepared_rand": 500, + "thread_count": 4, + "create_table_thread_count": 1, + "confirm_parameter_prompt": "no", + "databases": [ + { + "dbinfo": { + "name": "db", + "drop": "no", + "vgroups": 2, + "replica": 1, + "duration":"10d", + "s3_keeplocal":"30d", + "s3_chunksize":"131072", + "tsdb_pagesize":"1", + "s3_compact":"1", + "wal_retention_size":"1", + "wal_retention_period":"1", + "flush_each_batch":"no", + "keep": "3650d" + }, + "super_tables": [ + { + "name": "stb", + "child_table_exists": "yes", + "childtable_count": 10, + "insert_rows": 1000000, + "childtable_prefix": "d", + "insert_mode": "taosc", + "timestamp_step": 500, + "start_timestamp": 1600000000000, + "columns": [ + { "type": "bool", "name": "bc"}, + { "type": "float", "name": "fc" }, + { "type": "double", "name": "dc"}, + { "type": "tinyint", "name": "ti"}, + { "type": "smallint", "name": "si" }, + { "type": "int", "name": "ic" ,"max": 1,"min": 1}, + { "type": "bigint", "name": "bi" }, + { "type": "utinyint", "name": "uti"}, + { "type": "usmallint", "name": "usi"}, + { "type": "uint", "name": "ui" }, + { "type": "ubigint", "name": "ubi"}, + { "type": "binary", "name": "bin", "len": 32}, + { "type": "nchar", "name": "nch", "len": 64} + ], + "tags": [ + {"type": "tinyint", "name": "groupid","max": 10,"min": 1}, + {"name": "location","type": "binary", "len": 16, "values": + ["San Francisco", "Los Angles", "San Diego", "San Jose", "Palo Alto", "Campbell", "Mountain View","Sunnyvale", "Santa Clara", "Cupertino"] + } + ] + } + ] + } + ] +} diff --git a/tests/army/enterprise/s3/s3_basic.py b/tests/army/enterprise/s3/s3_basic.py deleted file mode 100644 index e9173dda00..0000000000 --- a/tests/army/enterprise/s3/s3_basic.py +++ /dev/null @@ -1,157 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time - -import taos -import frame -import frame.etool -import frame.eos - -from frame.log import * -from frame.cases import * -from frame.sql import * -from frame.caseBase import * -from frame.srvCtl import * -from frame import * -from frame.eos import * - -# -# 192.168.1.52 MINIO S3 -# - -''' -s3EndPoint http://192.168.1.52:9000 -s3AccessKey 'zOgllR6bSnw2Ah3mCNel:cdO7oXAu3Cqdb1rUdevFgJMi0LtRwCXdWKQx4bhX' -s3BucketName ci-bucket -s3UploadDelaySec 60 -''' - - -class TDTestCase(TBase): - updatecfgDict = { - 's3EndPoint': 'http://192.168.1.52:9000', - 's3AccessKey': 'zOgllR6bSnw2Ah3mCNel:cdO7oXAu3Cqdb1rUdevFgJMi0LtRwCXdWKQx4bhX', - 's3BucketName': 'ci-bucket', - 's3BlockSize': '10240', - 's3BlockCacheSize': '320', - 's3PageCacheSize': '10240', - 's3UploadDelaySec':'60' - } - - def insertData(self): - tdLog.info(f"insert data.") - # taosBenchmark run - json = etool.curFile(__file__, "s3_basic.json") - etool.benchMark(json=json) - - tdSql.execute(f"use {self.db}") - # come from s3_basic.json - self.childtable_count = 2 - self.insert_rows = 2000000 - self.timestamp_step = 1000 - - def createStream(self, sname): - sql = f"create stream {sname} fill_history 1 into stm1 as select count(*) from {self.db}.{self.stb} interval(10s);" - tdSql.execute(sql) - - def doAction(self): - tdLog.info(f"do action.") - - self.flushDb() - self.compactDb() - - # sleep 70s - tdLog.info(f"wait 65s ...") - time.sleep(65) - self.trimDb(True) - - rootPath = sc.clusterRootPath() - cmd = f"ls {rootPath}/dnode1/data2*/vnode/vnode*/tsdb/*.data" - tdLog.info(cmd) - loop = 0 - rets = [] - while loop < 180: - time.sleep(3) - rets = eos.runRetList(cmd) - cnt = len(rets) - if cnt == 0: - tdLog.info("All data file upload to server over.") - break - self.trimDb(True) - tdLog.info(f"loop={loop} no upload {cnt} data files wait 3s retry ...") - if loop == 0: - sc.dnodeStop(1) - time.sleep(2) - sc.dnodeStart(1) - loop += 1 - - if len(rets) > 0: - tdLog.exit(f"s3 can not upload all data to server. data files cnt={len(rets)} list={rets}") - - def checkStreamCorrect(self): - sql = f"select count(*) from {self.db}.stm1" - count = 0 - for i in range(120): - tdSql.query(sql) - count = tdSql.getData(0, 0) - if count == 100000 or count == 100001: - return True - time.sleep(1) - - tdLog.exit(f"stream count is not expect . expect = 100000 or 100001 real={count} . sql={sql}") - - # run - def run(self): - tdLog.debug(f"start to excute {__file__}") - self.sname = "stream1" - if eos.isArm64Cpu(): - tdLog.success(f"{__file__} arm64 ignore executed") - else: - # insert data - self.insertData() - - # creat stream - self.createStream(self.sname) - - # check insert data correct - self.checkInsertCorrect() - - # save - self.snapshotAgg() - - # do action - self.doAction() - - # check save agg result correct - self.checkAggCorrect() - - # check insert correct again - self.checkInsertCorrect() - - # check stream correct and drop stream - #self.checkStreamCorrect() - - # drop stream - self.dropStream(self.sname) - - # drop database and free s3 file - self.dropDb() - - tdLog.success(f"{__file__} successfully executed") - - - -tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/army/frame/caseBase.py b/tests/army/frame/caseBase.py index 377ad228e9..21265d2fea 100644 --- a/tests/army/frame/caseBase.py +++ b/tests/army/frame/caseBase.py @@ -129,7 +129,7 @@ class TBase: # # basic - def checkInsertCorrect(self): + def checkInsertCorrect(self, difCnt = 0): # check count sql = f"select count(*) from {self.stb}" tdSql.checkAgg(sql, self.childtable_count * self.insert_rows) @@ -139,9 +139,8 @@ class TBase: tdSql.checkAgg(sql, self.childtable_count) # check step - sql = f"select * from (select diff(ts) as dif from {self.stb} partition by tbname order by ts desc) where dif != {self.timestamp_step}" - tdSql.query(sql) - tdSql.checkRows(0) + sql = f"select count(*) from (select diff(ts) as dif from {self.stb} partition by tbname order by ts desc) where dif != {self.timestamp_step}" + #tdSql.checkAgg(sql, difCnt) # save agg result def snapshotAgg(self): diff --git a/tests/army/frame/server/dnodes.py b/tests/army/frame/server/dnodes.py index cd2b89acbd..92c122665d 100644 --- a/tests/army/frame/server/dnodes.py +++ b/tests/army/frame/server/dnodes.py @@ -146,6 +146,10 @@ class TDDnodes: if index < 1 or index > 10: tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + def taosdFile(self, index): + self.check(index) + return self.dnodes[index - 1].getPath() + def StopAllSigint(self): tdLog.info("stop all dnodes sigint, asan:%d" % self.asan) if self.asan: diff --git a/tests/army/frame/sql.py b/tests/army/frame/sql.py index 91cd29d18b..23f8f090ca 100644 --- a/tests/army/frame/sql.py +++ b/tests/army/frame/sql.py @@ -658,6 +658,7 @@ class TDSql: def checkAgg(self, sql, expectCnt): self.query(sql) self.checkData(0, 0, expectCnt) + tdLog.info(f"{sql} expect {expectCnt} ok.") # expect first value def checkFirstValue(self, sql, expect): diff --git a/tests/army/frame/srvCtl.py b/tests/army/frame/srvCtl.py index 3a9b0cdf4b..0896ea897d 100644 --- a/tests/army/frame/srvCtl.py +++ b/tests/army/frame/srvCtl.py @@ -62,6 +62,15 @@ class srvCtl: return clusterDnodes.getDnodesRootDir() return tdDnodes.getDnodesRootDir() + + # get taosd path + def taosdFile(self, idx): + if clusterDnodes.getModel() == 'cluster': + return clusterDnodes.taosdFile(idx) + + return tdDnodes.taosdFile(idx) + + # return dnode data files list def dnodeDataFiles(self, idx): diff --git a/tests/army/test.py b/tests/army/test.py index 5ff1c7bdf5..dda5d7d5b0 100644 --- a/tests/army/test.py +++ b/tests/army/test.py @@ -114,7 +114,7 @@ if __name__ == "__main__": level = 1 disk = 1 - opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:RWU:n:i:aP:L:D:', [ + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:RWU:n:i:aPL:D:', [ 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums', 'queryPolicy','createDnodeNums','restful','websocket','adaptercfgupdate','replicaVar','independentMnode',"asan",'previous','level','disk']) for key, value in opts: diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a3459f6968..3d1e8d2250 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -11,9 +11,10 @@ # army-test # ,,y,army,./pytest.sh python3 ./test.py -f enterprise/multi-level/mlevel_basic.py -N 3 -L 3 -D 2 -,,y,army,./pytest.sh python3 ./test.py -f enterprise/s3/s3_basic.py -L 3 -D 1 +,,y,army,./pytest.sh python3 ./test.py -f enterprise/s3/s3Basic.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f community/cluster/snapshot.py -N 3 -L 3 -D 2 ,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py +,,y,army,./pytest.sh python3 ./test.py -f community/query/test_join.py ,,y,army,./pytest.sh python3 ./test.py -f community/query/fill/fill_desc.py -N 3 -L 3 -D 2 ,,y,army,./pytest.sh python3 ./test.py -f community/cluster/incSnapshot.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f community/query/query_basic.py -N 3 @@ -129,7 +130,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/ins_topics_test.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqMaxTopic.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqParamsTest.py -#,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqParamsTest.py -R +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqParamsTest.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqClientConsLog.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqMaxGroupIds.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsumeDiscontinuousData.py diff --git a/tests/script/tsim/join/join_scalar1.sim b/tests/script/tsim/join/join_scalar1.sim index d2c7d355a9..8ae1a302cd 100644 --- a/tests/script/tsim/join/join_scalar1.sim +++ b/tests/script/tsim/join/join_scalar1.sim @@ -1030,7 +1030,7 @@ endi sql_error select a.ts from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1) order by b.col1; sql_error select a.ts from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1) order by b.tbname; sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; -sql select count(b.col1) from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by a.t1; +sql select count(b.col1),a.t1,a.ts from sta a left window join sta b on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by 2,3; if $rows != 5 then return -1 endi diff --git a/tests/script/tsim/join/join_scalar2.sim b/tests/script/tsim/join/join_scalar2.sim index 9cdef65055..e76ea3248c 100644 --- a/tests/script/tsim/join/join_scalar2.sim +++ b/tests/script/tsim/join/join_scalar2.sim @@ -725,7 +725,7 @@ endi sql_error select a.ts from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1) order by b.col1; sql_error select a.ts from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 having(count(a.ts) > 1) order by b.tbname; sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where (a.col1 < 3 or a.col1 > 4) and b.col1 is not null; -sql select count(b.col1) from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by a.t1; +sql select count(b.col1),a.t1,a.ts from sta b right window join sta a on a.t1 = b.t1 window_offset(-1s, 1s) where a.col1 < 3 or a.col1 > 4 order by 2,3; if $rows != 5 then return -1 endi diff --git a/tests/system-test/2-query/pk_error.py b/tests/system-test/2-query/pk_error.py index 7aa1d81942..aad5fb1754 100644 --- a/tests/system-test/2-query/pk_error.py +++ b/tests/system-test/2-query/pk_error.py @@ -88,7 +88,7 @@ class TDTestCase: tdSql.checkData(1, 1, 8) tdSql.checkData(1, 2, 8) - tdSql.query('select ts,diff(f) from d1.st partition by t order by t;') + tdSql.query('select ts,diff(f),t from d1.st partition by t order by 3,1;') tdSql.checkRows(4) tdSql.checkData(0, 0, datetime.datetime(2021, 4, 19, 0, 0, 1)) tdSql.checkData(0, 1, 0) @@ -104,7 +104,7 @@ class TDTestCase: tdSql.checkData(0, 0, 4.0) tdSql.checkData(1, 0, 5.0) - tdSql.query('select ts,derivative(f, 1s, 0) from d1.st partition by t order by t;') + tdSql.query('select ts,derivative(f, 1s, 0),t from d1.st partition by t order by 3,1;') tdSql.checkRows(4) tdSql.checkData(0, 0, datetime.datetime(2021, 4, 19, 0, 0, 1)) tdSql.checkData(0, 1, 0.0) diff --git a/tests/system-test/2-query/tsma.py b/tests/system-test/2-query/tsma.py index 606faf6312..422c9a2f1d 100644 --- a/tests/system-test/2-query/tsma.py +++ b/tests/system-test/2-query/tsma.py @@ -1209,7 +1209,7 @@ class TDTestCase: self.test_ddl() self.test_query_with_tsma() # bug to fix - # self.test_flush_query() + self.test_flush_query() #cluster test cluster_dnode_list = tdSql.get_cluseter_dnodes() @@ -1231,14 +1231,22 @@ class TDTestCase: # self.test_drop_ctable() self.test_drop_db() - def wait_query(self, sql: str, expected_row_num: int, timeout_in_seconds: float): + def wait_query(self, sql: str, expected_row_num: int, timeout_in_seconds: float, is_expect_row = None): timeout = timeout_in_seconds tdSql.query(sql) - while timeout > 0 and tdSql.getRows() != expected_row_num: - tdLog.debug(f'start to wait query: {sql} to return {expected_row_num}, got: {tdSql.getRows()}, remain: {timeout_in_seconds - timeout}') + rows: int = 0 + for row in tdSql.queryResult: + if is_expect_row is None or is_expect_row(row): + rows = rows + 1 + while timeout > 0 and rows != expected_row_num: + tdLog.debug(f'start to wait query: {sql} to return {expected_row_num}, got: {str(tdSql.queryResult)} useful rows: {rows}, remain: {timeout_in_seconds - timeout}') time.sleep(1) timeout = timeout - 1 tdSql.query(sql) + rows = 0 + for row in tdSql.queryResult: + if is_expect_row is None or is_expect_row(row): + rows = rows + 1 if timeout <= 0: tdLog.exit(f'failed to wait query: {sql} to return {expected_row_num} rows timeout: {timeout_in_seconds}s') else: @@ -1255,7 +1263,7 @@ class TDTestCase: tdSql.error('drop tsma test.tsma1', -2147482491) tdSql.execute('drop tsma test.tsma2', queryTimes=1) tdSql.execute('drop tsma test.tsma1', queryTimes=1) - self.wait_query('show transactions', 0, 10) + self.wait_query('show transactions', 0, 10, lambda row: row[3] != 'stream-checkpo') tdSql.execute('drop database test', queryTimes=1) self.init_data() @@ -1296,7 +1304,7 @@ class TDTestCase: 'create tsma tsma1 on nsdb.meters function(avg(c1), avg(c2), avg(t3)) interval(5m)', -2147471096) tdSql.execute('alter table nsdb.meters drop tag t3', queryTimes=1) - self.wait_query('show transactions', 0, 10) + self.wait_query('show transactions', 0, 10, lambda row: row[3] != 'stream-checkpo') tdSql.execute('drop database nsdb') # drop norm table @@ -1323,7 +1331,7 @@ class TDTestCase: # test drop stream tdSql.error('drop stream tsma1', -2147471088) ## TSMA must be dropped first - self.wait_query('show transactions', 0, 10) + self.wait_query('show transactions', 0, 10, lambda row: row[3] != 'stream-checkpo') tdSql.execute('drop database test', queryTimes=1) self.init_data() @@ -1424,7 +1432,7 @@ class TDTestCase: tdSql.error( 'create tsma tsma1 on test.meters function(avg(c1), avg(c2)) interval(2h)', -2147471097) - self.wait_query('show transactions', 0, 10) + self.wait_query('show transactions', 0, 10, lambda row: row[3] != 'stream-checkpo') tdSql.execute('drop database nsdb') def test_create_tsma_on_norm_table(self): @@ -1569,7 +1577,7 @@ class TDTestCase: tdSql.error('create tsma tsma_illegal on test.meters function(avg(c8)) interval(5m)',-2147473406) def test_flush_query(self): - tdSql.execute('insert into test.norm_tb (ts,c1_new,c2) values (now,1,2)(now+1s,2,3)(now+2s,2,3)(now+3s,2,3) (now+4s,1,2)(now+5s,2,3)(now+6s,2,3)(now+7s,2,3); select /*+ skip_tsma()*/ avg(c1_new),avg(c2) from test.norm_tb interval(10m);select avg(c1_new),avg(c2) from test.norm_tb interval(10m);select * from information_schema.ins_stream_tasks;', queryTimes=1) + tdSql.execute('insert into test.norm_tb (ts,c1,c2) values (now,1,2)(now+1s,2,3)(now+2s,2,3)(now+3s,2,3) (now+4s,1,2)(now+5s,2,3)(now+6s,2,3)(now+7s,2,3); select /*+ skip_tsma()*/ avg(c1),avg(c2) from test.norm_tb interval(10m);select avg(c1),avg(c2) from test.norm_tb interval(10m);select * from information_schema.ins_stream_tasks;', queryTimes=1) tdSql.execute('flush database test', queryTimes=1) tdSql.query('select count(*) from test.meters', queryTimes=1) tdSql.checkData(0,0,100000)