diff --git a/docs/en/12-taos-sql/03-table.md b/docs/en/12-taos-sql/03-table.md index a10abd28a5..5a884cc7e2 100644 --- a/docs/en/12-taos-sql/03-table.md +++ b/docs/en/12-taos-sql/03-table.md @@ -25,7 +25,7 @@ create_definition: col_name column_definition column_definition: - type_name [comment 'string_value'] + type_name [comment 'string_value'] [PRIMARY KEY] table_options: table_option ... @@ -41,11 +41,12 @@ table_option: { **More explanations** 1. The first column of a table MUST be of type TIMESTAMP. It is automatically set as the primary key. -2. The maximum length of the table name is 192 bytes. -3. The maximum length of each row is 48k(64k since version 3.0.5.0) bytes, please note that the extra 2 bytes used by each BINARY/NCHAR/GEOMETRY column are also counted. -4. The name of the subtable can only consist of characters from the English alphabet, digits and underscore. Table names can't start with a digit. Table names are case insensitive. -5. The maximum length in bytes must be specified when using BINARY/NCHAR/GEOMETRY types. -6. Escape character "\`" can be used to avoid the conflict between table names and reserved keywords, above rules will be bypassed when using escape character on table names, but the upper limit for the name length is still valid. The table names specified using escape character are case sensitive. +2. In addition to the timestamp primary key column, an additional primary key column can be specified using the `PRIMARY KEY` keyword. The second column specified as the primary key must be of type integer or string (varchar). +3. The maximum length of the table name is 192 bytes. +4. The maximum length of each row is 48k(64k since version 3.0.5.0) bytes, please note that the extra 2 bytes used by each BINARY/NCHAR/GEOMETRY column are also counted. +5. The name of the subtable can only consist of characters from the English alphabet, digits and underscore. Table names can't start with a digit. Table names are case insensitive. +6. The maximum length in bytes must be specified when using BINARY/NCHAR/GEOMETRY types. +7. Escape character "\`" can be used to avoid the conflict between table names and reserved keywords, above rules will be bypassed when using escape character on table names, but the upper limit for the name length is still valid. The table names specified using escape character are case sensitive. For example \`aBc\` and \`abc\` are different table names but `abc` and `aBc` are same table names because they are both converted to `abc` internally. Only ASCII visible characters can be used with escape character. @@ -107,6 +108,7 @@ You can perform the following modifications on existing tables: 2. DROP COLUMN: deletes a column from the supertable. 3. MODIFY COLUMN: changes the length of the data type specified for the column. Note that you can only specify a length greater than the current length. 4. RENAME COLUMN: renames a specified column in the table. +5. The primary key column of a table cannot be modified or added or deleted using ADD/DROP COLUMN. ### Add a Column diff --git a/docs/en/12-taos-sql/04-stable.md b/docs/en/12-taos-sql/04-stable.md index 66d93aed58..e0e21f4e82 100644 --- a/docs/en/12-taos-sql/04-stable.md +++ b/docs/en/12-taos-sql/04-stable.md @@ -147,6 +147,7 @@ Modifications to the table schema of a supertable take effect on all subtables w - DROP TAG: deletes a tag from the supertable. When you delete a tag from a supertable, it is automatically deleted from all subtables within the supertable. - MODIFY TAG: modifies the definition of a tag in the supertable. You can use this keyword to change the length of a BINARY or NCHAR tag column. Note that you can only specify a length greater than the current length. - RENAME TAG: renames a specified tag in the supertable. When you rename a tag in a supertable, it is automatically renamed in all subtables within the supertable. +- Like odinary tables, the primary key of a supertable cannot be modified or added or deleted using ADD/DROP COLUMN. ### Add a Column diff --git a/docs/en/12-taos-sql/05-insert.md b/docs/en/12-taos-sql/05-insert.md index 32227a2214..2f1bd97ac0 100644 --- a/docs/en/12-taos-sql/05-insert.md +++ b/docs/en/12-taos-sql/05-insert.md @@ -57,6 +57,7 @@ INSERT INTO ``` 6. However, an INSERT statement that writes data to multiple subtables can succeed for some tables and fail for others. This situation is caused because vnodes perform write operations independently of each other. One vnode failing to write data does not affect the ability of other vnodes to write successfully. +7. The primary key column value must be specified and cannot be NULL. **Normal Syntax** 1. The USING clause automatically creates the specified subtable if it does not exist. If it's unknown whether the table already exists, the table can be created automatically while inserting using the SQL statement below. To use this functionality, a STable must be used as template and tag values must be provided. Any tags that you do not specify will be assigned a null value. 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/07-tag-index.md b/docs/en/12-taos-sql/07-tag-index.md index 024d0ed574..54e68edbb9 100644 --- a/docs/en/12-taos-sql/07-tag-index.md +++ b/docs/en/12-taos-sql/07-tag-index.md @@ -34,6 +34,13 @@ SELECT * FROM information_schema.INS_INDEXES You can also add filter conditions to limit the results. + +````sql +SHOW INDEXES FROM tbl_name [FROM db_name]; +SHOW INDEXES FROM [db_name.]tbl_name ; +```` +Use `show indexes` commands to show indices that have been created for the specified database or table. + ## Detailed Specification 1. Indexes can improve query performance significantly if they are used properly. The operators supported by tag index include `=`, `>`, `>=`, `<`, `<=`. If you use these operators with tags, indexes can improve query performance significantly. However, for operators not in this scope, indexes don't help. More and more operators will be added in future. diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 07be7ae5ce..27dbbfcc08 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -503,38 +503,38 @@ TO_CHAR(ts, format_str_literal) **Supported Formats** -| **Format** | **Comment**| **example** | -| --- | --- | --- | -|AM,am,PM,pm| Meridiem indicator(without periods) | 07:00:00am| -|A.M.,a.m.,P.M.,p.m.| Meridiem indicator(with periods)| 07:00:00a.m.| -|YYYY,yyyy|year, 4 or more digits| 2023-10-10| -|YYY,yyy| year, last 3 digits| 023-10-10| -|YY,yy| year, last 2 digits| 23-10-10| -|Y,y| year, last digit| 3-10-10| -|MONTH|full uppercase of month| 2023-JANUARY-01| -|Month|full capitalized month| 2023-January-01| -|month|full lowercase of month| 2023-january-01| -|MON| abbreviated uppercase of month(3 char)| JAN, SEP| -|Mon| abbreviated capitalized month| Jan, Sep| -|mon|abbreviated lowercase of month| jan, sep| -|MM,mm|month number 01-12|2023-01-01| -|DD,dd|month day, 01-31|| -|DAY|full uppercase of week day|MONDAY| -|Day|full capitalized week day|Monday| -|day|full lowercase of week day|monday| -|DY|abbreviated uppercase of week day|MON| -|Dy|abbreviated capitalized week day|Mon| -|dy|abbreviated lowercase of week day|mon| -|DDD|year day, 001-366|| -|D,d|week day number, 1-7, Sunday(1) to Saturday(7)|| -|HH24,hh24|hour of day, 00-23|2023-01-30 23:59:59| -|hh12,HH12, hh, HH| hour of day, 01-12|2023-01-30 12:59:59PM| -|MI,mi|minute, 00-59|| -|SS,ss|second, 00-59|| -|MS,ms|milli second, 000-999|| -|US,us|micro second, 000000-999999|| -|NS,ns|nano second, 000000000-999999999|| -|TZH,tzh|time zone hour|2023-01-30 11:59:59PM +08| +| **Format** | **Comment** | **example** | +| ------------------- | ---------------------------------------------- | ------------------------- | +| AM,am,PM,pm | Meridiem indicator(without periods) | 07:00:00am | +| A.M.,a.m.,P.M.,p.m. | Meridiem indicator(with periods) | 07:00:00a.m. | +| YYYY,yyyy | year, 4 or more digits | 2023-10-10 | +| YYY,yyy | year, last 3 digits | 023-10-10 | +| YY,yy | year, last 2 digits | 23-10-10 | +| Y,y | year, last digit | 3-10-10 | +| MONTH | full uppercase of month | 2023-JANUARY-01 | +| Month | full capitalized month | 2023-January-01 | +| month | full lowercase of month | 2023-january-01 | +| MON | abbreviated uppercase of month(3 char) | JAN, SEP | +| Mon | abbreviated capitalized month | Jan, Sep | +| mon | abbreviated lowercase of month | jan, sep | +| MM,mm | month number 01-12 | 2023-01-01 | +| DD,dd | month day, 01-31 | | +| DAY | full uppercase of week day | MONDAY | +| Day | full capitalized week day | Monday | +| day | full lowercase of week day | monday | +| DY | abbreviated uppercase of week day | MON | +| Dy | abbreviated capitalized week day | Mon | +| dy | abbreviated lowercase of week day | mon | +| DDD | year day, 001-366 | | +| D,d | week day number, 1-7, Sunday(1) to Saturday(7) | | +| HH24,hh24 | hour of day, 00-23 | 2023-01-30 23:59:59 | +| hh12,HH12, hh, HH | hour of day, 01-12 | 2023-01-30 12:59:59PM | +| MI,mi | minute, 00-59 | | +| SS,ss | second, 00-59 | | +| MS,ms | milli second, 000-999 | | +| US,us | micro second, 000000-999999 | | +| NS,ns | nano second, 000000000-999999999 | | +| TZH,tzh | time zone hour | 2023-01-30 11:59:59PM +08 | **More explanations**: - The output format of `Month`, `Day` are left aligined, like`2023-OCTOBER -01`, `2023-SEPTEMBER-01`, `September` is the longest, no paddings. Week days are slimilar. @@ -955,6 +955,7 @@ FIRST(expr) - FIRST(\*) can be used to get the first non-null value of all columns; When querying a super table and multiResultFunctionStarReturnTags is set to 0 (default), FIRST(\*) only returns columns of super table; When set to 1, returns columns and tags of the super table. - NULL will be returned if all the values of the specified column are all NULL - A result will NOT be returned if all the columns in the result set are all NULL +- For a table with composite primary key, the data with the smallest primary key value is returned. ### INTERP @@ -988,6 +989,7 @@ ignore_null_values: { - `INTERP` can be applied to supertable by interpolating primary key sorted data of all its childtables. It can also be used with `partition by tbname` when applied to supertable to generate interpolation on each single timeline. - Pseudocolumn `_irowts` can be used along with `INTERP` to return the timestamps associated with interpolation points(support after version 3.0.2.0). - Pseudocolumn `_isfilled` can be used along with `INTERP` to indicate whether the results are original records or data points generated by interpolation algorithm(support after version 3.0.3.0). +- For a table with composite primary key, onley the data with the smallest primary key value is used to generate interpolation. **Example** @@ -1017,6 +1019,7 @@ LAST(expr) - LAST(\*) can be used to get the last non-NULL value of all columns; When querying a super table and multiResultFunctionStarReturnTags is set to 0 (default), LAST(\*) only returns columns of super table; When set to 1, returns columns and tags of the super table. - If the values of a column in the result set are all NULL, NULL is returned for that column; if all columns in the result are all NULL, no result will be returned. - When it's used on a STable, if there are multiple values with the timestamp in the result set, one of them will be returned randomly and it's not guaranteed that the same value is returned if the same query is run multiple times. +- For a table with composite primary key, the data with the largest primary key value is returned. ### LAST_ROW @@ -1038,6 +1041,7 @@ LAST_ROW(expr) - LAST_ROW(\*) can be used to get the last value of all columns; When querying a super table and multiResultFunctionStarReturnTags is set to 0 (default), LAST_ROW(\*) only returns columns of super table; When set to 1, returns columns and tags of the super table. - When it's used on a STable, if there are multiple values with the timestamp in the result set, one of them will be returned randomly and it's not guaranteed that the same value is returned if the same query is run multiple times. - Can't be used with `INTERVAL`. +- Like `LAST`, the data with the largest primary key value is returned for a table with composite primary key. ### MAX @@ -1144,7 +1148,7 @@ TOP(expr, k) UNIQUE(expr) ``` -**Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword. +**Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword. For a table with composite primary key, only the data with the smallest primary key value is returned. **Return value type**:Same as the data type of the column being operated upon @@ -1190,7 +1194,7 @@ ignore_negative: { } ``` -**Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored. +**Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored. For tables with composite primary key, the data with the smallest primary key value is used to calculate the derivative. **Return value type**: DOUBLE @@ -1213,7 +1217,7 @@ ignore_negative: { } ``` -**Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. +**Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored. For tables with composite primary key, the data with the smallest primary key value is used to calculate the difference. **Return value type**:Same as the data type of the column being operated upon @@ -1233,7 +1237,7 @@ ignore_negative: { IRATE(expr) ``` -**Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. +**Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. For tables with composite primary key, the data with the smallest primary key value is used to calculate the rate. **Return value type**: DOUBLE @@ -1323,7 +1327,7 @@ STATEDURATION(expr, oper, val, unit) TWA(expr) ``` -**Description**: Time weighted average on a specific column within a time range +**Description**: Time weighted average on a specific column within a time range. For tables with composite primary key, the data with the smallest primary key value is used to calculate the average. **Return value type**: DOUBLE diff --git a/docs/en/12-taos-sql/14-stream.md b/docs/en/12-taos-sql/14-stream.md index 337660a36c..3f93f69f0f 100644 --- a/docs/en/12-taos-sql/14-stream.md +++ b/docs/en/12-taos-sql/14-stream.md @@ -11,13 +11,14 @@ Because stream processing is built in to TDengine, you are no longer reliant on ## Create a Stream ```sql -CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name SUBTABLE(expression) AS subquery +CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name[(field1_name, field2_name [PRIMARY KEY], ...)] [TAGS (create_definition [, create_definition] ...)] SUBTABLE(expression) AS subquery stream_options: { TRIGGER [AT_ONCE | WINDOW_CLOSE | MAX_DELAY time] WATERMARK time IGNORE EXPIRED [0|1] DELETE_MARK time FILL_HISTORY [0|1] + IGNORE UPDATE [0|1] } ``` @@ -32,7 +33,7 @@ subquery: SELECT [DISTINCT] select_list [window_clause] ``` -Session windows, state windows, and sliding windows are supported. When you configure a session or state window for a supertable, you must use PARTITION BY TBNAME. +Session windows, state windows, and sliding windows are supported. When you configure a session or state window for a supertable, you must use PARTITION BY TBNAME. If the source table has a composite primary key, state windows, event windows, and count windows are not supported. Subtable Clause defines the naming rules of auto-created subtable, you can see more details in below part: Partitions of Stream. diff --git a/docs/en/12-taos-sql/27-indexing.md b/docs/en/12-taos-sql/27-indexing.md index 1badd38d17..dfe3ef527c 100644 --- a/docs/en/12-taos-sql/27-indexing.md +++ b/docs/en/12-taos-sql/27-indexing.md @@ -1,65 +1,134 @@ --- -title: Indexing -sidebar_label: Indexing -description: This document describes the SQL statements related to indexing in TDengine. +sidebar_label: Window Pre-Aggregation +title: Window Pre-Aggregation +description: Instructions for using Window Pre-Aggregation --- -TDengine supports SMA and tag indexing. +To improve the performance of aggregate function queries on large datasets, you can create Time-Range Small Materialized Aggregates (TSMA) objects. These objects perform pre-computation on specified aggregate functions using fixed time windows and store the computed results. When querying, you can retrieve the pre-computed results to enhance query performance. -## Create an Index +## Creating TSMA ```sql -CREATE INDEX index_name ON tb_name (col_name [, col_name] ...) +-- Create TSMA based on a super table or regular table +CREATE TSMA tsma_name ON [dbname.]table_name FUNCTION (func_name(func_param) [, ...] ) INTERVAL(time_duration); +-- Create a large window TSMA based on a small window TSMA +CREATE RECURSIVE TSMA tsma_name ON [db_name.]tsma_name1 INTERVAL(time_duration); -CREATE SMA INDEX index_name ON tb_name index_option - -index_option: - FUNCTION(functions) INTERVAL(interval_val [, interval_offset]) [SLIDING(sliding_val)] [WATERMARK(watermark_val)] [MAX_DELAY(max_delay_val)] - -functions: - function [, function] ... +time_duration: + number unit ``` -### tag Indexing - [tag index](../tag-index) +To create a TSMA, you need to specify the TSMA name, table name, function list, and window size. When creating a TSMA based on an existing TSMA, using the `RECURSIVE` keyword, you don't need to specify the `FUNCTION()`. It will create a TSMA with the same function list as the existing TSMA, and the INTERVAL must be a multiple of the window of the base TSMA. -### SMA Indexing +The naming rule for TSMA is similar to the table name, with a maximum length of the table name length minus the length of the output table suffix. The table name length limit is 193, and the output table suffix is `_tsma_res_stb_`. The maximum length of the TSMA name is 178. -Performs pre-aggregation on the specified column over the time window defined by the INTERVAL clause. The type is specified in functions_string. SMA indexing improves aggregate query performance for the specified time period. One supertable can only contain one SMA index. +TSMA can only be created based on super tables and regular tables, not on subtables. -- The max, min, and sum functions are supported. -- WATERMARK: Enter a value between 0ms and 900000ms. The most precise unit supported is milliseconds. The default value is 5 seconds. This option can be used only on supertables. -- MAX_DELAY: Enter a value between 1ms and 900000ms. The most precise unit supported is milliseconds. The default value is the value of interval provided that it does not exceed 900000ms. This option can be used only on supertables. Note: Retain the default value if possible. Configuring a small MAX_DELAY may cause results to be frequently pushed, affecting storage and query performance. +In the function list, you can only specify supported aggregate functions (see below), and the number of function parameters must be 1, even if the current function supports multiple parameters. The function parameters must be ordinary column names, not tag columns. Duplicate functions and columns in the function list will be deduplicated. When calculating TSMA, all `intermediate results of the functions` will be output to another super table, and the output super table also includes all tag columns of the original table. The maximum number of functions in the function list is the maximum number of columns in the output table (including tag columns) minus the four additional columns added for TSMA calculation, namely `_wstart`, `_wend`, `_wduration`, and a new tag column `tbname`, minus the number of tag columns in the original table. If the number of columns exceeds the limit, an error `Too many columns` will be reported. + +Since the output of TSMA is a super table, the row length of the output table is subject to the maximum row length limit. The size of the `intermediate results of different functions` varies, but they are generally larger than the original data size. If the row length of the output table exceeds the maximum row length limit, an error `Row length exceeds max length` will be reported. In this case, you need to reduce the number of functions or split commonly used functions groups into multiple TSMA objects. + +The window size is limited to [1ms ~ 1h]. The unit of INTERVAL is the same as the INTERVAL clause in the query, such as a (milliseconds), b (nanoseconds), h (hours), m (minutes), s (seconds), u (microseconds). + +TSMA is a database-level object, but it is globally unique. The number of TSMA that can be created in the cluster is limited by the parameter `maxTsmaNum`, with a default value of 8 and a range of [0-12]. Note that since TSMA background calculation uses stream computing, creating a TSMA will create a stream. Therefore, the number of TSMA that can be created is also limited by the number of existing streams and the maximum number of streams that can be created. + +## Supported Functions +| function | comments | +|---|---| +|min|| +|max|| +|sum|| +|first|| +|last|| +|avg|| +|count| If you want to use count(*), you should create the count(ts) function| +|spread|| +|stddev|| +|hyperloglog|| +||| + +## Drop TSMA +```sql +DROP TSMA [db_name.]tsma_name; +``` + +If there are other TSMA created based on the TSMA being deleted, the delete operation will report an `Invalid drop base tsma, drop recursive tsma first` error. Therefore, all Recursive TSMA must be deleted first. + +## TSMA Calculation +The calculation result of TSMA is a super table in the same database as the original table, but it is not visible to users. It cannot be deleted and will be automatically deleted when `DROP TSMA` is executed. The calculation of TSMA is done through stream computing, which is a background asynchronous process. The calculation result of TSMA is not guaranteed to be real-time, but it can guarantee eventual correctness. + +When there is a large amount of historical data, after creating TSMA, the stream computing will first calculate the historical data. During this period, newly created TSMA will not be used. The calculation will be automatically recalculated when data updates, deletions, or expired data arrive. During the recalculation period, the TSMA query results are not guaranteed to be real-time. If you want to query real-time data, you can use the hint `/*+ skip_tsma() */` in the SQL statement or disable the `querySmaOptimize` parameter to query from the original data. + +## Using and Limitations of TSMA + +Client configuration parameter: `querySmaOptimize`, used to control whether to use TSMA during queries. Set it to `True` to use TSMA, and `False` to query from the original data. + +Client configuration parameter: `maxTsmaCalcDelay`, in seconds, is used to control the acceptable TSMA calculation delay for users. If the calculation progress of a TSMA is within this range from the latest time, the TSMA will be used. If it exceeds this range, it will not be used. The default value is 600 (10 minutes), with a minimum value of 600 (10 minutes) and a maximum value of 86400 (1 day). + +### Using TSMA Duraing Query + +The aggregate functions defined in TSMA can be directly used in most query scenarios. If multiple TSMA are available, the one with the larger window size is preferred. For unclosed windows, the calculation can be done using smaller window TSMA or the original data. However, there are certain scenarios where TSMA cannot be used (see below). In such cases, the entire query will be calculated using the original data. + +The default behavior for queries without specified window sizes is to prioritize the use of the largest window TSMA that includes all the aggregate functions used in the query. For example, `SELECT COUNT(*) FROM stable GROUP BY tbname` will use the TSMA with the largest window that includes the `count(ts)` function. Therefore, when using aggregate queries frequently, it is recommended to create TSMA objects with larger window size. + +When specifying the window size, which is the `INTERVAL` statement, use the largest TSMA window that is divisible by the window size of the query. In window queries, the window size of the `INTERVAL`, `OFFSET`, and `SLIDING` all affect the TSMA window size that can be used. Divisible window TSMA refers to a TSMA window size that is divisible by the `INTERVAL`, `OFFSET`, and `SLIDING` of the query statement. Therefore, when using window queries frequently, consider the window size, as well as the offset and sliding size when creating TSMA objects. + +Example 1. If TSMA with window size of `5m` and `10m` is created, and the query is `INTERVAL(30m)`, the TSMA with window size of `10m` will be used. If the query is `INTERVAL(30m, 10m) SLIDING(5m)`, only the TSMA with window size of `5m` can be used for the query. + +### Limitations of Query + +When the parameter `querySmaOptimize` is enabled and there is no `skip_tsma()` hint, the following query scenarios cannot use TSMA: + +- When the aggregate functions defined in a TSMA do not cover the function list of the current query. +- Non-`INTERVAL` windows or the query window size (including `INTERVAL, SLIDING, OFFSET`) is not multiples of the defined window size. For example, if the defined window is 2m and the query uses a 5-minute window, but if there is a 1m window available, it can be used. +- Query with filtering on any regular column (non-primary key time column) in the `WHERE` condition. +- When `PARTITION` or `GROUP BY` includes any regular column or its expression +- When other faster optimization logic can be used, such as last cache optimization, if it meets the conditions for last optimization, it will be prioritized. If last optimization is not possible, then it will be determined whether TSMA optimization can be used. +- When the current TSMA calculation progress delay is greater than the configuration parameter `maxTsmaCalcDelay` + +Some examples: ```sql -DROP DATABASE IF EXISTS d0; -CREATE DATABASE d0; -USE d0; -CREATE TABLE IF NOT EXISTS st1 (ts timestamp, c1 int, c2 float, c3 double) TAGS (t1 int unsigned); -CREATE TABLE ct1 USING st1 TAGS(1000); -CREATE TABLE ct2 USING st1 TAGS(2000); -INSERT INTO ct1 VALUES(now+0s, 10, 2.0, 3.0); -INSERT INTO ct1 VALUES(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3); -CREATE SMA INDEX sma_index_name1 ON st1 FUNCTION(max(c1),max(c2),min(c1)) INTERVAL(5m,10s) SLIDING(5m) WATERMARK 5s MAX_DELAY 1m; --- query from SMA Index -ALTER LOCAL 'querySmaOptimize' '1'; -SELECT max(c2),min(c1) FROM st1 INTERVAL(5m,10s) SLIDING(5m); -SELECT _wstart,_wend,_wduration,max(c2),min(c1) FROM st1 INTERVAL(5m,10s) SLIDING(5m); --- query from raw data -ALTER LOCAL 'querySmaOptimize' '0'; +SELECT agg_func_list [, pesudo_col_list] FROM stable WHERE exprs [GROUP/PARTITION BY [tbname] [, tag_list]] [HAVING ...] [INTERVAL(time_duration, offset) SLIDING(duration)]...; + +-- create +CREATE TSMA tsma1 ON stable FUNCTION(COUNT(ts), SUM(c1), SUM(c3), MIN(c1), MIN(c3), AVG(c1)) INTERVAL(1m); +-- query +SELECT COUNT(*), SUM(c1) + SUM(c3) FROM stable; ---- use tsma1 +SELECT COUNT(*), AVG(c1) FROM stable GROUP/PARTITION BY tbname, tag1, tag2; --- use tsma1 +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(1h); ---use tsma1 +SELECT COUNT(*), MIN(c1), SPREAD(c1) FROM stable INTERVAL(1h); ----- can't use, spread func not defined, although SPREAD can be calculated by MIN and MAX which are defined. +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(30s); ----- can't use tsma1, time_duration not fit. Normally, query_time_duration should be multple of create_duration. +SELECT COUNT(*), MIN(c1) FROM stable where c2 > 0; ---- can't use tsma1, can't do c2 filtering +SELECT COUNT(*) FROM stable GROUP BY c2; ---- can't use any tsma +SELECT MIN(c3), MIN(c2) FROM stable INTERVAL(1m); ---- can't use tsma1, c2 is not defined in tsma1. + +-- Another tsma2 created with INTERVAL(1h) based on tsma1 +CREATE RECURSIVE TSMA tsma2 on tsma1 INTERVAL(1h); +SELECT COUNT(*), SUM(c1) FROM stable; ---- use tsma2 +SELECT COUNT(*), AVG(c1) FROM stable GROUP/PARTITION BY tbname, tag1, tag2; --- use tsma2 +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(2h); ---use tsma2 +SELECT COUNT(*), MIN(c1) FROM stable WHERE ts < '2023-01-01 10:10:10' INTERVAL(30m); --use tsma1 +SELECT COUNT(*), MIN(c1) + MIN(c3) FROM stable INTERVAL(30m); ---use tsma1 +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(1h) SLIDING(30m); ---use tsma1 +SELECT COUNT(*), MIN(c1), SPREAD(c1) FROM stable INTERVAL(1h); ----- can't use tsma1 or tsma2, spread func not defined +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(30s); ----- can't use tsma1 or tsma2, time_duration not fit. Normally, query_time_duration should be multple of create_duration. +SELECT COUNT(*), MIN(c1) FROM stable where c2 > 0; ---- can't use tsma1 or tsam2, can't do c2 filtering ``` -## Delete an Index +### Limitations of Usage + +After creating a TSMA, there are certain restrictions on operations that can be performed on the original table: + +- You must delete all TSMAs on the table before you can delete the table itself. +- All tag columns of the original table cannot be deleted, nor can the tag column names or sub-table tag values be modified. You must first delete the TSMA before you can delete the tag column. +- If some columns are being used by the TSMA, these columns cannot be deleted. You must first delete the TSMA. However, adding new columns to the table is not affected. However, new columns added are not included in any TSMA, so if you want to calculate the new columns, you need to create new TSMA for them. + +## Show TSMA ```sql -DROP INDEX index_name; +SHOW [db_name.]TSMAS; +SELECT * FROM information_schema.ins_tsma; ``` -## View Indices - -````sql -SHOW INDEXES FROM tbl_name [FROM db_name]; -SHOW INDEXES FROM [db_name.]tbl_name ; -```` - -Shows indices that have been created for the specified database or table. +If more functions are specified during creation, and the column names are longer, the function list may be truncated when displayed (currently supports a maximum output of 256KB) \ No newline at end of file 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..54dd8e2c6b --- /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/en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md index 0bdf143a60..1a9df366e3 100755 --- a/docs/en/14-reference/12-config/index.md +++ b/docs/en/14-reference/12-config/index.md @@ -241,6 +241,16 @@ Please note the `taoskeeper` needs to be installed and running to create the `lo | Default Value | 0 | | Notes | When this parameter is set to 0, last(\*)/last_row(\*)/first(\*) only returns the columns of the super table; When it is 1, return the columns and tags of the super table. | +### maxTsmaCalcDelay + +| Attribute | Description | +| -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | +| Applicable | Client only | +| Meaning | Query allowed tsma calculation delay, if the tsma calculation delay is greater than the configured value, the TSMA will not be used. | +| Value Range | 600s - 86400s, 10 minutes to 1 hour | +| Default value | 600s | + + ## Locale Parameters ### timezone @@ -760,6 +770,15 @@ The charset that takes effect is UTF-8. | Value Range | 1-10000| | Default Value | 20 | +### maxTsmaNum + +| Attribute | Description | +| --------- | ----------------------------- | +| Applicable | Server Only | +| Meaning | Max num of TSMAs | +| Value Range | 0-12 | +| Default Value | 8 | + ## 3.0 Parameters | # | **Parameter** | **Applicable to 2.x ** | **Applicable to 3.0 ** | Current behavior in 3.0 | diff --git a/docs/en/14-reference/13-schemaless/13-schemaless.md b/docs/en/14-reference/13-schemaless/13-schemaless.md index 4a259f100c..e28c56f9e1 100644 --- a/docs/en/14-reference/13-schemaless/13-schemaless.md +++ b/docs/en/14-reference/13-schemaless/13-schemaless.md @@ -27,6 +27,7 @@ where: - `tag_set` will be used as tags, with format like `=,=` Enter a space between `tag_set` and `field_set`. - `field_set`will be used as data columns, with format like `=,=` Enter a space between `field_set` and `timestamp`. - `timestamp` is the primary key timestamp corresponding to this row of data +- schemaless writing does not support writing data to tables with a second primary key column. All data in tag_set is automatically converted to the NCHAR data type and does not require double quotes ("). @@ -38,24 +39,24 @@ In the schemaless writing data line protocol, each data item in the field_set ne - If there are double quotes on both sides and a B/b prefix, it means VARBINARY type. Hexadecimal start with \x or string can be used in double quotes. For example `B"\x98f46e"` `B"hello"`. - Spaces, equals sign (=), comma (,), double quote ("), and backslash (\\) need to be escaped with a backslash (\\) in front. (All refer to the ASCII character). The rules are as follows: -| **Serial number** | **Element** | **Escape characters** | -| -------- | ----------- | ----------------------------- | -| 1 | Measurement | Comma, Space | -| 2 | Tag key | Comma, Equals Sign, Space | -| 3 | Tag value | Comma, Equals Sign, Space | -| 4 | Field key | Comma, Equals Sign, Space | -| 5 | Field value | Double quote, Backslash | +| **Serial number** | **Element** | **Escape characters** | +| ----------------- | ----------- | ------------------------- | +| 1 | Measurement | Comma, Space | +| 2 | Tag key | Comma, Equals Sign, Space | +| 3 | Tag value | Comma, Equals Sign, Space | +| 4 | Field key | Comma, Equals Sign, Space | +| 5 | Field value | Double quote, Backslash | With two contiguous backslashes, the first is interpreted as an escape character. Examples of backslash escape rules are as follows: -| **Serial number** | **Backslashes** | **Interpreted as** | -| -------- | ----------- | ----------------------------- | -| 1 | \ | \ | -| 2 | \\\\ | \ | -| 3 | \\\\\\ | \\\\ | -| 4 | \\\\\\\\ | \\\\ | -| 5 | \\\\\\\\\\ | \\\\\\ | -| 6 | \\\\\\\\\\\\ | \\\\\\ | +| **Serial number** | **Backslashes** | **Interpreted as** | +| ----------------- | --------------- | ------------------ | +| 1 | \ | \ | +| 2 | \\\\ | \ | +| 3 | \\\\\\ | \\\\ | +| 4 | \\\\\\\\ | \\\\ | +| 5 | \\\\\\\\\\ | \\\\\\ | +| 6 | \\\\\\\\\\\\ | \\\\\\ | - Numeric types will be distinguished from data types by the suffix. diff --git a/docs/en/21-tdinternal/08-compress.md b/docs/en/21-tdinternal/08-compress.md new file mode 100644 index 0000000000..a3b073c3a7 --- /dev/null +++ b/docs/en/21-tdinternal/08-compress.md @@ -0,0 +1,92 @@ + +--- + +title: Configurable Column Compression +description: Configurable column storage compression method +--- + +# Configurable Storage Compression + +Since TDengine 3.3.0.0, more advanced compression feature is introduced, you can specify compression or not, the compression method and compression level for each column. + +## Compression Terminology Definition + +### Compression Level Definition + +- Level 1 Compression: Encoding the data, which is essentially a form of compression +- Level 2 Compression: Compressing data blocks. + +### Compression Algorithm Level + +In this article, it specifically refers to the level within the secondary compression algorithm, such as zstd, at least 8 levels can be selected, each level has different performance, essentially it is a tradeoff between compression ratio, compression speed, and decompression speed. To avoid the difficulty of choice, it is simplified and defined as the following three levels: + +- high: The highest compression ratio, the worst compression speed and decompression speed. +- low: The best compression speed and decompression speed, the lowest compression ratio. +- medium: Balancing compression ratio, compression speed, and decompression speed. + +### Compression Algorithm List + +- Encoding algorithm list (Level 1 compression): simple8b, bit-packing, delta-i, delta-d, disabled + +- Compression algorithm list (Level 2 compression): lz4, zlib, zstd, tsz, xz, disabled + +- Default compression algorithm list and applicable range for each data type + +| Data Type | Optional Encoding Algorithm | Default Encoding Algorithm | Optional Compression Algorithm|Default Compression Algorithm| Default Compression Level| +| :-----------:|:----------:|:-------:|:-------:|:----------:|:----:| + tinyint/untinyint/smallint/usmallint/int/uint | simple8b| simple8b | lz4/zlib/zstd/xz| lz4 | medium| +| bigint/ubigint/timestamp | simple8b/delta-i | delta-i |lz4/zlib/zstd/xz | lz4| medium| +|float/double | delta-d|delta-d |lz4/zlib/zstd/xz/tsz|tsz| medium| +|binary/nchar| disabled| disabled|lz4/zlib/zstd/xz| lz4| medium| +|bool| bit-packing| bit-packing| lz4/zlib/zstd/xz| lz4| medium| + +Note: For floating point types, if configured as tsz, its precision is determined by the global configuration of taosd. If configured as tsz, but the lossy compression flag is not configured, lz4 is used for compression by default. + +## SQL + +### Create Table with Compression + +```sql +CREATE [dbname.]tabname (colName colType [ENCODE 'encode_type'] [COMPRESS 'compress_type' [LEVEL 'level'], [, other cerate_definition]...]) +``` + +**Parameter Description** + +- tabname: Super table or ordinary table name +- encode_type: Level 1 compression, specific parameters see the above list +- compress_type: Level 2 compression, specific parameters see the above list +- level: Specifically refers to the level of secondary compression, the default value is medium, supports abbreviation as 'h'/'l'/'m' + +**Function Description** + +- Specify the compression method for the column when creating a table + +### Change Compression Method + +```sql +ALTER TABLE [db_name.]tabName MODIFY COLUMN colName [ENCODE 'ecode_type'] [COMPRESS 'compress_type'] [LEVEL "high"] +``` + +**Parameter Description** + +- tabName: Table name, can be a super table or an ordinary table +- colName: The column to change the compression algorithm, can only be a normal column + +**Function Description** + +- Change the compression method of the column + +### View Compression Dethod + +```sql +DESCRIBE [dbname.]tabName +``` + +**Function Description** + +- Display basic information of the column, including type and compression method + +## Compatibility + +- Fully compatible with existing data +- Can't be rolled back once you upgrade to 3.3.0.0 diff --git a/docs/zh/12-taos-sql/03-table.md b/docs/zh/12-taos-sql/03-table.md index 7e20f20574..f0c2bd407b 100644 --- a/docs/zh/12-taos-sql/03-table.md +++ b/docs/zh/12-taos-sql/03-table.md @@ -23,7 +23,7 @@ create_subtable_clause: { } create_definition: - col_name column_type + col_name column_type [PRIMARY KEY] table_options: table_option ... @@ -38,12 +38,13 @@ table_option: { **使用说明** -1. 表的第一个字段必须是 TIMESTAMP,并且系统自动将其设为主键; -2. 表名最大长度为 192; -3. 表的每行长度不能超过 48KB(从 3.0.5.0 版本开始为 64KB);(注意:每个 BINARY/NCHAR/GEOMETRY 类型的列还会额外占用 2 个字节的存储位置) -4. 子表名只能由字母、数字和下划线组成,且不能以数字开头,不区分大小写 -5. 使用数据类型 BINARY/NCHAR/GEOMETRY,需指定其最长的字节数,如 BINARY(20),表示 20 字节; -6. 为了兼容支持更多形式的表名,TDengine 引入新的转义符 "\`",可以让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。但是同样具有长度限制要求。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 +1. 表的第一个字段必须是 TIMESTAMP,并且系统自动将其设为主键。 +2. 除时间戳主键列之外,还可以通过 PRIAMRY KEY 关键字指定第二列为额外的主键列。被指定为主键列的第二列必须为整型或字符串类型(varchar)。 +3. 表名最大长度为 192。 +4. 表的每行长度不能超过 48KB(从 3.0.5.0 版本开始为 64KB);(注意:每个 BINARY/NCHAR/GEOMETRY 类型的列还会额外占用 2 个字节的存储位置)。 +5. 子表名只能由字母、数字和下划线组成,且不能以数字开头,不区分大小写。 +6. 使用数据类型 BINARY/NCHAR/GEOMETRY,需指定其最长的字节数,如 BINARY(20),表示 20 字节。 +7. 为了兼容支持更多形式的表名,TDengine 引入新的转义符 "\`",可以让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。但是同样具有长度限制要求。使用转义字符以后,不再对转义字符中的内容进行大小写统一, 例如:\`aBc\` 和 \`abc\` 是不同的表名,但是 abc 和 aBc 是相同的表名。 **参数说明** @@ -106,6 +107,7 @@ alter_table_option: { 2. DROP COLUMN:删除列。 3. MODIFY COLUMN:修改列定义,如果数据列的类型是可变长类型,那么可以使用此指令修改其宽度,只能改大,不能改小。 4. RENAME COLUMN:修改列名称。 +5. 普通表的主键列不能被修改,也不能通过 ADD/DROP COLUMN 来添加/删除主键列。 ### 增加列 diff --git a/docs/zh/12-taos-sql/04-stable.md b/docs/zh/12-taos-sql/04-stable.md index 853d2bf981..923d7acdc6 100644 --- a/docs/zh/12-taos-sql/04-stable.md +++ b/docs/zh/12-taos-sql/04-stable.md @@ -148,6 +148,7 @@ alter_table_option: { - DROP TAG:删除超级表的一个标签。从超级表删除某个标签后,该超级表下的所有子表也会自动删除该标签。 - MODIFY TAG:修改超级表的一个标签的列宽度。标签的类型只能是 nchar 和 binary,使用此指令可以修改其宽度,只能改大,不能改小。 - RENAME TAG:修改超级表的一个标签的名称。从超级表修改某个标签名后,该超级表下的所有子表也会自动更新该标签名。 +- 与普通表一样,超级表的主键列不允许被修改,也不允许通过 ADD/DROP COLUMN 来添加或删除主键列。 ### 增加列 diff --git a/docs/zh/12-taos-sql/05-insert.md b/docs/zh/12-taos-sql/05-insert.md index fa330cabae..b2c34f4c55 100644 --- a/docs/zh/12-taos-sql/05-insert.md +++ b/docs/zh/12-taos-sql/05-insert.md @@ -57,6 +57,7 @@ INSERT INTO INSERT INTO d1001 USING meters TAGS('Beijing.Chaoyang', 2) VALUES('a'); ``` 6. 对于向多个子表插入数据的情况,依然会有部分数据写入失败,部分数据写入成功的情况。这是因为多个子表可能分布在不同的 VNODE 上,客户端将 INSERT 语句完整解析后,将数据发往各个涉及的 VNODE 上,每个 VNODE 独立进行写入操作。如果某个 VNODE 因为某些原因(比如网络问题或磁盘故障)导致写入失败,并不会影响其他 VNODE 节点的写入。 +7. 主键列值必须指定且不能为 NULL。 **正常语法说明** 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/07-tag-index.md b/docs/zh/12-taos-sql/07-tag-index.md index 0e5b3ba2fb..c016a5b513 100644 --- a/docs/zh/12-taos-sql/07-tag-index.md +++ b/docs/zh/12-taos-sql/07-tag-index.md @@ -34,6 +34,13 @@ SELECT * FROM information_schema.INS_INDEXES 也可以为上面的查询语句加上过滤条件以缩小查询范围。 +或者通过 SHOW 命令查看指定表上的索引 + +```sql +SHOW INDEXES FROM tbl_name [FROM db_name]; +SHOW INDEXES FROM [db_name.]tbl_name; +``` + ## 使用说明 1. 索引使用得当能够提升数据过滤的效率,目前支持的过滤算子有 `=`, `>`, `>=`, `<`, `<=`。如果查询过滤条件中使用了这些算子,则索引能够明显提升查询效率。但如果查询过滤条件中使用的是其它算子,则索引起不到作用,查询效率没有变化。未来会逐步添加更多的算子。 diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 71accc6322..6f4f9b3d84 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -503,38 +503,38 @@ TO_CHAR(ts, format_str_literal) **支持的格式** -| **格式** | **说明**| **例子** | -| --- | --- | --- | -|AM,am,PM,pm| 无点分隔的上午下午 | 07:00:00am| -|A.M.,a.m.,P.M.,p.m.| 有点分隔的上午下午| 07:00:00a.m.| -|YYYY,yyyy|年, 4个及以上数字| 2023-10-10| -|YYY,yyy| 年, 最后3位数字| 023-10-10| -|YY,yy| 年, 最后2位数字| 23-10-10| -|Y,y|年, 最后一位数字| 3-10-10| -|MONTH|月, 全大写| 2023-JANUARY-01| -|Month|月, 首字母大写| 2023-January-01| -|month|月, 全小写| 2023-january-01| -|MON| 月, 缩写, 全大写(三个字符)| JAN, SEP| -|Mon| 月, 缩写, 首字母大写| Jan, Sep| -|mon|月, 缩写, 全小写| jan, sep| -|MM,mm|月, 数字 01-12|2023-01-01| -|DD,dd|月日, 01-31|| -|DAY|周日, 全大写|MONDAY| -|Day|周日, 首字符大写|Monday| -|day|周日, 全小写|monday| -|DY|周日, 缩写, 全大写|MON| -|Dy|周日, 缩写, 首字符大写|Mon| -|dy|周日, 缩写, 全小写|mon| -|DDD|年日, 001-366|| -|D,d|周日, 数字, 1-7, Sunday(1) to Saturday(7)|| -|HH24,hh24|小时, 00-23|2023-01-30 23:59:59| -|hh12,HH12, hh, HH| 小时, 01-12|2023-01-30 12:59:59PM| -|MI,mi|分钟, 00-59|| -|SS,ss|秒, 00-59|| -|MS,ms|毫秒, 000-999|| -|US,us|微秒, 000000-999999|| -|NS,ns|纳秒, 000000000-999999999|| -|TZH,tzh|时区小时|2023-01-30 11:59:59PM +08| +| **格式** | **说明** | **例子** | +| ------------------- | ----------------------------------------- | ------------------------- | +| AM,am,PM,pm | 无点分隔的上午下午 | 07:00:00am | +| A.M.,a.m.,P.M.,p.m. | 有点分隔的上午下午 | 07:00:00a.m. | +| YYYY,yyyy | 年, 4个及以上数字 | 2023-10-10 | +| YYY,yyy | 年, 最后3位数字 | 023-10-10 | +| YY,yy | 年, 最后2位数字 | 23-10-10 | +| Y,y | 年, 最后一位数字 | 3-10-10 | +| MONTH | 月, 全大写 | 2023-JANUARY-01 | +| Month | 月, 首字母大写 | 2023-January-01 | +| month | 月, 全小写 | 2023-january-01 | +| MON | 月, 缩写, 全大写(三个字符) | JAN, SEP | +| Mon | 月, 缩写, 首字母大写 | Jan, Sep | +| mon | 月, 缩写, 全小写 | jan, sep | +| MM,mm | 月, 数字 01-12 | 2023-01-01 | +| DD,dd | 月日, 01-31 | | +| DAY | 周日, 全大写 | MONDAY | +| Day | 周日, 首字符大写 | Monday | +| day | 周日, 全小写 | monday | +| DY | 周日, 缩写, 全大写 | MON | +| Dy | 周日, 缩写, 首字符大写 | Mon | +| dy | 周日, 缩写, 全小写 | mon | +| DDD | 年日, 001-366 | | +| D,d | 周日, 数字, 1-7, Sunday(1) to Saturday(7) | | +| HH24,hh24 | 小时, 00-23 | 2023-01-30 23:59:59 | +| hh12,HH12, hh, HH | 小时, 01-12 | 2023-01-30 12:59:59PM | +| MI,mi | 分钟, 00-59 | | +| SS,ss | 秒, 00-59 | | +| MS,ms | 毫秒, 000-999 | | +| US,us | 微秒, 000000-999999 | | +| NS,ns | 纳秒, 000000000-999999999 | | +| TZH,tzh | 时区小时 | 2023-01-30 11:59:59PM +08 | **使用说明**: - `Month`, `Day`等的输出格式是左对齐的, 右侧添加空格, 如`2023-OCTOBER -01`, `2023-SEPTEMBER-01`, 9月是月份中英文字母数最长的, 因此9月没有空格. 星期类似. @@ -957,6 +957,7 @@ FIRST(expr) - 如果要返回各个列的首个(时间戳最小)非 NULL 值,可以使用 FIRST(\*);查询超级表,且multiResultFunctionStarReturnTags设置为 0 (默认值) 时,FIRST(\*)只返回超级表的普通列;设置为 1 时,返回超级表的普通列和标签列。 - 如果结果集中的某列全部为 NULL 值,则该列的返回结果也是 NULL; - 如果结果集中所有列全部为 NULL 值,则不返回结果。 +- 对于存在复合主键的表的查询,若最小时间戳的数据有多条,则只有对应的复合主键最小的数据被返回。 ### INTERP @@ -989,6 +990,7 @@ ignore_null_values: { - INTERP 作用于超级表时, 会将该超级表下的所有子表数据按照主键列排序后进行插值计算,也可以搭配 PARTITION BY tbname 使用,将结果强制规约到单个时间线。 - INTERP 可以与伪列 _irowts 一起使用,返回插值点所对应的时间戳(3.0.2.0版本以后支持)。 - INTERP 可以与伪列 _isfilled 一起使用,显示返回结果是否为原始记录或插值算法产生的数据(3.0.3.0版本以后支持)。 +- INTERP 对于带复合主键的表的查询,若存在相同时间戳的数据,则只有对应的复合主键最小的数据参与运算。 ### LAST @@ -1009,6 +1011,7 @@ LAST(expr) - 如果要返回各个列的最后(时间戳最大)一个非 NULL 值,可以使用 LAST(\*);查询超级表,且multiResultFunctionStarReturnTags设置为 0 (默认值) 时,LAST(\*)只返回超级表的普通列;设置为 1 时,返回超级表的普通列和标签列。 - 如果结果集中的某列全部为 NULL 值,则该列的返回结果也是 NULL;如果结果集中所有列全部为 NULL 值,则不返回结果。 - 在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。 +- 对于存在复合主键的表的查询,若最大时间戳的数据有多条,则只有对应的复合主键最大的数据被返回。 ### LAST_ROW @@ -1029,6 +1032,7 @@ LAST_ROW(expr) - 如果要返回各个列的最后一条记录(时间戳最大),可以使用 LAST_ROW(\*);查询超级表,且multiResultFunctionStarReturnTags设置为 0 (默认值) 时,LAST_ROW(\*)只返回超级表的普通列;设置为 1 时,返回超级表的普通列和标签列。 - 在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。 - 不能与 INTERVAL 一起使用。 +- 与 LAST 函数一样,对于存在复合主键的表的查询,若最大时间戳的数据有多条,则只有对应的复合主键最大的数据被返回。 ### MAX @@ -1135,7 +1139,7 @@ TOP(expr, k) UNIQUE(expr) ``` -**功能说明**:返回该列数据首次出现的值。该函数功能与 distinct 相似。 +**功能说明**:返回该列数据首次出现的值。该函数功能与 distinct 相似。对于存在复合主键的表的查询,若最小时间戳的数据有多条,则只有对应的复合主键最小的数据被返回。 **返回数据类型**:同应用的字段。 @@ -1181,7 +1185,7 @@ ignore_negative: { } ``` -**功能说明**:统计表中某列数值的单位变化率。其中单位时间区间的长度可以通过 time_interval 参数指定,最小可以是 1 秒(1s);ignore_negative 参数的值可以是 0 或 1,为 1 时表示忽略负值。 +**功能说明**:统计表中某列数值的单位变化率。其中单位时间区间的长度可以通过 time_interval 参数指定,最小可以是 1 秒(1s);ignore_negative 参数的值可以是 0 或 1,为 1 时表示忽略负值。对于存在复合主键的表的查询,若时间戳相同的数据存在多条,则只有对应的复合主键最小的数据参与运算。 **返回数据类型**:DOUBLE。 @@ -1204,7 +1208,7 @@ ignore_negative: { } ``` -**功能说明**:统计表中某列的值与前一行对应值的差。 ignore_negative 取值为 0|1 , 可以不填,默认值为 0. 不忽略负值。ignore_negative 为 1 时表示忽略负数。 +**功能说明**:统计表中某列的值与前一行对应值的差。 ignore_negative 取值为 0|1 , 可以不填,默认值为 0. 不忽略负值。ignore_negative 为 1 时表示忽略负数。对于你存在复合主键的表的查询,若时间戳相同的数据存在多条,则只有对应的复合主键最小的数据参与运算。 **返回数据类型**:同应用字段。 @@ -1224,7 +1228,7 @@ ignore_negative: { IRATE(expr) ``` -**功能说明**:计算瞬时增长率。使用时间区间中最后两个样本数据来计算瞬时增长速率;如果这两个值呈递减关系,那么只取最后一个数用于计算,而不是使用二者差值。 +**功能说明**:计算瞬时增长率。使用时间区间中最后两个样本数据来计算瞬时增长速率;如果这两个值呈递减关系,那么只取最后一个数用于计算,而不是使用二者差值。对于存在复合主键的表的查询,若时间戳相同的数据存在多条,则只有对应的复合主键最小的数据参与运算。 **返回数据类型**:DOUBLE。 @@ -1314,7 +1318,7 @@ STATEDURATION(expr, oper, val, unit) TWA(expr) ``` -**功能说明**:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。 +**功能说明**:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。对于存在复合主键的表的查询,若时间戳相同的数据存在多条,则只有对应的复合主键最小的数据参与运算。 **返回数据类型**:DOUBLE。 diff --git a/docs/zh/12-taos-sql/14-stream.md b/docs/zh/12-taos-sql/14-stream.md index 125f868758..5691716ce8 100644 --- a/docs/zh/12-taos-sql/14-stream.md +++ b/docs/zh/12-taos-sql/14-stream.md @@ -8,7 +8,7 @@ description: 流式计算的相关 SQL 的详细语法 ## 创建流式计算 ```sql -CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name[(field1_name, ...)] [TAGS (create_definition [, create_definition] ...)] SUBTABLE(expression) AS subquery +CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name[(field1_name, field2_name [PRIMARY KEY], ...)] [TAGS (create_definition [, create_definition] ...)] SUBTABLE(expression) AS subquery stream_options: { TRIGGER [AT_ONCE | WINDOW_CLOSE | MAX_DELAY time] WATERMARK time @@ -30,9 +30,9 @@ subquery: SELECT select_list [window_clause] ``` -支持会话窗口、状态窗口、滑动窗口、事件窗口和计数窗口,其中,状态窗口、事件窗口和计数窗口搭配超级表时必须与partition by tbname一起使用 +支持会话窗口、状态窗口、滑动窗口、事件窗口和计数窗口,其中,状态窗口、事件窗口和计数窗口搭配超级表时必须与partition by tbname一起使用。对于数据源表是复合主键的流,不支持状态窗口、事件窗口、计数窗口的计算。 -stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,会自动创建;如果已存在,则检查列的schema信息。详见 写入已存在的超级表 +stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,会自动创建;如果已存在,则检查列的schema信息。详见 写入已存在的超级表。 TAGS 子句定义了流计算中创建TAG的规则,可以为每个partition对应的子表生成自定义的TAG值,详见 自定义TAG ```sql diff --git a/docs/zh/12-taos-sql/27-indexing.md b/docs/zh/12-taos-sql/27-indexing.md index cf8cac1bed..31057a67f8 100644 --- a/docs/zh/12-taos-sql/27-indexing.md +++ b/docs/zh/12-taos-sql/27-indexing.md @@ -1,66 +1,132 @@ --- -sidebar_label: 索引 -title: 索引 -description: 索引功能的使用细节 +sidebar_label: 窗口预聚集 +title: 窗口预聚集 +description: 窗口预聚集使用说明 --- -TDengine 从 3.0.0.0 版本开始引入了索引功能,支持 SMA 索引和 tag 索引。 +为了提高大数据量的聚合函数查询性能,通过创建窗口预聚集 (TSMA Time-Range Small Materialized Aggregates) 对象, 使用固定时间窗口对指定的聚集函数进行预计算,并将计算结果存储下来,查询时通过查询预计算结果以提高查询性能。 -## 创建索引 +## 创建TSMA ```sql +-- 创建基于超级表或普通表的tsma +CREATE TSMA tsma_name ON [dbname.]table_name FUNCTION (func_name(func_param) [, ...] ) INTERVAL(time_duration); +-- 创建基于小窗口tsma的大窗口tsma +CREATE RECURSIVE TSMA tsma_name ON [db_name.]tsma_name1 INTERVAL(time_duration); -CREATE INDEX index_name ON tb_name index_option - -CREATE SMA INDEX index_name ON tb_name index_option - -index_option: - FUNCTION(functions) INTERVAL(interval_val [, interval_offset]) [SLIDING(sliding_val)] [WATERMARK(watermark_val)] [MAX_DELAY(max_delay_val)] - -functions: - function [, function] ... +time_duration: + number unit ``` -### tag 索引 - [tag 索引](../tag-index) +创建 TSMA 时需要指定 TSMA 名字, 表名字, 函数列表以及窗口大小. 当基于 TSMA 创建时 TSMA 时, 即使用 `RECURSIVE` 关键字, 不需要指定 `FUNCTION()`, 将创建与已有 TSMA 相同的函数列表的TSMA, 且 INTERVAL 必须为所基于的TSMA窗口的整数倍。 -### SMA 索引 +其中 TSMA 命名规则与表名字类似, 长度最大限制为表名长度限制减去输出表后缀长度, 表名长度限制为193, 输出表后缀为`_tsma_res_stb_`, TSMA 名字最大长度为178. -对指定列按 INTERVAL 子句定义的时间窗口创建进行预聚合计算,预聚合计算类型由 functions_string 指定。SMA 索引能提升指定时间段的聚合查询的性能。目前,限制一个超级表只能创建一个 SMA INDEX。 +TSMA只能基于超级表和普通表创建, 不能基于子表创建. -- 支持的函数包括 MAX、MIN 和 SUM。 -- WATERMARK: 最小单位毫秒,取值范围 [0ms, 900000ms],默认值为 5 秒,只可用于超级表。 -- MAX_DELAY: 最小单位毫秒,取值范围 [1ms, 900000ms],默认值为 interval 的值(但不能超过最大值),只可用于超级表。注:不建议 MAX_DELAY 设置太小,否则会过于频繁的推送结果,影响存储和查询性能,如无特殊需求,取默认值即可。 +函数列表中只能指定支持的聚集函数(见下文), 并且函数参数必须为1个, 即使当前函数支持多个参数, 函数参数内必须为普通列名, 不能为标签列. 函数列表中完全相同的函数和列会被去重, 如同时创建两个avg(c1), 则只会计算一个输出. TSMA 计算时将会把所有`函数中间结果`都输出到另一张超级表中, 输出超级表还包含了原始表的所有tag列. 函数列表中函数个数最多支持创建表最大列个数(包括tag列)减去 TSMA 计算附加的四列, 分别为`_wstart`, `_wend`, `_wduration`, 以及一个新增tag列 `tbname`, 再减去原始表的tag列数. 若列个数超出限制, 会报`Too many columns`错误. + +由于TSMA输出为一张超级表, 因此输出表的行长度受最大行长度限制, 不同函数的`中间结果`大小各异, 一般都大于原始数据大小, 若输出表的行长度大于最大行长度限制, 将会报`Row length exceeds max length`错误. 此时需要减少函数个数或者将常用的函数进行分组拆分到多个TSMA中. + +窗口大小的限制为[1ms ~ 1h]. INTERVAL 的单位与查询中INTERVAL字句相同, 如 a (毫秒), b (纳秒), h (小时), m (分钟), s (秒), u (微妙). + +TSMA为库内对象, 但名字全局唯一. 集群内一共可创建TSMA个数受参数`maxTsmaNum`限制, 参数默认值为8, 范围: [0-12]. 注意, 由于TSMA后台计算使用流计算, 因此每创建一条TSMA, 将会创建一条流, 因此能够创建的TSMA条数也受当前已经存在的流条数和最大可创建流条数限制. + +## 支持的函数列表 +| 函数| 备注 | +|---|---| +|min|| +|max|| +|sum|| +|first|| +|last|| +|avg|| +|count| 若想使用count(*), 则应创建count(ts)函数| +|spread|| +|stddev|| +|hyperloglog|| +||| + +## 删除TSMA +```sql +DROP TSMA [db_name.]tsma_name; +``` +若存在其他TSMA基于当前被删除TSMA创建, 则删除操作报`Invalid drop base tsma, drop recursive tsma first`错误. 因此需先删除 所有Recursive TSMA. + +## TSMA的计算 +TSMA的计算结果为与原始表相同库下的一张超级表, 此表用户不可见. 不可删除, 在`DROP TSMA`时自动删除. TSMA的计算是通过流计算完成的, 此过程为后台异步过程, TSMA的计算结果不保证实时性, 但可以保证最终正确性. + +当存在大量历史数据时, 创建TSMA之后, 流计算将会首先计算历史数据, 此期间新创建的TSMA不会被使用. 数据更新删除或者过期数据到来时自动重新计算影响部分数据。 在重新计算期间 TSMA 查询结果不保证实时性。若希望查询实时数据, 可以通过在 SQL 中添加 hint `/*+ skip_tsma() */` 或者关闭参数`querySmaOptimize`从原始数据查询。 + +## TSMA的使用与限制 + +客户端配置参数: `querySmaOptimize`, 用于控制查询时是否使用TSMA, `True`为使用, `False`为不使用即从原始数据查询. + +客户端配置参数:`maxTsmaCalcDelay`,单位 s,用于控制用户可以接受的 TSMA 计算延迟,若 TSMA 的计算进度与最新时间差距在此范围内, 则该 TSMA 将会被使用, 若超出该范围, 则不使用, 默认值: 600(10 分钟), 最小值: 600(10 分钟), 最大值: 86400(1 天). + +### 查询时使用TSMA + +已在 TSMA 中定义的 agg 函数在大部分查询场景下都可直接使用, 若存在多个可用的 TSMA, 优先使用大窗口的 TSMA, 未闭合窗口通过查询小窗口TSMA或者原始数据计算。 同时也有某些场景不能使用 TSMA(见下文)。 不可用时整个查询将使用原始数据进行计算。 + +未指定窗口大小的查询语句默认优先使用包含所有查询聚合函数的最大窗口 TSMA 进行数据的计算。 如`SELECT COUNT(*) FROM stable GROUP BY tbname`将会使用包含count(ts)且窗口最大的TSMA。因此若使用聚合查询频率高时, 应当尽可能创建大窗口的TSMA. + +指定窗口大小时即 `INTERVAL` 语句,使用最大的可整除窗口 TSMA。 窗口查询中, `INTERVAL` 的窗口大小, `OFFSET` 以及 `SLIDING` 都影响能使用的 TSMA 窗口大小, 可整 除窗口 TSMA 即 TSMA 窗口大小可被查询语句的 `INTERVAL, OFFSET, SLIDING` 整除的窗口。因此若使用窗口查询较多时, 需要考虑经常查询的窗口大小, 以及 offset, sliding大小来创建TSMA. + +例 1. 如 创建 TSMA 窗口大小 `5m` 一条, `10m` 一条, 查询时 `INTERVAL(30m)`, 那么优先使用 `10m` 的 TSMA, 若查询为 `INTERVAL(30m, 10m) SLIDING(5m)`, 那么仅可使用 `5m` 的 TSMA 查询。 + + +### 查询限制 + +在开启了参数`querySmaOptimize`并且无`skip_tsma()` hint时, 以下查询场景无法使用TSMA: + +- 某个TSMA 中定义的 agg 函数不能覆盖当前查询的函数列表时 +- 非 `INTERVAL` 的其他窗口,或者 `INTERVAL` 查询窗口大小(包括 `INTERVAL,SLIDING,OFFSET`)不是定义窗口的整数倍,如定义窗口为 2m,查询使用 5 分钟窗口,但若存在 1m 的窗口,则可以使用。 +- 查询 `WHERE` 条件中包含任意普通列(非主键时间列)的过滤。 +- `PARTITION` 或者 `GROUY BY` 包含任意普通列或其表达式时 +- 可以使用其他更快的优化逻辑时, 如last cache优化, 若符合last优化的条件, 则先走last 优化, 无法走last时, 再判断是否可以走tsma优化 +- 当前 TSMA 计算进度延迟大于配置参数 `maxTsmaCalcDelay`时 + +下面是一些例子: ```sql -DROP DATABASE IF EXISTS d0; -CREATE DATABASE d0; -USE d0; -CREATE TABLE IF NOT EXISTS st1 (ts timestamp, c1 int, c2 float, c3 double) TAGS (t1 int unsigned); -CREATE TABLE ct1 USING st1 TAGS(1000); -CREATE TABLE ct2 USING st1 TAGS(2000); -INSERT INTO ct1 VALUES(now+0s, 10, 2.0, 3.0); -INSERT INTO ct1 VALUES(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3); -CREATE SMA INDEX sma_index_name1 ON st1 FUNCTION(max(c1),max(c2),min(c1)) INTERVAL(5m,10s) SLIDING(5m) WATERMARK 5s MAX_DELAY 1m; --- 从 SMA 索引查询 -ALTER LOCAL 'querySmaOptimize' '1'; -SELECT max(c2),min(c1) FROM st1 INTERVAL(5m,10s) SLIDING(5m); -SELECT _wstart,_wend,_wduration,max(c2),min(c1) FROM st1 INTERVAL(5m,10s) SLIDING(5m); --- 从原始数据查询 -ALTER LOCAL 'querySmaOptimize' '0'; +SELECT agg_func_list [, pesudo_col_list] FROM stable WHERE exprs [GROUP/PARTITION BY [tbname] [, tag_list]] [HAVING ...] [INTERVAL(time_duration, offset) SLIDING(duration)]...; + +-- 创建 +CREATE TSMA tsma1 ON stable FUNCTION(COUNT(ts), SUM(c1), SUM(c3), MIN(c1), MIN(c3), AVG(c1)) INTERVAL(1m); +-- 查询 +SELECT COUNT(*), SUM(c1) + SUM(c3) FROM stable; ---- use tsma1 +SELECT COUNT(*), AVG(c1) FROM stable GROUP/PARTITION BY tbname, tag1, tag2; --- use tsma1 +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(1h); ---use tsma1 +SELECT COUNT(*), MIN(c1), SPREAD(c1) FROM stable INTERVAL(1h); ----- can't use, spread func not defined, although SPREAD can be calculated by MIN and MAX which are defined. +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(30s); ----- can't use tsma1, time_duration not fit. Normally, query_time_duration should be multple of create_duration. +SELECT COUNT(*), MIN(c1) FROM stable where c2 > 0; ---- can't use tsma1, can't do c2 filtering +SELECT COUNT(*) FROM stable GROUP BY c2; ---- can't use any tsma +SELECT MIN(c3), MIN(c2) FROM stable INTERVAL(1m); ---- can't use tsma1, c2 is not defined in tsma1. + +-- Another tsma2 created with INTERVAL(1h) based on tsma1 +CREATE RECURSIVE TSMA tsma2 on tsma1 INTERVAL(1h); +SELECT COUNT(*), SUM(c1) FROM stable; ---- use tsma2 +SELECT COUNT(*), AVG(c1) FROM stable GROUP/PARTITION BY tbname, tag1, tag2; --- use tsma2 +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(2h); ---use tsma2 +SELECT COUNT(*), MIN(c1) FROM stable WHERE ts < '2023-01-01 10:10:10' INTERVAL(30m); --use tsma1 +SELECT COUNT(*), MIN(c1) + MIN(c3) FROM stable INTERVAL(30m); ---use tsma1 +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(1h) SLIDING(30m); ---use tsma1 +SELECT COUNT(*), MIN(c1), SPREAD(c1) FROM stable INTERVAL(1h); ----- can't use tsma1 or tsma2, spread func not defined +SELECT COUNT(*), MIN(c1) FROM stable INTERVAL(30s); ----- can't use tsma1 or tsma2, time_duration not fit. Normally, query_time_duration should be multple of create_duration. +SELECT COUNT(*), MIN(c1) FROM stable where c2 > 0; ---- can't use tsma1 or tsam2, can't do c2 filtering ``` -## 删除索引 +### 使用限制 +创建TSMA之后, 对原始超级表的操作有以下限制: + +- 必须删除该表上的所有TSMA才能删除该表. +- 原始表所有tag列不能删除, 也不能修改tag列名或子表的tag值, 必须先删除TSMA, 才能删除tag列. +- 若某些列被TSMA使用了, 则这些列不能被删除, 必须先删除TSMA. 添加列不受影响, 但是新添加的列不在任何TSMA中, 因此若要计算新增列, 需要新创建其他的TSMA. + +## 查看TSMA ```sql -DROP INDEX index_name; +SHOW [db_name.]TSMAS; +SELECT * FROM information_schema.ins_tsma; ``` - -## 查看索引 - -````sql -SHOW INDEXES FROM tbl_name [FROM db_name]; -SHOW INDEXES FROM [db_name.]tbl_name; -```` - -显示在所指定的数据库或表上已创建的索引。 +若创建时指定的较多的函数, 且列名较长, 在显示函数列表时可能会被截断(目前最大支持输出256KB). \ No newline at end of file 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..c0daeb41c0 --- /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/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index 1bada64431..cb6ae8451f 100755 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -240,6 +240,16 @@ taos -C | 缺省值 | 0 | | 补充说明 | 该参数设置为 0 时,last(\*)/last_row(\*)/first(\*) 只返回超级表的普通列;为 1 时,返回超级表的普通列和标签列 | +### maxTsmaCalcDelay + +| 属性 | 说明 | +| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| 适用范围 | 仅客户端适用 | +| 含义 | 查询时客户端可允许的tsma计算延迟, 若tsma的计算延迟大于配置值, 则该TSMA将不会被使用. | +| 取值范围 | 600s - 86400s, 即10分钟-1小时 | +| 缺省值 | 600s | + + ## 区域相关 ### timezone @@ -745,6 +755,15 @@ charset 的有效值是 UTF-8。 | 取值范围 | 1-10000 | | 缺省值 | 20 | +### maxTsmaNum + +| 属性 | 说明 | +| -------- | --------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 集群内可创建的TSMA个数 | +| 取值范围 | 0-12 | +| 缺省值 | 8 | + ## 压缩参数 ### compressMsgSize diff --git a/docs/zh/14-reference/13-schemaless/13-schemaless.md b/docs/zh/14-reference/13-schemaless/13-schemaless.md index 47737ab7ee..7168aea18c 100644 --- a/docs/zh/14-reference/13-schemaless/13-schemaless.md +++ b/docs/zh/14-reference/13-schemaless/13-schemaless.md @@ -28,6 +28,7 @@ measurement,tag_set field_set timestamp - tag_set 将作为标签数据,其格式形如 `=,=`,也即可以使用英文逗号来分隔多个标签数据。它与 field_set 之间使用一个半角空格来分隔。 - field_set 将作为普通列数据,其格式形如 `=,=`,同样是使用英文逗号来分隔多个普通列的数据。它与 timestamp 之间使用一个半角空格来分隔。 - timestamp 即本行数据对应的主键时间戳。 +- 无模式写入不支持含第二主键列的表的数据写入。 tag_set 中的所有的数据自动转化为 nchar 数据类型,并不需要使用双引号(")。 diff --git a/docs/zh/21-tdinternal/01-arch.md b/docs/zh/21-tdinternal/01-arch.md index e2480b6682..52212bc714 100644 --- a/docs/zh/21-tdinternal/01-arch.md +++ b/docs/zh/21-tdinternal/01-arch.md @@ -201,7 +201,7 @@ TDengine 采用数据驱动的方式让缓存中的数据写入硬盘进行持 除此之外,TDengine 也提供了数据分级存储的功能,将不同时间段的数据存储在挂载的不同介质上的目录里,从而实现不同“热度”的数据存储在不同的存储介质上,充分利用存储,节约成本。比如,最新采集的数据需要经常访问,对硬盘的读取性能要求高,那么用户可以配置将这些数据存储在 SSD 盘上。超过一定期限的数据,查询需求量没有那么高,那么可以存储在相对便宜的 HDD 盘上。 -多级存储支持 3 级,每级最多可配置 16 个挂载点。 +多级存储支持 3 级,每级最多可配置 128 个挂载点。 TDengine 多级存储配置方式如下(在配置文件/etc/taos/taos.cfg 中): diff --git a/docs/zh/21-tdinternal/08-compress.md b/docs/zh/21-tdinternal/08-compress.md new file mode 100644 index 0000000000..9653a9366b --- /dev/null +++ b/docs/zh/21-tdinternal/08-compress.md @@ -0,0 +1,91 @@ +--- +title: 可配置压缩算法 +description: 可配置压缩算法 +--- + +# 可配置存储压缩 + +从 TDengine 3.3.0.0 版本开始,TDengine 提供了更高级的压缩功能,用户可以在建表时针对每一列配置是否进行压缩、以及使用的压缩算法和压缩级别。 + +## 压缩术语定义 + +### 压缩等级 + +- 一级压缩:对数据进行编码,本质也是一种压缩 +- 二级压缩:在编码的基础上对数据块进行压缩 + +### 压缩级别 + +在本文中特指二级压缩算法内部的级别,比如zstd,至少8个level可选,每个level 下都有不同表现,本质是压缩率、压缩速度、解压速度之间的 tradeoff,为了避免选择困难,特简化定义为如下三种级别: + +- high:压缩率最高,压缩速度和解压速度相对最差。 +- low:压缩速度和解压速度最好,压缩率相对最低。 +- medium:兼顾压缩率、压缩速度和解压速度。 + +### 压缩算法列表 + +- 编码算法列表(一级压缩):simple8b, bit-packing,delta-i, delta-d, disabled + +- 压缩算法列表(二级压缩): lz4、zlib、zstd、tsz、xz、disabled + +- 各个数据类型的默认压缩算法列表和适用范围 + +| 数据类型 | 可选编码算法 | 编码算法默认值 | 可选压缩算法|可选压缩算法| 压缩等级默认值| +| :-----------:|:----------:|:-------:|:-------:|:----------:|:----:| + tinyint/untinyint/smallint/usmallint/int/uint | simple8b| simple8b | lz4/zlib/zstd/xz| lz4 | medium| +| bigint/ubigint/timestamp | simple8b/delta-i | delta-i |lz4/zlib/zstd/xz | lz4| medium| +|float/double | delta-d|delta-d |lz4/zlib/zstd/xz/tsz|tsz| medium| +|binary/nchar| disabled| disabled|lz4/zlib/zstd/xz| lz4| medium| +|bool| bit-packing| bit-packing| lz4/zlib/zstd/xz| lz4| medium| + +注意: 针对浮点类型,如果配置为tsz, 其精度由taosd的全局配置决定,如果配置为tsz, 但是没有配置有损压缩标志, 则使用lz4进行压缩 + +## SQL 语法 + +### 建表时指定压缩 + +```sql +CREATE [dbname.]tabname (colName colType [ENCODE 'encode_type'] [COMPRESS 'compress_type' [LEVEL 'level'], [, other cerate_definition]...]) +``` + +**参数说明** + +- tabname:超级表或者普通表名称 +- encode_type: 一级压缩,具体参数见上面列表 +- compress_type: 二级压缩,具体参数见上面列表 +- level: 特指二级压缩的级别,默认值为medium, 支持简写为 'h'/'l'/'m' + +**功能说明** + +- 创建表的时候指定列的压缩方式 + +### 更改列的压缩方式 + +```sql +ALTER TABLE [db_name.]tabName MODIFY COLUMN colName [ENCODE 'ecode_type'] [COMPRESS 'compress_type'] [LEVEL "high"] + +``` + +**参数说明** + +- tabName: 表名,可以为超级表、普通表 +- colName: 待更改压缩算法的列, 只能为普通列 + +**功能说明** + +- 更改列的压缩方式 + +### 查看列的压缩方式 + +```sql +DESCRIBE [dbname.]tabName +``` + +**功能说明** + +- 显示列的基本信息,包括类型、压缩方式 + +## 兼容性 + +- 完全兼容已经存在的数据 +- 从更低版本升级到 3.3.0.0 后不能回退 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/libs/executor/storageapi.h b/include/libs/executor/storageapi.h index cba32bec04..fcb2e4d405 100644 --- a/include/libs/executor/storageapi.h +++ b/include/libs/executor/storageapi.h @@ -308,6 +308,13 @@ typedef struct SUpdateInfo { SScalableBf* pCloseWinSBF; SHashObj* pMap; uint64_t maxDataVersion; + int8_t pkColType; + int32_t pkColLen; + char* pKeyBuff; + char* pValueBuff; + + int (*comparePkRowFn)(void* pValue1, void* pTs, void* pPkVal, __compar_fn_t cmpPkFn); + __compar_fn_t comparePkCol; } SUpdateInfo; typedef struct { @@ -375,17 +382,17 @@ typedef struct SStateStore { void** ppVal, int32_t* pVLen); int32_t (*streamStateCountWinAdd)(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen); - SUpdateInfo* (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp); - TSKEY (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol); - bool (*updateInfoIsUpdated)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts); + SUpdateInfo* (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen); + TSKEY (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol, int32_t primaryKeyCol); + bool (*updateInfoIsUpdated)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len); bool (*updateInfoIsTableInserted)(SUpdateInfo* pInfo, int64_t tbUid); - bool (*isIncrementalTimeStamp)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts); + bool (*isIncrementalTimeStamp)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len); void (*updateInfoDestroy)(SUpdateInfo* pInfo); void (*windowSBfDelete)(SUpdateInfo* pInfo, uint64_t count); void (*windowSBfAdd)(SUpdateInfo* pInfo, uint64_t count); - SUpdateInfo* (*updateInfoInitP)(SInterval* pInterval, int64_t watermark, bool igUp); + SUpdateInfo* (*updateInfoInitP)(SInterval* pInterval, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen); void (*updateInfoAddCloseWindowSBF)(SUpdateInfo* pInfo); void (*updateInfoDestoryColseWinSBF)(SUpdateInfo* pInfo); int32_t (*updateInfoSerialize)(void* buf, int32_t bufLen, const SUpdateInfo* pInfo); diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 44332d8b51..5b889171b3 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -270,7 +270,6 @@ typedef struct SJoinTableNode { SNode* addPrimCond; bool hasSubQuery; bool isLowLevelJoin; - SNode* pParent; SNode* pLeft; SNode* pRight; SNode* pOnCond; diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 9b7a433c18..0aa00d50b4 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -488,7 +488,7 @@ struct SStreamTask { SSHashObj* pNameMap; void* pBackend; int8_t subtableWithoutMd5; - char reserve[255]; + char reserve[256]; }; typedef int32_t (*startComplete_fn_t)(struct SStreamMeta*); diff --git a/include/libs/stream/tstreamUpdate.h b/include/libs/stream/tstreamUpdate.h index af93c6ac01..632a82743f 100644 --- a/include/libs/stream/tstreamUpdate.h +++ b/include/libs/stream/tstreamUpdate.h @@ -25,28 +25,10 @@ extern "C" { #endif -typedef struct SUpdateKey { - int64_t tbUid; - TSKEY ts; -} SUpdateKey; - -//typedef struct SUpdateInfo { -// SArray *pTsBuckets; -// uint64_t numBuckets; -// SArray *pTsSBFs; -// uint64_t numSBFs; -// int64_t interval; -// int64_t watermark; -// TSKEY minTS; -// SScalableBf *pCloseWinSBF; -// SHashObj *pMap; -// uint64_t maxDataVersion; -//} SUpdateInfo; - -SUpdateInfo *updateInfoInitP(SInterval *pInterval, int64_t watermark, bool igUp); -SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, bool igUp); -TSKEY updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol); -bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts); +SUpdateInfo *updateInfoInitP(SInterval *pInterval, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen); +SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen); +TSKEY updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol, int32_t primaryKeyCol); +bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len); bool updateInfoIsTableInserted(SUpdateInfo *pInfo, int64_t tbUid); void updateInfoDestroy(SUpdateInfo *pInfo); void updateInfoAddCloseWindowSBF(SUpdateInfo *pInfo); @@ -55,7 +37,7 @@ int32_t updateInfoSerialize(void *buf, int32_t bufLen, const SUpdateInfo *p int32_t updateInfoDeserialize(void *buf, int32_t bufLen, SUpdateInfo *pInfo); void windowSBfDelete(SUpdateInfo *pInfo, uint64_t count); void windowSBfAdd(SUpdateInfo *pInfo, uint64_t count); -bool isIncrementalTimeStamp(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts); +bool isIncrementalTimeStamp(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len); #ifdef __cplusplus } 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/include/util/tcompression.h b/include/util/tcompression.h index ab98058b87..683a8f2cee 100644 --- a/include/util/tcompression.h +++ b/include/util/tcompression.h @@ -236,35 +236,25 @@ typedef struct { __data_compress_init initFn; __data_compress_l1_fn_t comprFn; __data_decompress_l1_fn_t decomprFn; -} TCompressL1FnSet; +} TCmprL1FnSet; typedef struct { char *name; __data_compress_init initFn; __data_compress_l2_fn_t comprFn; __data_decompress_l2_fn_t decomprFn; -} TCompressL2FnSet; +} TCmprL2FnSet; -typedef struct { - int8_t type; - int8_t level; - __data_compress_init initFn; - __data_compress_l1_fn_t l1CmprFn; - __data_decompress_l1_fn_t l1DecmprFn; - __data_compress_l2_fn_t l2CmprFn; - __data_decompress_l2_fn_t l2DecmprFn; -} TCompressPara; - -typedef enum L1Compress { +typedef enum { L1_UNKNOWN = 0, L1_SIMPLE_8B, L1_XOR, L1_RLE, L1_DELTAD, L1_DISABLED = 0xFF, -} EL1CompressFuncType; +} TCmprL1Type; -typedef enum L2Compress { +typedef enum { L2_UNKNOWN = 0, L2_LZ4, L2_ZLIB, @@ -272,7 +262,20 @@ typedef enum L2Compress { L2_TSZ, L2_XZ, L2_DISABLED = 0xFF, -} EL2ComressFuncType; +} TCmprL2Type; + +typedef enum { + L2_LVL_NOCHANGE = 0, + L2_LVL_LOW, + L2_LVL_MEDIUM, + L2_LVL_HIGH, + L2_LVL_DISABLED = 0xFF, +} TCmprLvlType; + +typedef struct { + char *name; + uint8_t lvl[3]; // l[0] = 'low', l[1] = 'mid', l[2] = 'high' +} TCmprLvlSet; int32_t tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t *level); diff --git a/include/util/tdef.h b/include/util/tdef.h index 6402ef902c..6ded54dc00 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -188,8 +188,8 @@ typedef enum ELogicConditionType { LOGIC_COND_TYPE_NOT, } ELogicConditionType; -#define ENCRYPTED_LEN(len) (len/16) * 16 + (len%16?1:0) * 16 -#define ENCRYPT_KEY_LEN 16 +#define ENCRYPTED_LEN(len) (len / 16) * 16 + (len % 16 ? 1 : 0) * 16 +#define ENCRYPT_KEY_LEN 16 #define ENCRYPT_KEY_LEN_MIN 8 #define TSDB_INT32_ID_LEN 11 @@ -525,7 +525,7 @@ typedef enum ELogicConditionType { #define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P #define TFS_MAX_TIERS 3 -#define TFS_MAX_DISKS_PER_TIER 16 +#define TFS_MAX_DISKS_PER_TIER 128 #define TFS_MAX_DISKS (TFS_MAX_TIERS * TFS_MAX_DISKS_PER_TIER) #define TFS_MIN_LEVEL 0 #define TFS_MAX_LEVEL (TFS_MAX_TIERS - 1) @@ -535,7 +535,7 @@ typedef enum ELogicConditionType { enum { TRANS_STAT_INIT = 0, TRANS_STAT_EXECUTING, TRANS_STAT_EXECUTED, TRANS_STAT_ROLLBACKING, TRANS_STAT_ROLLBACKED }; enum { TRANS_OPER_INIT = 0, TRANS_OPER_EXECUTE, TRANS_OPER_ROLLBACK }; -enum { ENCRYPT_KEY_STAT_UNKNOWN = 0, ENCRYPT_KEY_STAT_UNSET, ENCRYPT_KEY_STAT_SET, ENCRYPT_KEY_STAT_LOADED}; +enum { ENCRYPT_KEY_STAT_UNKNOWN = 0, ENCRYPT_KEY_STAT_UNSET, ENCRYPT_KEY_STAT_SET, ENCRYPT_KEY_STAT_LOADED }; typedef struct { char dir[TSDB_FILENAME_LEN]; diff --git a/include/util/thash.h b/include/util/thash.h index 08caad495d..c6275d276c 100644 --- a/include/util/thash.h +++ b/include/util/thash.h @@ -180,6 +180,13 @@ void taosHashCancelIterate(SHashObj *pHashObj, void *p); */ void *taosHashGetKey(void *data, size_t *keyLen); +/** + * Get the corresponding value length for a given data in hash table + * @param data + * @return + */ +int32_t taosHashGetValueSize(void *data); + /** * return the payload data with the specified key(reference number added) * diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index c029b1871a..337407f8d2 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -57,9 +57,9 @@ else arch=$cpuType fi -echo "${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r ${arch} -e taoskeeper" +echo "${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r ${arch} -e taoskeeper -t ver-${tdengine_ver}" echo "$top_dir=${top_dir}" -taoskeeper_binary=`${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r $arch -e taoskeeper` +taoskeeper_binary=`${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r $arch -e taoskeeper -t ver-${tdengine_ver}` echo "taoskeeper_binary: ${taoskeeper_binary}" # copy config files @@ -76,6 +76,13 @@ if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then cp ${compile_dir}/test/cfg/taosadapter.service ${pkg_dir}${install_home_path}/cfg || : fi +if [ -f "%{_compiledir}/../../../explorer/target/taos-explorer.service" ]; then + cp %{_compiledir}/../../../explorer/target/taos-explorer.service ${pkg_dir}${install_home_path}/cfg || : +fi +if [ -f "%{_compiledir}/../../../explorer/server/example/explorer.toml" ]; then + cp %{_compiledir}/../../../explorer/server/example/explorer.toml ${pkg_dir}${install_home_path}/cfg || : +fi + cp ${taoskeeper_binary} ${pkg_dir}${install_home_path}/bin #cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_path}/init.d cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script @@ -93,6 +100,10 @@ if [ -f "${compile_dir}/build/bin/taosadapter" ]; then cp ${compile_dir}/build/bin/taosadapter ${pkg_dir}${install_home_path}/bin ||: fi +if [ -f "${compile_dir}/../../../explorer/target/release/taos-explorer" ]; then + cp ${compile_dir}/../../../explorer/target/release/taos-explorer ${pkg_dir}${install_home_path}/bin ||: +fi + cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver [ -f ${compile_dir}/build/lib/${wslibfile} ] && cp ${compile_dir}/build/lib/${wslibfile} ${pkg_dir}${install_home_path}/driver ||: diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index b846cd447b..6b324486b2 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -72,6 +72,14 @@ if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper.service ]; then cp %{_compiledir}/../build-taoskeeper/taoskeeper.service %{buildroot}%{homepath}/cfg ||: fi +if [ -f %{_compiledir}/../../../explorer/target/taos-explorer.service ]; then + cp %{_compiledir}/../../../explorer/target/taos-explorer.service %{buildroot}%{homepath}/cfg ||: +fi + +if [ -f %{_compiledir}/../../../explorer/server/example/explorer.toml ]; then + cp %{_compiledir}/../../../explorer/server/example/explorer.toml %{buildroot}%{homepath}/cfg ||: +fi + #cp %{_compiledir}/../packaging/rpm/taosd %{buildroot}%{homepath}/init.d cp %{_compiledir}/../packaging/tools/post.sh %{buildroot}%{homepath}/script cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/script @@ -84,6 +92,10 @@ cp %{_compiledir}/build/bin/udfd %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin +if [ -f %{_compiledir}/../../../explorer/target/release/taos-explorer ]; then + cp %{_compiledir}/../../../explorer/target/release/taos-explorer %{buildroot}%{homepath}/bin +fi + if [ -f %{_compiledir}/../build-taoskeeper/taoskeeper ]; then cp %{_compiledir}/../build-taoskeeper/taoskeeper %{buildroot}%{homepath}/bin fi diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index ae774a3289..5a83cdc6a8 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -16,49 +16,27 @@ serverFqdn="" script_dir=$(dirname $(readlink -f "$0")) # Dynamic directory -clientName="taos" -serverName="taosd" +PREFIX="taos" +clientName="${PREFIX}" +serverName="${PREFIX}d" udfdName="udfd" -configFile="taos.cfg" +configFile="${PREFIX}.cfg" productName="TDengine" emailName="taosdata.com" -uninstallScript="rmtaos" -historyFile="taos_history" +uninstallScript="rm${PREFIX}" +historyFile="${PREFIX}_history" tarName="package.tar.gz" -dataDir="/var/lib/taos" -logDir="/var/log/taos" -configDir="/etc/taos" -installDir="/usr/local/taos" -adapterName="taosadapter" -benchmarkName="taosBenchmark" -dumpName="taosdump" -demoName="taosdemo" -xname="taosx" -keeperName="taoskeeper" - -clientName2="taos" -serverName2="${clientName2}d" -configFile2="${clientName2}.cfg" -productName2="TDengine" -emailName2="taosdata.com" -xname2="${clientName2}x" -adapterName2="${clientName2}adapter" -keeperName2="${clientName2}keeper" - -explorerName="${clientName2}-explorer" -benchmarkName2="${clientName2}Benchmark" -demoName2="${clientName2}demo" -dumpName2="${clientName2}dump" -uninstallScript2="rm${clientName2}" - -historyFile="${clientName2}_history" -logDir="/var/log/${clientName2}" -configDir="/etc/${clientName2}" -installDir="/usr/local/${clientName2}" - -data_dir=${dataDir} -log_dir=${logDir} -cfg_install_dir=${configDir} +dataDir="/var/lib/${PREFIX}" +logDir="/var/log/${PREFIX}" +configDir="/etc/${PREFIX}" +installDir="/usr/local/${PREFIX}" +adapterName="${PREFIX}adapter" +benchmarkName="${PREFIX}Benchmark" +dumpName="${PREFIX}dump" +demoName="${PREFIX}demo" +xname="${PREFIX}x" +explorerName="${PREFIX}-explorer" +keeperName="${PREFIX}keeper" bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" @@ -71,7 +49,6 @@ install_main_dir=${installDir} bin_dir="${installDir}/bin" service_config_dir="/etc/systemd/system" -web_port=6041 # Color setting RED='\033[0;31m' @@ -179,6 +156,26 @@ done #echo "verType=${verType} interactiveFqdn=${interactiveFqdn}" +tools=(${clientName} ${benchmarkName} ${dumpName} ${demoName} remove.sh udfd set_core.sh TDinsight.sh start_pre.sh) +if [ "${verMode}" == "cluster" ]; then + services=(${serverName} ${adapterName} ${xname} ${explorerName} ${keeperName}) +elif [ "${verMode}" == "edge" ]; then + if [ "${pagMode}" == "full" ]; then + services=(${serverName} ${adapterName} ${keeperName} ${explorerName}) + else + services=(${serverName}) + tools=(${clientName} ${benchmarkName} remove.sh start_pre.sh) + fi +else + services=(${serverName} ${adapterName} ${xname} ${explorerName} ${keeperName}) +fi + +function install_services() { + for service in "${services[@]}"; do + install_service ${service} + done +} + function kill_process() { pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then @@ -196,6 +193,7 @@ function install_main_path() { ${csudo}mkdir -p ${install_main_dir}/driver ${csudo}mkdir -p ${install_main_dir}/examples ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${configDir} # ${csudo}mkdir -p ${install_main_dir}/init.d if [ "$verMode" == "cluster" ]; then ${csudo}mkdir -p ${install_main_dir}/share @@ -208,44 +206,48 @@ function install_main_path() { function install_bin() { # Remove links - ${csudo}rm -f ${bin_link_dir}/${clientName2} || : - ${csudo}rm -f ${bin_link_dir}/${serverName2} || : - ${csudo}rm -f ${bin_link_dir}/${udfdName} || : - ${csudo}rm -f ${bin_link_dir}/${adapterName} || : - ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : - ${csudo}rm -f ${bin_link_dir}/${demoName2} || : - ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : - ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : - ${csudo}rm -f ${bin_link_dir}/${keeperName2} || : - ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : + for tool in "${tools[@]}"; do + ${csudo}rm -f ${bin_link_dir}/${tool} || : + done - ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* + for service in "${services[@]}"; do + ${csudo}rm -f ${bin_link_dir}/${service} || : + done + + if [ "${verType}" == "client" ]; then + ${csudo}cp -r ${script_dir}/bin/${clientName} ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/bin/${benchmarkName} ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/bin/${dumpName} ${install_main_dir}/bin + ${csudo}cp -r ${script_dir}/bin/remove.sh ${install_main_dir}/bin + else + ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin + fi + + if [[ "${verMode}" == "cluster" && "${verType}" != "client" ]]; then + if [ -d ${script_dir}/${xname}/bin ]; then + ${csudo}cp -r ${script_dir}/${xname}/bin/* ${install_main_dir}/bin + fi + fi + + if [ -f ${script_dir}/bin/quick_deploy.sh ]; then + ${csudo}cp -r ${script_dir}/bin/quick_deploy.sh ${install_main_dir}/bin + fi + + ${csudo}chmod 0555 ${install_main_dir}/bin/* + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}mv ${install_main_dir}/bin/remove.sh ${install_main_dir}/uninstall.sh || : #Make link - [ -x ${install_main_dir}/bin/${clientName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${clientName2} ${bin_link_dir}/${clientName2} || : - [ -x ${install_main_dir}/bin/${serverName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${serverName2} ${bin_link_dir}/${serverName2} || : - [ -x ${install_main_dir}/bin/${udfdName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${udfdName} ${bin_link_dir}/${udfdName} || : - [ -x ${install_main_dir}/bin/${adapterName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${adapterName2} ${bin_link_dir}/${adapterName2} || : - [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${demoName2} || : - [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${benchmarkName2} || : - [ -x ${install_main_dir}/bin/${dumpName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${dumpName2} ${bin_link_dir}/${dumpName2} || : - [ -x ${install_main_dir}/bin/${keeperName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${keeperName2} ${bin_link_dir}/${keeperName2} || : - [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -sf ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : - if [ "$clientName2" == "${clientName}" ]; then - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : - fi - [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : + for tool in "${tools[@]}"; do + if [ "${tool}" == "remove.sh" ]; then + [ -x ${install_main_dir}/uninstall.sh ] && ${csudo}ln -sf ${install_main_dir}/uninstall.sh ${bin_link_dir}/${uninstallScript} || : + else + [ -x ${install_main_dir}/bin/${tool} ] && ${csudo}ln -sf ${install_main_dir}/bin/${tool} ${bin_link_dir}/${tool} || : + fi + done - if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then - ${csudo}rm -f ${bin_link_dir}/${xname2} || : - ${csudo}rm -f ${bin_link_dir}/${explorerName} || : - - #Make link - [ -x ${install_main_dir}/bin/${xname2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${xname2} ${bin_link_dir}/${xname2} || : - [ -x ${install_main_dir}/bin/${explorerName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${explorerName} ${bin_link_dir}/${explorerName} || : - [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || : - fi + for service in "${services[@]}"; do + [ -x ${install_main_dir}/bin/${service} ] && ${csudo}ln -sf ${install_main_dir}/bin/${service} ${bin_link_dir}/${service} || : + done } function install_lib() { @@ -356,7 +358,7 @@ function install_header() { ${csudo}ln -sf ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h ${csudo}ln -sf ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h ${csudo}ln -sf ${install_main_dir}/include/tdef.h ${inc_link_dir}/tdef.h - ${csudo}ln -sf ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h + ${csudo}ln -sf ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h [ -f ${install_main_dir}/include/taosws.h ] && ${csudo}ln -sf ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || : } @@ -415,10 +417,10 @@ function set_hostname() { # ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network || : # fi - if [ -f ${cfg_install_dir}/${configFile2} ]; then - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/${configFile2} + if [ -f ${configDir}/${configFile} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${configDir}/${configFile} else - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${script_dir}/cfg/${configFile2} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${script_dir}/cfg/${configFile} fi serverFqdn=$newHostname @@ -453,11 +455,11 @@ function set_ipAsFqdn() { echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}" localFqdn="127.0.0.1" # Write the local FQDN to configuration file - - if [ -f ${cfg_install_dir}/${configFile2} ]; then - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile2} + + if [ -f ${configDir}/${configFile} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${configDir}/${configFile} else - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${script_dir}/cfg/${configFile2} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${script_dir}/cfg/${configFile} fi serverFqdn=$localFqdn echo @@ -479,11 +481,11 @@ function set_ipAsFqdn() { if [[ $retval != 0 ]]; then read -p "Please choose an IP from local IP list:" localFqdn else - # Write the local FQDN to configuration file - if [ -f ${cfg_install_dir}/${configFile2} ]; then - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile2} + # Write the local FQDN to configuration file + if [ -f ${configDir}/${configFile} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${configDir}/${configFile} else - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${script_dir}/cfg/${configFile2} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${script_dir}/cfg/${configFile} fi serverFqdn=$localFqdn break @@ -499,91 +501,121 @@ function local_fqdn_check() { echo echo -e -n "System hostname is: ${GREEN}$serverFqdn${NC}" echo - set_hostname + set_hostname +} + +function install_taosx_config() { + [ ! -z $1 ] && return 0 || : # only install client + + fileName="${script_dir}/${xname}/etc/${PREFIX}/${xname}.toml" + if [ -f ${fileName} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*=\s*).*/\1\"${serverFqdn}\"/" ${fileName} + + if [ -f "${configDir}/${xname}.toml" ]; then + ${csudo}cp ${fileName} ${configDir}/${xname}.toml.new + else + ${csudo}cp ${fileName} ${configDir}/${xname}.toml + fi + fi +} + + +function install_explorer_config() { + [ ! -z $1 ] && return 0 || : # only install client + + if [ "$verMode" == "cluster" ]; then + fileName="${script_dir}/${xname}/etc/${PREFIX}/explorer.toml" + else + fileName="${script_dir}/cfg/explorer.toml" + fi + + if [ -f ${fileName} ]; then + ${csudo}sed -i "s/localhost/${serverFqdn}/g" ${fileName} + + if [ -f "${configDir}/explorer.toml" ]; then + ${csudo}cp ${fileName} ${configDir}/explorer.toml.new + else + ${csudo}cp ${fileName} ${configDir}/explorer.toml + fi + fi } function install_adapter_config() { - if [ -f ${script_dir}/cfg/${adapterName}.toml ]; then - ${csudo}sed -i -r "s/localhost/${serverFqdn}/g" ${script_dir}/cfg/${adapterName}.toml - fi - if [ ! -f "${cfg_install_dir}/${adapterName}.toml" ]; then - ${csudo}mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/${adapterName}.toml ] && ${csudo}cp ${script_dir}/cfg/${adapterName}.toml ${cfg_install_dir} - [ -f ${cfg_install_dir}/${adapterName}.toml ] && ${csudo}chmod 644 ${cfg_install_dir}/${adapterName}.toml - else - [ -f ${script_dir}/cfg/${adapterName}.toml ] && - ${csudo}cp -f ${script_dir}/cfg/${adapterName}.toml ${cfg_install_dir}/${adapterName}.toml.new - fi - - [ -f ${cfg_install_dir}/${adapterName}.toml ] && - ${csudo}ln -sf ${cfg_install_dir}/${adapterName}.toml ${install_main_dir}/cfg/${adapterName}.toml - [ ! -z $1 ] && return 0 || : # only install client + fileName="${script_dir}/cfg/${adapterName}.toml" + if [ -f ${fileName} ]; then + ${csudo}sed -i -r "s/localhost/${serverFqdn}/g" ${fileName} + + if [ -f "${configDir}/${adapterName}.toml" ]; then + ${csudo}cp ${fileName} ${configDir}/${adapterName}.toml.new + else + ${csudo}cp ${fileName} ${configDir}/${adapterName}.toml + fi + fi } function install_keeper_config() { - if [ -f ${script_dir}/cfg/${keeperName2}.toml ]; then - ${csudo}sed -i -r "s/127.0.0.1/${serverFqdn}/g" ${script_dir}/cfg/${keeperName2}.toml - fi - if [ -f "${configDir}/keeper.toml" ]; then - echo "The file keeper.toml will be renamed to ${keeperName2}.toml" - ${csudo}cp ${script_dir}/cfg/${keeperName2}.toml ${configDir}/${keeperName2}.toml.new - ${csudo}mv ${configDir}/keeper.toml ${configDir}/${keeperName2}.toml - elif [ -f "${configDir}/${keeperName2}.toml" ]; then - # "taoskeeper.toml exists,new config is taoskeeper.toml.new" - ${csudo}cp ${script_dir}/cfg/${keeperName2}.toml ${configDir}/${keeperName2}.toml.new - else - ${csudo}cp ${script_dir}/cfg/${keeperName2}.toml ${configDir}/${keeperName2}.toml - fi - command -v systemctl >/dev/null 2>&1 && ${csudo}systemctl daemon-reload >/dev/null 2>&1 || true -} - -function install_config() { - - if [ ! -f "${cfg_install_dir}/${configFile2}" ]; then - ${csudo}mkdir -p ${cfg_install_dir} - if [ -f ${script_dir}/cfg/${configFile2} ]; then - ${csudo} echo "monitor 1" >> ${script_dir}/cfg/${configFile2} - ${csudo} echo "monitorFQDN ${serverFqdn}" >> ${script_dir}/cfg/${configFile2} - ${csudo} echo "audit 1" >> ${script_dir}/cfg/${configFile2} - ${csudo}cp ${script_dir}/cfg/${configFile2} ${cfg_install_dir} - fi - ${csudo}chmod 644 ${cfg_install_dir}/* - else - ${csudo} echo "monitor 1" >> ${script_dir}/cfg/${configFile2} - ${csudo} echo "monitorFQDN ${serverFqdn}" >> ${script_dir}/cfg/${configFile2} - ${csudo} echo "audit 1" >> ${script_dir}/cfg/${configFile2} - ${csudo}cp -f ${script_dir}/cfg/${configFile2} ${cfg_install_dir}/${configFile2}.new - fi - - ${csudo}ln -sf ${cfg_install_dir}/${configFile2} ${install_main_dir}/cfg - [ ! -z $1 ] && return 0 || : # only install client + fileName="${script_dir}/cfg/${keeperName}.toml" + if [ -f ${fileName} ]; then + ${csudo}sed -i -r "s/127.0.0.1/${serverFqdn}/g" ${fileName} + + if [ -f "${configDir}/${keeperName}.toml" ]; then + ${csudo}cp ${fileName} ${configDir}/${keeperName}.toml.new + else + ${csudo}cp ${fileName} ${configDir}/${keeperName}.toml + fi + fi +} + +function install_taosd_config() { + fileName="${script_dir}/cfg/${configFile}" + if [ -f ${fileName} ]; then + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$serverFqdn/" ${script_dir}/cfg/${configFile} + ${csudo}echo "monitor 1" >>${script_dir}/cfg/${configFile} + ${csudo}echo "monitorFQDN ${serverFqdn}" >>${script_dir}/cfg/${configFile} + ${csudo}echo "audit 1" >>${script_dir}/cfg/${configFile} + + if [ -f "${configDir}/${configFile}" ]; then + ${csudo}cp ${fileName} ${configDir}/${configFile}.new + else + ${csudo}cp ${fileName} ${configDir}/${configFile} + fi + fi + + ${csudo}ln -sf ${configDir}/${configFile} ${install_main_dir}/cfg +} +function install_config() { + + [ ! -z $1 ] && return 0 || : # only install client + if ((${update_flag} == 1)); then return 0 fi if [ "$interactiveFqdn" == "no" ]; then + install_taosd_config return 0 fi local_fqdn_check + install_taosd_config echo - echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName2}:6030) of an existing ${productName2} cluster node to join${NC}" + echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName}:6030) of an existing ${productName} cluster node to join${NC}" echo echo -e -n "${GREEN}OR leave it blank to build one${NC}:" read firstEp while true; do if [ ! -z "$firstEp" ]; then - if [ -f ${cfg_install_dir}/${configFile2} ]; then - ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/${configFile2} + if [ -f ${configDir}/${configFile} ]; then + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${configDir}/${configFile} else - ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${script_dir}/cfg/${configFile2} + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${script_dir}/cfg/${configFile} fi break else @@ -605,37 +637,21 @@ function install_config() { done } -function install_share_etc() { - [ ! -d ${script_dir}/share/etc ] && return - for c in `ls ${script_dir}/share/etc/`; do - if [ -e /etc/${clientName2}/$c ]; then - out=/etc/${clientName2}/$c.new.`date +%F` - ${csudo}cp -f ${script_dir}/share/etc/$c $out ||: - else - ${csudo}mkdir -p /etc/${clientName2} >/dev/null 2>/dev/null ||: - ${csudo}cp -f ${script_dir}/share/etc/$c /etc/${clientName2}/$c ||: - fi - done +function install_log() { + ${csudo}mkdir -p ${logDir} && ${csudo}chmod 777 ${logDir} - [ ! -d ${script_dir}/share/srv ] && return - ${csudo} cp ${script_dir}/share/srv/* ${service_config_dir} ||: -} - -function install_log() { - ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - - ${csudo}ln -sf ${log_dir} ${install_main_dir}/log + ${csudo}ln -sf ${logDir} ${install_main_dir}/log } function install_data() { - ${csudo}mkdir -p ${data_dir} + ${csudo}mkdir -p ${dataDir} - ${csudo}ln -sf ${data_dir} ${install_main_dir}/data + ${csudo}ln -sf ${dataDir} ${install_main_dir}/data } function install_connector() { if [ -d "${script_dir}/connector/" ]; then - ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ || echo "failed to copy connector" + ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ || echo "failed to copy connector" ${csudo}cp ${script_dir}/start-all.sh ${install_main_dir}/ || echo "failed to copy start-all.sh" ${csudo}cp ${script_dir}/stop-all.sh ${install_main_dir}/ || echo "failed to copy stop-all.sh" ${csudo}cp ${script_dir}/README.md ${install_main_dir}/ || echo "failed to copy README.md" @@ -644,59 +660,36 @@ function install_connector() { function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples || echo "failed to copy examples" + ${csudo}cp -rf ${script_dir}/examples ${install_main_dir}/ || echo "failed to copy examples" fi } -function install_web() { - if [ -d "${script_dir}/share" ]; then - ${csudo}cp -rf ${script_dir}/share/* ${install_main_dir}/share > /dev/null 2>&1 ||: - fi -} - -function install_taosx() { - if [ -f "${script_dir}/taosx/install_taosx.sh" ]; then - cd ${script_dir}/taosx - chmod a+x install_taosx.sh - bash install_taosx.sh -e $serverFqdn +function install_plugins() { + if [ -d ${script_dir}/${xname}/plugins ]; then + ${csudo}cp -rf ${script_dir}/${xname}/plugins/ ${install_main_dir}/ || echo "failed to copy ${PREFIX}x plugins" fi } function clean_service_on_sysvinit() { - if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then - ${csudo}service ${serverName2} stop || : - fi - - if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then - ${csudo}service tarbitratord stop || : + if ps aux | grep -v grep | grep $1 &>/dev/null; then + ${csudo}service $1 stop || : fi if ((${initd_mod} == 1)); then - if [ -e ${service_config_dir}/${serverName2} ]; then - ${csudo}chkconfig --del ${serverName2} || : - fi - - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}chkconfig --del tarbitratord || : + if [ -e ${service_config_dir}/$1 ]; then + ${csudo}chkconfig --del $1 || : fi elif ((${initd_mod} == 2)); then - if [ -e ${service_config_dir}/${serverName2} ]; then - ${csudo}insserv -r ${serverName2} || : - fi - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}insserv -r tarbitratord || : + if [ -e ${service_config_dir}/$1 ]; then + ${csudo}insserv -r $1 || : fi elif ((${initd_mod} == 3)); then - if [ -e ${service_config_dir}/${serverName2} ]; then - ${csudo}update-rc.d -f ${serverName2} remove || : - fi - if [ -e ${service_config_dir}/tarbitratord ]; then - ${csudo}update-rc.d -f tarbitratord remove || : + if [ -e ${service_config_dir}/$1 ]; then + ${csudo}update-rc.d -f $1 remove || : fi fi - ${csudo}rm -f ${service_config_dir}/${serverName2} || : - ${csudo}rm -f ${service_config_dir}/tarbitratord || : + ${csudo}rm -f ${service_config_dir}/$1 || : if $(which init &>/dev/null); then ${csudo}init q || : @@ -704,96 +697,68 @@ function clean_service_on_sysvinit() { } function install_service_on_sysvinit() { - clean_service_on_sysvinit + if [ "$1" != "${serverName}" ]; then + return + fi + + clean_service_on_sysvinit $1 sleep 1 if ((${os_type} == 1)); then - # ${csudo}cp -f ${script_dir}/init.d/${serverName}.deb ${install_main_dir}/init.d/${serverName} ${csudo}cp ${script_dir}/init.d/${serverName}.deb ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName} elif ((${os_type} == 2)); then - # ${csudo}cp -f ${script_dir}/init.d/${serverName}.rpm ${install_main_dir}/init.d/${serverName} ${csudo}cp ${script_dir}/init.d/${serverName}.rpm ${service_config_dir}/${serverName} && ${csudo}chmod a+x ${service_config_dir}/${serverName} fi if ((${initd_mod} == 1)); then - ${csudo}chkconfig --add ${serverName2} || : - ${csudo}chkconfig --level 2345 ${serverName2} on || : + ${csudo}chkconfig --add $1 || : + ${csudo}chkconfig --level 2345 $1 on || : elif ((${initd_mod} == 2)); then - ${csudo}insserv ${serverName2} || : - ${csudo}insserv -d ${serverName2} || : + ${csudo}insserv $1} || : + ${csudo}insserv -d $1 || : elif ((${initd_mod} == 3)); then - ${csudo}update-rc.d ${serverName2} defaults || : + ${csudo}update-rc.d $1 defaults || : fi } function clean_service_on_systemd() { - service_config="${service_config_dir}/${serverName2}.service" - if systemctl is-active --quiet ${serverName2}; then - echo "${productName} is running, stopping it..." - ${csudo}systemctl stop ${serverName2} &>/dev/null || echo &>/dev/null - fi - ${csudo}systemctl disable ${serverName2} &>/dev/null || echo &>/dev/null - ${csudo}rm -f ${service_config} + service_config="${service_config_dir}/$1.service" - tarbitratord_service_config="${service_config_dir}/tarbitratord.service" - if systemctl is-active --quiet tarbitratord; then - echo "tarbitrator is running, stopping it..." - ${csudo}systemctl stop tarbitratord &>/dev/null || echo &>/dev/null + if systemctl is-active --quiet $1; then + echo "$1 is running, stopping it..." + ${csudo}systemctl stop $1 &>/dev/null || echo &>/dev/null fi - ${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null - ${csudo}rm -f ${tarbitratord_service_config} + ${csudo}systemctl disable $1 &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${service_config} } function install_service_on_systemd() { - clean_service_on_systemd + clean_service_on_systemd $1 - install_share_etc - - [ -f ${script_dir}/cfg/${serverName2}.service ] && - ${csudo}cp ${script_dir}/cfg/${serverName2}.service \ - ${service_config_dir}/ || : - - # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then - # [ -f ${script_dir}/cfg/${serverName2}.service ] && - # ${csudo}cp ${script_dir}/cfg/${serverName2}.service \ - # ${service_config_dir}/${serverName2}.service || : - # fi - - ${csudo}systemctl daemon-reload - - ${csudo}systemctl enable ${serverName2} - ${csudo}systemctl daemon-reload -} - -function install_adapter_service() { - if ((${service_mod} == 0)); then - [ -f ${script_dir}/cfg/${adapterName2}.service ] && - ${csudo}cp ${script_dir}/cfg/${adapterName2}.service \ - ${service_config_dir}/ || : - - ${csudo}systemctl enable ${adapterName2} - ${csudo}systemctl daemon-reload + cfg_source_dir=${script_dir}/cfg + if [[ "$1" == "${xname}" || "$1" == "${explorerName}" ]]; then + if [ "$verMode" == "cluster" ]; then + cfg_source_dir=${script_dir}/${xname}/etc/systemd/system + else + cfg_source_dir=${script_dir}/cfg + fi fi -} -function install_keeper_service() { - if ((${service_mod} == 0)); then - [ -f ${script_dir}/cfg/${clientName2}keeper.service ] && - ${csudo}cp ${script_dir}/cfg/${clientName2}keeper.service \ - ${service_config_dir}/ || : - - ${csudo}systemctl enable ${clientName2}keeper - ${csudo}systemctl daemon-reload + if [ -f ${cfg_source_dir}/$1.service ]; then + ${csudo}cp ${cfg_source_dir}/$1.service ${service_config_dir}/ || : fi + + ${csudo}systemctl enable $1 + ${csudo}systemctl daemon-reload } function install_service() { if ((${service_mod} == 0)); then - install_service_on_systemd + install_service_on_systemd $1 elif ((${service_mod} == 1)); then - install_service_on_sysvinit + install_service_on_sysvinit $1 else - kill_process ${serverName2} + kill_process $1 fi } @@ -830,10 +795,10 @@ function is_version_compatible() { if [ -f ${script_dir}/driver/vercomp.txt ]; then min_compatible_version=$(cat ${script_dir}/driver/vercomp.txt) else - min_compatible_version=$(${script_dir}/bin/${serverName2} -V | head -1 | cut -d ' ' -f 5) + min_compatible_version=$(${script_dir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 5) fi - exist_version=$(${installDir}/bin/${serverName2} -V | head -1 | cut -d ' ' -f 3) + exist_version=$(${installDir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 3) vercomp $exist_version "3.0.0.0" case $? in 2) @@ -857,7 +822,7 @@ deb_erase() { echo -e -n "${RED}Existing TDengine deb is detected, do you want to remove it? [yes|no] ${NC}:" read confirm if [ "yes" == "$confirm" ]; then - ${csudo}dpkg --remove tdengine ||: + ${csudo}dpkg --remove tdengine || : break elif [ "no" == "$confirm" ]; then break @@ -871,7 +836,7 @@ rpm_erase() { echo -e -n "${RED}Existing TDengine rpm is detected, do you want to remove it? [yes|no] ${NC}:" read confirm if [ "yes" == "$confirm" ]; then - ${csudo}rpm -e tdengine ||: + ${csudo}rpm -e tdengine || : break elif [ "no" == "$confirm" ]; then break @@ -893,23 +858,23 @@ function updateProduct() { fi if echo $osinfo | grep -qwi "centos"; then - rpm -q tdengine 2>&1 > /dev/null && rpm_erase tdengine ||: + rpm -q tdengine 2>&1 >/dev/null && rpm_erase tdengine || : elif echo $osinfo | grep -qwi "ubuntu"; then - dpkg -l tdengine 2>&1 | grep ii > /dev/null && deb_erase tdengine ||: + dpkg -l tdengine 2>&1 | grep ii >/dev/null && deb_erase tdengine || : fi tar -zxf ${tarName} install_jemalloc - echo "Start to update ${productName2}..." + echo "Start to update ${productName}..." # Stop the service if running - if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then + if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then if ((${service_mod} == 0)); then - ${csudo}systemctl stop ${serverName2} || : + ${csudo}systemctl stop ${serverName} || : elif ((${service_mod} == 1)); then - ${csudo}service ${serverName2} stop || : + ${csudo}service ${serverName} stop || : else - kill_process ${serverName2} + kill_process ${serverName} fi sleep 1 fi @@ -922,82 +887,73 @@ function updateProduct() { install_config if [ "$verMode" == "cluster" ]; then - install_connector - install_taosx + install_connector + install_plugins fi install_examples - install_web if [ -z $1 ]; then install_bin - install_service - install_adapter_service - install_adapter_config - install_keeper_service - if [ "${verMode}" != "cloud" ]; then - install_keeper_config + install_services + + if [ "${pagMode}" != "lite" ]; then + install_adapter_config + install_taosx_config + install_explorer_config + if [ "${verMode}" != "cloud" ]; then + install_keeper_config + fi fi openresty_work=false echo - echo -e "${GREEN_DARK}To configure ${productName2} ${NC}\t\t: edit ${cfg_install_dir}/${configFile2}" - [ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To configure ${clientName2}Adapter ${NC}\t: edit ${configDir}/${clientName2}adapter.toml" + echo -e "${GREEN_DARK}To configure ${productName} ${NC}\t\t: edit ${configDir}/${configFile}" + [ -f ${configDir}/${adapterName}.toml ] && [ -f ${installDir}/bin/${adapterName} ] && + echo -e "${GREEN_DARK}To configure ${adapterName} ${NC}\t: edit ${configDir}/${adapterName}.toml" if [ "$verMode" == "cluster" ]; then - echo -e "${GREEN_DARK}To configure ${clientName2}-explorer ${NC}\t: edit ${configDir}/explorer.toml" + echo -e "${GREEN_DARK}To configure ${explorerName} ${NC}\t: edit ${configDir}/explorer.toml" fi if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${csudo}systemctl start ${serverName2}${NC}" - [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName2}adapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}systemctl start ${serverName}${NC}" + [ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${csudo}service ${serverName2} start${NC}" - [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}service ${clientName2}adapter start${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}service ${serverName} start${NC}" + [ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}service ${clientName}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ./${serverName2}${NC}" - [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${clientName2}adapter ${NC}" - fi - - echo -e "${GREEN_DARK}To enable ${clientName2}keeper ${NC}\t\t: sudo systemctl enable ${clientName2}keeper ${NC}" - if [ "$verMode" == "cluster" ];then - echo -e "${GREEN_DARK}To start ${clientName2}x ${NC}\t\t\t: sudo systemctl start ${clientName2}x ${NC}" - echo -e "${GREEN_DARK}To start ${clientName2}-explorer ${NC}\t\t: sudo systemctl start ${clientName2}-explorer ${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ./${serverName}${NC}" + [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${clientName}adapter ${NC}" fi - # if [ ${openresty_work} = 'true' ]; then - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}" - # else - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell${NC}" - # fi - - # if ((${prompt_force} == 1)); then - # echo "" - # echo -e "${RED}Please run '${serverName2} --force-keep-file' at first time for the exist ${productName2} $exist_version!${NC}" - # fi + echo -e "${GREEN_DARK}To enable ${clientName}keeper ${NC}\t\t: sudo systemctl enable ${clientName}keeper ${NC}" + if [ "$verMode" == "cluster" ]; then + echo -e "${GREEN_DARK}To start ${clientName}x ${NC}\t\t\t: sudo systemctl start ${clientName}x ${NC}" + echo -e "${GREEN_DARK}To start ${clientName}-explorer ${NC}\t\t: sudo systemctl start ${clientName}-explorer ${NC}" + fi echo - echo "${productName2} is updated successfully!" + echo "${productName} is updated successfully!" echo - if [ "$verMode" == "cluster" ];then + if [ "$verMode" == "cluster" ]; then echo -e "\033[44;32;1mTo start all the components : ./start-all.sh${NC}" fi - echo -e "\033[44;32;1mTo access ${productName2} : ${clientName2} -h $serverFqdn${NC}" - if [ "$verMode" == "cluster" ];then + echo -e "\033[44;32;1mTo access ${productName} : ${clientName} -h $serverFqdn${NC}" + if [ "$verMode" == "cluster" ]; then echo -e "\033[44;32;1mTo access the management system : http://$serverFqdn:6060${NC}" echo -e "\033[44;32;1mTo read the user manual : http://$serverFqdn:6060/docs${NC}" fi else - install_bin + install_bin echo - echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}" + echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}" fi cd $script_dir - rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } function installProduct() { @@ -1008,7 +964,7 @@ function installProduct() { fi tar -zxf ${tarName} - echo "Start to install ${productName2}..." + echo "Start to install ${productName}..." install_main_path @@ -1025,105 +981,114 @@ function installProduct() { install_config if [ "$verMode" == "cluster" ]; then - install_connector - install_taosx + install_connector + install_plugins fi - install_examples - install_web + install_examples + if [ -z $1 ]; then # install service and client # For installing new install_bin - install_service - install_adapter_service - install_adapter_config - install_keeper_service - if [ "${verMode}" != "cloud" ]; then - install_keeper_config - fi - openresty_work=false + install_services + if [ "${pagMode}" != "lite" ]; then + install_adapter_config + install_taosx_config + install_explorer_config + if [ "${verMode}" != "cloud" ]; then + install_keeper_config + fi + fi + + openresty_work=false # Ask if to start the service echo - echo -e "${GREEN_DARK}To configure ${productName2} ${NC}\t\t: edit ${cfg_install_dir}/${configFile2}" - [ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To configure ${clientName2}Adapter ${NC}\t: edit ${configDir}/${clientName2}adapter.toml" + echo -e "${GREEN_DARK}To configure ${productName} ${NC}\t\t: edit ${configDir}/${configFile}" + [ -f ${configDir}/${clientName}adapter.toml ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To configure ${clientName}Adapter ${NC}\t: edit ${configDir}/${clientName}adapter.toml" if [ "$verMode" == "cluster" ]; then - echo -e "${GREEN_DARK}To configure ${clientName2}-explorer ${NC}\t: edit ${configDir}/explorer.toml" + echo -e "${GREEN_DARK}To configure ${clientName}-explorer ${NC}\t: edit ${configDir}/explorer.toml" fi if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${csudo}systemctl start ${serverName2}${NC}" - [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName2}adapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}systemctl start ${serverName}${NC}" + [ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${csudo}service ${serverName2} start${NC}" - [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${csudo}service ${clientName2}adapter start${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}service ${serverName} start${NC}" + [ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}service ${clientName}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName2} ${NC}\t\t: ${serverName2}${NC}" - [ -f ${installDir}/bin/${clientName2}adapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName2}Adapter ${NC}\t\t: ${clientName2}adapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${serverName}${NC}" + [ -f ${installDir}/bin/${clientName}adapter ] && + echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${clientName}adapter ${NC}" fi - echo -e "${GREEN_DARK}To enable ${clientName2}keeper ${NC}\t\t: sudo systemctl enable ${clientName2}keeper ${NC}" - - if [ "$verMode" == "cluster" ];then - echo -e "${GREEN_DARK}To start ${clientName2}x ${NC}\t\t\t: sudo systemctl start ${clientName2}x ${NC}" - echo -e "${GREEN_DARK}To start ${clientName2}-explorer ${NC}\t\t: sudo systemctl start ${clientName2}-explorer ${NC}" + echo -e "${GREEN_DARK}To enable ${clientName}keeper ${NC}\t\t: sudo systemctl enable ${clientName}keeper ${NC}" + + if [ "$verMode" == "cluster" ]; then + echo -e "${GREEN_DARK}To start ${clientName}x ${NC}\t\t\t: sudo systemctl start ${clientName}x ${NC}" + echo -e "${GREEN_DARK}To start ${clientName}-explorer ${NC}\t\t: sudo systemctl start ${clientName}-explorer ${NC}" fi - # if [ ! -z "$firstEp" ]; then - # tmpFqdn=${firstEp%%:*} - # substr=":" - # if [[ $firstEp =~ $substr ]]; then - # tmpPort=${firstEp#*:} - # else - # tmpPort="" - # fi - # if [[ "$tmpPort" != "" ]]; then - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: ${clientName2} -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}" - # else - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: ${clientName2} -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}" - # fi - # echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}" - # echo - # elif [ ! -z "$serverFqdn" ]; then - # echo -e "${GREEN_DARK}To access ${productName2} ${NC}\t\t: ${clientName2} -h $serverFqdn${GREEN_DARK} to login into ${productName2} server${NC}" - # echo - # fi echo - echo "${productName2} is installed successfully!" + echo "${productName} is installed successfully!" echo - if [ "$verMode" == "cluster" ];then + if [ "$verMode" == "cluster" ]; then echo -e "\033[44;32;1mTo start all the components : sudo ./start-all.sh${NC}" fi - echo -e "\033[44;32;1mTo access ${productName2} : ${clientName2} -h $serverFqdn${NC}" - if [ "$verMode" == "cluster" ];then + echo -e "\033[44;32;1mTo access ${productName} : ${clientName} -h $serverFqdn${NC}" + if [ "$verMode" == "cluster" ]; then echo -e "\033[44;32;1mTo access the management system : http://$serverFqdn:6060${NC}" echo -e "\033[44;32;1mTo read the user manual : http://$serverFqdn:6060/docs-en${NC}" fi echo else # Only install client install_bin - + echo - echo -e "\033[44;32;1m${productName2} client is installed successfully!${NC}" + echo -e "\033[44;32;1m${productName} client is installed successfully!${NC}" fi - + cd $script_dir touch ~/.${historyFile} rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } +check_java_env() { + if ! command -v java &> /dev/null + then + echo -e "\033[31mWarning: Java command not found. Version 1.8+ is required.\033[0m" + return + fi + + java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}') + java_version_ok=false + if [[ $(echo "$java_version" | cut -d"." -f1) -gt 1 ]]; then + java_version_ok=true + elif [[ $(echo "$java_version" | cut -d"." -f1) -eq 1 && $(echo "$java_version" | cut -d"." -f2) -ge 8 ]]; then + java_version_ok=true + fi + + if $java_version_ok; then + echo -e "\033[32mJava ${java_version} has been found.\033[0m" + else + echo -e "\033[31mWarning: Java Version 1.8+ is required, but version ${java_version} has been found.\033[0m" + fi +} + ## ==============================Main program starts from here============================ serverFqdn=$(hostname) if [ "$verType" == "server" ]; then + if [ -x ${script_dir}/${xname}/bin/${xname} ]; then + check_java_env + fi # Check default 2.x data file. - if [ -x ${data_dir}/dnode/dnodeCfg.json ]; then - echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of ${productName2} 2.x, please clear it before installing!\033[0m" + if [ -x ${dataDir}/dnode/dnodeCfg.json ]; then + echo -e "\033[44;31;5mThe default data directory ${dataDir} contains old data of ${productName} 2.x, please clear it before installing!\033[0m" else # Install server and client - if [ -x ${bin_dir}/${serverName2} ]; then + if [ -x ${bin_dir}/${serverName} ]; then update_flag=1 updateProduct else @@ -1133,7 +1098,7 @@ if [ "$verType" == "server" ]; then elif [ "$verType" == "client" ]; then interactiveFqdn=no # Only install client - if [ -x ${bin_dir}/${clientName2} ]; then + if [ -x ${bin_dir}/${clientName} ]; then update_flag=1 updateProduct client else @@ -1142,5 +1107,3 @@ elif [ "$verType" == "client" ]; then else echo "please input correct verType" fi - - diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 4b0faaa958..3744892526 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -231,12 +231,8 @@ fi if [ "$verMode" == "cluster" ]; then sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >>remove_temp.sh - sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" remove_temp.sh - sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" remove_temp.sh - sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" remove_temp.sh - sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" remove_temp.sh - cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'` - sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" remove_temp.sh + sed -i "s/PREFIX=\"taos\"/PREFIX=\"${serverName2}\"/g" remove_temp.sh + sed -i "s/productName=\"TDengine\"/productName=\"${productName2}\"/g" remove_temp.sh mv remove_temp.sh ${install_dir}/bin/remove.sh fi if [ "$verMode" == "cloud" ]; then @@ -262,12 +258,10 @@ cp ${install_files} ${install_dir} cp ${install_dir}/install.sh install_temp.sh if [ "$verMode" == "cluster" ]; then sed -i 's/verMode=edge/verMode=cluster/g' install_temp.sh - sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_temp.sh - sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_temp.sh - sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" install_temp.sh - sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_temp.sh + sed -i "s/PREFIX=\"taos\"/PREFIX=\"${serverName2}\"/g" install_temp.sh + sed -i "s/productName=\"TDengine\"/productName=\"${productName2}\"/g" install_temp.sh cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'` - sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" install_temp.sh + sed -i "s/emailName=\"taosdata.com\"/emailName=\"${cusDomain}\"/g" install_temp.sh mv install_temp.sh ${install_dir}/install.sh fi if [ "$verMode" == "cloud" ]; then @@ -367,8 +361,7 @@ if [ "$verMode" == "cluster" ]; then # copy taosx if [ -d ${top_dir}/../enterprise/src/plugins/taosx/release/taosx ]; then - cp -r ${top_dir}/../enterprise/src/plugins/taosx/release/taosx ${install_dir} - cp ${top_dir}/../enterprise/packaging/install_taosx.sh ${install_dir}/taosx + cp -r ${top_dir}/../enterprise/src/plugins/taosx/release/taosx ${install_dir} cp ${top_dir}/../enterprise/src/plugins/taosx/packaging/uninstall.sh ${install_dir}/taosx sed -i 's/target=\"\"/target=\"taosx\"/g' ${install_dir}/taosx/uninstall.sh fi diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index eb33263286..427e238a7b 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -16,6 +16,8 @@ #include "cJSON.h" #include "clientInt.h" #include "parser.h" +#include "tcol.h" +#include "tcompression.h" #include "tdatablock.h" #include "tdef.h" #include "tglobal.h" @@ -27,7 +29,7 @@ static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3_32(db, strlen(db)); } static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id, - int8_t t) { + int8_t t, SColCmprWrapper* pColCmprRow) { char* string = NULL; cJSON* json = cJSON_CreateObject(); if (json == NULL) { @@ -67,6 +69,23 @@ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sch cJSON* isPk = cJSON_CreateBool(s->flags & COL_IS_KEY); cJSON_AddItemToObject(column, "isPrimarykey", isPk); cJSON_AddItemToArray(columns, column); + + if (pColCmprRow == NULL || pColCmprRow->nCols <= i) { + continue; + } + SColCmpr* pColCmpr = pColCmprRow->pColCmpr + i; + const char* encode = columnEncodeStr(COMPRESS_L1_TYPE_U32(pColCmpr->alg)); + const char* compress = columnCompressStr(COMPRESS_L2_TYPE_U32(pColCmpr->alg)); + const char* level = columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pColCmpr->alg)); + + cJSON* encodeJson = cJSON_CreateString(encode); + cJSON_AddItemToObject(column, "encode", encodeJson); + + cJSON* compressJson = cJSON_CreateString(compress); + cJSON_AddItemToObject(column, "compress", compressJson); + + cJSON* levelJson = cJSON_CreateString(level); + cJSON_AddItemToObject(column, "level", levelJson); } cJSON_AddItemToObject(json, "columns", columns); @@ -96,6 +115,30 @@ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sch return string; } +static int32_t setCompressOption(cJSON* json, uint32_t para) { + uint8_t encode = COMPRESS_L1_TYPE_U32(para); + if (encode != 0) { + const char* encodeStr = columnEncodeStr(encode); + cJSON* encodeJson = cJSON_CreateString(encodeStr); + cJSON_AddItemToObject(json, "encode", encodeJson); + return 0; + } + uint8_t compress = COMPRESS_L2_TYPE_U32(para); + if (compress != 0) { + const char* compressStr = columnCompressStr(compress); + cJSON* compressJson = cJSON_CreateString(compressStr); + cJSON_AddItemToObject(json, "compress", compressJson); + return 0; + } + uint8_t level = COMPRESS_L2_TYPE_LEVEL_U32(para); + if (level != 0) { + const char* levelStr = columnLevelStr(level); + cJSON* levelJson = cJSON_CreateString(levelStr); + cJSON_AddItemToObject(json, "level", levelJson); + return 0; + } + return 0; +} static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) { SMAlterStbReq req = {0}; cJSON* json = NULL; @@ -180,6 +223,13 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) { cJSON_AddItemToObject(json, "colNewName", colNewName); break; } + case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: { + TAOS_FIELD* field = taosArrayGet(req.pFields, 0); + cJSON* colName = cJSON_CreateString(field->name); + cJSON_AddItemToObject(json, "colName", colName); + setCompressOption(json, field->bytes); + break; + } default: break; } @@ -205,7 +255,7 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) { if (tDecodeSVCreateStbReq(&coder, &req) < 0) { goto _err; } - string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE); + string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE, &req.colCmpr); _err: uDebug("create stable return, sql json:%s", string); tDecoderClear(&coder); @@ -373,8 +423,8 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) { if (pCreateReq->type == TSDB_CHILD_TABLE) { string = buildCreateCTableJson(req.pReqs, req.nReqs); } else if (pCreateReq->type == TSDB_NORMAL_TABLE) { - string = - buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); + string = buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, + TSDB_NORMAL_TABLE, &pCreateReq->colCmpr); } } @@ -549,6 +599,12 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "colValueNull", isNullCJson); break; } + case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: { + cJSON* colName = cJSON_CreateString(vAlterTbReq.colName); + cJSON_AddItemToObject(json, "colName", colName); + setCompressOption(json, vAlterTbReq.compress); + break; + } default: break; } @@ -714,11 +770,11 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { // build create stable pReq.pColumns = taosArrayInit(req.schemaRow.nCols, sizeof(SFieldWithOptions)); for (int32_t i = 0; i < req.schemaRow.nCols; i++) { - SSchema* pSchema = req.schemaRow.pSchema + i; - SFieldWithOptions field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes}; + SSchema* pSchema = req.schemaRow.pSchema + i; + SFieldWithOptions field = {.type = pSchema->type, .flags = pSchema->flags, .bytes = pSchema->bytes}; strcpy(field.name, pSchema->name); - // todo get active compress param - setDefaultOptionsForField(&field); + SColCmpr *p = &req.colCmpr.pColCmpr[i]; + field.compress = p->alg; taosArrayPush(pReq.pColumns, &field); } pReq.pTags = taosArrayInit(req.schemaTag.nCols, sizeof(SField)); @@ -1346,10 +1402,10 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { } pVgData->vg = pInfo; - int tlen = 0; + int tlen = 0; req.source = TD_REQ_FROM_TAOX; tEncodeSize(tEncodeSVAlterTbReq, &req, tlen, code); - if(code != 0){ + if (code != 0) { code = TSDB_CODE_OUT_OF_MEMORY; goto end; } @@ -1365,7 +1421,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { SEncoder coder = {0}; tEncoderInit(&coder, pBuf, tlen - sizeof(SMsgHead)); code = tEncodeSVAlterTbReq(&coder, &req); - if(code != 0){ + if (code != 0) { tEncoderClear(&coder); code = TSDB_CODE_OUT_OF_MEMORY; goto end; @@ -1631,7 +1687,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { rspObj.common.resType = RES_TYPE__TMQ; int8_t dataVersion = *(int8_t*)data; - if (dataVersion >= MQ_DATA_RSP_VERSION){ + if (dataVersion >= MQ_DATA_RSP_VERSION) { data = POINTER_SHIFT(data, sizeof(int8_t) + sizeof(int32_t)); dataLen -= sizeof(int8_t) + sizeof(int32_t); } @@ -1777,7 +1833,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) rspObj.common.resType = RES_TYPE__TMQ_METADATA; int8_t dataVersion = *(int8_t*)data; - if (dataVersion >= MQ_DATA_RSP_VERSION){ + if (dataVersion >= MQ_DATA_RSP_VERSION) { data = POINTER_SHIFT(data, sizeof(int8_t) + sizeof(int32_t)); dataLen -= sizeof(int8_t) + sizeof(int32_t); } @@ -1913,7 +1969,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name)); } void* rawData = getRawDataFromRes(pRetrieve); - char err[ERR_MSG_LEN] = {0}; + char err[ERR_MSG_LEN] = {0}; code = rawBlockBindData(pQuery, pTableMeta, rawData, &pCreateReqDst, fields, pSW->nCols, true, err, ERR_MSG_LEN); taosMemoryFree(fields); if (code != TSDB_CODE_SUCCESS) { @@ -1982,9 +2038,9 @@ char* tmq_get_json_meta(TAOS_RES* res) { void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); } -static int32_t getOffSetLen(const void *rsp){ - const SMqDataRspCommon *pRsp = rsp; - SEncoder coder = {0}; +static int32_t getOffSetLen(const void* rsp) { + const SMqDataRspCommon* pRsp = rsp; + SEncoder coder = {0}; tEncoderInit(&coder, NULL, 0); if (tEncodeSTqOffsetVal(&coder, &pRsp->reqOffset) < 0) return -1; if (tEncodeSTqOffsetVal(&coder, &pRsp->rspOffset) < 0) return -1; @@ -1993,13 +2049,13 @@ static int32_t getOffSetLen(const void *rsp){ return pos; } -typedef int32_t __encode_func__(SEncoder *pEncoder, const void *pRsp); +typedef int32_t __encode_func__(SEncoder* pEncoder, const void* pRsp); -static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, void* rspObj, tmq_raw_data* raw){ - int32_t len = 0; +static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, void* rspObj, tmq_raw_data* raw) { + int32_t len = 0; int32_t code = 0; SEncoder encoder = {0}; - void* buf = NULL; + void* buf = NULL; tEncodeSize(encodeFunc, rspObj, len, code); if (code < 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -2007,17 +2063,17 @@ static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, void* rspObj, tmq_ra } len += sizeof(int8_t) + sizeof(int32_t); buf = taosMemoryCalloc(1, len); - if(buf == NULL){ + if (buf == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto FAILED; } tEncoderInit(&encoder, buf, len); if (tEncodeI8(&encoder, MQ_DATA_RSP_VERSION) < 0) { - terrno = TSDB_CODE_INVALID_MSG; - goto FAILED; + terrno = TSDB_CODE_INVALID_MSG; + goto FAILED; } int32_t offsetLen = getOffSetLen(rspObj); - if(offsetLen <= 0){ + if (offsetLen <= 0) { terrno = TSDB_CODE_INVALID_MSG; goto FAILED; } @@ -2025,7 +2081,7 @@ static int32_t encodeMqDataRsp(__encode_func__* encodeFunc, void* rspObj, tmq_ra terrno = TSDB_CODE_INVALID_MSG; goto FAILED; } - if(encodeFunc(&encoder, rspObj) < 0){ + if (encodeFunc(&encoder, rspObj) < 0) { terrno = TSDB_CODE_INVALID_MSG; goto FAILED; } @@ -2053,7 +2109,7 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { uDebug("tmq get raw type meta:%p", raw); } else if (TD_RES_TMQ(res)) { SMqRspObj* rspObj = ((SMqRspObj*)res); - if(encodeMqDataRsp(tEncodeMqDataRsp, &rspObj->rsp, raw) != 0){ + if (encodeMqDataRsp(tEncodeMqDataRsp, &rspObj->rsp, raw) != 0) { uError("tmq get raw type error:%d", terrno); return terrno; } @@ -2062,7 +2118,7 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { } else if (TD_RES_TMQ_METADATA(res)) { SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res); - if(encodeMqDataRsp(tEncodeSTaosxRsp, &rspObj->rsp, raw) != 0){ + if (encodeMqDataRsp(tEncodeSTaosxRsp, &rspObj->rsp, raw) != 0) { uError("tmq get raw type error:%d", terrno); return terrno; } diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 0802ec672a..6225cf703c 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -832,7 +832,7 @@ static int32_t smlFindNearestPowerOf2(int32_t length, uint8_t type) { return result; } -static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SHashObj *schemaHash, SArray *cols, +static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SHashObj *schemaHash, SArray *cols, SArray *checkDumplicateCols, ESchemaAction *action, bool isTag) { int32_t code = TSDB_CODE_SUCCESS; for (int j = 0; j < taosArrayGetSize(cols); ++j) { @@ -843,6 +843,13 @@ static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SH return code; } } + + for (int j = 0; j < taosArrayGetSize(checkDumplicateCols); ++j) { + SSmlKv *kv = (SSmlKv *)taosArrayGet(checkDumplicateCols, j); + if(taosHashGet(schemaHash, kv->key, kv->keyLen) != NULL){ + return TSDB_CODE_PAR_DUPLICATED_COLUMN; + } + } return TSDB_CODE_SUCCESS; } @@ -1106,7 +1113,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { } ESchemaAction action = SCHEMA_ACTION_NULL; - code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->tags, &action, true); + code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->tags, sTableData->cols, &action, true); if (code != TSDB_CODE_SUCCESS) { goto end; } @@ -1181,7 +1188,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES); } action = SCHEMA_ACTION_NULL; - code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->cols, &action, false); + code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->cols, sTableData->tags, &action, false); if (code != TSDB_CODE_SUCCESS) { goto end; } @@ -1290,17 +1297,24 @@ end: return code; } -static void smlInsertMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols) { +static int32_t smlInsertMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols, SHashObj *checkDuplicate) { + terrno = 0; for (int16_t i = 0; i < taosArrayGetSize(cols); ++i) { SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i); int ret = taosHashPut(metaHash, kv->key, kv->keyLen, &i, SHORT_BYTES); if (ret == 0) { taosArrayPush(metaArray, kv); + if(taosHashGet(checkDuplicate, kv->key, kv->keyLen) != NULL) { + return TSDB_CODE_PAR_DUPLICATED_COLUMN; + } + }else if(terrno == TSDB_CODE_DUP_KEY){ + return TSDB_CODE_PAR_DUPLICATED_COLUMN; } } + return TSDB_CODE_SUCCESS; } -static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols, bool isTag, SSmlMsgBuf *msg) { +static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols, bool isTag, SSmlMsgBuf *msg, SHashObj* checkDuplicate) { for (int i = 0; i < taosArrayGetSize(cols); ++i) { SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i); @@ -1332,6 +1346,11 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols int ret = taosHashPut(metaHash, kv->key, kv->keyLen, &size, SHORT_BYTES); if (ret == 0) { taosArrayPush(metaArray, kv); + if(taosHashGet(checkDuplicate, kv->key, kv->keyLen) != NULL) { + return TSDB_CODE_PAR_DUPLICATED_COLUMN; + } + }else{ + return ret; } } } @@ -1456,7 +1475,7 @@ static int32_t smlPushCols(SArray *colsArray, SArray *cols) { taosHashPut(kvHash, kv->key, kv->keyLen, &kv, POINTER_BYTES); if (terrno == TSDB_CODE_DUP_KEY) { taosHashCleanup(kvHash); - return terrno; + return TSDB_CODE_PAR_DUPLICATED_COLUMN; } } @@ -1512,12 +1531,12 @@ static int32_t smlParseLineBottom(SSmlHandle *info) { if (tableMeta) { // update meta uDebug("SML:0x%" PRIx64 " smlParseLineBottom update meta, format:%d, linenum:%d", info->id, info->dataFormat, info->lineNum); - ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, elements->colArray, false, &info->msgBuf); + ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, elements->colArray, false, &info->msgBuf, (*tableMeta)->tagHash); if (ret == TSDB_CODE_SUCCESS) { - ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, tinfo->tags, true, &info->msgBuf); + ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, tinfo->tags, true, &info->msgBuf, (*tableMeta)->colHash); } if (ret != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " smlUpdateMeta failed", info->id); + uError("SML:0x%" PRIx64 " smlUpdateMeta failed, ret:%d", info->id, ret); return ret; } } else { @@ -1527,13 +1546,19 @@ static int32_t smlParseLineBottom(SSmlHandle *info) { if (meta == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - taosHashPut(info->superTables, elements->measure, elements->measureLen, &meta, POINTER_BYTES); - terrno = 0; - smlInsertMeta(meta->tagHash, meta->tags, tinfo->tags); - if (terrno == TSDB_CODE_DUP_KEY) { - return terrno; + ret = taosHashPut(info->superTables, elements->measure, elements->measureLen, &meta, POINTER_BYTES); + if (ret != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " put measuer to hash failed", info->id); + return ret; + } + ret = smlInsertMeta(meta->tagHash, meta->tags, tinfo->tags, NULL); + if (ret == TSDB_CODE_SUCCESS) { + ret = smlInsertMeta(meta->colHash, meta->cols, elements->colArray, meta->tagHash); + } + if (ret != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " insert meta failed:%s", info->id, tstrerror(ret)); + return ret; } - smlInsertMeta(meta->colHash, meta->cols, elements->colArray); } } uDebug("SML:0x%" PRIx64 " smlParseLineBottom end, format:%d, linenum:%d", info->id, info->dataFormat, info->lineNum); 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/common/src/tmsg.c b/source/common/src/tmsg.c index 6c2358a1d7..45b0b6ac2b 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -69,7 +69,7 @@ static int32_t tDecodeSVAlterTbReqCommon(SDecoder *pDecoder, SVAlterTbReq *pReq); static int32_t tDecodeSBatchDeleteReqCommon(SDecoder *pDecoder, SBatchDeleteReq *pReq); static int32_t tEncodeTableTSMAInfoRsp(SEncoder *pEncoder, const STableTSMAInfoRsp *pRsp); -static int32_t tDecodeTableTSMAInfoRsp(SDecoder* pDecoder, STableTSMAInfoRsp* pRsp); +static int32_t tDecodeTableTSMAInfoRsp(SDecoder *pDecoder, STableTSMAInfoRsp *pRsp); int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) { if (pMsg == NULL) { @@ -895,8 +895,8 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq if (tEncodeI64(&encoder, pReq->normSourceTbUid) < 0) return -1; if (tEncodeI32(&encoder, taosArrayGetSize(pReq->pVgroupVerList)) < 0) return -1; - for(int32_t i = 0; i < taosArrayGetSize(pReq->pVgroupVerList); ++i) { - SVgroupVer* p = taosArrayGet(pReq->pVgroupVerList, i); + for (int32_t i = 0; i < taosArrayGetSize(pReq->pVgroupVerList); ++i) { + SVgroupVer *p = taosArrayGet(pReq->pVgroupVerList, i); if (tEncodeI32(&encoder, p->vgId) < 0) return -1; if (tEncodeI64(&encoder, p->ver) < 0) return -1; } @@ -8000,7 +8000,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea } } if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI64(&decoder, &pReq->smaId)< 0) return -1; + if (tDecodeI64(&decoder, &pReq->smaId) < 0) return -1; } tEndDecode(&decoder); @@ -8445,8 +8445,8 @@ static int32_t tDecodeSVDropTbRsp(SDecoder *pCoder, SVDropTbRsp *pReq) { } int32_t tEncodeSVDropTbBatchReq(SEncoder *pCoder, const SVDropTbBatchReq *pReq) { - int32_t nReqs = taosArrayGetSize(pReq->pArray); - SVDropTbReq *pDropTbReq; + int32_t nReqs = taosArrayGetSize(pReq->pArray); + SVDropTbReq *pDropTbReq; if (tStartEncode(pCoder) < 0) return -1; @@ -8709,6 +8709,7 @@ int32_t tEncodeSVAlterTbReq(SEncoder *pEncoder, const SVAlterTbReq *pReq) { } break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: + if (tEncodeCStr(pEncoder, pReq->colName) < 0) return -1; if (tEncodeU32(pEncoder, pReq->compress) < 0) return -1; break; default: @@ -8763,6 +8764,7 @@ static int32_t tDecodeSVAlterTbReqCommon(SDecoder *pDecoder, SVAlterTbReq *pReq) } break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS: + if (tDecodeCStr(pDecoder, &pReq->colName) < 0) return -1; if (tDecodeU32(pDecoder, &pReq->compress) < 0) return -1; break; default: @@ -9200,7 +9202,7 @@ int32_t tEncodeMqDataRspCommon(SEncoder *pEncoder, const SMqDataRspCommon *pRsp) int32_t tEncodeMqDataRsp(SEncoder *pEncoder, const void *pRsp) { if (tEncodeMqDataRspCommon(pEncoder, pRsp) < 0) return -1; - if (tEncodeI64(pEncoder, ((SMqDataRsp*)pRsp)->sleepTime) < 0) return -1; + if (tEncodeI64(pEncoder, ((SMqDataRsp *)pRsp)->sleepTime) < 0) return -1; return 0; } @@ -9253,7 +9255,7 @@ int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRspCommon *pRsp) { int32_t tDecodeMqDataRsp(SDecoder *pDecoder, void *pRsp) { if (tDecodeMqDataRspCommon(pDecoder, pRsp) < 0) return -1; if (!tDecodeIsEnd(pDecoder)) { - if (tDecodeI64(pDecoder, &((SMqDataRsp*)pRsp)->sleepTime) < 0) return -1; + if (tDecodeI64(pDecoder, &((SMqDataRsp *)pRsp)->sleepTime) < 0) return -1; } return 0; @@ -9272,9 +9274,7 @@ static void tDeleteMqDataRspCommon(void *rsp) { tOffsetDestroy(&pRsp->rspOffset); } -void tDeleteMqDataRsp(void *rsp) { - tDeleteMqDataRspCommon(rsp); -} +void tDeleteMqDataRsp(void *rsp) { tDeleteMqDataRspCommon(rsp); } int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const void *rsp) { if (tEncodeMqDataRspCommon(pEncoder, rsp) < 0) return -1; @@ -9300,7 +9300,7 @@ int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, void *rsp) { pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t)); pRsp->createTableReq = taosArrayInit(pRsp->createTableNum, sizeof(void *)); for (int32_t i = 0; i < pRsp->createTableNum; i++) { - void * pCreate = NULL; + void *pCreate = NULL; uint64_t len = 0; if (tDecodeBinaryAlloc(pDecoder, &pCreate, &len) < 0) return -1; int32_t l = (int32_t)len; @@ -10114,7 +10114,7 @@ void setFieldWithOptions(SFieldWithOptions *fieldWithOptions, SField *field) { fieldWithOptions->type = field->type; strncpy(fieldWithOptions->name, field->name, TSDB_COL_NAME_LEN); } -int32_t tSerializeTableTSMAInfoReq(void* buf, int32_t bufLen, const STableTSMAInfoReq* pReq) { +int32_t tSerializeTableTSMAInfoReq(void *buf, int32_t bufLen, const STableTSMAInfoReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -10129,13 +10129,13 @@ int32_t tSerializeTableTSMAInfoReq(void* buf, int32_t bufLen, const STableTSMAIn return tlen; } -int32_t tDeserializeTableTSMAInfoReq(void* buf, int32_t bufLen, STableTSMAInfoReq* pReq) { +int32_t tDeserializeTableTSMAInfoReq(void *buf, int32_t bufLen, STableTSMAInfoReq *pReq) { SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); if (tStartDecode(&decoder) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; - if (tDecodeI8(&decoder, (uint8_t*)&pReq->fetchingWithTsmaName) < 0) return -1; + if (tDecodeI8(&decoder, (uint8_t *)&pReq->fetchingWithTsmaName) < 0) return -1; tEndDecode(&decoder); @@ -10143,7 +10143,7 @@ int32_t tDeserializeTableTSMAInfoReq(void* buf, int32_t bufLen, STableTSMAInfoRe return 0; } -static int32_t tEncodeTableTSMAInfo(SEncoder* pEncoder, const STableTSMAInfo* pTsmaInfo) { +static int32_t tEncodeTableTSMAInfo(SEncoder *pEncoder, const STableTSMAInfo *pTsmaInfo) { if (tEncodeCStr(pEncoder, pTsmaInfo->name) < 0) return -1; if (tEncodeU64(pEncoder, pTsmaInfo->tsmaId) < 0) return -1; if (tEncodeCStr(pEncoder, pTsmaInfo->tb) < 0) return -1; @@ -10160,7 +10160,7 @@ static int32_t tEncodeTableTSMAInfo(SEncoder* pEncoder, const STableTSMAInfo* pT int32_t size = pTsmaInfo->pFuncs ? pTsmaInfo->pFuncs->size : 0; if (tEncodeI32(pEncoder, size) < 0) return -1; for (int32_t i = 0; i < size; ++i) { - STableTSMAFuncInfo* pFuncInfo = taosArrayGet(pTsmaInfo->pFuncs, i); + STableTSMAFuncInfo *pFuncInfo = taosArrayGet(pTsmaInfo->pFuncs, i); if (tEncodeI32(pEncoder, pFuncInfo->funcId) < 0) return -1; if (tEncodeI16(pEncoder, pFuncInfo->colId) < 0) return -1; } @@ -10168,13 +10168,13 @@ static int32_t tEncodeTableTSMAInfo(SEncoder* pEncoder, const STableTSMAInfo* pT size = pTsmaInfo->pTags ? pTsmaInfo->pTags->size : 0; if (tEncodeI32(pEncoder, size) < 0) return -1; for (int32_t i = 0; i < size; ++i) { - const SSchema* pSchema = taosArrayGet(pTsmaInfo->pTags, i); + const SSchema *pSchema = taosArrayGet(pTsmaInfo->pTags, i); if (tEncodeSSchema(pEncoder, pSchema) < 0) return -1; } size = pTsmaInfo->pUsedCols ? pTsmaInfo->pUsedCols->size : 0; if (tEncodeI32(pEncoder, size) < 0) return -1; for (int32_t i = 0; i < size; ++i) { - const SSchema* pSchema = taosArrayGet(pTsmaInfo->pUsedCols, i); + const SSchema *pSchema = taosArrayGet(pTsmaInfo->pUsedCols, i); if (tEncodeSSchema(pEncoder, pSchema) < 0) return -1; } @@ -10187,7 +10187,7 @@ static int32_t tEncodeTableTSMAInfo(SEncoder* pEncoder, const STableTSMAInfo* pT return 0; } -static int32_t tDecodeTableTSMAInfo(SDecoder* pDecoder, STableTSMAInfo* pTsmaInfo) { +static int32_t tDecodeTableTSMAInfo(SDecoder *pDecoder, STableTSMAInfo *pTsmaInfo) { if (tDecodeCStrTo(pDecoder, pTsmaInfo->name) < 0) return -1; if (tDecodeU64(pDecoder, &pTsmaInfo->tsmaId) < 0) return -1; if (tDecodeCStrTo(pDecoder, pTsmaInfo->tb) < 0) return -1; @@ -10219,7 +10219,7 @@ static int32_t tDecodeTableTSMAInfo(SDecoder* pDecoder, STableTSMAInfo* pTsmaInf if (!pTsmaInfo->pTags) return -1; for (int32_t i = 0; i < size; ++i) { SSchema schema = {0}; - if(tDecodeSSchema(pDecoder, &schema) < 0) return -1; + if (tDecodeSSchema(pDecoder, &schema) < 0) return -1; taosArrayPush(pTsmaInfo->pTags, &schema); } } @@ -10239,7 +10239,7 @@ static int32_t tDecodeTableTSMAInfo(SDecoder* pDecoder, STableTSMAInfo* pTsmaInf if (tDecodeI64(pDecoder, &pTsmaInfo->reqTs) < 0) return -1; if (tDecodeI64(pDecoder, &pTsmaInfo->rspTs) < 0) return -1; if (tDecodeI64(pDecoder, &pTsmaInfo->delayDuration) < 0) return -1; - if (tDecodeI8(pDecoder, (int8_t*)&pTsmaInfo->fillHistoryFinished) < 0) return -1; + if (tDecodeI8(pDecoder, (int8_t *)&pTsmaInfo->fillHistoryFinished) < 0) return -1; return 0; } @@ -10247,13 +10247,13 @@ static int32_t tEncodeTableTSMAInfoRsp(SEncoder *pEncoder, const STableTSMAInfoR int32_t size = pRsp->pTsmas ? pRsp->pTsmas->size : 0; if (tEncodeI32(pEncoder, size) < 0) return -1; for (int32_t i = 0; i < size; ++i) { - STableTSMAInfo* pInfo = taosArrayGetP(pRsp->pTsmas, i); + STableTSMAInfo *pInfo = taosArrayGetP(pRsp->pTsmas, i); if (tEncodeTableTSMAInfo(pEncoder, pInfo) < 0) return -1; } return 0; } -static int32_t tDecodeTableTSMAInfoRsp(SDecoder* pDecoder, STableTSMAInfoRsp* pRsp) { +static int32_t tDecodeTableTSMAInfoRsp(SDecoder *pDecoder, STableTSMAInfoRsp *pRsp) { int32_t size = 0; if (tDecodeI32(pDecoder, &size) < 0) return -1; if (size <= 0) return 0; @@ -10268,7 +10268,7 @@ static int32_t tDecodeTableTSMAInfoRsp(SDecoder* pDecoder, STableTSMAInfoRsp* pR return 0; } -int32_t tSerializeTableTSMAInfoRsp(void* buf, int32_t bufLen, const STableTSMAInfoRsp* pRsp) { +int32_t tSerializeTableTSMAInfoRsp(void *buf, int32_t bufLen, const STableTSMAInfoRsp *pRsp) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -10282,7 +10282,7 @@ int32_t tSerializeTableTSMAInfoRsp(void* buf, int32_t bufLen, const STableTSMAIn return tlen; } -int32_t tDeserializeTableTSMAInfoRsp(void* buf, int32_t bufLen, STableTSMAInfoRsp* pRsp) { +int32_t tDeserializeTableTSMAInfoRsp(void *buf, int32_t bufLen, STableTSMAInfoRsp *pRsp) { SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); @@ -10295,7 +10295,7 @@ int32_t tDeserializeTableTSMAInfoRsp(void* buf, int32_t bufLen, STableTSMAInfoRs return 0; } -void tFreeTableTSMAInfo(void* p) { +void tFreeTableTSMAInfo(void *p) { STableTSMAInfo *pTsmaInfo = p; if (pTsmaInfo) { taosArrayDestroy(pTsmaInfo->pFuncs); @@ -10305,20 +10305,20 @@ void tFreeTableTSMAInfo(void* p) { } } -void tFreeAndClearTableTSMAInfo(void* p) { - STableTSMAInfo* pTsmaInfo = (STableTSMAInfo*)p; +void tFreeAndClearTableTSMAInfo(void *p) { + STableTSMAInfo *pTsmaInfo = (STableTSMAInfo *)p; if (pTsmaInfo) { tFreeTableTSMAInfo(pTsmaInfo); taosMemoryFree(pTsmaInfo); } } -int32_t tCloneTbTSMAInfo(STableTSMAInfo* pInfo, STableTSMAInfo** pRes) { +int32_t tCloneTbTSMAInfo(STableTSMAInfo *pInfo, STableTSMAInfo **pRes) { int32_t code = TSDB_CODE_SUCCESS; if (NULL == pInfo) { return TSDB_CODE_SUCCESS; } - STableTSMAInfo* pRet = taosMemoryCalloc(1, sizeof(STableTSMAInfo)); + STableTSMAInfo *pRet = taosMemoryCalloc(1, sizeof(STableTSMAInfo)); if (!pRet) return TSDB_CODE_OUT_OF_MEMORY; *pRet = *pInfo; @@ -10357,7 +10357,7 @@ static int32_t tEncodeStreamProgressReq(SEncoder *pEncoder, const SStreamProgres return 0; } -int32_t tSerializeStreamProgressReq(void* buf, int32_t bufLen, const SStreamProgressReq* pReq) { +int32_t tSerializeStreamProgressReq(void *buf, int32_t bufLen, const SStreamProgressReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -10371,7 +10371,7 @@ int32_t tSerializeStreamProgressReq(void* buf, int32_t bufLen, const SStreamProg return tlen; } -static int32_t tDecodeStreamProgressReq(SDecoder* pDecoder, SStreamProgressReq* pReq) { +static int32_t tDecodeStreamProgressReq(SDecoder *pDecoder, SStreamProgressReq *pReq) { if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->vgId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->fetchIdx) < 0) return -1; @@ -10379,7 +10379,7 @@ static int32_t tDecodeStreamProgressReq(SDecoder* pDecoder, SStreamProgressReq* return 0; } -int32_t tDeserializeStreamProgressReq(void* buf, int32_t bufLen, SStreamProgressReq* pReq) { +int32_t tDeserializeStreamProgressReq(void *buf, int32_t bufLen, SStreamProgressReq *pReq) { SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf, bufLen); @@ -10392,7 +10392,7 @@ int32_t tDeserializeStreamProgressReq(void* buf, int32_t bufLen, SStreamProgress return 0; } -static int32_t tEncodeStreamProgressRsp(SEncoder* pEncoder, const SStreamProgressRsp* pRsp) { +static int32_t tEncodeStreamProgressRsp(SEncoder *pEncoder, const SStreamProgressRsp *pRsp) { if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->vgId) < 0) return -1; if (tEncodeI8(pEncoder, pRsp->fillHisFinished) < 0) return -1; @@ -10402,7 +10402,7 @@ static int32_t tEncodeStreamProgressRsp(SEncoder* pEncoder, const SStreamProgres return 0; } -int32_t tSerializeStreamProgressRsp(void* buf, int32_t bufLen, const SStreamProgressRsp* pRsp) { +int32_t tSerializeStreamProgressRsp(void *buf, int32_t bufLen, const SStreamProgressRsp *pRsp) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -10416,17 +10416,17 @@ int32_t tSerializeStreamProgressRsp(void* buf, int32_t bufLen, const SStreamProg return tlen; } -static int32_t tDecodeStreamProgressRsp(SDecoder* pDecoder, SStreamProgressRsp* pRsp) { +static int32_t tDecodeStreamProgressRsp(SDecoder *pDecoder, SStreamProgressRsp *pRsp) { if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->vgId) < 0) return -1; - if (tDecodeI8(pDecoder, (int8_t*)&pRsp->fillHisFinished) < 0) return -1; + if (tDecodeI8(pDecoder, (int8_t *)&pRsp->fillHisFinished) < 0) return -1; if (tDecodeI64(pDecoder, &pRsp->progressDelay) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->fetchIdx) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->subFetchIdx) < 0) return -1; return 0; } -int32_t tDeserializeSStreamProgressRsp(void* buf, int32_t bufLen, SStreamProgressRsp* pRsp) { +int32_t tDeserializeSStreamProgressRsp(void *buf, int32_t bufLen, SStreamProgressRsp *pRsp) { SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); @@ -10440,22 +10440,22 @@ int32_t tDeserializeSStreamProgressRsp(void* buf, int32_t bufLen, SStreamProgres } int32_t tEncodeSMDropTbReqOnSingleVg(SEncoder *pEncoder, const SMDropTbReqsOnSingleVg *pReq) { - const SVgroupInfo* pVgInfo = &pReq->vgInfo; + const SVgroupInfo *pVgInfo = &pReq->vgInfo; if (tEncodeI32(pEncoder, pVgInfo->vgId) < 0) return -1; if (tEncodeU32(pEncoder, pVgInfo->hashBegin) < 0) return -1; if (tEncodeU32(pEncoder, pVgInfo->hashEnd) < 0) return -1; if (tEncodeSEpSet(pEncoder, &pVgInfo->epSet) < 0) return -1; if (tEncodeI32(pEncoder, pVgInfo->numOfTable) < 0) return -1; - int32_t size = pReq->pTbs ? pReq->pTbs->size: 0; + int32_t size = pReq->pTbs ? pReq->pTbs->size : 0; if (tEncodeI32(pEncoder, size) < 0) return -1; for (int32_t i = 0; i < size; ++i) { - const SVDropTbReq* pInfo = taosArrayGet(pReq->pTbs, i); + const SVDropTbReq *pInfo = taosArrayGet(pReq->pTbs, i); if (tEncodeSVDropTbReq(pEncoder, pInfo) < 0) return -1; } return 0; } -int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder* pDecoder, SMDropTbReqsOnSingleVg* pReq) { +int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder *pDecoder, SMDropTbReqsOnSingleVg *pReq) { if (tDecodeI32(pDecoder, &pReq->vgInfo.vgId) < 0) return -1; if (tDecodeU32(pDecoder, &pReq->vgInfo.hashBegin) < 0) return -1; if (tDecodeU32(pDecoder, &pReq->vgInfo.hashEnd) < 0) return -1; @@ -10477,18 +10477,18 @@ int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder* pDecoder, SMDropTbReqsOnSingleVg* } void tFreeSMDropTbReqOnSingleVg(void *p) { - SMDropTbReqsOnSingleVg* pReq = p; + SMDropTbReqsOnSingleVg *pReq = p; taosArrayDestroy(pReq->pTbs); } -int32_t tSerializeSMDropTbsReq(void* buf, int32_t bufLen, const SMDropTbsReq* pReq){ +int32_t tSerializeSMDropTbsReq(void *buf, int32_t bufLen, const SMDropTbsReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); tStartEncode(&encoder); int32_t size = pReq->pVgReqs ? pReq->pVgReqs->size : 0; if (tEncodeI32(&encoder, size) < 0) return -1; for (int32_t i = 0; i < size; ++i) { - SMDropTbReqsOnSingleVg* pVgReq = taosArrayGet(pReq->pVgReqs, i); + SMDropTbReqsOnSingleVg *pVgReq = taosArrayGet(pReq->pVgReqs, i); if (tEncodeSMDropTbReqOnSingleVg(&encoder, pVgReq) < 0) return -1; } tEndEncode(&encoder); @@ -10497,7 +10497,7 @@ int32_t tSerializeSMDropTbsReq(void* buf, int32_t bufLen, const SMDropTbsReq* pR return tlen; } -int32_t tDeserializeSMDropTbsReq(void* buf, int32_t bufLen, SMDropTbsReq* pReq) { +int32_t tDeserializeSMDropTbsReq(void *buf, int32_t bufLen, SMDropTbsReq *pReq) { SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); tStartDecode(&decoder); @@ -10518,12 +10518,12 @@ int32_t tDeserializeSMDropTbsReq(void* buf, int32_t bufLen, SMDropTbsReq* pReq) return 0; } -void tFreeSMDropTbsReq(void* p) { - SMDropTbsReq* pReq = p; +void tFreeSMDropTbsReq(void *p) { + SMDropTbsReq *pReq = p; taosArrayDestroyEx(pReq->pVgReqs, tFreeSMDropTbReqOnSingleVg); } -int32_t tEncodeVFetchTtlExpiredTbsRsp(SEncoder* pCoder, const SVFetchTtlExpiredTbsRsp* pRsp) { +int32_t tEncodeVFetchTtlExpiredTbsRsp(SEncoder *pCoder, const SVFetchTtlExpiredTbsRsp *pRsp) { if (tEncodeI32(pCoder, pRsp->vgId) < 0) return -1; int32_t size = pRsp->pExpiredTbs ? pRsp->pExpiredTbs->size : 0; if (tEncodeI32(pCoder, size) < 0) return -1; @@ -10533,7 +10533,7 @@ int32_t tEncodeVFetchTtlExpiredTbsRsp(SEncoder* pCoder, const SVFetchTtlExpiredT return 0; } -int32_t tDecodeVFetchTtlExpiredTbsRsp(SDecoder* pCoder, SVFetchTtlExpiredTbsRsp* pRsp) { +int32_t tDecodeVFetchTtlExpiredTbsRsp(SDecoder *pCoder, SVFetchTtlExpiredTbsRsp *pRsp) { if (tDecodeI32(pCoder, &pRsp->vgId) < 0) return -1; int32_t size = 0; if (tDecodeI32(pCoder, &size) < 0) return -1; @@ -10549,7 +10549,7 @@ int32_t tDecodeVFetchTtlExpiredTbsRsp(SDecoder* pCoder, SVFetchTtlExpiredTbsRsp* return 0; } -void tFreeFetchTtlExpiredTbsRsp(void* p) { - SVFetchTtlExpiredTbsRsp* pRsp = p; +void tFreeFetchTtlExpiredTbsRsp(void *p) { + SVFetchTtlExpiredTbsRsp *pRsp = p; taosArrayDestroy(pRsp->pExpiredTbs); } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index 75d5669824..885086e37a 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -16,6 +16,8 @@ #define _DEFAULT_SOURCE #include "mmInt.h" +#define PROCESS_THRESHOLD (2000 * 1000) + static inline int32_t mmAcquire(SMnodeMgmt *pMgmt) { int32_t code = 0; taosThreadRwlockRdlock(&pMgmt->lock); @@ -53,6 +55,14 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { int32_t code = mndProcessRpcMsg(pMsg); + if (pInfo->timestamp != 0) { + int64_t cost = taosGetTimestampUs() - pInfo->timestamp; + if (cost > PROCESS_THRESHOLD) { + dGWarn("worker:%d,message has been processed for too long, type:%s, cost: %" PRId64 "s", pInfo->threadNum, + TMSG_INFO(pMsg->msgType), cost / (1000 * 1000)); + } + } + if (IsReq(pMsg) && pMsg->info.handle != NULL && code != TSDB_CODE_ACTION_IN_PROGRESS) { if (code != 0 && terrno != 0) code = terrno; mmSendRsp(pMsg, code); 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/mndArbGroup.c b/source/dnode/mnode/impl/src/mndArbGroup.c index 92ab5274e4..d0a86bdde7 100644 --- a/source/dnode/mnode/impl/src/mndArbGroup.c +++ b/source/dnode/mnode/impl/src/mndArbGroup.c @@ -27,6 +27,8 @@ #define ARBGROUP_VER_NUMBER 1 #define ARBGROUP_RESERVE_SIZE 64 +static SHashObj *arbUpdateHash = NULL; + static int32_t mndArbGroupActionInsert(SSdb *pSdb, SArbGroup *pGroup); static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *pNew); static int32_t mndArbGroupActionDelete(SSdb *pSdb, SArbGroup *pGroup); @@ -74,10 +76,14 @@ int32_t mndInitArbGroup(SMnode *pMnode) { mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ARBGROUP, mndRetrieveArbGroups); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_ARBGROUP, mndCancelGetNextArbGroup); + arbUpdateHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); + return sdbSetTable(pMnode->pSdb, table); } -void mndCleanupArbGroup(SMnode *pMnode) {} +void mndCleanupArbGroup(SMnode *pMnode) { + taosHashCleanup(arbUpdateHash); +} SArbGroup *mndAcquireArbGroup(SMnode *pMnode, int32_t vgId) { SArbGroup *pGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &vgId); @@ -221,8 +227,7 @@ static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *p mInfo("arbgroup:%d, skip to perform update action, old row:%p new row:%p, old version:%" PRId64 " new version:%" PRId64, pOld->vgId, pOld, pNew, pOld->version, pNew->version); - taosThreadMutexUnlock(&pOld->mutex); - return 0; + goto _OVER; } for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { @@ -232,7 +237,11 @@ static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *p pOld->assignedLeader.dnodeId = pNew->assignedLeader.dnodeId; memcpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE); pOld->version++; + +_OVER: taosThreadMutexUnlock(&pOld->mutex); + + taosHashRemove(arbUpdateHash, &pOld->vgId, sizeof(int32_t)); return 0; } @@ -645,6 +654,11 @@ static void *mndBuildArbUpdateGroupReq(int32_t *pContLen, SArbGroup *pNewGroup) } static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup) { + if (taosHashGet(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId)) != NULL) { + mInfo("vgId:%d, arb skip to pullup arb-update-group request, since it is in process", pNewGroup->vgId); + return 0; + } + int32_t contLen = 0; void *pHead = mndBuildArbUpdateGroupReq(&contLen, pNewGroup); if (!pHead) { @@ -653,7 +667,11 @@ static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup) { } SRpcMsg rpcMsg = {.msgType = TDMT_MND_ARB_UPDATE_GROUP, .pCont = pHead, .contLen = contLen, .info.noResp = true}; - return tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + int32_t ret = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + if (ret == 0) { + taosHashPut(arbUpdateHash, &pNewGroup->vgId, sizeof(pNewGroup->vgId), NULL, 0); + } + return ret; } static int32_t mndProcessArbUpdateGroupReq(SRpcMsg *pReq) { @@ -930,8 +948,12 @@ static int32_t mndProcessArbCheckSyncRsp(SRpcMsg *pRsp) { SVArbCheckSyncRsp syncRsp = {0}; if (tDeserializeSVArbCheckSyncRsp(pRsp->pCont, pRsp->contLen, &syncRsp) != 0) { - terrno = TSDB_CODE_INVALID_MSG; mInfo("arb sync check failed, since:%s", tstrerror(pRsp->code)); + if (pRsp->code == TSDB_CODE_MND_ARB_TOKEN_MISMATCH) { + terrno = TSDB_CODE_SUCCESS; + return 0; + } + terrno = TSDB_CODE_INVALID_MSG; return -1; } 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 aaa0c42262..02c932289f 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -1457,8 +1457,8 @@ static void mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) { pCxt->pCreateStreamReq->igUpdate = 0; pCxt->pCreateStreamReq->lastTs = pCxt->pCreateSmaReq->lastTs; pCxt->pCreateStreamReq->smaId = pCxt->pSma->uid; - pCxt->pCreateStreamReq->ast = strdup(pCxt->pCreateSmaReq->ast); - pCxt->pCreateStreamReq->sql = strdup(pCxt->pCreateSmaReq->sql); + pCxt->pCreateStreamReq->ast = taosStrdup(pCxt->pCreateSmaReq->ast); + pCxt->pCreateStreamReq->sql = taosStrdup(pCxt->pCreateSmaReq->sql); // construct tags pCxt->pCreateStreamReq->pTags = taosArrayInit(pCxt->pCreateStreamReq->numOfTags, sizeof(SField)); @@ -1494,7 +1494,7 @@ static void mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) { static void mndCreateTSMABuildDropStreamReq(SCreateTSMACxt* pCxt) { tstrncpy(pCxt->pDropStreamReq->name, pCxt->streamName, TSDB_STREAM_FNAME_LEN); pCxt->pDropStreamReq->igNotExists = false; - pCxt->pDropStreamReq->sql = strdup(pCxt->pDropSmaReq->name); + pCxt->pDropStreamReq->sql = taosStrdup(pCxt->pDropSmaReq->name); pCxt->pDropStreamReq->sqlLen = strlen(pCxt->pDropStreamReq->sql); } 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 4e1adcc366..c87b8e84f4 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -325,7 +325,7 @@ static int32_t createSchemaByFields(const SArray* pFields, SSchemaWrapper* pWrap return TSDB_CODE_SUCCESS; } -static bool hasPrimaryKey(SSchemaWrapper* pWrapper) { +static bool hasDestPrimaryKey(SSchemaWrapper* pWrapper) { if (pWrapper->nCols < 2) { return false; } @@ -442,7 +442,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, pObj->outputSchema.pSchema = pFullSchema; } - bool hasKey = hasPrimaryKey(&pObj->outputSchema); + bool hasKey = hasDestPrimaryKey(&pObj->outputSchema); SPlanContext cxt = { .pAstRoot = pAst, .topicQuery = false, @@ -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 7b6563f4b4..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; @@ -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/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 7119699a32..df54591ae8 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -887,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; @@ -2659,6 +2661,8 @@ int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) { SMetaEntry e = {0}; SDecoder dc = {0}; + *ppColCmprObj = NULL; + metaRLock(pMeta); rc = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData); if (rc < 0) { diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index fe7daf2bf1..0e6b85bd2b 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/tsdb/tsdbDataFileRW.c b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c index eddbdd0b2f..18ddf74399 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c @@ -48,9 +48,24 @@ static int32_t tsdbDataFileReadHeadFooter(SDataFileReader *reader) { if (reader->fd[ftype]) { int32_t encryptAlgorithm = reader->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm; char* encryptKey = reader->config->tsdb->pVnode->config.tsdbCfg.encryptKey; +#if 1 code = tsdbReadFile(reader->fd[ftype], reader->config->files[ftype].file.size - sizeof(SHeadFooter), (uint8_t *)reader->headFooter, sizeof(SHeadFooter), 0, encryptAlgorithm, encryptKey); TSDB_CHECK_CODE(code, lino, _exit); +#else + int64_t size = reader->config->files[ftype].file.size; + for (; size > TSDB_FHDR_SIZE; size--) { + code = tsdbReadFile(reader->fd[ftype], size - sizeof(SHeadFooter), (uint8_t *)reader->headFooter, + sizeof(SHeadFooter), 0, encryptAlgorithm, encryptKey); + if (code) continue; + if (reader->headFooter->brinBlkPtr->offset + reader->headFooter->brinBlkPtr->size + sizeof(SHeadFooter) == size) { + break; + } + } + if (size <= TSDB_FHDR_SIZE) { + TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit); + } +#endif } reader->ctx->headFooterLoaded = true; diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index 6195c37ab2..7741a1b096 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -897,6 +897,7 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) { // commit code = commit_edit(fs); + ASSERT(code == 0); TSDB_CHECK_CODE(code, lino, _exit); // schedule merge @@ -973,11 +974,11 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) { _exit: if (code) { - TSDB_ERROR_LOG(TD_VID(fs->tsdb->pVnode), lino, code); + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(fs->tsdb->pVnode), __func__, lino, tstrerror(code)); } else { - tsdbDebug("vgId:%d %s done, etype:%d", TD_VID(fs->tsdb->pVnode), __func__, fs->etype); - tsem_post(&fs->canEdit); + tsdbInfo("vgId:%d %s done, etype:%d", TD_VID(fs->tsdb->pVnode), __func__, fs->etype); } + tsem_post(&fs->canEdit); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbFSetRW.c b/source/dnode/vnode/src/tsdb/tsdbFSetRW.c index 304e4ccb9b..f6ca515d1e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSetRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSetRW.c @@ -46,7 +46,7 @@ static int32_t tsdbFSetWriteTableDataBegin(SFSetWriter *writer, const TABLEID *t code = tsdbUpdateSkmTb(writer->config->tsdb, writer->ctx->tbid, writer->skmTb); code = metaGetColCmpr(writer->config->tsdb->pVnode->pMeta, tbid->suid ? tbid->suid : tbid->uid, &writer->pColCmprObj); - TSDB_CHECK_CODE(code, lino, _exit); + // TSDB_CHECK_CODE(code, lino, _exit); writer->blockDataIdx = 0; for (int32_t i = 0; i < ARRAY_SIZE(writer->blockData); i++) { @@ -301,15 +301,3 @@ _exit: } return code; } -// int32_t tsdbGetCompressByUid(SFSetWriter *writer, tb_uid_t uid, struct SColCompressInfo *info) { -// SHashObj *p = NULL; -// int32_t code = metaGetColCmpr(writer->config->tsdb->pVnode->pMeta, uid, &p); -// if (code < 0) { -// ASSERT(0); -// taosHashCleanup(p); -// p = NULL; -// } else { -// } -// info->pColCmpr = p; -// return code; -// } diff --git a/source/dnode/vnode/src/tsdb/tsdbMerge.c b/source/dnode/vnode/src/tsdb/tsdbMerge.c index 87f48acaac..971020e7d6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMerge.c +++ b/source/dnode/vnode/src/tsdb/tsdbMerge.c @@ -580,9 +580,9 @@ int32_t tsdbMerge(void *arg) { } */ // do merge - tsdbDebug("vgId:%d merge begin, fid:%d", TD_VID(tsdb->pVnode), merger->fid); + tsdbInfo("vgId:%d merge begin, fid:%d", TD_VID(tsdb->pVnode), merger->fid); code = tsdbDoMerge(merger); - tsdbDebug("vgId:%d merge done, fid:%d", TD_VID(tsdb->pVnode), mergeArg->fid); + tsdbInfo("vgId:%d merge done, fid:%d", TD_VID(tsdb->pVnode), mergeArg->fid); TSDB_CHECK_CODE(code, lino, _exit); _exit: diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index 136bf3bfbe..932bf2d92c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -14,8 +14,8 @@ */ #include "cos.h" -#include "tsdb.h" #include "crypt.h" +#include "tsdb.h" #include "vnd.h" static int32_t tsdbOpenFileImpl(STsdbFD *pFD) { @@ -61,6 +61,7 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) { // taosMemoryFree(pFD); goto _exit; } + pFD->s3File = 1; /* const char *object_name = taosDirEntryBaseName((char *)path); long s3_size = 0; @@ -86,7 +87,6 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) { goto _exit; } #else - pFD->s3File = 1; pFD->pFD = (TdFilePtr)&pFD->s3File; int32_t vid = 0; sscanf(object_name, "v%df%dver%" PRId64 ".data", &vid, &pFD->fid, &pFD->cid); @@ -170,7 +170,7 @@ void tsdbCloseFile(STsdbFD **ppFD) { } } -static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char* encryptKey) { +static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *encryptKey) { int32_t code = 0; if (!pFD->pFD) { @@ -182,7 +182,7 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char* e if (pFD->pgno > 0) { int64_t offset = PAGE_OFFSET(pFD->pgno, pFD->szPage); - if (pFD->lcn > 1) { + if (pFD->s3File && pFD->lcn > 1) { SVnodeCfg *pCfg = &pFD->pTsdb->pVnode->config; int64_t chunksize = (int64_t)pCfg->tsdbPageSize * pCfg->s3ChunkSize; int64_t chunkoffset = chunksize * (pFD->lcn - 1); @@ -198,27 +198,27 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char* e } taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage); - - if(encryptAlgorithm == DND_CA_SM4){ - //if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){ - unsigned char PacketData[128]; - int NewLen; - int32_t count = 0; + + if (encryptAlgorithm == DND_CA_SM4) { + // if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){ + unsigned char PacketData[128]; + int NewLen; + int32_t count = 0; while (count < pFD->szPage) { SCryptOpts opts = {0}; opts.len = 128; opts.source = pFD->pBuf + count; opts.result = PacketData; opts.unitLen = 128; - //strncpy(opts.key, tsEncryptKey, 16); + // strncpy(opts.key, tsEncryptKey, 16); strncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN); NewLen = CBC_Encrypt(&opts); memcpy(pFD->pBuf + count, PacketData, NewLen); - count += NewLen; + count += NewLen; } - //tsdbDebug("CBC_Encrypt count:%d %s", count, __FUNCTION__); + // tsdbDebug("CBC_Encrypt count:%d %s", count, __FUNCTION__); } n = taosWriteFile(pFD->pFD, pFD->pBuf, pFD->szPage); @@ -237,7 +237,7 @@ _exit: return code; } -static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgorithm, char* encryptKey) { +static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgorithm, char *encryptKey) { int32_t code = 0; // ASSERT(pgno <= pFD->szFile); @@ -297,20 +297,19 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgor } //} - if(encryptAlgorithm == DND_CA_SM4){ - //if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){ - unsigned char PacketData[128]; - int NewLen; + if (encryptAlgorithm == DND_CA_SM4) { + // if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){ + unsigned char PacketData[128]; + int NewLen; int32_t count = 0; - while(count < pFD->szPage) - { + while (count < pFD->szPage) { SCryptOpts opts = {0}; opts.len = 128; opts.source = pFD->pBuf + count; opts.result = PacketData; opts.unitLen = 128; - //strncpy(opts.key, tsEncryptKey, 16); + // strncpy(opts.key, tsEncryptKey, 16); strncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN); NewLen = CBC_Decrypt(&opts); @@ -318,7 +317,7 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgor memcpy(pFD->pBuf + count, PacketData, NewLen); count += NewLen; } - //tsdbDebug("CBC_Decrypt count:%d %s", count, __FUNCTION__); + // tsdbDebug("CBC_Decrypt count:%d %s", count, __FUNCTION__); } // check @@ -333,8 +332,8 @@ _exit: return code; } -int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t size, int32_t encryptAlgorithm, - char* encryptKey) { +int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf, int64_t size, int32_t encryptAlgorithm, + char *encryptKey) { int32_t code = 0; int64_t fOffset = LOGIC_TO_FILE_OFFSET(offset, pFD->szPage); int64_t pgno = OFFSET_PGNO(fOffset, pFD->szPage); @@ -366,8 +365,8 @@ _exit: return code; } -static int32_t tsdbReadFileImp(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int32_t encryptAlgorithm, - char* encryptKey) { +static int32_t tsdbReadFileImp(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int32_t encryptAlgorithm, + char *encryptKey) { int32_t code = 0; int64_t n = 0; int64_t fOffset = LOGIC_TO_FILE_OFFSET(offset, pFD->szPage); @@ -572,8 +571,8 @@ _exit: return code; } -int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint, - int32_t encryptAlgorithm, char* encryptKey) { +int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, int64_t szHint, + int32_t encryptAlgorithm, char *encryptKey) { int32_t code = 0; if (!pFD->pFD) { code = tsdbOpenFileImpl(pFD); @@ -582,7 +581,7 @@ int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size, } } - if (pFD->lcn > 1 /*pFD->s3File && tsS3BlockSize < 0*/) { + if (pFD->s3File && pFD->lcn > 1 /* && tsS3BlockSize < 0*/) { return tsdbReadFileS3(pFD, offset, pBuf, size, szHint); } else { return tsdbReadFileImp(pFD, offset, pBuf, size, encryptAlgorithm, encryptKey); @@ -593,20 +592,19 @@ _exit: } int32_t tsdbReadFileToBuffer(STsdbFD *pFD, int64_t offset, int64_t size, SBuffer *buffer, int64_t szHint, - int32_t encryptAlgorithm, char* encryptKey) { + int32_t encryptAlgorithm, char *encryptKey) { int32_t code; code = tBufferEnsureCapacity(buffer, buffer->size + size); if (code) return code; - code = tsdbReadFile(pFD, offset, (uint8_t *)tBufferGetDataEnd(buffer), size, szHint, - encryptAlgorithm, encryptKey); + code = tsdbReadFile(pFD, offset, (uint8_t *)tBufferGetDataEnd(buffer), size, szHint, encryptAlgorithm, encryptKey); if (code) return code; buffer->size += size; return code; } -int32_t tsdbFsyncFile(STsdbFD *pFD, int32_t encryptAlgorithm, char* encryptKey) { +int32_t tsdbFsyncFile(STsdbFD *pFD, int32_t encryptAlgorithm, char *encryptKey) { int32_t code = 0; /* if (pFD->s3File) { @@ -726,7 +724,7 @@ int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) { // read int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm; - char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; + char *encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; code = tsdbReadFile(pReader->pHeadFD, offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey); if (code) goto _err; @@ -765,7 +763,7 @@ int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk) { // read int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm; - char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; + char *encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; code = tsdbReadFile(pReader->aSttFD[iStt], offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey); if (code) goto _err; @@ -800,7 +798,7 @@ int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *m // read int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm; - char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; + char *encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; code = tsdbReadFile(pReader->pHeadFD, offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey); if (code) goto _err; @@ -895,7 +893,7 @@ int32_t tsdbReadDelDatav1(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelDa // read int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm; - char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; + char *encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; code = tsdbReadFile(pReader->pReadH, offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey); if (code) goto _err; @@ -937,7 +935,7 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx) { // read int32_t encryptAlgorithm = pReader->pTsdb->pVnode->config.tsdbCfg.encryptAlgorithm; - char* encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; + char *encryptKey = pReader->pTsdb->pVnode->config.tsdbCfg.encryptKey; code = tsdbReadFile(pReader->pReadH, offset, pReader->aBuf[0], size, 0, encryptAlgorithm, encryptKey); if (code) goto _err; diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index 2e0b44f5f8..5a138d2bed 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -528,7 +528,7 @@ static int32_t tsdbMigrateDataFileLCS3(SRTNer *rtner, const STFileObj *fobj, int if (fdFrom == NULL) code = terrno; TSDB_CHECK_CODE(code, lino, _exit); - tsdbInfo("vgId: %d, open lcfile: %s size: %" PRId64, TD_VID(rtner->tsdb->pVnode), fname, lc_size); + tsdbInfo("vgId:%d, open lcfile: %s size: %" PRId64, TD_VID(rtner->tsdb->pVnode), fname, lc_size); snprintf(dot2 + 1, TSDB_FQDN_LEN - (dot2 + 1 - object_name), "%d.data", lcn); fdTo = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); @@ -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) { @@ -671,7 +671,7 @@ static int32_t tsdbDoS3MigrateOnFileSet(SRTNer *rtner, STFileSet *fset) { int64_t chunksize = (int64_t)pCfg->tsdbPageSize * pCfg->s3ChunkSize; int32_t lcn = fobj->f->lcn; - if (lcn < 1 && taosCheckExistFile(fobj->fname)) { + if (/*lcn < 1 && */ taosCheckExistFile(fobj->fname)) { int32_t mtime = 0; int64_t size = 0; taosStatFile(fobj->fname, &size, &mtime, NULL); diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c index 6e56b5677a..478778319d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c @@ -65,9 +65,27 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con int32_t encryptAlgoirthm = config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm; char* encryptKey = config->tsdb->pVnode->config.tsdbCfg.encryptKey; +#if 1 code = tsdbReadFile(reader[0]->fd, offset, (uint8_t *)(reader[0]->footer), sizeof(SSttFooter), 0, encryptAlgoirthm, encryptKey); TSDB_CHECK_CODE(code, lino, _exit); +#else + int64_t size = config->file->size; + + for (; size > TSDB_FHDR_SIZE; size--) { + code = tsdbReadFile(reader[0]->fd, size - sizeof(SSttFooter), (uint8_t *)(reader[0]->footer), sizeof(SSttFooter), 0, encryptAlgoirthm, + encryptKey); + if (code) continue; + if ((*reader)->footer->sttBlkPtr->offset + (*reader)->footer->sttBlkPtr->size + sizeof(SSttFooter) == size || + (*reader)->footer->statisBlkPtr->offset + (*reader)->footer->statisBlkPtr->size + sizeof(SSttFooter) == size || + (*reader)->footer->tombBlkPtr->offset + (*reader)->footer->tombBlkPtr->size + sizeof(SSttFooter) == size) { + break; + } + } + if (size <= TSDB_FHDR_SIZE) { + TSDB_CHECK_CODE(code = TSDB_CODE_FILE_CORRUPTED, lino, _exit); + } +#endif _exit: if (code) { 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/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 1c775fcce7..78905863fe 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -596,6 +596,7 @@ int32_t ctgCopyTbMeta(SCatalog *pCtg, SCtgTbMetaCtx *ctx, SCtgDBCache **pDb, SCt } memcpy(&(*pTableMeta)->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta)); + (*pTableMeta)->schemaExt = NULL; return TSDB_CODE_SUCCESS; } @@ -2883,14 +2884,24 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe SMetaRes res = {0}; STableMeta *pTableMeta = NULL; if (tbMeta->tableType != TSDB_CHILD_TABLE) { + int32_t schemaExtSize = 0; int32_t metaSize = CTG_META_SIZE(tbMeta); - pTableMeta = taosMemoryCalloc(1, metaSize); + if (tbMeta->schemaExt != NULL) { + schemaExtSize = tbMeta->tableInfo.numOfColumns * sizeof(SSchemaExt); + } + pTableMeta = taosMemoryCalloc(1, metaSize + schemaExtSize); if (NULL == pTableMeta) { ctgReleaseTbMetaToCache(pCtg, dbCache, pCache); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(pTableMeta, tbMeta, metaSize); + if (tbMeta->schemaExt != NULL) { + pTableMeta->schemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize); + memcpy(pTableMeta->schemaExt, tbMeta->schemaExt, schemaExtSize); + } else { + pTableMeta->schemaExt = NULL; + } CTG_UNLOCK(CTG_READ, &pCache->metaLock); taosHashRelease(dbCache->tbCache, pCache); @@ -2999,6 +3010,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe } memcpy(&pTableMeta->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta)); + pTableMeta->schemaExt = NULL; CTG_UNLOCK(CTG_READ, &pCache->metaLock); taosHashRelease(dbCache->tbCache, pCache); diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index cb44b7d433..847c694b80 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..fac216e6e6 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -500,6 +500,8 @@ typedef struct SStreamScanInfo { SStoreTqReader readerFn; SStateStore stateStore; SSDataBlock* pCheckpointRes; + int8_t pkColType; + int32_t pkColLen; } SStreamScanInfo; typedef struct { @@ -566,8 +568,13 @@ typedef struct SOpCheckPointInfo { SHashObj* children; // key:child id } SOpCheckPointInfo; +typedef struct SSteamOpBasicInfo { + int32_t primaryPkIndex; +} SSteamOpBasicInfo; + typedef struct SStreamIntervalOperatorInfo { SOptrBasicInfo binfo; // basic info + SSteamOpBasicInfo basic; SAggSupporter aggSup; // aggregate supporter SExprSupp scalarSupp; // supporter for perform scalar function SGroupResInfo groupResInfo; // multiple results build supporter @@ -633,6 +640,7 @@ typedef struct SResultWindowInfo { typedef struct SStreamSessionAggOperatorInfo { SOptrBasicInfo binfo; + SSteamOpBasicInfo basic; SStreamAggSupporter streamAggSup; SExprSupp scalarSupp; // supporter for perform scalar function SGroupResInfo groupResInfo; @@ -665,6 +673,7 @@ typedef struct SStreamSessionAggOperatorInfo { typedef struct SStreamStateAggOperatorInfo { SOptrBasicInfo binfo; + SSteamOpBasicInfo basic; SStreamAggSupporter streamAggSup; SExprSupp scalarSupp; // supporter for perform scalar function SGroupResInfo groupResInfo; @@ -691,6 +700,7 @@ typedef struct SStreamStateAggOperatorInfo { typedef struct SStreamEventAggOperatorInfo { SOptrBasicInfo binfo; + SSteamOpBasicInfo basic; SStreamAggSupporter streamAggSup; SExprSupp scalarSupp; // supporter for perform scalar function SGroupResInfo groupResInfo; @@ -719,6 +729,7 @@ typedef struct SStreamEventAggOperatorInfo { typedef struct SStreamCountAggOperatorInfo { SOptrBasicInfo binfo; + SSteamOpBasicInfo basic; SStreamAggSupporter streamAggSup; SExprSupp scalarSupp; // supporter for perform scalar function SGroupResInfo groupResInfo; @@ -742,6 +753,7 @@ typedef struct SStreamCountAggOperatorInfo { typedef struct SStreamPartitionOperatorInfo { SOptrBasicInfo binfo; + SSteamOpBasicInfo basic; SPartitionBySupporter partitionSup; SExprSupp scalarSup; SExprSupp tbnameCalSup; @@ -775,6 +787,7 @@ typedef struct SStreamFillSupporter { } SStreamFillSupporter; typedef struct SStreamFillOperatorInfo { + SSteamOpBasicInfo basic; SStreamFillSupporter* pFillSup; SSDataBlock* pRes; SSDataBlock* pSrcBlock; @@ -911,7 +924,7 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, SExprSupp* pExpSup, i SReadHandle* pHandle, STimeWindowAggSupp* pTwAggSup, const char* taskIdStr, SStorageAPI* pApi, int32_t tsIndex); void initDownStream(struct SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, uint16_t type, int32_t tsColIndex, - STimeWindowAggSupp* pTwSup); + STimeWindowAggSupp* pTwSup, struct SSteamOpBasicInfo* pBasic); void getMaxTsWins(const SArray* pAllWins, SArray* pMaxWins); void initGroupResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList); void getSessionHashKey(const SSessionKey* pKey, SSessionKey* pHashKey); @@ -939,11 +952,12 @@ void compactTimeWindow(SExprSupp* pSup, SStreamAggSupporter* pAggSup, STimeW SSHashObj* pStUpdated, SSHashObj* pStDeleted, bool addGap); int32_t releaseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI); void resetWinRange(STimeWindow* winRange); -bool checkExpiredData(SStateStore* pAPI, SUpdateInfo* pUpdateInfo, STimeWindowAggSupp* pTwSup, uint64_t tableId, TSKEY ts); +bool checkExpiredData(SStateStore* pAPI, SUpdateInfo* pUpdateInfo, STimeWindowAggSupp* pTwSup, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len); 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/groupoperator.c b/source/libs/executor/src/groupoperator.c index 670771adcc..9a31e993b2 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -1267,7 +1267,7 @@ void initParDownStream(SOperatorInfo* downstream, SPartitionBySupporter* pParSup pScanInfo->pPartScalarSup = pExpr; pScanInfo->pPartTbnameSup = pTbnameExpr; if (!pScanInfo->pUpdateInfo) { - pScanInfo->pUpdateInfo = pAPI->stateStore.updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, 0, pScanInfo->igCheckUpdate); + pScanInfo->pUpdateInfo = pAPI->stateStore.updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, 0, pScanInfo->igCheckUpdate, pScanInfo->pkColType, pScanInfo->pkColLen); } } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index c30059fffd..838db4c571 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1380,7 +1380,7 @@ bool comparePrimaryKey(SColumnInfoData* pCol, int32_t rowId, void* pVal) { return false; } -bool hasPrimaryKey(SStreamScanInfo* pInfo) { +bool hasPrimaryKeyCol(SStreamScanInfo* pInfo) { return pInfo->primaryKeyIndex != -1; } @@ -1391,7 +1391,7 @@ static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, } int32_t rowId = 0; - if (hasPrimaryKey(pInfo)) { + if (hasPrimaryKeyCol(pInfo)) { SColumnInfoData* pPkCol = taosArrayGet(pPreRes->pDataBlock, pInfo->primaryKeyIndex); for (; rowId < pPreRes->info.rows; rowId++) { if (comparePrimaryKey(pPkCol, rowId, pVal)) { @@ -1630,7 +1630,7 @@ static void getPreVersionDataBlock(uint64_t uid, TSKEY startTs, TSKEY endTs, int SColumnInfoData* pTsCol = (SColumnInfoData*)taosArrayGet(pPreRes->pDataBlock, pInfo->primaryTsIndex); SColumnInfoData* pPkCol = NULL; - if (hasPrimaryKey(pInfo)) { + if (hasPrimaryKeyCol(pInfo)) { pPkCol = (SColumnInfoData*)taosArrayGet(pPreRes->pDataBlock, pInfo->primaryKeyIndex); } for (int32_t i = 0; i < pPreRes->info.rows; i++) { @@ -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) && mode == STREAM_DELETE_DATA) )) { + if (pInfo->partitionSup.needCalc && ( startData[0] != endData[0] || (hasPrimaryKeyCol(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; @@ -1682,7 +1682,7 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr uint64_t groupId = pSrcGp[i]; if (groupId == 0) { void* pVal = NULL; - if (hasPrimaryKey(pInfo) && pSrcPkCol) { + if (hasPrimaryKeyCol(pInfo) && pSrcPkCol) { pVal = colDataGetData(pSrcPkCol, i); } groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], ver, pVal); @@ -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) && mode == STREAM_DELETE_DATA) )) { + if (pInfo->partitionSup.needCalc && ( startData[0] != endData[0] || (hasPrimaryKeyCol(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; @@ -1759,7 +1759,7 @@ static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcB uint64_t groupId = pSrcGp[i]; if (groupId == 0) { void* pVal = NULL; - if (hasPrimaryKey(pInfo) && pSrcPkCol) { + if (hasPrimaryKeyCol(pInfo) && pSrcPkCol) { pVal = colDataGetData(pSrcPkCol, i); } groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], ver, pVal); @@ -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) && mode == STREAM_DELETE_DATA) )) { + if (pInfo->partitionSup.needCalc && ( srcStartTsCol[0] != srcEndTsCol[0] || (hasPrimaryKeyCol(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; @@ -1824,7 +1824,7 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS uint64_t groupId = srcGp[i]; if (groupId == 0) { void* pVal = NULL; - if (hasPrimaryKey(pInfo) && pSrcPkCol) { + if (hasPrimaryKeyCol(pInfo) && pSrcPkCol) { pVal = colDataGetData(pSrcPkCol, i); } groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], ver, pVal); @@ -1915,7 +1915,7 @@ static int32_t generateDeleteResultBlockImpl(SStreamScanInfo* pInfo, SSDataBlock char tbname[VARSTR_HEADER_SIZE + TSDB_TABLE_NAME_LEN] = {0}; if (groupId == 0) { void* pVal = NULL; - if (hasPrimaryKey(pInfo) && pSrcPkCol) { + if (hasPrimaryKeyCol(pInfo) && pSrcPkCol) { pVal = colDataGetData(pSrcPkCol, i); } groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], ver, pVal); @@ -1979,9 +1979,9 @@ void appendDataToSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndT appendOneRowToSpecialBlockImpl(pBlock, pStartTs, pEndTs, pStartTs, pEndTs, pUid, pGp, pTbName, NULL); } -bool checkExpiredData(SStateStore* pAPI, SUpdateInfo* pUpdateInfo, STimeWindowAggSupp* pTwSup, uint64_t tableId, TSKEY ts) { +bool checkExpiredData(SStateStore* pAPI, SUpdateInfo* pUpdateInfo, STimeWindowAggSupp* pTwSup, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len) { bool isExpired = false; - bool isInc = pAPI->isIncrementalTimeStamp(pUpdateInfo, tableId, ts); + bool isInc = pAPI->isIncrementalTimeStamp(pUpdateInfo, tableId, ts, pPkVal, len); if (!isInc) { isExpired = isOverdue(ts, pTwSup); } @@ -1997,7 +1997,7 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock ASSERT(pColDataInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP); TSKEY* tsCol = (TSKEY*)pColDataInfo->pData; SColumnInfoData* pPkColDataInfo = NULL; - if (hasPrimaryKey(pInfo)) { + if (hasPrimaryKeyCol(pInfo)) { pPkColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryKeyIndex); } @@ -2017,7 +2017,13 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock isClosed = isCloseWindow(&win, &pInfo->twAggSup); } // must check update info first. - bool update = pInfo->stateStore.updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.id.uid, tsCol[rowId]); + void* pPkVal = NULL; + int32_t pkLen = 0; + if (hasPrimaryKeyCol(pInfo)) { + pPkVal = colDataGetData(pPkColDataInfo, rowId); + pkLen = colDataGetRowLength(pPkColDataInfo, rowId); + } + bool update = pInfo->stateStore.updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.id.uid, tsCol[rowId], pPkVal, pkLen); bool isDeleted = isClosed && isSignleIntervalWindow(pInfo) && isDeletedStreamWindow(&win, pBlock->info.id.groupId, pInfo->pState, &pInfo->twAggSup, &pInfo->stateStore); if ((update || isDeleted) && out) { @@ -2517,7 +2523,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { if (pInfo->pRecoverRes != NULL) { calBlockTbName(pInfo, pInfo->pRecoverRes, 0); if (!pInfo->igCheckUpdate && pInfo->pUpdateInfo) { - TSKEY maxTs = pAPI->stateStore.updateInfoFillBlockData(pInfo->pUpdateInfo, pInfo->pRecoverRes, pInfo->primaryTsIndex); + TSKEY maxTs = pAPI->stateStore.updateInfoFillBlockData(pInfo->pUpdateInfo, pInfo->pRecoverRes, pInfo->primaryTsIndex, pInfo->primaryKeyIndex); pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs); } if (pInfo->pCreateTbRes->info.rows > 0) { @@ -3202,8 +3208,10 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pDeleteDataRes = createSpecialDataBlock(STREAM_DELETE_DATA); pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX}; pInfo->pUpdateDataRes = createSpecialDataBlock(STREAM_CLEAR); - if (hasPrimaryKey(pInfo)) { + if (hasPrimaryKeyCol(pInfo)) { addPrimaryKeyCol(pInfo->pUpdateDataRes, pkType.type, pkType.bytes); + pInfo->pkColType = pkType.type; + pInfo->pkColLen = pkType.bytes; } pInfo->assignBlockUid = pTableScanNode->assignBlockUid; pInfo->partitionSup.needCalc = false; diff --git a/source/libs/executor/src/streamcountwindowoperator.c b/source/libs/executor/src/streamcountwindowoperator.c index f2d3bbb29a..491a1da6aa 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); @@ -242,7 +243,7 @@ static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl for (int32_t i = 0; i < rows;) { if (pInfo->ignoreExpiredData && checkExpiredData(&pInfo->streamAggSup.stateStore, pInfo->streamAggSup.pUpdateInfo, &pInfo->twAggSup, - pSDataBlock->info.id.uid, startTsCols[i])) { + pSDataBlock->info.id.uid, startTsCols[i], NULL, 0)) { i++; continue; } @@ -728,7 +729,7 @@ SOperatorInfo* createStreamCountAggOperatorInfo(SOperatorInfo* downstream, SPhys setOperatorStreamStateFn(pOperator, streamCountReleaseState, streamCountReloadState); if (downstream) { - initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); + initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup, &pInfo->basic); code = appendDownstream(pOperator, &downstream, 1); } return pOperator; diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index 99b377e1d3..1116851323 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); @@ -310,7 +312,7 @@ static void doStreamEventAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl blockDataEnsureCapacity(pAggSup->pScanBlock, rows); for (int32_t i = 0; i < rows; i += winRows) { if (pInfo->ignoreExpiredData && checkExpiredData(&pInfo->streamAggSup.stateStore, pInfo->streamAggSup.pUpdateInfo, - &pInfo->twAggSup, pSDataBlock->info.id.uid, tsCols[i])) { + &pInfo->twAggSup, pSDataBlock->info.id.uid, tsCols[i], NULL, 0)) { i++; continue; } @@ -776,7 +778,7 @@ SOperatorInfo* createStreamEventAggOperatorInfo(SOperatorInfo* downstream, SPhys pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamEventAgg, NULL, destroyStreamEventOperatorInfo, optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); setOperatorStreamStateFn(pOperator, streamEventReleaseState, streamEventReloadState); - initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); + initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup, &pInfo->basic); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index 0e3e74f16f..08ce0e25f1 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -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); @@ -481,13 +487,14 @@ void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SStreamInt pScanInfo->windowSup.pIntervalAggSup = &pInfo->aggSup; if (!pScanInfo->pUpdateInfo) { pScanInfo->pUpdateInfo = - pAPI->updateInfoInitP(&pInfo->interval, pInfo->twAggSup.waterMark, pScanInfo->igCheckUpdate); + pAPI->updateInfoInitP(&pInfo->interval, pInfo->twAggSup.waterMark, pScanInfo->igCheckUpdate, pScanInfo->pkColType, pScanInfo->pkColLen); } pScanInfo->interval = pInfo->interval; pScanInfo->twAggSup = pInfo->twAggSup; pScanInfo->pState = pInfo->pState; pInfo->pUpdateInfo = pScanInfo->pUpdateInfo; + pInfo->basic.primaryPkIndex = pScanInfo->primaryKeyIndex; } void compactFunctions(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int32_t numOfOutput, @@ -820,6 +827,10 @@ static int32_t getNextQualifiedFinalWindow(SInterval* pInterval, STimeWindow* pN return startPos; } +bool hasSrcPrimaryKeyCol(SSteamOpBasicInfo* pInfo) { + return pInfo->primaryPkIndex != -1; +} + static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, uint64_t groupId, SSHashObj* pUpdatedMap, SSHashObj* pDeletedMap) { SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperator->info; @@ -839,6 +850,13 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDat SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); tsCols = (int64_t*)pColDataInfo->pData; + void* pPkVal = NULL; + int32_t pkLen = 0; + SColumnInfoData* pPkColDataInfo = NULL; + if (hasSrcPrimaryKeyCol(&pInfo->basic)) { + pPkColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); + } + if (pSDataBlock->info.window.skey != tsCols[0] || pSDataBlock->info.window.ekey != tsCols[endRowId]) { qError("table uid %" PRIu64 " data block timestamp range may not be calculated! minKey %" PRId64 ",maxKey %" PRId64, @@ -862,9 +880,15 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDat } while (1) { bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup); + if (hasSrcPrimaryKeyCol(&pInfo->basic) && !IS_FINAL_INTERVAL_OP(pOperator) && pInfo->ignoreExpiredData && + pSDataBlock->info.type != STREAM_PULL_DATA) { + pPkVal = colDataGetData(pPkColDataInfo, startPos); + pkLen = colDataGetRowLength(pPkColDataInfo, startPos); + } + if ((!IS_FINAL_INTERVAL_OP(pOperator) && pInfo->ignoreExpiredData && pSDataBlock->info.type != STREAM_PULL_DATA && checkExpiredData(&pInfo->stateStore, pInfo->pUpdateInfo, &pInfo->twAggSup, pSDataBlock->info.id.uid, - nextWin.ekey)) || + nextWin.ekey, pPkVal, pkLen)) || !inSlidingWindow(&pInfo->interval, &nextWin, &pSDataBlock->info)) { startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCols, startPos, nextWin.ekey, &nextWin); if (startPos < 0) { @@ -1664,6 +1688,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); @@ -1679,7 +1705,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); @@ -1715,14 +1740,14 @@ void initDummyFunction(SqlFunctionCtx* pDummy, SqlFunctionCtx* pCtx, int32_t num } void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, uint16_t type, int32_t tsColIndex, - STimeWindowAggSupp* pTwSup) { + STimeWindowAggSupp* pTwSup, struct SSteamOpBasicInfo* pBasic) { if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION) { SStreamPartitionOperatorInfo* pScanInfo = downstream->info; pScanInfo->tsColIndex = tsColIndex; } if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - initDownStream(downstream->pDownstream[0], pAggSup, type, tsColIndex, pTwSup); + initDownStream(downstream->pDownstream[0], pAggSup, type, tsColIndex, pTwSup, pBasic); return; } SStreamScanInfo* pScanInfo = downstream->info; @@ -1730,10 +1755,11 @@ void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, uin pScanInfo->pState = pAggSup->pState; if (!pScanInfo->pUpdateInfo) { pScanInfo->pUpdateInfo = pAggSup->stateStore.updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, pTwSup->waterMark, - pScanInfo->igCheckUpdate); + pScanInfo->igCheckUpdate, pScanInfo->pkColType, pScanInfo->pkColLen); } pScanInfo->twAggSup = *pTwSup; pAggSup->pUpdateInfo = pScanInfo->pUpdateInfo; + pBasic->primaryPkIndex = pScanInfo->primaryKeyIndex; } static TSKEY sesionTs(void* pKey) { @@ -2106,10 +2132,22 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData } TSKEY* endTsCols = (int64_t*)pEndTsCol->pData; + + void* pPkVal = NULL; + int32_t pkLen = 0; + SColumnInfoData* pPkColDataInfo = NULL; + if (hasSrcPrimaryKeyCol(&pInfo->basic)) { + pPkColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); + } + for (int32_t i = 0; i < rows;) { + if (hasSrcPrimaryKeyCol(&pInfo->basic) && !IS_FINAL_SESSION_OP(pOperator) && pInfo->ignoreExpiredData) { + pPkVal = colDataGetData(pPkColDataInfo, i); + pkLen = colDataGetRowLength(pPkColDataInfo, i); + } if (!IS_FINAL_SESSION_OP(pOperator) && pInfo->ignoreExpiredData && checkExpiredData(&pInfo->streamAggSup.stateStore, pInfo->streamAggSup.pUpdateInfo, &pInfo->twAggSup, - pSDataBlock->info.id.uid, endTsCols[i])) { + pSDataBlock->info.id.uid, endTsCols[i], pPkVal, pkLen)) { i++; continue; } @@ -3051,7 +3089,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh setOperatorStreamStateFn(pOperator, streamSessionReleaseState, streamSessionReloadState); if (downstream) { - initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); + initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup, &pInfo->basic); code = appendDownstream(pOperator, &downstream, 1); } return pOperator; @@ -3250,6 +3288,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); @@ -3263,7 +3304,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); @@ -3481,7 +3521,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl SColumnInfoData* pKeyColInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->stateCol.slotId); for (int32_t i = 0; i < rows; i += winRows) { if (pInfo->ignoreExpiredData && checkExpiredData(&pInfo->streamAggSup.stateStore, pInfo->streamAggSup.pUpdateInfo, - &pInfo->twAggSup, pSDataBlock->info.id.uid, tsCols[i]) || + &pInfo->twAggSup, pSDataBlock->info.id.uid, tsCols[i], NULL, 0) || colDataIsNull_s(pKeyColInfo, i)) { i++; continue; @@ -3948,7 +3988,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); setOperatorStreamStateFn(pOperator, streamStateReleaseState, streamStateReloadState); - initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); + initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup, &pInfo->basic); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 659ab79eb4..16b0474f9c 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -720,7 +720,6 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0); } - bool blockFull = false; while ((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_SUPER_TABLE)) == 0) { if (pInfo->pCur->mr.me.type != TSDB_CHILD_TABLE) { continue; @@ -743,25 +742,19 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { } if ((smrSuperTable.me.stbEntry.schemaTag.nCols + numOfRows) > pOperator->resultInfo.capacity) { - blockFull = true; - } else { - sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &pInfo->pCur->mr, dbname, tableName, &numOfRows, - dataBlock); - } - - pAPI->metaReaderFn.clearReader(&smrSuperTable); - - if (blockFull || numOfRows >= pOperator->resultInfo.capacity) { relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); numOfRows = 0; if (pInfo->pRes->info.rows > 0) { pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur); + pAPI->metaReaderFn.clearReader(&smrSuperTable); break; } - - blockFull = false; + } else { + sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &pInfo->pCur->mr, dbname, tableName, &numOfRows, + dataBlock); } + pAPI->metaReaderFn.clearReader(&smrSuperTable); } if (numOfRows > 0) { diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 5f59fabec5..1a51620856 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -300,6 +300,9 @@ static int32_t joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDs COPY_BASE_OBJECT_FIELD(table, tableNodeCopy); COPY_SCALAR_FIELD(joinType); COPY_SCALAR_FIELD(subType); + CLONE_NODE_FIELD(pWindowOffset); + CLONE_NODE_FIELD(pJLimit); + CLONE_NODE_FIELD(addPrimCond); COPY_SCALAR_FIELD(hasSubQuery); COPY_SCALAR_FIELD(isLowLevelJoin); CLONE_NODE_FIELD(pLeft); 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..8f77f0dedf 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); @@ -4394,7 +4394,6 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare } case QUERY_NODE_JOIN_TABLE: { SJoinTableNode* pJoinTable = (SJoinTableNode*)*pTable; - pJoinTable->pParent = pJoinParent; code = translateJoinTable(pCxt, pJoinTable); if (TSDB_CODE_SUCCESS == code) { code = translateTable(pCxt, &pJoinTable->pLeft, (SNode*)pJoinTable); @@ -5695,8 +5694,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 +5704,7 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* pInfo->pRealTable->pVgroupList = vgsInfo; } else { taosMemoryFree(vgsInfo); - } + } vgsInfo = NULL; if (pInfo->pRealTable->pTsmas) { @@ -5714,12 +5713,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 +7224,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 +7244,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 +7741,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 +8117,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 +10709,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 +10727,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 +10770,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 +10815,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 +10917,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 +10928,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 +11026,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 +11067,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 +11079,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 +11095,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 +12038,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 +12504,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 +12590,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 +12657,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 +12683,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 +12883,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/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index d76af7c3b4..5bd484f137 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -315,19 +315,15 @@ STableMeta* tableMetaDup(const STableMeta* pTableMeta) { size_t schemaExtSize = hasSchemaExt ? pTableMeta->tableInfo.numOfColumns * sizeof(SSchemaExt) : 0; size_t size = sizeof(STableMeta) + numOfFields * sizeof(SSchema); - int32_t cpSize = sizeof(STableMeta) - sizeof(void*); STableMeta* p = taosMemoryMalloc(size + schemaExtSize); - if (NULL == p) return NULL; - memcpy(p, pTableMeta, cpSize); + memcpy(p, pTableMeta, schemaExtSize+size); if (hasSchemaExt) { p->schemaExt = (SSchemaExt*)(((char*)p) + size); - memcpy(p->schemaExt, pTableMeta->schemaExt, schemaExtSize); } else { p->schemaExt = NULL; } - memcpy(p->schema, pTableMeta->schema, numOfFields * sizeof(SSchema)); return p; } diff --git a/source/libs/planner/inc/planInt.h b/source/libs/planner/inc/planInt.h index 24b31f9f37..79cf87d941 100644 --- a/source/libs/planner/inc/planInt.h +++ b/source/libs/planner/inc/planInt.h @@ -60,6 +60,7 @@ bool keysHasCol(SNodeList* pKeys); bool keysHasTbname(SNodeList* pKeys); SFunctionNode* createGroupKeyAggFunc(SColumnNode* pGroupCol); int32_t getTimeRangeFromNode(SNode** pPrimaryKeyCond, STimeWindow* pTimeRange, bool* pIsStrict); +int32_t tagScanSetExecutionMode(SScanLogicNode* pScan); #define CLONE_LIMIT 1 #define CLONE_SLIMIT 1 << 1 diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 60bce622be..23b8baf031 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -392,60 +392,6 @@ static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealT static bool needScanDefaultCol(EScanType scanType) { return SCAN_TYPE_TABLE_COUNT != scanType; } -static EDealRes tagScanNodeHasTbnameFunc(SNode* pNode, void* pContext) { - if (QUERY_NODE_FUNCTION == nodeType(pNode) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pNode)->funcType || - (QUERY_NODE_COLUMN == nodeType(pNode) && COLUMN_TYPE_TBNAME == ((SColumnNode*)pNode)->colType)) { - *(bool*)pContext = true; - return DEAL_RES_END; - } - return DEAL_RES_CONTINUE; -} - -static bool tagScanNodeListHasTbname(SNodeList* pCols) { - bool hasTbname = false; - nodesWalkExprs(pCols, tagScanNodeHasTbnameFunc, &hasTbname); - return hasTbname; -} - -static bool tagScanNodeHasTbname(SNode* pKeys) { - bool hasTbname = false; - nodesWalkExpr(pKeys, tagScanNodeHasTbnameFunc, &hasTbname); - return hasTbname; -} - -static int32_t tagScanSetExecutionMode(SScanLogicNode* pScan) { - pScan->onlyMetaCtbIdx = false; - - if (pScan->tableType == TSDB_CHILD_TABLE) { - pScan->onlyMetaCtbIdx = false; - return TSDB_CODE_SUCCESS; - } - - if (tagScanNodeListHasTbname(pScan->pScanPseudoCols)) { - pScan->onlyMetaCtbIdx = false; - return TSDB_CODE_SUCCESS; - } - - if (pScan->node.pConditions == NULL) { - pScan->onlyMetaCtbIdx = true; - return TSDB_CODE_SUCCESS; - } - - SNode* pCond = nodesCloneNode(pScan->node.pConditions); - SNode* pTagCond = NULL; - SNode* pTagIndexCond = NULL; - filterPartitionCond(&pCond, NULL, &pTagIndexCond, &pTagCond, NULL); - if (pTagIndexCond || tagScanNodeHasTbname(pTagCond)) { - pScan->onlyMetaCtbIdx = false; - } else { - pScan->onlyMetaCtbIdx = true; - } - nodesDestroyNode(pCond); - nodesDestroyNode(pTagIndexCond); - nodesDestroyNode(pTagCond); - return TSDB_CODE_SUCCESS; -} - static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, SLogicNode** pLogicNode) { SScanLogicNode* pScan = NULL; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index eee0766589..191f7167e1 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -5142,7 +5142,6 @@ int32_t stbJoinOptRewriteToTagScan(SLogicNode* pJoin, SNode* pNode) { NODES_DESTORY_NODE(pScan->node.pConditions); pScan->node.requireDataOrder = DATA_ORDER_LEVEL_NONE; pScan->node.resultDataOrder = DATA_ORDER_LEVEL_NONE; - pScan->onlyMetaCtbIdx = true; SNodeList* pTags = nodesMakeList(); int32_t code = nodesCollectColumnsFromNode(pJoinNode->pTagEqCond, NULL, COLLECT_COL_TYPE_TAG, &pTags); @@ -5177,6 +5176,8 @@ int32_t stbJoinOptRewriteToTagScan(SLogicNode* pJoin, SNode* pNode) { code = stbJoinOptAddFuncToScanNode("_vgid", pScan); } + tagScanSetExecutionMode(pScan); + if (code) { nodesDestroyList(pTags); } diff --git a/source/libs/planner/src/planUtil.c b/source/libs/planner/src/planUtil.c index 3b9b348ff5..02572a1a90 100644 --- a/source/libs/planner/src/planUtil.c +++ b/source/libs/planner/src/planUtil.c @@ -615,3 +615,61 @@ int32_t getTimeRangeFromNode(SNode** pPrimaryKeyCond, STimeWindow* pTimeRange, b } +static EDealRes tagScanNodeHasTbnameFunc(SNode* pNode, void* pContext) { + if (QUERY_NODE_FUNCTION == nodeType(pNode) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pNode)->funcType || + (QUERY_NODE_COLUMN == nodeType(pNode) && COLUMN_TYPE_TBNAME == ((SColumnNode*)pNode)->colType)) { + *(bool*)pContext = true; + return DEAL_RES_END; + } + return DEAL_RES_CONTINUE; +} + +static bool tagScanNodeListHasTbname(SNodeList* pCols) { + bool hasTbname = false; + nodesWalkExprs(pCols, tagScanNodeHasTbnameFunc, &hasTbname); + return hasTbname; +} + +static bool tagScanNodeHasTbname(SNode* pKeys) { + bool hasTbname = false; + nodesWalkExpr(pKeys, tagScanNodeHasTbnameFunc, &hasTbname); + return hasTbname; +} + + + +int32_t tagScanSetExecutionMode(SScanLogicNode* pScan) { + pScan->onlyMetaCtbIdx = false; + + if (pScan->tableType == TSDB_CHILD_TABLE) { + pScan->onlyMetaCtbIdx = false; + return TSDB_CODE_SUCCESS; + } + + if (tagScanNodeListHasTbname(pScan->pScanPseudoCols)) { + pScan->onlyMetaCtbIdx = false; + return TSDB_CODE_SUCCESS; + } + + if (pScan->node.pConditions == NULL) { + pScan->onlyMetaCtbIdx = true; + return TSDB_CODE_SUCCESS; + } + + SNode* pCond = nodesCloneNode(pScan->node.pConditions); + SNode* pTagCond = NULL; + SNode* pTagIndexCond = NULL; + filterPartitionCond(&pCond, NULL, &pTagIndexCond, &pTagCond, NULL); + if (pTagIndexCond || tagScanNodeHasTbname(pTagCond)) { + pScan->onlyMetaCtbIdx = false; + } else { + pScan->onlyMetaCtbIdx = true; + } + nodesDestroyNode(pCond); + nodesDestroyNode(pTagIndexCond); + nodesDestroyNode(pTagCond); + return TSDB_CODE_SUCCESS; +} + + + diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 079fd7d29d..4b8695e8ae 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -475,6 +475,8 @@ int32_t schHandleDropCallback(void *param, SDataBuf *pMsg, int32_t code) { SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId, pParam->taskId, code); + // called if drop task rsp received code + rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT); if (pMsg) { taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); @@ -486,7 +488,6 @@ int32_t schHandleNotifyCallback(void *param, SDataBuf *pMsg, int32_t code) { SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 " task notify rsp received, code:0x%x", pParam->queryId, pParam->taskId, code); - rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT); if (pMsg) { taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 123458f372..662d02a48f 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -2179,6 +2179,7 @@ int32_t copyDataAt(RocksdbCfInst* pSrc, STaskDbWrapper* pDst, int8_t i) { } _EXIT: + rocksdb_writebatch_destroy(wb); rocksdb_iter_destroy(pIter); rocksdb_readoptions_destroy(pRdOpt); taosMemoryFree(err); diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 4c16e47163..52002b7ea8 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -1094,13 +1094,10 @@ _end: int32_t streamStatePutParName(SStreamState* pState, int64_t groupId, const char tbname[TSDB_TABLE_NAME_LEN]) { #ifdef USE_ROCKSDB - if (tSimpleHashGetSize(pState->parNameMap) > MAX_TABLE_NAME_NUM) { - if (tSimpleHashGet(pState->parNameMap, &groupId, sizeof(int64_t)) == NULL) { - streamStatePutParName_rocksdb(pState, groupId, tbname); - } - return TSDB_CODE_SUCCESS; + if (tSimpleHashGet(pState->parNameMap, &groupId, sizeof(int64_t)) == NULL) { + tSimpleHashPut(pState->parNameMap, &groupId, sizeof(int64_t), tbname, TSDB_TABLE_NAME_LEN); + streamStatePutParName_rocksdb(pState, groupId, tbname); } - tSimpleHashPut(pState->parNameMap, &groupId, sizeof(int64_t), tbname, TSDB_TABLE_NAME_LEN); return TSDB_CODE_SUCCESS; #else return tdbTbUpsert(pState->pTdbState->pParNameDb, &groupId, sizeof(int64_t), tbname, TSDB_TABLE_NAME_LEN, @@ -1112,10 +1109,11 @@ int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal #ifdef USE_ROCKSDB void* pStr = tSimpleHashGet(pState->parNameMap, &groupId, sizeof(int64_t)); if (!pStr) { - if (tSimpleHashGetSize(pState->parNameMap) > MAX_TABLE_NAME_NUM) { - return streamStateGetParName_rocksdb(pState, groupId, pVal); + int32_t code = streamStateGetParName_rocksdb(pState, groupId, pVal); + if (code == TSDB_CODE_SUCCESS) { + tSimpleHashPut(pState->parNameMap, &groupId, sizeof(int64_t), *pVal, TSDB_TABLE_NAME_LEN); } - return TSDB_CODE_FAILED; + return code; } *pVal = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN); memcpy(*pVal, pStr, TSDB_TABLE_NAME_LEN); diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index 764bf6e026..0adb7050c6 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -13,6 +13,8 @@ * along with this program. If not, see . */ +#include "tcompare.h" +#include "tdatablock.h" #include "tencode.h" #include "tstreamUpdate.h" #include "ttime.h" @@ -31,6 +33,39 @@ static int64_t adjustExpEntries(int64_t entries) { return TMIN(DEFAULT_EXPECTED_ENTRIES, entries); } +int compareKeyTs(void* pTs1, void* pTs2, void* pPkVal, __compar_fn_t cmpPkFn) { + return compareInt64Val(pTs1, pTs2);; +} + +int compareKeyTsAndPk(void* pValue1, void* pTs, void* pPkVal, __compar_fn_t cmpPkFn) { + int res = compareInt64Val(pValue1, pTs); + if (res != 0) { + return res; + } else { + void* pk1 = (char*)pValue1 + sizeof(TSKEY); + return cmpPkFn(pk1, pPkVal); + } +} + +int32_t getKeyBuff(TSKEY ts, int64_t tbUid, void* pVal, int32_t len, char* buff) { + *(TSKEY*)buff = ts; + memcpy(buff+ sizeof(TSKEY), &tbUid, sizeof(int64_t)); + if (len == 0) { + return sizeof(TSKEY) + sizeof(int64_t); + } + memcpy(buff, pVal, len); + return sizeof(TSKEY) + sizeof(int64_t) + len; +} + +int32_t getValueBuff(TSKEY ts, char* pVal, int32_t len, char* buff) { + *(TSKEY*)buff = ts; + if (len == 0) { + return sizeof(TSKEY); + } + memcpy(buff + sizeof(TSKEY), pVal, len); + return sizeof(TSKEY) + len; +} + void windowSBfAdd(SUpdateInfo *pInfo, uint64_t count) { if (pInfo->numSBFs < count) { count = pInfo->numSBFs; @@ -89,11 +124,11 @@ static int64_t adjustWatermark(int64_t adjInterval, int64_t originInt, int64_t w return watermark; } -SUpdateInfo *updateInfoInitP(SInterval *pInterval, int64_t watermark, bool igUp) { - return updateInfoInit(pInterval->interval, pInterval->precision, watermark, igUp); +SUpdateInfo *updateInfoInitP(SInterval *pInterval, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen) { + return updateInfoInit(pInterval->interval, pInterval->precision, watermark, igUp, pkType, pkLen); } -SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, bool igUp) { +SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen) { SUpdateInfo *pInfo = taosMemoryCalloc(1, sizeof(SUpdateInfo)); if (pInfo == NULL) { return NULL; @@ -133,6 +168,17 @@ SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t waterma _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT); pInfo->pMap = taosHashInit(DEFAULT_MAP_CAPACITY, hashFn, true, HASH_NO_LOCK); pInfo->maxDataVersion = 0; + pInfo->pkColLen = pkLen; + pInfo->pkColType = pkType; + pInfo->pKeyBuff = taosMemoryCalloc(1, sizeof(TSKEY) + sizeof(int64_t) + pkLen); + pInfo->pValueBuff = taosMemoryCalloc(1, sizeof(TSKEY) + pkLen); + if (pkLen != 0) { + pInfo->comparePkRowFn = compareKeyTsAndPk; + pInfo->comparePkCol = getKeyComparFunc(pkType, TSDB_ORDER_ASC);; + } else { + pInfo->comparePkRowFn = compareKeyTs; + pInfo->comparePkCol = NULL; + } return pInfo; } @@ -168,47 +214,60 @@ bool updateInfoIsTableInserted(SUpdateInfo *pInfo, int64_t tbUid) { return false; } -TSKEY updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol) { +TSKEY updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol, int32_t primaryKeyCol) { if (pBlock == NULL || pBlock->info.rows == 0) return INT64_MIN; TSKEY maxTs = INT64_MIN; + void* pPkVal = NULL; + void* pMaxPkVal = NULL; + int32_t maxLen = 0; + int32_t len = 0; int64_t tbUid = pBlock->info.id.uid; SColumnInfoData *pColDataInfo = taosArrayGet(pBlock->pDataBlock, primaryTsCol); + SColumnInfoData *pPkDataInfo = NULL; + if (primaryKeyCol >= 0) { + pPkDataInfo = taosArrayGet(pBlock->pDataBlock, primaryKeyCol); + } for (int32_t i = 0; i < pBlock->info.rows; i++) { TSKEY ts = ((TSKEY *)pColDataInfo->pData)[i]; - maxTs = TMAX(maxTs, ts); + if (maxTs < ts) { + maxTs = ts; + if (primaryKeyCol >= 0) { + pMaxPkVal = colDataGetData(pPkDataInfo, i); + maxLen = colDataGetRowLength(pPkDataInfo, i); + } + } SScalableBf *pSBf = getSBf(pInfo, ts); if (pSBf) { - SUpdateKey updateKey = { - .tbUid = tbUid, - .ts = ts, - }; - tScalableBfPut(pSBf, &updateKey, sizeof(SUpdateKey)); + if (primaryKeyCol >= 0) { + pPkVal = colDataGetData(pPkDataInfo, i); + len = colDataGetRowLength(pPkDataInfo, i); + } + int32_t buffLen = getKeyBuff(ts, tbUid, pPkVal, len, pInfo->pKeyBuff); + tScalableBfPut(pSBf, pInfo->pKeyBuff, buffLen); } } - TSKEY *pMaxTs = taosHashGet(pInfo->pMap, &tbUid, sizeof(int64_t)); - if (pMaxTs == NULL || *pMaxTs > maxTs) { - taosHashPut(pInfo->pMap, &tbUid, sizeof(int64_t), &maxTs, sizeof(TSKEY)); + void *pMaxTs = taosHashGet(pInfo->pMap, &tbUid, sizeof(int64_t)); + if (pMaxTs == NULL || pInfo->comparePkRowFn(pMaxTs, &maxTs, pMaxPkVal, pInfo->comparePkCol) == -1) { + int32_t valueLen = getValueBuff(maxTs, pMaxPkVal, maxLen, pInfo->pValueBuff); + taosHashPut(pInfo->pMap, &tbUid, sizeof(int64_t), pInfo->pValueBuff, valueLen); } return maxTs; } -bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) { +bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len) { int32_t res = TSDB_CODE_FAILED; + int32_t buffLen = 0; - SUpdateKey updateKey = { - .tbUid = tableId, - .ts = ts, - }; - - TSKEY *pMapMaxTs = taosHashGet(pInfo->pMap, &tableId, sizeof(uint64_t)); + buffLen = getKeyBuff(ts, tableId, pPkVal, len, pInfo->pKeyBuff); + void* *pMapMaxTs = taosHashGet(pInfo->pMap, &tableId, sizeof(uint64_t)); uint64_t index = ((uint64_t)tableId) % pInfo->numBuckets; TSKEY maxTs = *(TSKEY *)taosArrayGet(pInfo->pTsBuckets, index); if (ts < maxTs - pInfo->watermark) { // this window has been closed. if (pInfo->pCloseWinSBF) { - res = tScalableBfPut(pInfo->pCloseWinSBF, &updateKey, sizeof(SUpdateKey)); + res = tScalableBfPut(pInfo->pCloseWinSBF, pInfo->pKeyBuff, buffLen); if (res == TSDB_CODE_SUCCESS) { return false; } else { @@ -221,18 +280,19 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) { SScalableBf *pSBf = getSBf(pInfo, ts); int32_t size = taosHashGetSize(pInfo->pMap); - if ((!pMapMaxTs && size < DEFAULT_MAP_SIZE) || (pMapMaxTs && *pMapMaxTs < ts)) { - taosHashPut(pInfo->pMap, &tableId, sizeof(uint64_t), &ts, sizeof(TSKEY)); + if ((!pMapMaxTs && size < DEFAULT_MAP_SIZE) || (pMapMaxTs && pInfo->comparePkRowFn(pMapMaxTs, &ts, pPkVal, pInfo->comparePkCol) == -1 )) { + int32_t valueLen = getValueBuff(ts, pPkVal, len, pInfo->pValueBuff); + taosHashPut(pInfo->pMap, &tableId, sizeof(uint64_t), pInfo->pValueBuff, valueLen); // pSBf may be a null pointer if (pSBf) { - res = tScalableBfPutNoCheck(pSBf, &updateKey, sizeof(SUpdateKey)); + res = tScalableBfPutNoCheck(pSBf, pInfo->pKeyBuff, buffLen); } return false; } // pSBf may be a null pointer if (pSBf) { - res = tScalableBfPut(pSBf, &updateKey, sizeof(SUpdateKey)); + res = tScalableBfPut(pSBf, pInfo->pKeyBuff, buffLen); } if (!pMapMaxTs && maxTs < ts) { @@ -262,6 +322,8 @@ void updateInfoDestroy(SUpdateInfo *pInfo) { } taosArrayDestroy(pInfo->pTsSBFs); + taosMemoryFreeClear(pInfo->pKeyBuff); + taosMemoryFreeClear(pInfo->pValueBuff); taosHashCleanup(pInfo->pMap); updateInfoDestoryColseWinSBF(pInfo); taosMemoryFree(pInfo); @@ -322,11 +384,15 @@ int32_t updateInfoSerialize(void *buf, int32_t bufLen, const SUpdateInfo *pInfo) while ((pIte = taosHashIterate(pInfo->pMap, pIte)) != NULL) { void *key = taosHashGetKey(pIte, &keyLen); if (tEncodeU64(&encoder, *(uint64_t *)key) < 0) return -1; - if (tEncodeI64(&encoder, *(TSKEY *)pIte) < 0) return -1; + int32_t valueSize = taosHashGetValueSize(pIte); + if (tEncodeBinary(&encoder, (const uint8_t *)pIte, valueSize) < 0) return -1; } if (tEncodeU64(&encoder, pInfo->maxDataVersion) < 0) return -1; + if (tEncodeI32(&encoder, pInfo->pkColLen) < 0) return -1; + if (tEncodeI8(&encoder, pInfo->pkColType) < 0) return -1; + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -371,28 +437,43 @@ int32_t updateInfoDeserialize(void *buf, int32_t bufLen, SUpdateInfo *pInfo) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT); pInfo->pMap = taosHashInit(mapSize, hashFn, true, HASH_NO_LOCK); uint64_t uid = 0; - ts = INT64_MIN; + void* pVal = NULL; + int32_t valSize = 0; for (int32_t i = 0; i < mapSize; i++) { if (tDecodeU64(&decoder, &uid) < 0) return -1; - if (tDecodeI64(&decoder, &ts) < 0) return -1; - taosHashPut(pInfo->pMap, &uid, sizeof(uint64_t), &ts, sizeof(TSKEY)); + if (tDecodeBinary(&decoder, (uint8_t**)&pVal, &valSize) < 0) return -1; + taosHashPut(pInfo->pMap, &uid, sizeof(uint64_t), pVal, valSize); } ASSERT(mapSize == taosHashGetSize(pInfo->pMap)); if (tDecodeU64(&decoder, &pInfo->maxDataVersion) < 0) return -1; + if (tDecodeI32(&decoder, &pInfo->pkColLen) < 0) return -1; + if (tDecodeI8(&decoder, &pInfo->pkColType) < 0) return -1; + + pInfo->pKeyBuff = taosMemoryCalloc(1, sizeof(TSKEY) + sizeof(int64_t) + pInfo->pkColLen); + pInfo->pValueBuff = taosMemoryCalloc(1, sizeof(TSKEY) + pInfo->pkColLen); + if (pInfo->pkColLen != 0) { + pInfo->comparePkRowFn = compareKeyTsAndPk; + pInfo->comparePkCol = getKeyComparFunc(pInfo->pkColType, TSDB_ORDER_ASC);; + } else { + pInfo->comparePkRowFn = compareKeyTs; + pInfo->comparePkCol = NULL; + } + tEndDecode(&decoder); tDecoderClear(&decoder); return 0; } -bool isIncrementalTimeStamp(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) { +bool isIncrementalTimeStamp(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len) { TSKEY *pMapMaxTs = taosHashGet(pInfo->pMap, &tableId, sizeof(uint64_t)); bool res = true; - if (pMapMaxTs && ts < *pMapMaxTs) { + if (pMapMaxTs && pInfo->comparePkRowFn(pMapMaxTs, &ts, pPkVal, pInfo->comparePkCol) == 1) { res = false; } else { - taosHashPut(pInfo->pMap, &tableId, sizeof(uint64_t), &ts, sizeof(TSKEY)); + int32_t valueLen = getValueBuff(ts, pPkVal, len, pInfo->pValueBuff); + taosHashPut(pInfo->pMap, &tableId, sizeof(uint64_t), pInfo->pValueBuff, valueLen); } return res; } 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/tcompression.c b/source/util/src/tcompression.c index 9c8c1acfb9..da67b68c1c 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -179,6 +179,7 @@ int32_t l2DecompressImpl_tsz(const char *const input, const int32_t inputSize, c #if defined(WINDOWS) || defined(_TD_DARWIN_64) // do nothing #else + int32_t l2ComressInitImpl_zlib(char *lossyColumns, float fPrecision, double dPrecision, uint32_t maxIntervals, uint32_t intervals, int32_t ifAdtFse, const char *compressor) { return 0; @@ -187,7 +188,7 @@ int32_t l2ComressInitImpl_zlib(char *lossyColumns, float fPrecision, double dPre int32_t l2CompressImpl_zlib(const char *const input, const int32_t inputSize, char *const output, int32_t outputSize, const char type, int8_t lvl) { uLongf dstLen = outputSize - 1; - int32_t ret = compress2((Bytef *)(output + 1), (uLongf *)&dstLen, (Bytef *)input, (uLong)inputSize, 9); + int32_t ret = compress2((Bytef *)(output + 1), (uLongf *)&dstLen, (Bytef *)input, (uLong)inputSize, lvl); if (ret == Z_OK) { output[0] = 1; return dstLen + 1; @@ -226,7 +227,7 @@ int32_t l2ComressInitImpl_zstd(char *lossyColumns, float fPrecision, double dPre int32_t l2CompressImpl_zstd(const char *const input, const int32_t inputSize, char *const output, int32_t outputSize, const char type, int8_t lvl) { - size_t len = ZSTD_compress(output + 1, outputSize - 1, input, inputSize, ZSTD_CLEVEL_DEFAULT); + size_t len = ZSTD_compress(output + 1, outputSize - 1, input, inputSize, lvl); if (len > inputSize) { output[0] = 0; memcpy(output + 1, input, inputSize); @@ -253,7 +254,7 @@ int32_t l2ComressInitImpl_xz(char *lossyColumns, float fPrecision, double dPreci } int32_t l2CompressImpl_xz(const char *const input, const int32_t inputSize, char *const output, int32_t outputSize, const char type, int8_t lvl) { - size_t len = FL2_compress(output + 1, outputSize - 1, input, inputSize, 0); + size_t len = FL2_compress(output + 1, outputSize - 1, input, inputSize, lvl); if (len > inputSize) { output[0] = 0; memcpy(output + 1, input, inputSize); @@ -274,14 +275,19 @@ int32_t l2DecompressImpl_xz(const char *const input, const int32_t compressedSiz } #endif -TCompressL1FnSet compressL1Dict[] = {{"PLAIN", NULL, tsCompressPlain2, tsDecompressPlain2}, - {"SIMPLE-8B", NULL, tsCompressINTImp2, tsDecompressINTImp2}, - {"DELTAI", NULL, tsCompressTimestampImp2, tsDecompressTimestampImp2}, - {"BIT-PACKING", NULL, tsCompressBoolImp2, tsDecompressBoolImp2}, - {"DELTAD", NULL, tsCompressDoubleImp2, tsDecompressDoubleImp2}}; +TCmprL1FnSet compressL1Dict[] = {{"PLAIN", NULL, tsCompressPlain2, tsDecompressPlain2}, + {"SIMPLE-8B", NULL, tsCompressINTImp2, tsDecompressINTImp2}, + {"DELTAI", NULL, tsCompressTimestampImp2, tsDecompressTimestampImp2}, + {"BIT-PACKING", NULL, tsCompressBoolImp2, tsDecompressBoolImp2}, + {"DELTAD", NULL, tsCompressDoubleImp2, tsDecompressDoubleImp2}}; + +TCmprLvlSet compressL2LevelDict[] = { + {"unknown", .lvl = {1, 2, 3}}, {"lz4", .lvl = {1, 2, 3}}, {"zlib", .lvl = {1, 6, 9}}, + {"zstd", .lvl = {1, 11, 22}}, {"tsz", .lvl = {1, 2, 3}}, {"xz", .lvl = {1, 6, 9}}, +}; #if defined(WINDOWS) || defined(_TD_DARWIN_64) -TCompressL2FnSet compressL2Dict[] = { +TCmprL2FnSet compressL2Dict[] = { {"unknown", l2ComressInitImpl_disabled, l2CompressImpl_disabled, l2DecompressImpl_disabled}, {"lz4", l2ComressInitImpl_lz4, l2CompressImpl_lz4, l2DecompressImpl_lz4}, {"zlib", l2ComressInitImpl_lz4, l2CompressImpl_lz4, l2DecompressImpl_lz4}, @@ -289,7 +295,7 @@ TCompressL2FnSet compressL2Dict[] = { {"tsz", l2ComressInitImpl_tsz, l2CompressImpl_tsz, l2DecompressImpl_tsz}, {"xz", l2ComressInitImpl_lz4, l2CompressImpl_lz4, l2DecompressImpl_lz4}}; #else -TCompressL2FnSet compressL2Dict[] = { +TCmprL2FnSet compressL2Dict[] = { {"unknown", l2ComressInitImpl_disabled, l2CompressImpl_disabled, l2DecompressImpl_disabled}, {"lz4", l2ComressInitImpl_lz4, l2CompressImpl_lz4, l2DecompressImpl_lz4}, {"zlib", l2ComressInitImpl_zlib, l2CompressImpl_zlib, l2DecompressImpl_zlib}, @@ -299,6 +305,17 @@ TCompressL2FnSet compressL2Dict[] = { #endif +int8_t tsGetCompressL2Level(uint8_t alg, uint8_t lvl) { + if (lvl == L2_LVL_LOW) { + return compressL2LevelDict[alg].lvl[0]; + } else if (lvl == L2_LVL_MEDIUM) { + return compressL2LevelDict[alg].lvl[1]; + } else if (lvl == L2_LVL_HIGH) { + return compressL2LevelDict[alg].lvl[2]; + } + return 1; +} + static const int32_t TEST_NUMBER = 1; #define is_bigendian() ((*(char *)&TEST_NUMBER) == 0) #define SIMPLE8B_MAX_INT64 ((uint64_t)1152921504606846974LL) @@ -2704,7 +2721,8 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int uTrace("encode:%s, compress:%s, level:%d, type:%s, l1:%d", compressL1Dict[l1].name, compressL2Dict[l2].name, \ lvl, tDataTypes[type].name, l1); \ int32_t len = compressL1Dict[l1].comprFn(pIn, nEle, pBuf, type); \ - return compressL2Dict[l2].comprFn(pBuf, len, pOut, nOut, type, lvl); \ + int8_t alvl = tsGetCompressL2Level(l2, lvl); \ + return compressL2Dict[l2].comprFn(pBuf, len, pOut, nOut, type, alvl); \ } else { \ uTrace("dencode:%s, decompress:%s, level:%d, type:%s", compressL1Dict[l1].name, compressL2Dict[l2].name, lvl, \ tDataTypes[type].name); \ @@ -2715,7 +2733,8 @@ int32_t tsDecompressBigint(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int if (compress) { \ uTrace("encode:%s, compress:%s, level:%d, type:%s", "disabled", compressL2Dict[l1].name, lvl, \ tDataTypes[type].name); \ - return compressL2Dict[l2].comprFn(pIn, nIn, pOut, nOut, type, lvl); \ + int8_t alvl = tsGetCompressL2Level(l2, lvl); \ + return compressL2Dict[l2].comprFn(pIn, nIn, pOut, nOut, type, alvl); \ } else { \ uTrace("dencode:%s, dcompress:%s, level:%d, type:%s", "disabled", compressL2Dict[l1].name, lvl, \ tDataTypes[type].name); \ @@ -2913,127 +2932,6 @@ int32_t tsDecompressBigint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, cmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_BIGINT, 0); } -// int32_t tsFindCompressAlg(int8_t dataType, uint8_t compress, TCompressL1FnSet *l1Fn, TCompressL2FnSet *l2Fn); - -// int32_t tsCompressImpl(int8_t type, void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, -// void *pBuf, int32_t nBuf) { -// TCompressL1FnSet fn1; -// TCompressL2FnSet fn2; - -// if (tsFindCompressAlg(type, cmprAlg, &fn1, &fn2)) return -1; - -// int32_t len = 0; -// uint8_t l1 = COMPRESS_L1_TYPE_U8(cmprAlg); -// uint8_t l2 = COMPRESS_L2_TYPE_U8(cmprAlg); -// uint8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(cmprAlg); - -// if (l2 == L2_DISABLED) { -// len = fn1.comprFn(pIn, nEle, pOut, type); -// } else { -// len = fn1.comprFn(pIn, nEle, pBuf, type); -// len = fn2.comprFn(pBuf, len, pOut, nOut, type, lvl); -// } -// return len; -// } -// int32_t tsDecompressImpl(int8_t type, void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t -// cmprAlg, -// void *pBuf, int32_t nBuf) { -// TCompressL1FnSet fn1; -// TCompressL2FnSet fn2; - -// if (tsFindCompressAlg(type, cmprAlg, &fn1, &fn2) != 0) return -1; - -// uint8_t l1 = COMPRESS_L1_TYPE_U8(cmprAlg); -// uint8_t l2 = COMPRESS_L2_TYPE_U8(cmprAlg); -// uint8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(cmprAlg); -// uint32_t len = 0; -// if (l2 == L2_DISABLED) { -// len = fn1.decomprFn(pIn, nEle, pOut, type); -// } else { -// len = fn2.decomprFn(pIn, nIn, pBuf, nBuf, type); -// if (len < 0) return -1; -// len = fn1.decomprFn(pBuf, nEle, pOut, type); -// } -// return len; -// } - -// int32_t tsFindCompressAlg(int8_t dataType, uint8_t compress, TCompressL1FnSet *l1Fn, TCompressL2FnSet *l2Fn) { -// uint8_t l1 = COMPRESS_L1_TYPE_U8(compress); -// uint8_t l2 = COMPRESS_L2_TYPE_U8(compress); -// uint8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(compress); - -// static int32_t l1Sz = sizeof(compressL1Dict) / sizeof(compressL1Dict[0]); -// if (l1 >= l1Sz) return -1; - -// static int32_t l2Sz = sizeof(compressL2Dict) / sizeof(compressL2Dict[0]); -// if (l2 >= l2Sz) return -1; - -// *l1Fn = compressL1Dict[l1]; -// *l2Fn = compressL2Dict[l2]; -// return 0; -// } - -// typedef struct { -// int8_t dtype; -// SArray *l1Set; -// SArray *l2Set; -// } TCompressCompatible; - -// SHashObj *algSet = NULL; - -// int32_t tsCompressSetInit() { -// algSet = taosHashInit(24, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); -// for (int i = TSDB_DATA_TYPE_NULL; i < TSDB_DATA_TYPE_MAX; i++) { -// TCompressCompatible p; -// p.dtype = i; -// p.l1Set = taosArrayInit(4, sizeof(int8_t)); -// p.l2Set = taosArrayInit(4, sizeof(int8_t)); - -// for (int8_t j = L1_DISABLED; j < L1_MAX; j++) { -// taosArrayPush(p.l1Set, &j); -// } - -// for (int8_t j = L2_DISABLED; j < L2_MAX; j++) { -// taosArrayPush(p.l2Set, &j); -// } - -// taosHashPut(algSet, &i, sizeof(i), &p, sizeof(TCompressCompatible)); -// } -// return 0; -// } -// int32_t tsCompressSetDestroy() { -// void *p = taosHashIterate(algSet, NULL); -// while (p) { -// TCompressCompatible *v = p; -// taosArrayDestroy(v->l1Set); -// taosArrayDestroy(v->l2Set); - -// taosHashIterate(algSet, p); -// } -// return 0; -// } - -// int32_t tsValidCompressAlgByDataTypes(int8_t type, int8_t compress) { -// // compress alg -// int8_t l1 = COMPRESS_L1_TYPE_U8(compress); -// int8_t l2 = COMPRESS_L2_TYPE_U8(compress); -// int8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(compress); - -// TCompressCompatible *p = taosHashGet(algSet, &type, sizeof(type)); -// if (p == NULL) return -1; - -// if (p->dtype != type) return -1; - -// if (taosArraySearch(p->l1Set, &l1, compareInt8Val, 0) == NULL) { -// return -1; -// } - -// if (taosArraySearch(p->l2Set, &l2, compareInt8Val, 0) == NULL) { -// return -1; -// } -// return 0; -// } - int32_t tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t *level) { DEFINE_VAR(cmprAlg) *l1Alg = l1; 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/source/util/src/thash.c b/source/util/src/thash.c index cf4f17bfbc..8c0ca3e5a7 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -719,6 +719,11 @@ void *taosHashGetKey(void *data, size_t *keyLen) { return GET_HASH_NODE_KEY(node); } +int32_t taosHashGetValueSize(void *data) { + SHashNode *node = GET_HASH_PNODE(data); + return node->dataLen; +} + // release the pNode, return next pNode, and lock the current entry static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { SHashNode *pOld = (SHashNode *)GET_HASH_PNODE(p); diff --git a/tests/army/community/cluster/snapshot.py b/tests/army/community/cluster/snapshot.py index eef650cc77..d18dbf2796 100644 --- a/tests/army/community/cluster/snapshot.py +++ b/tests/army/community/cluster/snapshot.py @@ -30,7 +30,7 @@ from frame.srvCtl import * class TDTestCase(TBase): updatecfgDict = { - "countAlwaysReturnValue" : "0", + "countAlwaysReturnValue" : "1", "lossyColumns" : "float,double", "fPrecision" : "0.000000001", "dPrecision" : "0.00000000000000001", @@ -106,7 +106,7 @@ class TDTestCase(TBase): # check count always return value sql = f"select count(*) from {self.db}.ta" tdSql.query(sql) - tdSql.checkRows(0) # countAlwaysReturnValue is false + tdSql.checkRows(1) # countAlwaysReturnValue is false # run def run(self): 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 c0975c6d75..db52c9baf8 100644 --- a/tests/army/community/storage/compressBasic.py +++ b/tests/army/community/storage/compressBasic.py @@ -118,18 +118,10 @@ class TDTestCase(TBase): sql = f"describe {self.db}.{self.stb}" tdSql.query(sql) - ''' # see AutoGen.types defEncodes = [ "delta-i","delta-i","simple8b","simple8b","simple8b","simple8b","simple8b","simple8b", "simple8b","simple8b","delta-d","delta-d","bit-packing", - "disabled","disabled","disabled","disabled","disabled"] - ''' - - # pass-ci have error - defEncodes = [ "delta-i","delta-i","simple8b","simple8b","simple8b","simple8b","simple8b","simple8b", - "simple8b","simple8b","delta-d","delta-d","bit-packing", - "disabled","disabled","disabled","disabled","simple8b"] - + "disabled","disabled","disabled","disabled"] count = tdSql.getRows() for i in range(count): diff --git a/tests/army/enterprise/s3/s3Basic.json b/tests/army/enterprise/s3/s3Basic.json index 4a2f4496f9..ef1585d2ba 100644 --- a/tests/army/enterprise/s3/s3Basic.json +++ b/tests/army/enterprise/s3/s3Basic.json @@ -32,7 +32,7 @@ { "name": "stb", "child_table_exists": "no", - "childtable_count": 10, + "childtable_count": 6, "insert_rows": 2000000, "childtable_prefix": "d", "insert_mode": "taosc", diff --git a/tests/army/enterprise/s3/s3Basic.py b/tests/army/enterprise/s3/s3Basic.py index b4b18e355e..8045a3f308 100644 --- a/tests/army/enterprise/s3/s3Basic.py +++ b/tests/army/enterprise/s3/s3Basic.py @@ -38,6 +38,10 @@ s3EndPoint http://192.168.1.52:9000 s3AccessKey 'zOgllR6bSnw2Ah3mCNel:cdO7oXAu3Cqdb1rUdevFgJMi0LtRwCXdWKQx4bhX' s3BucketName ci-bucket s3UploadDelaySec 60 + +for test: +"s3AccessKey" : "fGPPyYjzytw05nw44ViA:vK1VcwxgSOykicx6hk8fL1x15uEtyDSFU3w4hTaZ" +"s3BucketName": "test-bucket" ''' @@ -63,7 +67,7 @@ class TDTestCase(TBase): tdSql.execute(f"use {self.db}") # come from s3_basic.json - self.childtable_count = 10 + self.childtable_count = 6 self.insert_rows = 2000000 self.timestamp_step = 1000 @@ -85,7 +89,7 @@ class TDTestCase(TBase): fileName = cols[8] #print(f" filesize={fileSize} fileName={fileName} line={line}") if fileSize > maxFileSize: - tdLog.info(f"error, {fileSize} over max size({maxFileSize})\n") + tdLog.info(f"error, {fileSize} over max size({maxFileSize}) {fileName}\n") overCnt += 1 else: tdLog.info(f"{fileName}({fileSize}) check size passed.") @@ -99,7 +103,7 @@ class TDTestCase(TBase): loop = 0 rets = [] overCnt = 0 - while loop < 180: + while loop < 100: time.sleep(3) # check upload to s3 @@ -335,7 +339,7 @@ class TDTestCase(TBase): self.snapshotAgg() self.doAction() self.checkAggCorrect() - self.checkInsertCorrect(difCnt=self.childtable_count*999999) + self.checkInsertCorrect(difCnt=self.childtable_count*1499999) self.checkDelete() self.doAction() diff --git a/tests/army/enterprise/s3/s3Basic1.json b/tests/army/enterprise/s3/s3Basic1.json index ef7a169f77..fb95c14e98 100644 --- a/tests/army/enterprise/s3/s3Basic1.json +++ b/tests/army/enterprise/s3/s3Basic1.json @@ -32,7 +32,7 @@ { "name": "stb", "child_table_exists": "yes", - "childtable_count": 10, + "childtable_count": 6, "insert_rows": 1000000, "childtable_prefix": "d", "insert_mode": "taosc", diff --git a/tests/army/frame/caseBase.py b/tests/army/frame/caseBase.py index 21265d2fea..491e432df7 100644 --- a/tests/army/frame/caseBase.py +++ b/tests/army/frame/caseBase.py @@ -140,7 +140,7 @@ class TBase: # check step 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) + tdSql.checkAgg(sql, difCnt) # save agg result def snapshotAgg(self): diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 716622f727..3d1e8d2250 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -14,6 +14,7 @@ ,,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 @@ -128,8 +129,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb0.py -N 3 -n 3 ,,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 +,,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/inner_join.sim b/tests/script/tsim/join/inner_join.sim index 65a6a3e3ff..7b9209813d 100644 --- a/tests/script/tsim/join/inner_join.sim +++ b/tests/script/tsim/join/inner_join.sim @@ -194,4 +194,12 @@ if $rows != 144 then return -1 endi +sql select a.ts, b.ts from tba1 a join sta b on a.ts = b.ts and a.t1 = b.t1; +if $rows != 4 then + return -1 +endi +sql select a.ts, b.ts from sta a join sta b on a.ts = b.ts and a.t1 = b.t1; +if $rows != 8 then + return -1 +endi 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/0-others/compatibility.py b/tests/system-test/0-others/compatibility.py index 4c2fe652b8..71adf6eaac 100644 --- a/tests/system-test/0-others/compatibility.py +++ b/tests/system-test/0-others/compatibility.py @@ -185,8 +185,8 @@ class TDTestCase: # baseVersion = "3.0.1.8" tdLog.printNoPrefix(f"==========step1:prepare and check data in old version-{BASEVERSION}") - tdLog.info(f" LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ") - os.system(f"LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ") + tdLog.info(f" LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -v 1 -y ") + os.system(f"LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -v 1 -y ") os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'flush database test '") os.system("LD_LIBRARY_PATH=/usr/lib taosBenchmark -f 0-others/com_alltypedata.json -y") os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'flush database curdb '") @@ -196,49 +196,81 @@ class TDTestCase: os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'select min(ui) from curdb.meters '") os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'select max(bi) from curdb.meters '") - # os.system(f"LD_LIBRARY_PATH=/usr/lib taos -s 'use test;create stream current_stream into current_stream_output_stb as select _wstart as `start`, _wend as wend, max(current) as max_current from meters where voltage <= 220 interval (5s);' ") - # os.system('LD_LIBRARY_PATH=/usr/lib taos -s "use test;create stream power_stream into power_stream_output_stb as select ts, concat_ws(\\".\\", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname;" ') - # os.system('LD_LIBRARY_PATH=/usr/lib taos -s "use test;show streams;" ') + os.system(f"LD_LIBRARY_PATH=/usr/lib taos -s 'use test;create stream current_stream into current_stream_output_stb as select _wstart as `start`, _wend as wend, max(current) as max_current from meters where voltage <= 220 interval (5s);' ") + os.system('LD_LIBRARY_PATH=/usr/lib taos -s "use test;create stream power_stream trigger at_once into power_stream_output_stb as select ts, concat_ws(\\".\\", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname;" ') + os.system('LD_LIBRARY_PATH=/usr/lib taos -s "use test;show streams;" ') + self.alter_string_in_file("0-others/tmqBasic.json", "/etc/taos/", cPath) # os.system("LD_LIBRARY_PATH=/usr/lib taosBenchmark -f 0-others/tmqBasic.json -y ") - os.system('LD_LIBRARY_PATH=/usr/lib taos -s "create topic if not exists tmq_test_topic as select current,voltage,phase from test.meters where voltage <= 106 and current <= 5;" ') + # create db/stb/select topic + + db_topic = "db_test_topic" + os.system(f'LD_LIBRARY_PATH=/usr/lib taos -s "create topic if not exists {db_topic} with meta as database test" ') + + stable_topic = "stable_test_meters_topic" + os.system(f'LD_LIBRARY_PATH=/usr/lib taos -s "create topic if not exists {stable_topic} as stable test.meters where tbname like \\"d3\\";" ') + + select_topic = "select_test_meters_topic" + os.system(f'LD_LIBRARY_PATH=/usr/lib taos -s "create topic if not exists {select_topic} as select current,voltage,phase from test.meters where voltage >= 170;" ') + os.system('LD_LIBRARY_PATH=/usr/lib taos -s "use test;show topics;" ') os.system(f" /usr/bin/taosadapter --version " ) consumer_dict = { "group.id": "g1", + "td.connect.websocket.scheme": "ws", "td.connect.user": "root", "td.connect.pass": "taosdata", "auto.offset.reset": "earliest", + "enable.auto.commit": "false", } - consumer = taosws.Consumer(conf={"group.id": "local", "td.connect.websocket.scheme": "ws"}) + consumer = taosws.Consumer(consumer_dict) try: - consumer.subscribe(["tmq_test_topic"]) + consumer.subscribe([select_topic]) except TmqError: tdLog.exit(f"subscribe error") - + first_consumer_rows = 0 while True: message = consumer.poll(timeout=1.0) if message: - print("message") - id = message.vgroup() - topic = message.topic() - database = message.database() - for block in message: - nrows = block.nrows() - ncols = block.ncols() - for row in block: - print(row) - values = block.fetchall() - print(nrows, ncols) - - consumer.commit(message) + first_consumer_rows += block.nrows() else: - print("break") + tdLog.notice("message is null and break") break + consumer.commit(message) + tdLog.debug(f"topic:{select_topic} ,first consumer rows is {first_consumer_rows} in old version") + break consumer.close() + # consumer_dict2 = { + # "group.id": "g2", + # "td.connect.websocket.scheme": "ws", + # "td.connect.user": "root", + # "td.connect.pass": "taosdata", + # "auto.offset.reset": "earliest", + # "enable.auto.commit": "false", + # } + # consumer = taosws.Consumer(consumer_dict2) + # try: + # consumer.subscribe([db_topic,stable_topic]) + # except TmqError: + # tdLog.exit(f"subscribe error") + # first_consumer_rows = 0 + # while True: + # message = consumer.poll(timeout=1.0) + # if message: + # for block in message: + # first_consumer_rows += block.nrows() + # else: + # tdLog.notice("message is null and break") + # break + # consumer.commit(message) + # tdLog.debug(f"topic:{select_topic} ,first consumer rows is {first_consumer_rows} in old version") + # break + + + tdLog.info(" LD_LIBRARY_PATH=/usr/lib taosBenchmark -f 0-others/compa4096.json -y ") os.system("LD_LIBRARY_PATH=/usr/lib taosBenchmark -f 0-others/compa4096.json -y") os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'flush database db4096 '") @@ -279,11 +311,10 @@ class TDTestCase: tdLog.printNoPrefix(f"==========step3:prepare and check data in new version-{nowServerVersion}") tdsql.query(f"select count(*) from {stb}") tdsql.checkData(0,0,tableNumbers*recordNumbers1) - # tdsql.query("show streams;") - # os.system(f"taosBenchmark -t {tableNumbers} -n {recordNumbers2} -y ") - # tdsql.query("show streams;") - # tdsql.query(f"select count(*) from {stb}") - # tdsql.checkData(0,0,tableNumbers*recordNumbers2) + tdsql.query("show streams;") + tdsql.checkRows(2) + + # checkout db4096 tdsql.query("select count(*) from db4096.stb0") @@ -334,7 +365,7 @@ class TDTestCase: # check stream tdsql.query("show streams;") - tdsql.checkRows(0) + tdsql.checkRows(2) #check TS-3131 tdsql.query("select *,tbname from d0.almlog where mcid='m0103';") @@ -348,39 +379,48 @@ class TDTestCase: print("The unordered list is the same as the ordered list.") else: tdLog.exit("The unordered list is not the same as the ordered list.") - tdsql.execute("insert into test.d80 values (now+1s, 11, 103, 0.21);") - tdsql.execute("insert into test.d9 values (now+5s, 4.3, 104, 0.4);") # check tmq + tdsql.execute("insert into test.d80 values (now+1s, 11, 190, 0.21);") + tdsql.execute("insert into test.d9 values (now+5s, 4.3, 104, 0.4);") conn = taos.connect() consumer = Consumer( { - "group.id": "tg75", - "client.id": "124", + "group.id": "g1", "td.connect.user": "root", "td.connect.pass": "taosdata", "enable.auto.commit": "true", "experimental.snapshot.enable": "true", } ) - consumer.subscribe(["tmq_test_topic"]) - + consumer.subscribe([select_topic]) + consumer_rows = 0 while True: - res = consumer.poll(10) - if not res: + message = consumer.poll(timeout=1.0) + tdLog.info(f" null {message}") + if message: + for block in message: + consumer_rows += block.nrows() + tdLog.info(f"consumer rows is {consumer_rows}") + else: + print("consumer has completed and break") break - err = res.error() - if err is not None: - raise err - val = res.value() - - for block in val: - print(block.fetchall()) + consumer.close() + tdsql.query("select current,voltage,phase from test.meters where voltage >= 170;") + all_rows = tdsql.queryRows + if consumer_rows < all_rows - first_consumer_rows : + tdLog.exit(f"consumer rows is {consumer_rows}, less than {all_rows - first_consumer_rows}") tdsql.query("show topics;") - tdsql.checkRows(1) + tdsql.checkRows(3) + tdsql.execute(f"drop topic {select_topic};",queryTimes=10) + tdsql.execute(f"drop topic {db_topic};",queryTimes=10) + tdsql.execute(f"drop topic {stable_topic};",queryTimes=10) + os.system(f" LD_LIBRARY_PATH={bPath}/build/lib {bPath}/build/bin/taosBenchmark -t {tableNumbers} -n {recordNumbers2} -y ") + tdsql.query(f"select count(*) from {stb}") + tdsql.checkData(0,0,tableNumbers*recordNumbers2) def stop(self): tdSql.close() diff --git a/tests/system-test/0-others/multilevel.py b/tests/system-test/0-others/multilevel.py index def2c3152b..7b0ebb4b78 100644 --- a/tests/system-test/0-others/multilevel.py +++ b/tests/system-test/0-others/multilevel.py @@ -182,10 +182,10 @@ class TDTestCase: else: checkFiles("%s/*/*" % i, 0) - def more_than_16_disks(self): - tdLog.info("============== more_than_16_disks test ===============") + def more_than_128_disks(self): + tdLog.info("============== more_than_128_disks test ===============") cfg={} - for i in range(17): + for i in range(129): if i == 0 : datadir = '/mnt/data%d 0 1' % (i+1) else: @@ -272,7 +272,7 @@ class TDTestCase: self.dir_permission_denied() self.file_distribution_same_level() self.three_level_basic() - self.more_than_16_disks() + self.more_than_128_disks() self.trim_database() self.missing_middle_level() 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/7-tmq/tmq_primary_key.py b/tests/system-test/7-tmq/tmq_primary_key.py index 8f62dc8783..7d0d3da4fc 100644 --- a/tests/system-test/7-tmq/tmq_primary_key.py +++ b/tests/system-test/7-tmq/tmq_primary_key.py @@ -62,7 +62,7 @@ class TDTestCase: while True: res = consumer.poll(1) if not res: - break + continue val = res.value() if val is None: continue @@ -173,7 +173,7 @@ class TDTestCase: while True: res = consumer.poll(1) if not res: - break + continue val = res.value() if val is None: continue @@ -282,7 +282,7 @@ class TDTestCase: while True: res = consumer.poll(1) if not res: - break + continue val = res.value() if val is None: continue @@ -391,7 +391,7 @@ class TDTestCase: while True: res = consumer.poll(1) if not res: - break + continue val = res.value() if val is None: continue diff --git a/tests/system-test/win-test-file b/tests/system-test/win-test-file index f10619bf02..96f9452827 100644 --- a/tests/system-test/win-test-file +++ b/tests/system-test/win-test-file @@ -61,8 +61,8 @@ python3 ./test.py -f 7-tmq/subscribeStb3.py python3 ./test.py -f 7-tmq/subscribeDb0.py -N 3 -n 3 python3 ./test.py -f 7-tmq/ins_topics_test.py python3 ./test.py -f 7-tmq/tmqMaxTopic.py -#python3 ./test.py -f 7-tmq/tmqParamsTest.py -#python3 ./test.py -f 7-tmq/tmqParamsTest.py -R +python3 ./test.py -f 7-tmq/tmqParamsTest.py +python3 ./test.py -f 7-tmq/tmqParamsTest.py -R python3 ./test.py -f 7-tmq/tmqClientConsLog.py python3 ./test.py -f 7-tmq/tmqMaxGroupIds.py python3 ./test.py -f 7-tmq/tmqConsumeDiscontinuousData.py diff --git a/utils/test/c/sml_test.c b/utils/test/c/sml_test.c index 9e04cfb75b..5e9d82e71e 100644 --- a/utils/test/c/sml_test.c +++ b/utils/test/c/sml_test.c @@ -1789,6 +1789,112 @@ int sml_td24559_Test() { return code; } +int sml_td29691_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "drop database if exists td29691"); + taos_free_result(pRes); + + pRes = taos_query(taos, "create database if not exists td29691"); + taos_free_result(pRes); + + // check column name duplication + const char *sql[] = { + "vbin,t1=1 f1=283i32,f2=3,f2=b\"hello\" 1632299372000", + }; + pRes = taos_query(taos, "use td29691"); + taos_free_result(pRes); + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + int code = taos_errno(pRes); + printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); + ASSERT(code == TSDB_CODE_PAR_DUPLICATED_COLUMN); + taos_free_result(pRes); + + // check tag name duplication + const char *sql1[] = { + "vbin,t1=1,t1=2 f2=b\"hello\" 1632299372000", + }; + pRes = taos_schemaless_insert(taos, (char **)sql1, sizeof(sql1) / sizeof(sql1[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + code = taos_errno(pRes); + printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); + ASSERT(code == TSDB_CODE_PAR_DUPLICATED_COLUMN); + taos_free_result(pRes); + + + // check column tag name duplication + const char *sql2[] = { + "vbin,t1=1,t2=2 t2=L\"ewe\",f2=b\"hello\" 1632299372000", + }; + pRes = taos_schemaless_insert(taos, (char **)sql2, sizeof(sql2) / sizeof(sql2[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + code = taos_errno(pRes); + printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); + ASSERT(code == TSDB_CODE_PAR_DUPLICATED_COLUMN); + taos_free_result(pRes); + + // insert data + const char *sql3[] = { + "vbin,t1=1,t2=2 f1=1,f2=b\"hello\" 1632299372000", + }; + pRes = taos_schemaless_insert(taos, (char **)sql3, sizeof(sql3) / sizeof(sql3[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + code = taos_errno(pRes); + printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); + ASSERT(code == 0); + taos_free_result(pRes); + + //check column tag name duplication when update + const char *sql4[] = { + "vbin,t1=1,t2=2,f1=ewe f1=1,f2=b\"hello\" 1632299372001", + }; + pRes = taos_schemaless_insert(taos, (char **)sql4, sizeof(sql4) / sizeof(sql4[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + code = taos_errno(pRes); + printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); + ASSERT(code == TSDB_CODE_PAR_DUPLICATED_COLUMN); + taos_free_result(pRes); + + //check column tag name duplication when update + const char *sql5[] = { + "vbin,t1=1,t2=2 f1=1,f2=b\"hello\",t1=3 1632299372002", + }; + pRes = taos_schemaless_insert(taos, (char **)sql5, sizeof(sql5) / sizeof(sql5[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + code = taos_errno(pRes); + printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); + ASSERT(code == TSDB_CODE_PAR_DUPLICATED_COLUMN); + taos_free_result(pRes); + + //check column tag name duplication when update + const char *sql7[] = { + "vbin,t1=1,t2=2,f1=ewe f2=b\"hello\" 1632299372003", + }; + pRes = taos_schemaless_insert(taos, (char **)sql7, sizeof(sql7) / sizeof(sql7[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + code = taos_errno(pRes); + printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); + ASSERT(code == TSDB_CODE_PAR_DUPLICATED_COLUMN); + taos_free_result(pRes); + + //check column tag name duplication when update + const char *sql6[] = { + "vbin,t1=1 t2=2,f1=1,f2=b\"hello\" 1632299372004", + }; + pRes = taos_schemaless_insert(taos, (char **)sql6, sizeof(sql6) / sizeof(sql6[0]), TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLI_SECONDS); + code = taos_errno(pRes); + printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); + ASSERT(code == TSDB_CODE_PAR_DUPLICATED_COLUMN); + taos_free_result(pRes); + + taos_close(taos); + + return code; +} + + int sml_td18789_Test() { TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -1808,11 +1914,11 @@ int sml_td18789_Test() { pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - int code = taos_errno(pRes); printf("%s result0:%s\n", __FUNCTION__, taos_errstr(pRes)); taos_free_result(pRes); + TAOS_ROW row = NULL; pRes = taos_query(taos, "select *,tbname from vbin order by _ts"); int rowIndex = 0; @@ -1952,6 +2058,8 @@ int main(int argc, char *argv[]) { } int ret = 0; + ret = sml_td29691_Test(); + ASSERT(ret); ret = sml_td29373_Test(); ASSERT(ret); ret = sml_td24559_Test(); diff --git a/utils/test/c/tmq_taosx_ci.c b/utils/test/c/tmq_taosx_ci.c index 8e9a67eb41..a391093609 100644 --- a/utils/test/c/tmq_taosx_ci.c +++ b/utils/test/c/tmq_taosx_ci.c @@ -19,8 +19,8 @@ #include #include #include "taos.h" -#include "types.h" #include "tmsg.h" +#include "types.h" static int running = 1; TdFilePtr g_fp = NULL; @@ -412,7 +412,8 @@ int buildStable(TAOS* pConn, TAOS_RES* pRes) { #ifdef WINDOWS pRes = taos_query(pConn, - "CREATE STABLE `meters_summary` (`_wstart` TIMESTAMP, `current` FLOAT, `groupid` INT, `location` VARCHAR(16)) TAGS (`group_id` BIGINT UNSIGNED)"); + "CREATE STABLE `meters_summary` (`_wstart` TIMESTAMP, `current` FLOAT, `groupid` INT, `location` " + "VARCHAR(16)) TAGS (`group_id` BIGINT UNSIGNED)"); if (taos_errno(pRes) != 0) { printf("failed to create super table meters_summary, reason:%s\n", taos_errstr(pRes)); return -1; @@ -420,7 +421,8 @@ int buildStable(TAOS* pConn, TAOS_RES* pRes) { taos_free_result(pRes); pRes = taos_query(pConn, - " CREATE TABLE `t_d2a450ee819dcf7576f0282d9ac22dbc` USING `meters_summary` (`group_id`) TAGS (13135550082773579308)"); + " CREATE TABLE `t_d2a450ee819dcf7576f0282d9ac22dbc` USING `meters_summary` (`group_id`) TAGS " + "(13135550082773579308)"); if (taos_errno(pRes) != 0) { printf("failed to create super table meters_summary, reason:%s\n", taos_errstr(pRes)); return -1; @@ -435,7 +437,8 @@ int buildStable(TAOS* pConn, TAOS_RES* pRes) { taos_free_result(pRes); #else pRes = taos_query(pConn, - "create stream meters_summary_s trigger at_once IGNORE EXPIRED 0 into meters_summary as select _wstart, max(current) as current, " + "create stream meters_summary_s trigger at_once IGNORE EXPIRED 0 into meters_summary as select " + "_wstart, max(current) as current, " "groupid, location from meters partition by groupid, location interval(10m)"); if (taos_errno(pRes) != 0) { printf("failed to create super table meters_summary, reason:%s\n", taos_errstr(pRes)); @@ -539,7 +542,8 @@ int32_t create_topic() { if (g_conf.subTable) { char topic[128] = {0}; - sprintf(topic, "create topic meters_summary_t1 %s as stable meters_summary", g_conf.meta == 0 ? "with meta" : "only meta"); + sprintf(topic, "create topic meters_summary_t1 %s as stable meters_summary", + g_conf.meta == 0 ? "with meta" : "only meta"); pRes = taos_query(pConn, topic); if (taos_errno(pRes) != 0) { printf("failed to create topic meters_summary_t1, reason:%s\n", taos_errstr(pRes)); @@ -653,8 +657,15 @@ void initLogFile() { if (g_conf.subTable) { char* result[] = { "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"meters_summary\",\"columns\":[{\"name\":\"_" - "wstart\",\"type\":9,\"isPrimarykey\":false},{\"name\":\"current\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"groupid\",\"type\":4,\"isPrimarykey\":false},{\"name\":" - "\"location\",\"type\":8,\"length\":16,\"isPrimarykey\":false}],\"tags\":[{\"name\":\"group_id\",\"type\":14}]}", + "wstart\",\"type\":9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}" + ",{\"name\":\"current\",\"type\":6,\"isPrimarykey\":false,\"encode\":\"delta-d\",\"compress\":\"lz4\"," + "\"level\":\"medium\"},{" + "\"name\":\"groupid\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\"," + "\"level\":\"medium\"},{\"name\":" + "\"location\",\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\"," + "\"level\":\"medium\"}],\"tags\":[{\"name\":\"group_id\"," + "\"type\":14}" + "]}", "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"t_d2a450ee819dcf7576f0282d9ac22dbc\",\"using\":" "\"meters_summary\",\"tagNum\":1,\"tags\":[{\"name\":\"group_id\",\"type\":14,\"value\":1.313555008277358e+" "19}],\"createList\":[]}"}; @@ -664,56 +675,107 @@ void initLogFile() { } } else { char* result[] = { - "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"tb1\",\"columns\":[{\"name\":\"ts\",\"type\":" - "9,\"isPrimarykey\":false},{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":4,\"isPrimarykey\":false}],\"tags\":[]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":64,\"isPrimarykey\":false},{" - "\"name\":\"c4\",\"type\":5,\"isPrimarykey\":false}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":" + "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"tb1\",\"columns\":[{\"name\":\"ts\"," + "\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":\"c1\"," + "\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c2\",\"type\":" + "4," + "\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":\"medium\"}],\"tags\":[]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\"," + "\"type\":9," + "\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}" + ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false,\"encode\":\"delta-d\",\"compress\":\"lz4\"," + "\"level\":\"medium\"}" + ",{" + "\"name\":\"c3\",\"type\":8,\"length\":64,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":" + "\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c4\",\"type\":5,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":" + "\"t3\"," + "\"type\":10,\"length\":" "8},{\"name\":\"t4\",\"type\":1},{\"name\":\"t2\",\"type\":8,\"length\":64}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct0\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct0\",\"using\":\"st1\",\"tagNum\":4," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct1\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct1\",\"using\":\"st1\",\"tagNum\":4," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":2000}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct2\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct2\",\"using\":\"st1\",\"tagNum\":4," + "\"tags\":[" "],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"using\":\"st1\",\"tagNum\":4," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":5000}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c2\",\"type\":10,\"length\":8,\"isPrimarykey\":false},{\"name\":\"cc3\",\"type\":5,\"isPrimarykey\":false}],\"tags\":[]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"jt\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}," - "{\"name\":\"i\",\"type\":4,\"isPrimarykey\":false}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt1\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{" + "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"columns\":[{\"name\":\"ts\"," + "\"type\":9," + "\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":\"c2\"," + "\"type\":10,\"length\":8,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\",\"level\":" + "\"medium\"},{\"name\":\"cc3\",\"type\":5," + "\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":\"medium\"}],\"tags\":[]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"jt\",\"columns\":[{\"name\":\"ts\"," + "\"type\":9," + "\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}," + "{\"name\":\"i\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt1\",\"using\":\"jt\",\"tagNum\":1," + "\"tags\":[{" "\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt2\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt2\",\"using\":\"jt\",\"tagNum\":1," + "\"tags\":[]" ",\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"stt\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":" + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"stt\",\"columns\":[{\"name\":\"ts\"," + "\"type\":9," + "\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}" + ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\"," + "\"level\":" + "\"medium\"},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":" + "false,\"encode\":\"delta-d\",\"compress\":\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":" + "\"lz4\",\"level\":\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":" "1}]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"sttb\",\"columns\":[{\"name\":\"ts\",\"type\":" - "9,\"isPrimarykey\":false},{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":" + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"sttb\",\"columns\":[{\"name\":\"ts\"," + "\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":" + "\"c1\"," + "\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c2\",\"type\":6," + "\"isPrimarykey\":false,\"encode\":\"delta-d\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":" + "\"c3\"," + "\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\",\"level\":" + "\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":" "1}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3,\"tags\":" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3," + "\"tags\":" "[{\"name\":\"t1\",\"type\":4,\"value\":2},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt1\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"sttb1\",\"using\":\"sttb\",\"tagNum\":3," - "\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":4},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb1\\\"\"}" + "\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":4},{\"name\":\"t3\",\"type\":10,\"value\":" + "\"\\\"sttb1\\\"\"}" ",{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt2\",\"using\":\"stt\",\"tagNum\":3,\"tags\":" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt2\",\"using\":\"stt\",\"tagNum\":3," + "\"tags\":" "[{\"name\":\"t1\",\"type\":4,\"value\":43},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt2\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":0}],\"createList\":[]}", "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"sttb2\",\"using\":\"sttb\",\"tagNum\":3," "\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":54},{\"name\":\"t3\",\"type\":10,\"value\":" "\"\\\"sttb2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3,\"tags\":" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3," + "\"tags\":" "[{\"name\":\"t1\",\"type\":4,\"value\":23},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt3\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"sttb3\",\"using\":\"sttb\",\"tagNum\":3," - "\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":4},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb3\\\"\"}" + "\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":4},{\"name\":\"t3\",\"type\":10,\"value\":" + "\"\\\"sttb3\\\"\"}" ",{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt4\",\"using\":\"stt\",\"tagNum\":3,\"tags\":" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt4\",\"using\":\"stt\",\"tagNum\":3," + "\"tags\":" "[{\"name\":\"t1\",\"type\":4,\"value\":433},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt4\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":0}],\"createList\":[]}", "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"sttb4\",\"using\":\"sttb\",\"tagNum\":3," @@ -726,24 +788,37 @@ void initLogFile() { } } else { if (g_conf.meta) { - if (g_conf.subTable){ - - }else{ + if (g_conf.subTable) { + } else { char* result[] = { - "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"tb1\",\"columns\":[{\"name\":\"ts\",\"type\":" - "9,\"isPrimarykey\":false},{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":4,\"isPrimarykey\":false}],\"tags\":[]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":" + "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"tb1\",\"columns\":[{\"name\":\"ts\"," + "\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":" + "\"c1\",\"type\":4,\"isPrimarykey\":false," + "\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":\"c2\",\"type\":4," + "\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":\"medium\"}],\"tags\":[]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}" + ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\"," + "\"level\":\"medium\"},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false,\"encode\":\"delta-d\"," + "\"compress\":\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":" + "\"lz4\",\"level\":\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":" "1}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct0\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct0\",\"using\":\"st1\",\"tagNum\":3," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct1\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct1\",\"using\":\"st1\",\"tagNum\":3," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":2000}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct2\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct2\",\"using\":\"st1\",\"tagNum\":3," + "\"tags\":[" "],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"using\":\"st1\",\"tagNum\":3," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":3000}],\"createList\":[]}", "{\"type\":\"alter\",\"tableType\":\"super\",\"tableName\":\"st1\",\"alterType\":5,\"colName\":\"c4\"," "\"colType\":5}", @@ -755,8 +830,11 @@ void initLogFile() { "\"colValue\":\"5000\",\"colValueNull\":false}", "{\"type\":\"drop\",\"tableNameList\":[\"ct3\",\"ct1\"]}", "{\"type\":\"drop\",\"tableType\":\"super\",\"tableName\":\"st1\"}", - "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":10,\"length\":4,\"isPrimarykey\":false}],\"tags\":[]}", + "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":" + "\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"},{\"name\":\"c2\",\"type\":10,\"length\":4," + "\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\",\"level\":\"medium\"}],\"tags\":[]}", "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":5,\"colName\":\"c3\"," "\"colType\":5}", "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":7,\"colName\":\"c2\"," @@ -766,25 +844,48 @@ void initLogFile() { "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":9}", "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":6,\"colName\":\"c1\"}", "{\"type\":\"drop\",\"tableNameList\":[\"n1\"]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"jt\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}," - "{\"name\":\"i\",\"type\":4,\"isPrimarykey\":false}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt1\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{" + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"jt\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}," + "{\"name\":\"i\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt1\",\"using\":\"jt\",\"tagNum\":1,\"tags\":" + "[{" "\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt2\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt2\",\"using\":\"jt\",\"tagNum\":1,\"tags\":" + "[]" ",\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}," - "{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}," + "{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":" + "false,\"encode\":\"delta-d\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":\"c3\",\"type\":8," + "\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\",\"level\":\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":1}]}", "{\"type\":\"drop\",\"tableType\":\"super\",\"tableName\":\"st1\"}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"stt\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":" + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"stt\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}" + ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\"," + "\"level\":\"medium\"},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":" + "false,\"encode\":\"delta-d\",\"compress\":\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":" + "\"lz4\",\"level\":\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":" "1}]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"sttb\",\"columns\":[{\"name\":\"ts\",\"type\":" - "9,\"isPrimarykey\":false},{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":" + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"sttb\",\"columns\":[{\"name\":\"ts\"," + "\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":" + "\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"},{\"name\":\"c2\",\"type\":6," + "\"isPrimarykey\":false,\"encode\":\"delta-d\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":\"c3\"," + "\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\",\"level\":" + "\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":" "1}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3,\"tags\":" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3," + "\"tags\":" "[{\"name\":\"t1\",\"type\":4,\"value\":2},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt1\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[{\"tableName\":\"stt1\",\"using\":\"stt\"," "\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2},{\"name\":\"t3\",\"type\":10,\"value\":" @@ -795,7 +896,8 @@ void initLogFile() { "\"\\\"stt2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":0}]},{\"tableName\":\"sttb2\",\"using\":\"sttb\"," "\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":54},{\"name\":\"t3\",\"type\":10,\"value\":" "\"\\\"sttb2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3,\"tags\":" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3," + "\"tags\":" "[{\"name\":\"t1\",\"type\":4,\"value\":23},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt3\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[{\"tableName\":\"stt3\",\"using\":\"stt\"," "\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":23},{\"name\":\"t3\",\"type\":10,\"value\":" @@ -816,9 +918,17 @@ void initLogFile() { if (g_conf.subTable) { char* result[] = { "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"meters_summary\",\"columns\":[{\"name\":\"_" - "wstart\",\"type\":9,\"isPrimarykey\":false},{\"name\":\"current\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"groupid\",\"type\":4,\"isPrimarykey\":false},{\"name\":" - "\"location\",\"type\":8,\"length\":16,\"isPrimarykey\":false}],\"tags\":[{\"name\":\"group_id\",\"type\":14}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"t_d2a450ee819dcf7576f0282d9ac22dbc\",\"using\":" + "wstart\",\"type\":9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":" + "\"medium\"},{\"name\":\"current\",\"type\":6,\"isPrimarykey\":false,\"encode\":\"delta-d\",\"compress\":" + "\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"groupid\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\"," + "\"level\":\"medium\"},{\"name\":" + "\"location\",\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\"," + "\"level\":\"medium\"}],\"tags\":[{\"name\":\"group_id\"," + "\"type\":" + "14}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"t_d2a450ee819dcf7576f0282d9ac22dbc\"," + "\"using\":" "\"meters_summary\",\"tagNum\":1,\"tags\":[{\"name\":\"group_id\",\"type\":14,\"value\":1.313555008277358e+" "19}],\"createList\":[]}"}; @@ -826,23 +936,36 @@ void initLogFile() { taosFprintfFile(pFile2, result[i]); taosFprintfFile(pFile2, "\n"); } - } - else { + } else { char* result[] = { - "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"tb1\",\"columns\":[{\"name\":\"ts\",\"type\":" - "9,\"isPrimarykey\":false},{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":4,\"isPrimarykey\":false}],\"tags\":[]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":" + "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"tb1\",\"columns\":[{\"name\":\"ts\"," + "\"type\":9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c1\",\"type\":4," + "\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":" + "\"c2\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"}],\"tags\":[]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}" + ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\"," + "\"level\":\"medium\"},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":" + "false,\"encode\":\"delta-d\",\"compress\":\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":" + "\"lz4\",\"level\":\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":" "1}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct0\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct0\",\"using\":\"st1\",\"tagNum\":3," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct1\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct1\",\"using\":\"st1\",\"tagNum\":3," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":2000}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct2\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct2\",\"using\":\"st1\",\"tagNum\":3," + "\"tags\":[" "],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"using\":\"st1\",\"tagNum\":3," + "\"tags\":[" "{\"name\":\"t1\",\"type\":4,\"value\":3000}],\"createList\":[]}", "{\"type\":\"alter\",\"tableType\":\"super\",\"tableName\":\"st1\",\"alterType\":5,\"colName\":\"c4\"," "\"colType\":5}", @@ -853,8 +976,11 @@ void initLogFile() { "{\"type\":\"alter\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"alterType\":4,\"colName\":\"t1\"," "\"colValue\":\"5000\",\"colValueNull\":false}", "{\"type\":\"delete\",\"sql\":\"delete from `ct3` where `ts` >= 1626006833600 and `ts` <= 1626006833605\"}", - "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":10,\"length\":4,\"isPrimarykey\":false}],\"tags\":[]}", + "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}" + ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\"," + "\"level\":\"medium\"},{\"name\":\"c2\",\"type\":10,\"length\":4," + "\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\",\"level\":\"medium\"}],\"tags\":[]}", "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":5,\"colName\":\"c3\"," "\"colType\":5}", "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":7,\"colName\":\"c2\"," @@ -863,21 +989,39 @@ void initLogFile() { "\"colNewName\":\"cc3\"}", "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":9}", "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":6,\"colName\":\"c1\"}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"jt\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}," - "{\"name\":\"i\",\"type\":4,\"isPrimarykey\":false}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt1\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{" + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"jt\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}," + "{\"name\":\"i\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt1\",\"using\":\"jt\",\"tagNum\":1,\"tags\":" + "[{" "\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}],\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt2\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt2\",\"using\":\"jt\",\"tagNum\":1,\"tags\":" + "[]" ",\"createList\":[]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"stt\",\"columns\":[{\"name\":\"ts\",\"type\":9,\"isPrimarykey\":false}" - ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":" + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"stt\",\"columns\":[{\"name\":\"ts\",\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"}" + ",{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\"," + "\"level\":\"medium\"},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":" + "false,\"encode\":\"delta-d\",\"compress\":\"lz4\",\"level\":\"medium\"},{" + "\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":" + "\"lz4\",\"level\":\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":" "1}]}", - "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"sttb\",\"columns\":[{\"name\":\"ts\",\"type\":" - "9,\"isPrimarykey\":false},{\"name\":\"c1\",\"type\":4,\"isPrimarykey\":false},{\"name\":\"c2\",\"type\":6,\"isPrimarykey\":false},{\"name\":\"c3\",\"type\":8,\"length\":16,\"isPrimarykey\":false}]," - "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":" + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"sttb\",\"columns\":[{\"name\":\"ts\"," + "\"type\":" + "9,\"isPrimarykey\":false,\"encode\":\"delta-i\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":" + "\"c1\",\"type\":4,\"isPrimarykey\":false,\"encode\":\"simple8b\",\"compress\":\"lz4\",\"level\":" + "\"medium\"},{\"name\":\"c2\",\"type\":6," + "\"isPrimarykey\":false,\"encode\":\"delta-d\",\"compress\":\"lz4\",\"level\":\"medium\"},{\"name\":\"c3\"," + "\"type\":8,\"length\":16,\"isPrimarykey\":false,\"encode\":\"disabled\",\"compress\":\"lz4\",\"level\":" + "\"medium\"}]," + "\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\"," + "\"type\":" "1}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3,\"tags\":" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3," + "\"tags\":" "[{\"name\":\"t1\",\"type\":4,\"value\":2},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt1\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[{\"tableName\":\"stt1\",\"using\":\"stt\"," "\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2},{\"name\":\"t3\",\"type\":10,\"value\":" @@ -888,7 +1032,8 @@ void initLogFile() { "\"\\\"stt2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":0}]},{\"tableName\":\"sttb2\",\"using\":\"sttb\"," "\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":54},{\"name\":\"t3\",\"type\":10,\"value\":" "\"\\\"sttb2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}]}", - "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3,\"tags\":" + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3," + "\"tags\":" "[{\"name\":\"t1\",\"type\":4,\"value\":23},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt3\\\"\"},{" "\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[{\"tableName\":\"stt3\",\"using\":\"stt\"," "\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":23},{\"name\":\"t3\",\"type\":10,\"value\":" @@ -911,12 +1056,12 @@ void initLogFile() { taosCloseFile(&pFile2); } -void testConsumeExcluded(int topic_type){ - TAOS* pConn = use_db(); - TAOS_RES *pRes = NULL; +void testConsumeExcluded(int topic_type) { + TAOS* pConn = use_db(); + TAOS_RES* pRes = NULL; - if(topic_type == 1){ - char *topic = "create topic topic_excluded with meta as database db_taosx"; + if (topic_type == 1) { + char* topic = "create topic topic_excluded with meta as database db_taosx"; pRes = taos_query(pConn, topic); if (taos_errno(pRes) != 0) { printf("failed to create topic topic_excluded, reason:%s\n", taos_errstr(pRes)); @@ -924,8 +1069,8 @@ void testConsumeExcluded(int topic_type){ return; } taos_free_result(pRes); - }else if(topic_type == 2){ - char *topic = "create topic topic_excluded as select * from stt"; + } else if (topic_type == 2) { + char* topic = "create topic topic_excluded as select * from stt"; pRes = taos_query(pConn, topic); if (taos_errno(pRes) != 0) { printf("failed to create topic topic_excluded, reason:%s\n", taos_errstr(pRes)); @@ -946,7 +1091,6 @@ void testConsumeExcluded(int topic_type){ tmq_conf_set(conf, "auto.offset.reset", "earliest"); tmq_conf_set(conf, "msg.consume.excluded", "1"); - tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); assert(tmq); @@ -967,19 +1111,15 @@ void testConsumeExcluded(int topic_type){ if (msg) { tmq_raw_data raw = {0}; tmq_get_raw(msg, &raw); - if(topic_type == 1){ - assert(raw.raw_type != 2 && raw.raw_type != 4 && - raw.raw_type != TDMT_VND_CREATE_STB && - raw.raw_type != TDMT_VND_ALTER_STB && - raw.raw_type != TDMT_VND_CREATE_TABLE && - raw.raw_type != TDMT_VND_ALTER_TABLE && - raw.raw_type != TDMT_VND_DELETE); - assert(raw.raw_type == TDMT_VND_DROP_STB || - raw.raw_type == TDMT_VND_DROP_TABLE); - }else if(topic_type == 2){ + if (topic_type == 1) { + assert(raw.raw_type != 2 && raw.raw_type != 4 && raw.raw_type != TDMT_VND_CREATE_STB && + raw.raw_type != TDMT_VND_ALTER_STB && raw.raw_type != TDMT_VND_CREATE_TABLE && + raw.raw_type != TDMT_VND_ALTER_TABLE && raw.raw_type != TDMT_VND_DELETE); + assert(raw.raw_type == TDMT_VND_DROP_STB || raw.raw_type == TDMT_VND_DROP_TABLE); + } else if (topic_type == 2) { assert(0); } -// printf("write raw data type: %d\n", raw.raw_type); + // printf("write raw data type: %d\n", raw.raw_type); tmq_free_raw(raw); taos_free_result(msg); @@ -1001,13 +1141,13 @@ void testConsumeExcluded(int topic_type){ taos_free_result(pRes); } -void testDetailError(){ +void testDetailError() { tmq_raw_data raw = {0}; raw.raw_type = 2; - int32_t code = tmq_write_raw((TAOS *)1, raw); + int32_t code = tmq_write_raw((TAOS*)1, raw); ASSERT(code); - const char *err = tmq_err2str(code); - char* tmp = strstr(err, "Invalid parameters,detail:taos:0x1 or data"); + const char* err = tmq_err2str(code); + char* tmp = strstr(err, "Invalid parameters,detail:taos:0x1 or data"); ASSERT(tmp != NULL); }