diff --git a/.github/workflows/taosd-ci.yml b/.github/workflows/taosd-ci.yml index c0eeecd8ea..d15fcd1884 100644 --- a/.github/workflows/taosd-ci.yml +++ b/.github/workflows/taosd-ci.yml @@ -10,6 +10,13 @@ on: paths-ignore: - 'packaging/**' - 'docs/**' + - 'tools/tdgpt/**' + - 'source/libs/executor/src/forecastoperator.c' + - 'source/libs/executor/src/anomalywindowoperator.c' + - 'include/common/tanalytics.h' + - 'source/common/src/tanalytics.c' + - 'tests/parallel/tdgpt_cases.task' + - 'tests/script/tsim/analytics' concurrency: group: ${{ github.workflow }}-${{ github.ref }}-TDengine @@ -19,76 +26,19 @@ env: WKC: '/var/lib/jenkins/workspace/TDinternal/community' jobs: - fetch-parameters: - runs-on: - group: CI - labels: [self-hosted, Linux, X64, testing] - outputs: - run_function_test: ${{ steps.parameters.outputs.run_function_test }} - run_tdgpt_test: ${{ steps.parameters.outputs.run_tdgpt_test }} - steps: - - name: Determine trigger source and fetch parameters - id: parameters - run: | - set -euo pipefail - target_branch=${{ github.event.pull_request.base.ref }} - - # Check whether to run tdgpt test cases - cd ${{ env.WKC }} - changed_files_non_doc=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $target_branch) | grep -v "^docs/en/" | grep -v "^docs/zh/" | grep -v ".md$" | tr '\n' ' ' || :) - echo "changed files exclude doc: ${changed_files_non_doc}" - - if [[ -n "$changed_files_non_doc" && "$changed_files_non_doc" =~ (forecastoperator\.c|anomalywindowoperator\.c|tanalytics\.h|tanalytics\.c|tdgpt_cases\.task|analytics|tdgpt) ]]; then - run_tdgpt_test="true" - else - run_tdgpt_test="false" - fi - echo "run tdgpt test: ${run_tdgpt_test}" - - # Check whether to run function test cases - changed_files_non_tdgpt=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $target_branch) | \ - grep -v "^docs/en/" | \ - grep -v "^docs/zh/" | \ - grep -v ".md$" | \ - grep -Ev "forecastoperator\.c|anomalywindowoperator\.c|tanalytics\.h|tanalytics\.c|tdgpt_cases\.task|analytics|tdgpt" | \ - tr '\n' ' ' || :) - echo "changed files exclude tdgpt: ${changed_files_non_tdgpt}" - - if [ -n "$changed_files_non_tdgpt" ]; then - run_function_test="true" - else - run_function_test="false" - fi - - echo "run function test: ${run_function_test}" - - # Output the results for GitHub Actions - echo "run_function_test=$run_function_test" >> $GITHUB_OUTPUT - echo "run_tdgpt_test=$run_tdgpt_test" >> $GITHUB_OUTPUT - - echo ${{ github.event.pull_request.head.ref }} - echo ${{ github.event.pull_request.base.ref }} - echo ${{ github.event.pull_request.number }} - run-tests-on-linux: uses: taosdata/.github/.github/workflows/run-tests-on-linux.yml@main - needs: fetch-parameters - if: ${{ needs.fetch-parameters.outputs.run_tdgpt_test == 'true' || needs.fetch-parameters.outputs.run_function_test == 'true' }} with: tdinternal: false - run_function_test: ${{ needs.fetch-parameters.outputs.run_function_test == 'true' }} - run_tdgpt_test: ${{ needs.fetch-parameters.outputs.run_tdgpt_test == 'true' }} + run_function_test: true + run_tdgpt_test: false run-tests-on-mac: uses: taosdata/.github/.github/workflows/run-tests-on-macos.yml@main - needs: fetch-parameters - if: ${{ needs.fetch-parameters.outputs.run_function_test == 'true' }} with: tdinternal: false run-tests-on-windows: uses: taosdata/.github/.github/workflows/run-tests-on-windows.yml@main - needs: fetch-parameters - if: ${{ needs.fetch-parameters.outputs.run_function_test == 'true' }} with: tdinternal: false diff --git a/.github/workflows/taosd-doc-build.yml b/.github/workflows/taosd-doc-build.yml index 28f1f10835..3ac922820a 100644 --- a/.github/workflows/taosd-doc-build.yml +++ b/.github/workflows/taosd-doc-build.yml @@ -7,7 +7,6 @@ on: - '3.0' paths: - 'docs/**' - - '*.md' env: DOC_WKC: "/root/doc_ci_work" diff --git a/CMakeLists.txt b/CMakeLists.txt index 2be056ec4e..07760e923b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,19 +21,18 @@ include(${TD_SUPPORT_DIR}/cmake.version) include(${TD_SUPPORT_DIR}/cmake.install) set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES OFF) - -add_library(api INTERFACE) -target_include_directories(api INTERFACE "include/client") - add_subdirectory(contrib) -add_subdirectory(source) -add_subdirectory(tools) -add_subdirectory(utils) -add_subdirectory(tests) -add_subdirectory(docs/doxgen) if(${BUILD_TEST}) include(CTest) enable_testing() add_subdirectory(examples/c) -endif(${BUILD_TEST}) \ No newline at end of file +endif(${BUILD_TEST}) + +add_library(api INTERFACE) +target_include_directories(api INTERFACE "include/client") +add_subdirectory(source) +add_subdirectory(tools) +add_subdirectory(utils) +add_subdirectory(tests) +add_subdirectory(docs/doxgen) diff --git a/README.md b/README.md index 9bc6c5dd83..3399ad5b2d 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ TDengine is an open source, high-performance, cloud native [time-series database For a full list of TDengine competitive advantages, please [check here](https://tdengine.com/tdengine/). The easiest way to experience TDengine is through [TDengine Cloud](https://cloud.tdengine.com). +For the latest TDengine component TDgpt, please refer to [TDgpt README](./tools/tdgpt/README.md) for details. + # 2. Documentation For user manual, system design and architecture, please refer to [TDengine Documentation](https://docs.tdengine.com) ([TDengine 文档](https://docs.taosdata.com)) diff --git a/docs/en/10-third-party/05-bi/03-powerbi.md b/docs/en/10-third-party/05-bi/03-powerbi.md index 85746da45b..dac8ee2b62 100644 --- a/docs/en/10-third-party/05-bi/03-powerbi.md +++ b/docs/en/10-third-party/05-bi/03-powerbi.md @@ -14,8 +14,8 @@ Power BI is a business analytics tool provided by Microsoft. By configuring the ## Configure Data Source -**Step 1**, Search and open the [ODBC Data Source (64 bit)] management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation). - +**Step 1**, Search and open the [ODBC Data Source (64 bit)] management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation). + **Step 2**, Open Power BI and log in, click [Home] -> [Get Data] -> [Other] -> [ODBC] -> [Connect], add data source. **Step 3**, Select the data source name just created, such as [MyTDengine], if you need to enter SQL, you can click the [Advanced options] tab, in the expanded dialog box enter the SQL statement. Click the [OK] button to connect to the configured data source. diff --git a/docs/en/10-third-party/05-bi/12-tableau.md b/docs/en/10-third-party/05-bi/12-tableau.md index db8a569926..cacfaf94c0 100644 --- a/docs/en/10-third-party/05-bi/12-tableau.md +++ b/docs/en/10-third-party/05-bi/12-tableau.md @@ -13,11 +13,11 @@ Prepare the following environment: - TDengine 3.3.5.8 and above version is installed and running normally (both Enterprise and Community versions are available). - taosAdapter is running normally, refer to [taosAdapter Reference](../../../tdengine-reference/components/taosadapter/). - Install and run Tableau Desktop (if not installed, please download and install Windows operating system 64-bit [Download Tableau Desktop](https://www.tableau.com/products/desktop/download)). Install Tableau please refer to [Tableau Desktop](https://www.tableau.com). -- Download the latest Windows operating system X64 client driver from the TDengine official website and install it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation). +- Download the latest Windows operating system X64 client driver from the TDengine official website and install it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation). ## Configure Data Source -**Step 1**, Search and open the "ODBC Data Source (64 bit)" management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation). +**Step 1**, Search and open the "ODBC Data Source (64 bit)" management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation). :::tip It should be noted that when configuring the ODBC data source for Tableau, the [Database] configuration item on the TDengine ODBC data source configuration page is required. You need to select a database that can be successfully connected. @@ -27,19 +27,19 @@ It should be noted that when configuring the ODBC data source for Tableau, the [ **Step 3**, Click the `DSN` radio button, then select the configured data source (MyTDengine), and click the `Connect` button. After the connection is successful, delete the content of the string attachment, and finally click the `Sign In` button. -![tableau-odbc](./tableau/tableau-odbc.jpg) +![tableau-odbc](./tableau/tableau-odbc.webp) ## Data Analysis **Step 1**, In the workbook page, the connected data sources will be displayed. Clicking on the dropdown list of databases will display the databases that require data analysis. On this basis, click the search button in the table options to display all tables in the database. Then, drag the table to be analyzed to the right area to display the table structure. -![tableau-workbook](./tableau/tableau-table.jpg) +![tableau-workbook](./tableau/tableau-table.webp) **Step 2**, Click the `Update Now` button below to display the data in the table. -![tableau-workbook](./tableau/tableau-data.jpg) +![tableau-workbook](./tableau/tableau-data.webp) **Step 3**, Click on the "Worksheet" at the bottom of the window to pop up the data analysis window, which displays all the fields of the analysis table. Drag the fields to the rows and columns to display the chart. -![tableau-workbook](./tableau/tableau-analysis.jpg) +![tableau-workbook](./tableau/tableau-analysis.webp) diff --git a/docs/en/10-third-party/05-bi/13-excel.md b/docs/en/10-third-party/05-bi/13-excel.md index 114954e81f..286c64bca2 100644 --- a/docs/en/10-third-party/05-bi/13-excel.md +++ b/docs/en/10-third-party/05-bi/13-excel.md @@ -13,30 +13,30 @@ Prepare the following environment: - TDengine 3.3.5.8 and above version is installed and running normally (both Enterprise and Community versions are available). - taosAdapter is running normally, refer to [taosAdapter Reference](../../../tdengine-reference/components/taosadapter/). - Install and run Excel. If not installed, please download and install it. For specific instructions, please refer to Microsoft's official documentation. -- Download the latest Windows operating system X64 client driver from the TDengine official website and install it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation). +- Download the latest Windows operating system X64 client driver from the TDengine official website and install it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation). ## Configure Data Source -**Step 1**, Search and open the [ODBC Data Source (64 bit)] management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation). - +**Step 1**, Search and open the [ODBC Data Source (64 bit)] management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation). + **Step 2**, Start Excel in the Windows system environment, then select [Data] -> [Get Data] -> [From Other Sources] -> [From ODBC]. -![excel-odbc](./excel/odbc-menu.jpg) +![excel-odbc](./excel/odbc-menu.webp) **Step 3**, In the pop-up window, select the data source you need to connect to from the drop-down list of [Data source name (DSN)], and then click the [OK] button. -![excel-odbc](./excel/odbc-select.jpg) +![excel-odbc](./excel/odbc-select.webp) **Step 4**, Enter the username and password for TDengine. -![excel-odbc](./excel/odbc-config.jpg) +![excel-odbc](./excel/odbc-config.webp) **Step 5**, In the pop-up [Navigator] dialog box, select the database tables you want to load, and then click [Load] to complete the data loading. -![excel-odbc](./excel/odbc-load.jpg) +![excel-odbc](./excel/odbc-load.webp) ## Data Analysis Select the imported data. On the [Insert] tab, choose the column chart, and then configure the data fields in the [PivotChart Fields] pane on the right. -![excel-odbc](./excel/odbc-data.jpg) +![excel-odbc](./excel/odbc-data.webp) diff --git a/docs/en/10-third-party/05-bi/14-finebi.md b/docs/en/10-third-party/05-bi/14-finebi.md new file mode 100644 index 0000000000..2088b381e9 --- /dev/null +++ b/docs/en/10-third-party/05-bi/14-finebi.md @@ -0,0 +1,82 @@ +--- +sidebar_label: FineBI +title: Integration With FineBI +toc_max_heading_level: 4 +--- + +Fanruan is a technology company specializing in the field of business intelligence and data analytics. With its self-developed core products, FineBI and FineReport, the company has established a leading position in the industry. Fanruan's BI tools are widely adopted by enterprises across various sectors, empowering users to achieve data visualization analysis, report generation, and data-driven decision support. + +By using the TDengine Java connector, FineBI can quickly access the data in TDengine. Users can directly connect to the TDengine database in FineBI, obtain time-series data for analysis, and create visual reports, and the entire process does not require any code writing. + +## Prerequisites + +- TDengine 3.3.4.0 and above version is installed and running normally (both Enterprise and Community versions are available). +- taosAdapter is running normally, refer to [taosAdapter Reference](../../../tdengine-reference/components/taosadapter/). +- Install FineBI (if not installed, please download and install [Download FineBI](https://intl.finebi.com/download)). +- Download the fine_conf_entity plugin to support the addition of JDBC drivers, [Download link](https://market.fanruan.com/plugin/1052a471-0239-4cd8-b832-045d53182c5d). +- Install the JDBC driver. Download the `TDengine JDBC connector` file `taos-jdbcdriver-3.4.0-dist.jar` or a higher version from `maven.org`. + +## Configure Data Source + +**Step 1**, In the `db.script` configuration file of the FineBI server, find the `SystemConfig.driverUpload` configuration item and change its value to true. + +- Windows system: The path of the configuration file is webapps/webroot/WEB-INF/embed/finedb/db.script under the installation directory. +- Linux/Mac system: The path of the configuration file is /usr/local/FineBI6.1/webapps/webroot/WEB-INF/embed/finedb/db.script. + +**Step 2**, Start the FineBI service. Enter `http://ip:37799/webroot/decision` in the browser, where "ip" is the IP address of the FineBI server. + +**Step 3**, After logging in to the FineBI Web page, click [System Management] -> [Plugin Management]. In the [Store App] on the right side, click [Install From Local] and select the downloaded `fine_conf_entity` plugin for installation. + +![finebi-workbook](./finebi/plugin.webp) + +**Step 4**, Click [System Management] -> [Data Connection] -> [Data Connection Management]. On the right-hand page, click the [Driver Management] button to open the configuration page. Then click the [New Driver] button, and in the pop-up window, enter a name (for example, `tdengine-websocket`) to configure the JDBC driver. + +![finebi-workbook](./finebi/connect-manage.webp) + +**Step 5**, On the driver configuration page, click the [Upload File] button. Select the downloaded TDengine Java Connector (e.g., `taos-jdbcdriver-3.4.0-dist.jar`) for uploading. After the upload is complete, select `com.taosdata.jdbc.ws.WebSocketDriver` from the drop-down list of [Driver], and then click [Save]. + +![finebi-workbook](./finebi/new-driver.webp) + +**Step 6**, On the "Data Connection Management" page, click the [New Data Connection] button. Subsequently, click "Others", and then on the right-side page, click "Other JDBC" to perform the connection configuration. + +![finebi-workbook](./finebi/jdbc-connect.webp) + +**Step 7**, On the configuration page, first enter the name of the data connection. Then, select "Custom" in the [Driver] option and choose the configured driver from the drop-down list (e.g., `com.taosdata.jdbc.ws.WebSocketDriver (tdengine-websocket)`). After that, configure the "Data Connection URL" (e.g., `jdbc:TAOS-WS://localhost:6041/power?user=root&password=taosdata&fineBIDialect=mysql`). Once the settings are completed, click [Test Connection] in the top-right corner to test the connection. After the verification is successful, click [Save] to finish the configuration. + +:::tip +`fineBIDialect=mysql` The meaning of this setting is to adopt the SQL dialect rules of the MySQL database. Simply put, it tells FineBI to parse and execute relevant queries and operations in the specific way that the MySQL database handles SQL statements. +::: + +![finebi-workbook](./finebi/jdbc-config.webp) + +## Data Analysis + +### Data preparation + +**Step 1**, Click [Public Data]. On the right - hand page, click [New Folder] to create a folder (e.g., TDengine). Then, click the [+] button on the right side of the folder to create a "Database Table" dataset or an "SQL Dataset". + +![finebi-workbook](./finebi/common.webp) + +**Step 2**, Click "Database Table" to open the database table selection page. In the "Data Connection" section on the left, select the previously created connection. Then, all the tables in the database of the current connection will be displayed on the right. Select the table you need to load (e.g., meters), and click [OK]. The data in the meters table will then be displayed. + +![finebi-workbook](./finebi/select-table.webp) + +![finebi-workbook](./finebi/table-data.webp) + +**Step 3**, Click "SQL Dataset" to open the configuration page for the SQL dataset. First, enter the table name (used for display on the FineBI page). Then, select the previously created connection from the drop-down list of "Data from Data Connection". After that, enter the SQL statement and click "Preview" to view the query results. Finally, click [OK] to successfully create the SQL dataset. + +![finebi-workbook](./finebi/sql-data-config.webp) + +### Smart Meter Example + +**Step 1**, Click [My Analysis]. On the right-hand page, click [New Folder] to create a folder (for example, `TDengine`). Then, click the [+] button on the right side of the folder to create an "Analysis Subject". + +![finebi-workbook](./finebi/analysis-object.webp) + +**Step 2**, On the analysis subject page, select the dataset (for example, `meters`) and then click the [OK] button to complete the association of the dataset. + +![finebi-workbook](./finebi/load-data.webp) + +**Step 3**, Click the [Component] tab at the bottom of the analysis subject page to open the chart configuration page. Drag the fields to the horizontal axis or the vertical axis, and then the chart will be displayed. + +![finebi-workbook](./finebi/analysis-chart.webp) diff --git a/docs/en/10-third-party/05-bi/excel/odbc-config.jpg b/docs/en/10-third-party/05-bi/excel/odbc-config.jpg deleted file mode 100644 index a62c9eb18f..0000000000 Binary files a/docs/en/10-third-party/05-bi/excel/odbc-config.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-config.webp b/docs/en/10-third-party/05-bi/excel/odbc-config.webp new file mode 100644 index 0000000000..d18c4523ba Binary files /dev/null and b/docs/en/10-third-party/05-bi/excel/odbc-config.webp differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-data.jpg b/docs/en/10-third-party/05-bi/excel/odbc-data.jpg deleted file mode 100644 index 9a16033e9b..0000000000 Binary files a/docs/en/10-third-party/05-bi/excel/odbc-data.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-data.webp b/docs/en/10-third-party/05-bi/excel/odbc-data.webp new file mode 100644 index 0000000000..ac7110309e Binary files /dev/null and b/docs/en/10-third-party/05-bi/excel/odbc-data.webp differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-load.jpg b/docs/en/10-third-party/05-bi/excel/odbc-load.jpg deleted file mode 100644 index 7a6f829ff9..0000000000 Binary files a/docs/en/10-third-party/05-bi/excel/odbc-load.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-load.webp b/docs/en/10-third-party/05-bi/excel/odbc-load.webp new file mode 100644 index 0000000000..1ba6bffc8d Binary files /dev/null and b/docs/en/10-third-party/05-bi/excel/odbc-load.webp differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-menu.jpg b/docs/en/10-third-party/05-bi/excel/odbc-menu.jpg deleted file mode 100644 index f7dedc9cbb..0000000000 Binary files a/docs/en/10-third-party/05-bi/excel/odbc-menu.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-menu.webp b/docs/en/10-third-party/05-bi/excel/odbc-menu.webp new file mode 100644 index 0000000000..c46f8ae619 Binary files /dev/null and b/docs/en/10-third-party/05-bi/excel/odbc-menu.webp differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-select.jpg b/docs/en/10-third-party/05-bi/excel/odbc-select.jpg deleted file mode 100644 index fe72c975d5..0000000000 Binary files a/docs/en/10-third-party/05-bi/excel/odbc-select.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/excel/odbc-select.webp b/docs/en/10-third-party/05-bi/excel/odbc-select.webp new file mode 100644 index 0000000000..ea745234d6 Binary files /dev/null and b/docs/en/10-third-party/05-bi/excel/odbc-select.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/analysis-chart.webp b/docs/en/10-third-party/05-bi/finebi/analysis-chart.webp new file mode 100644 index 0000000000..3272dede26 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/analysis-chart.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/analysis-object.webp b/docs/en/10-third-party/05-bi/finebi/analysis-object.webp new file mode 100644 index 0000000000..8863ac2515 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/analysis-object.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/common.webp b/docs/en/10-third-party/05-bi/finebi/common.webp new file mode 100644 index 0000000000..ebf4e0ffff Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/common.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/connect-manage.webp b/docs/en/10-third-party/05-bi/finebi/connect-manage.webp new file mode 100644 index 0000000000..2ff0aa497f Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/connect-manage.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/jdbc-config.webp b/docs/en/10-third-party/05-bi/finebi/jdbc-config.webp new file mode 100644 index 0000000000..e5f4f436a9 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/jdbc-config.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/jdbc-connect.webp b/docs/en/10-third-party/05-bi/finebi/jdbc-connect.webp new file mode 100644 index 0000000000..fa32255b62 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/jdbc-connect.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/load-data.webp b/docs/en/10-third-party/05-bi/finebi/load-data.webp new file mode 100644 index 0000000000..f55748cb26 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/load-data.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/new-driver.webp b/docs/en/10-third-party/05-bi/finebi/new-driver.webp new file mode 100644 index 0000000000..53a3294ea6 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/new-driver.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/plugin.webp b/docs/en/10-third-party/05-bi/finebi/plugin.webp new file mode 100644 index 0000000000..b44fb0a83a Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/plugin.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/select-table.webp b/docs/en/10-third-party/05-bi/finebi/select-table.webp new file mode 100644 index 0000000000..190ad4dee0 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/select-table.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/sql-data-config.webp b/docs/en/10-third-party/05-bi/finebi/sql-data-config.webp new file mode 100644 index 0000000000..c27cc5bed3 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/sql-data-config.webp differ diff --git a/docs/en/10-third-party/05-bi/finebi/table-data.webp b/docs/en/10-third-party/05-bi/finebi/table-data.webp new file mode 100644 index 0000000000..4ecd7ae189 Binary files /dev/null and b/docs/en/10-third-party/05-bi/finebi/table-data.webp differ diff --git a/docs/en/10-third-party/05-bi/tableau/tableau-analysis.jpg b/docs/en/10-third-party/05-bi/tableau/tableau-analysis.jpg deleted file mode 100644 index 600bd286ac..0000000000 Binary files a/docs/en/10-third-party/05-bi/tableau/tableau-analysis.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/tableau/tableau-analysis.webp b/docs/en/10-third-party/05-bi/tableau/tableau-analysis.webp new file mode 100644 index 0000000000..8ed29a42ce Binary files /dev/null and b/docs/en/10-third-party/05-bi/tableau/tableau-analysis.webp differ diff --git a/docs/en/10-third-party/05-bi/tableau/tableau-data.jpg b/docs/en/10-third-party/05-bi/tableau/tableau-data.jpg deleted file mode 100644 index 9b8c7ba546..0000000000 Binary files a/docs/en/10-third-party/05-bi/tableau/tableau-data.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/tableau/tableau-data.webp b/docs/en/10-third-party/05-bi/tableau/tableau-data.webp new file mode 100644 index 0000000000..03c82ab7bc Binary files /dev/null and b/docs/en/10-third-party/05-bi/tableau/tableau-data.webp differ diff --git a/docs/en/10-third-party/05-bi/tableau/tableau-odbc.jpg b/docs/en/10-third-party/05-bi/tableau/tableau-odbc.jpg deleted file mode 100644 index fe7c03f963..0000000000 Binary files a/docs/en/10-third-party/05-bi/tableau/tableau-odbc.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/tableau/tableau-odbc.webp b/docs/en/10-third-party/05-bi/tableau/tableau-odbc.webp new file mode 100644 index 0000000000..e28116fb47 Binary files /dev/null and b/docs/en/10-third-party/05-bi/tableau/tableau-odbc.webp differ diff --git a/docs/en/10-third-party/05-bi/tableau/tableau-table.jpg b/docs/en/10-third-party/05-bi/tableau/tableau-table.jpg deleted file mode 100644 index cb77a54197..0000000000 Binary files a/docs/en/10-third-party/05-bi/tableau/tableau-table.jpg and /dev/null differ diff --git a/docs/en/10-third-party/05-bi/tableau/tableau-table.webp b/docs/en/10-third-party/05-bi/tableau/tableau-table.webp new file mode 100644 index 0000000000..18bdf5c196 Binary files /dev/null and b/docs/en/10-third-party/05-bi/tableau/tableau-table.webp differ diff --git a/docs/en/14-reference/02-tools/10-taosbenchmark.md b/docs/en/14-reference/02-tools/10-taosbenchmark.md index 19f498eab1..338cc74a3d 100644 --- a/docs/en/14-reference/02-tools/10-taosbenchmark.md +++ b/docs/en/14-reference/02-tools/10-taosbenchmark.md @@ -371,10 +371,14 @@ Specify the configuration parameters for tag and data columns in `super_tables` ### Query Parameters -In query scenarios, `filetype` must be set to `query`. +`filetype` must be set to `query`. + +`query_mode` connect method: +- "taosc": Native. +- "rest" : RESTful. + `query_times` specifies the number of times to run the query, numeric type. -Query scenarios can control the execution of slow query statements by setting `kill_slow_query_threshold` and `kill_slow_query_interval` parameters, where threshold controls that queries exceeding the specified exec_usec time will be killed by taosBenchmark, in seconds; interval controls the sleep time to avoid continuous slow query CPU consumption, in seconds. For other common parameters, see [General Configuration Parameters](#general-configuration-parameters) @@ -382,13 +386,26 @@ For other common parameters, see [General Configuration Parameters](#general-con Configuration parameters for querying specified tables (can specify supertables, subtables, or regular tables) are set in `specified_table_query`. - **mixed_query** : Query Mode . "yes" is `Mixed Query`, "no" is `General Query`, default is "no". - `General Query`: + `General Query`: Each SQL in `sqls` starts `threads` threads to query this SQL, Each thread exits after executing the `query_times` queries, and only after all threads executing this SQL have completed can the next SQL be executed. The total number of queries(`General Query`) = the number of `sqls` * `query_times` * `threads` - `Mixed Query`: + `Mixed Query`: All SQL statements in `sqls` are divided into `threads` groups, with each thread executing one group. Each SQL statement needs to execute `query_times` queries. - The total number of queries(`Mixed Query`) = the number of `sqls` * `query_times` + The total number of queries(`Mixed Query`) = the number of `sqls` * `query_times`. + +- **batch_query** : Batch query power switch. +"yes": indicates that it is enabled. +"no": indicates that it is not enabled, and other values report errors. +Batch query refers to dividing all SQL statements in SQL into `threads` groups, with each thread executing one group. +Each SQL statement is queried only once before exiting, and the main thread waits for all threads to complete before determining if the `query_interval` parameter is set. If sleep is required for a specified time, each thread group is restarted and the previous process is repeated until the number of queries is exhausted. +Functional limitations: +- Only supports scenarios where `mixed_query` is set to 'yes'. +- Restful queries are not supported, meaning `query_made` cannot be 'rest'. + - **query_interval** : Query interval, in millisecond, default is 0. +When the 'batch_query' switch is turned on, it indicates the interval time after each batch query is completed, When closed, it indicates the interval time between each SQL query completion. +If the execution time of the query exceeds the interval time, it will no longer wait. If the execution time of the query is less than the interval time, it is necessary to wait to make up for the interval time. + - **threads** : Number of threads executing the SQL query, default is 1. - **sqls**: - **sql**: The SQL command to execute, required. diff --git a/docs/en/14-reference/09-error-code.md b/docs/en/14-reference/09-error-code.md index d071bcdc81..725f5a22f5 100644 --- a/docs/en/14-reference/09-error-code.md +++ b/docs/en/14-reference/09-error-code.md @@ -462,8 +462,8 @@ This document details the server error codes that may be encountered when using | 0x80002688 | Cannot use 'year' or 'month' as true_for duration | Use year or month as true_for_duration | Check and correct the SQL statement | | 0x80002689 | Invalid using cols function | Illegal using cols function | Check and correct the SQL statement | | 0x8000268A | Cols function's first param must be a select function that output a single row | The first parameter of the cols function should be a selection function | Check and correct the SQL statement | -| 0x8000268B | Invalid using cols function with multiple output columns | Illegal using the cols function for multiple column output | Check and correct the SQL statement | -| 0x8000268C | Invalid using alias for cols function | Illegal cols function alias | Check and correct the SQL statement | +| 0x8000268B | Invalid using alias for cols function | Illegal cols function alias | Check and correct the SQL statement | +| 0x8000268C | Join primary key col must be timestmap type | Join primary key data type error | Check and correct the SQL statement | | 0x800026FF | Parser internal error | Internal error in parser | Preserve the scene and logs, report issue on GitHub | | 0x80002700 | Planner internal error | Internal error in planner | Preserve the scene and logs, report issue on GitHub | | 0x80002701 | Expect ts equal | JOIN condition validation failed | Preserve the scene and logs, report issue on GitHub | diff --git a/docs/zh/10-third-party/05-bi/12-tableau.md b/docs/zh/10-third-party/05-bi/12-tableau.md index 4a22d0f779..b53833debb 100644 --- a/docs/zh/10-third-party/05-bi/12-tableau.md +++ b/docs/zh/10-third-party/05-bi/12-tableau.md @@ -26,18 +26,18 @@ Tableau 是一款知名的商业智能工具,它支持多种数据源,可方 **第 3 步**,点击 `DSN` 单选框,接着选择已配置好的数据源(MyTDengine),然后点击`连接`按钮。待连接成功后,删除字符串附加部分的内容,最后点击`登录`按钮即可。 -![tableau-odbc](./tableau/tableau-odbc.jpg) +![tableau-odbc](./tableau/tableau-odbc.webp) ## 数据分析 **第 1 步**,在工作簿页面中,选择已连接的数据源。点击数据库的下拉列表,会显示需要进行数据分析的数据库。在此基础上,点击表选项中的查找按钮,即可将该数据库下的所有表显示出来。然后,拖动需要分析的表到右侧区域,即可显示出表结构。 -![tableau-workbook](./tableau/tableau-table.jpg) +![tableau-workbook](./tableau/tableau-table.webp) **第 2 步**,点击下方的"立即更新"按钮,即可将表中的数据展示出来。 -![tableau-workbook](./tableau/tableau-data.jpg) +![tableau-workbook](./tableau/tableau-data.webp) **第 3 步**,点击窗口下方的"工作表",弹出数据分析窗口, 并展示分析表的所有字段,将字段拖动到行列即可展示出图表。 -![tableau-workbook](./tableau/tableau-analysis.jpg) \ No newline at end of file +![tableau-workbook](./tableau/tableau-analysis.webp) \ No newline at end of file diff --git a/docs/zh/10-third-party/05-bi/13-excel.md b/docs/zh/10-third-party/05-bi/13-excel.md index bfa6b5b832..06281b88f0 100644 --- a/docs/zh/10-third-party/05-bi/13-excel.md +++ b/docs/zh/10-third-party/05-bi/13-excel.md @@ -19,22 +19,22 @@ title: 与 Excel 集成 **第 2 步**,在 Windows 系统环境下启动 Excel,之后选择【数据】->【获取数据】->【自其他源】->【从ODBC】。 -![excel-odbc](./excel/odbc-menu.jpg) +![excel-odbc](./excel/odbc-menu.webp) **第 3 步**,在弹出窗口的【数据源名称(DSN)】下拉列表中选择需要连接的数据源后,点击【确定】按钮。 -![excel-odbc](./excel/odbc-select.jpg) +![excel-odbc](./excel/odbc-select.webp) **第 4 步**,输入 TDengine 的用户名密码。 -![excel-odbc](./excel/odbc-config.jpg) +![excel-odbc](./excel/odbc-config.webp) **第 5 步**,在弹出的【导航器】对话框中,选择要加载的库表, 并点击【加载】完成数据加载。 -![excel-odbc](./excel/odbc-load.jpg) +![excel-odbc](./excel/odbc-load.webp) ## 数据分析 选中导入的数据,在【插入】选项卡中选择柱状图,并且在右侧的【数据透视图】中配置数据字段。 -![excel-odbc](./excel/odbc-data.jpg) +![excel-odbc](./excel/odbc-data.webp) diff --git a/docs/zh/10-third-party/05-bi/14-finebi.md b/docs/zh/10-third-party/05-bi/14-finebi.md new file mode 100644 index 0000000000..5ffa6e76a7 --- /dev/null +++ b/docs/zh/10-third-party/05-bi/14-finebi.md @@ -0,0 +1,83 @@ +--- +sidebar_label: FineBI +title: 与 FineBI 集成 +--- + +帆软是一家专注于商业智能与数据分析领域的科技企业,凭借自主研发的 FineBI 和 FineReport 两款核心产品在行业内占据重要地位。帆软的 BI 工具广泛应用于各类企业,帮助用户实现数据的可视化分析、报表生成和数据决策支持。 + +通过使用 `TDengine Java connector` 连接器,FineBI 可以快速访问 TDengine 的数据。用户可以在 FineBI 中直接连接 TDengine 数据库,获取时序数据进行分析并制作可视化报表,整个过程不需要任何代码编写过程。 + +## 前置条件 + +准备以下环境: + +- TDengine 3.3.4.0 以上版本集群已部署并正常运行(企业及社区版均可)。 +- taosAdapter 能够正常运行,详细参考 [taosAdapter 参考手册](../../../reference/components/taosadapter)。 +- FineBI 安装(如未安装,请下载并安装 [FineBI 下载](https://www.finebi.com/product/download))。 +- 下载 `fine_conf_entity` 插件用于支持允许添加JDBC驱动, [下载地址](https://market.fanruan.com/plugin/1052a471-0239-4cd8-b832-045d53182c5d)。 +- 安装 JDBC 驱动。从 `maven.org` 下载 `TDengine JDBC` 连接器文件 `taos-jdbcdriver-3.4.0-dist.jar` 或以上版本。 + +## 配置数据源 + +**第 1 步**,在 FineBI 服务端 `db.script` 配置文件中,找到 `SystemConfig.driverUpload` 配置项并将其修改为 `true`。 + +- Windows 系统:配置文件路径是安装目录下 `webapps/webroot/WEB-INF/embed/finedb/db.script`。 +- Liunx/Mac 系统:配置文件路径是 `/usr/local/FineBI6.1/webapps/webroot/WEB-INF/embed/finedb/db.script`。 + +**第 2 步**,启动 FineBI 服务,在浏览器中输入 `http://ip:37799/webroot/decision`, 其中 ip 是 FineBI 服务端 ip 地址。 + +**第 3 步**, 打开 FineBI Web 页面登录后,点击【管理系统】->【插件管理】,在右侧的【应用商城】中点击【从本地安装】选择已下载的 `fine_conf_entity` 插件进行安装。 + +![finebi-workbook](./finebi/plugin.webp) + +**第 4 步**,点击【管理系统】->【数据连接】->【数据连接管理】,在右侧页面中点击【驱动管理】按钮打开配置页面,点击【新建驱动】按钮并在弹出窗口中输入名称(比如 `tdengine-websocket`),进行 JDBC 驱动配置。 + +![finebi-workbook](./finebi/connect-manage.webp) + +**第 5 步**,在驱动配置页面中点击【上传文件】按钮,选择已下载的 `TDengine Java Connector`(比如 `taos-jdbcdriver-3.4.0-dist.jar`)进行上传,上传完成后在【驱动】的下拉列表中选择 `com.taosdata.jdbc.ws.WebSocketDriver`,并点击【保存】。 + +![finebi-workbook](./finebi/new-driver.webp) + +**第 6 步**,在 “数据连接管理” 页面中,点击【新建数据连接】按钮,随后点击 “其他” ,在右侧页面中点击 “其他JDBC” 进行连接配置。 + +![finebi-workbook](./finebi/jdbc-connect.webp) + +**第 7 步**,在配置页面,先输入数据连接名称,接着在【驱动】选项中选择 “自定义”,并从下拉列表里选取已配置的驱动(例如 `com.taosdata.jdbc.ws.WebSocketDriver (tdengine-websocket)`),之后配置 “数据连接 URL”(例如 `jdbc:TAOS-WS://localhost:6041/power?user=root&password=taosdata&fineBIDialect=mysql`)。设置完成后,点击右上角的【测试连接】进行连接测试,验证成功后点击【保存】即可完成配置。 + +:::tip +`fineBIDialect=mysql` 设置的含义是采用 MySQL 数据库的 SQL 方言规则。简单来说,就是告诉 FineBI 按照 MySQL 数据库处理 SQL 语句的特定方式来解析和执行相关的查询与操作。 +::: + +![finebi-workbook](./finebi/jdbc-config.webp) + +## 数据分析 + +### 数据准备 + +**第 1 步**,点击【公共数据】在右侧页面中点击【新建文件夹】即可创建一个文件夹(比如 `TDengine`), 接着在文件夹的右侧点击【+】按钮,可创建 “数据库表” 数据集或 “SQL数据集”。 + +![finebi-workbook](./finebi/common.webp) + +**第 2 步**,点击 “数据库表”,打开数据库选表页面,在左侧 “数据连接” 中选择已创建的连接,则在右侧会显示当前连接的数据库中的所有表,选择需要加载的表(比如 `meters`),点击【确定】即可显示 `meters` 表中的数据。 + +![finebi-workbook](./finebi/select-table.webp) + +![finebi-workbook](./finebi/table-data.webp) + +**第 3 步**,点击 “SQL数据集”,打开 SQL 数据集的配置页面,首先输入表名(用于在 FineBI 页面显示),接着在 “数据来自数据连接” 下拉列表中选择已创建的连接, 之后输入 SQL 语句并点击预览即可看到查询结果,最后点击【确定】SQL 数据集即可创建成功。 + +![finebi-workbook](./finebi/sql-data-config.webp) + +### 智能电表样例 + +**第 1 步**,点击【我的分析】在右侧页面中点击【新建文件夹】即可创建一个文件夹(比如 `TDengine),` 接着在文件夹的右侧点击【+】按钮,可创建 “分析主题”。 + +![finebi-workbook](./finebi/analysis-object.webp) + +**第 2 步**,在分析主题页面选择数据集(比如 `meters`)后点击【确定】按钮,即可完成数据集关联。 + +![finebi-workbook](./finebi/load-data.webp) + +**第 3 步**,点击分析主题页面下方的【组件】标签,打开图表配置页面, 拖动字段到横轴或纵轴即可展示出图表。 + +![finebi-workbook](./finebi/analysis-chart.webp) diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-config.jpg b/docs/zh/10-third-party/05-bi/excel/odbc-config.jpg deleted file mode 100644 index 58d3395e1b..0000000000 Binary files a/docs/zh/10-third-party/05-bi/excel/odbc-config.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-config.webp b/docs/zh/10-third-party/05-bi/excel/odbc-config.webp new file mode 100644 index 0000000000..5b22e7279a Binary files /dev/null and b/docs/zh/10-third-party/05-bi/excel/odbc-config.webp differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-data.jpg b/docs/zh/10-third-party/05-bi/excel/odbc-data.jpg deleted file mode 100644 index abe54bba2f..0000000000 Binary files a/docs/zh/10-third-party/05-bi/excel/odbc-data.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-data.webp b/docs/zh/10-third-party/05-bi/excel/odbc-data.webp new file mode 100644 index 0000000000..4ce26abc82 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/excel/odbc-data.webp differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-load.jpg b/docs/zh/10-third-party/05-bi/excel/odbc-load.jpg deleted file mode 100644 index 87d5958d35..0000000000 Binary files a/docs/zh/10-third-party/05-bi/excel/odbc-load.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-load.webp b/docs/zh/10-third-party/05-bi/excel/odbc-load.webp new file mode 100644 index 0000000000..822cb9ea74 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/excel/odbc-load.webp differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-menu.jpg b/docs/zh/10-third-party/05-bi/excel/odbc-menu.jpg deleted file mode 100644 index eed00a8a75..0000000000 Binary files a/docs/zh/10-third-party/05-bi/excel/odbc-menu.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-menu.webp b/docs/zh/10-third-party/05-bi/excel/odbc-menu.webp new file mode 100644 index 0000000000..3d894ed58e Binary files /dev/null and b/docs/zh/10-third-party/05-bi/excel/odbc-menu.webp differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-select.jpg b/docs/zh/10-third-party/05-bi/excel/odbc-select.jpg deleted file mode 100644 index a6b66f4ea8..0000000000 Binary files a/docs/zh/10-third-party/05-bi/excel/odbc-select.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/excel/odbc-select.webp b/docs/zh/10-third-party/05-bi/excel/odbc-select.webp new file mode 100644 index 0000000000..0cd3a1e90b Binary files /dev/null and b/docs/zh/10-third-party/05-bi/excel/odbc-select.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/analysis-chart.webp b/docs/zh/10-third-party/05-bi/finebi/analysis-chart.webp new file mode 100644 index 0000000000..1ff91e5e34 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/analysis-chart.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/analysis-object.webp b/docs/zh/10-third-party/05-bi/finebi/analysis-object.webp new file mode 100644 index 0000000000..4248631ecd Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/analysis-object.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/common.webp b/docs/zh/10-third-party/05-bi/finebi/common.webp new file mode 100644 index 0000000000..29ab3b2de6 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/common.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/connect-manage.webp b/docs/zh/10-third-party/05-bi/finebi/connect-manage.webp new file mode 100644 index 0000000000..556138f019 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/connect-manage.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/jdbc-config.webp b/docs/zh/10-third-party/05-bi/finebi/jdbc-config.webp new file mode 100644 index 0000000000..fc68a281d0 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/jdbc-config.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/jdbc-connect.webp b/docs/zh/10-third-party/05-bi/finebi/jdbc-connect.webp new file mode 100644 index 0000000000..e68eda5013 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/jdbc-connect.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/load-data.webp b/docs/zh/10-third-party/05-bi/finebi/load-data.webp new file mode 100644 index 0000000000..6801703b91 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/load-data.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/new-driver.webp b/docs/zh/10-third-party/05-bi/finebi/new-driver.webp new file mode 100644 index 0000000000..f83d5a5164 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/new-driver.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/plugin.webp b/docs/zh/10-third-party/05-bi/finebi/plugin.webp new file mode 100644 index 0000000000..80c947a544 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/plugin.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/select-table.webp b/docs/zh/10-third-party/05-bi/finebi/select-table.webp new file mode 100644 index 0000000000..d95380472e Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/select-table.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/sql-data-config.webp b/docs/zh/10-third-party/05-bi/finebi/sql-data-config.webp new file mode 100644 index 0000000000..90ac4729a6 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/sql-data-config.webp differ diff --git a/docs/zh/10-third-party/05-bi/finebi/table-data.webp b/docs/zh/10-third-party/05-bi/finebi/table-data.webp new file mode 100644 index 0000000000..14bee7b6bc Binary files /dev/null and b/docs/zh/10-third-party/05-bi/finebi/table-data.webp differ diff --git a/docs/zh/10-third-party/05-bi/tableau/tableau-analysis.jpg b/docs/zh/10-third-party/05-bi/tableau/tableau-analysis.jpg deleted file mode 100644 index 7408804a54..0000000000 Binary files a/docs/zh/10-third-party/05-bi/tableau/tableau-analysis.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/tableau/tableau-analysis.webp b/docs/zh/10-third-party/05-bi/tableau/tableau-analysis.webp new file mode 100644 index 0000000000..a1880e702d Binary files /dev/null and b/docs/zh/10-third-party/05-bi/tableau/tableau-analysis.webp differ diff --git a/docs/zh/10-third-party/05-bi/tableau/tableau-data.jpg b/docs/zh/10-third-party/05-bi/tableau/tableau-data.jpg deleted file mode 100644 index fe6b8a38e4..0000000000 Binary files a/docs/zh/10-third-party/05-bi/tableau/tableau-data.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/tableau/tableau-data.webp b/docs/zh/10-third-party/05-bi/tableau/tableau-data.webp new file mode 100644 index 0000000000..7a3d817354 Binary files /dev/null and b/docs/zh/10-third-party/05-bi/tableau/tableau-data.webp differ diff --git a/docs/zh/10-third-party/05-bi/tableau/tableau-odbc.jpg b/docs/zh/10-third-party/05-bi/tableau/tableau-odbc.jpg deleted file mode 100644 index e02ba8ee53..0000000000 Binary files a/docs/zh/10-third-party/05-bi/tableau/tableau-odbc.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/tableau/tableau-odbc.webp b/docs/zh/10-third-party/05-bi/tableau/tableau-odbc.webp new file mode 100644 index 0000000000..a7ff63f30d Binary files /dev/null and b/docs/zh/10-third-party/05-bi/tableau/tableau-odbc.webp differ diff --git a/docs/zh/10-third-party/05-bi/tableau/tableau-table.jpg b/docs/zh/10-third-party/05-bi/tableau/tableau-table.jpg deleted file mode 100644 index 75dd059bf9..0000000000 Binary files a/docs/zh/10-third-party/05-bi/tableau/tableau-table.jpg and /dev/null differ diff --git a/docs/zh/10-third-party/05-bi/tableau/tableau-table.webp b/docs/zh/10-third-party/05-bi/tableau/tableau-table.webp new file mode 100644 index 0000000000..6c775329dc Binary files /dev/null and b/docs/zh/10-third-party/05-bi/tableau/tableau-table.webp differ diff --git a/docs/zh/14-reference/02-tools/10-taosbenchmark.md b/docs/zh/14-reference/02-tools/10-taosbenchmark.md index 1f97b0702a..f22596246f 100644 --- a/docs/zh/14-reference/02-tools/10-taosbenchmark.md +++ b/docs/zh/14-reference/02-tools/10-taosbenchmark.md @@ -280,27 +280,45 @@ taosBenchmark -f ### 查询配置参数 查询场景下 `filetype` 必须设置为 `query`。 + +`query_mode` 查询连接方式,取值为: + - “taosc”: 通过 Native 连接方式查询。 + - “rest” : 通过 restful 连接方式查询。 + `query_times` 指定运行查询的次数,数值类型。 -查询场景可以通过设置 `kill_slow_query_threshold` 和 `kill_slow_query_interval` 参数来控制杀掉慢查询语句的执行,threshold 控制如果 exec_usec 超过指定时间的查询将被 taosBenchmark 杀掉,单位为秒。 -interval 控制休眠时间,避免持续查询慢查询消耗 CPU,单位为秒。 -其它通用参数详见 [通用配置参数](#通用配置参数) +其它通用参数详见 [通用配置参数](#通用配置参数)。 #### 执行指定查询语句 查询指定表(可以指定超级表、子表或普通表)的配置参数在 `specified_table_query` 中设置。 -- **mixed_query**:查询模式 - “yes”:`混合查询` - "no"(默认值):`普通查询` - `普通查询`:`sqls` 中每个 sql 启动 `threads` 个线程查询此 sql,执行完 `query_times` 次查询后退出,执行此 sql 的所有线程都完成后进入下一个 sql + +- **mixed_query**:混合查询开关。 + “yes”: 开启 “混合查询”。 + “no” : 关闭 “混合查询” ,即 “普通查询”。 + + - 普通查询: + + `sqls` 中每个 sql 启动 `threads` 个线程查询此 sql, 执行完 `query_times` 次查询后退出,执行此 sql 的所有线程都完成后进入下一个 sql `查询总次数` = `sqls` 个数 * `query_times` * `threads` - `混合查询`:`sqls` 中所有 sql 分成 `threads` 个组,每个线程执行一组,每个 sql 都需执行 `query_times` 次查询 + - 混合查询: + + `sqls` 中所有 sql 分成 `threads` 个组,每个线程执行一组, 每个 sql 都需执行 `query_times` 次查询 `查询总次数` = `sqls` 个数 * `query_times` +- **batch_query**:批查询功开关。 + 取值范围 “yes” 表示开启,"no" 不开启,其它值报错。 + 批查询是指 `sqls` 中所有 sql 分成 `threads` 个组,每个线程执行一组,每个 sql 只执行一次查询后退出,主线程等待所有线程都执行完,再判断是否设置有 `query_interval` 参数,如果有需要 sleep 指定时间,再启动各线程组重复前面的过程,直到查询次数耗尽为止。 + 功能限制条件: + - 只支持 `mixed_query` 为 "yes" 的场景。 + - 不支持 restful 查询,即 `query_mode` 不能为 "rest"。 + - **query_interval**:查询时间间隔,单位:millisecond,默认值为 0。 + "batch_query" 开关打开时,表示是每批查询完间隔时间;关闭时,表示每个 sql 查询完间隔时间 + 如果执行查询的时间超过间隔时间,那么将不再等待,如果执行查询的时间不足间隔时间,需等待补足间隔时间 - **threads**:执行查询 SQL 的线程数,默认值为 1。 diff --git a/docs/zh/14-reference/09-error-code.md b/docs/zh/14-reference/09-error-code.md index 353ce16ed4..87809022dd 100644 --- a/docs/zh/14-reference/09-error-code.md +++ b/docs/zh/14-reference/09-error-code.md @@ -479,8 +479,8 @@ description: TDengine 服务端的错误码列表和详细说明 | 0x80002688 | Cannot use 'year' or 'month' as true_for duration | 不能使用 n(月), y(年) 作为 true_for 的时间单位 | 检查并修正 SQL 语句 | | 0x80002689 | Invalid using cols function | cols 函数使用错误 | 检查并修正 SQL 语句 | | 0x8000268A | Cols function's first param must be a select function that output a single row | cols 函数第一个参数应该为选择函数 | 检查并修正 SQL 语句 | -| 0x8000268B | Invalid using cols function with multiple output columns | 多列输出的 cols 函数使用错误 | 检查并修正 SQL 语句 | -| 0x8000268C | Invalid using alias for cols function | cols 函数输出列重命名错误 | 检查并修正 SQL 语句 | +| 0x8000268B | Invalid using alias for cols function | cols 函数输出列重命名错误 | 检查并修正 SQL 语句 | +| 0x8000268C | Join primary key col must be timestmap type | 关联查询主键列等值条件类型错误 | 检查并修正 SQL 语句 | | 0x800026FF | Parser internal error | 解析器内部错误 | 保留现场和日志,github上报issue | | 0x80002700 | Planner internal error | 计划期内部错误 | 保留现场和日志,github上报issue | | 0x80002701 | Expect ts equal | JOIN 条件校验失败 | 保留现场和日志,github上报issue | diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 9ed565090e..c79a7c4870 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -155,6 +155,13 @@ typedef struct SJoinLogicNode { bool grpJoin; bool hashJoinHint; bool batchScanHint; + + // FOR CONST JOIN + bool noPrimKeyEqCond; + bool leftConstPrimGot; + bool rightConstPrimGot; + bool leftNoOrderedSubQuery; + bool rightNoOrderedSubQuery; // FOR HASH JOIN int32_t timeRangeTarget; // table onCond filter diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 7191b4ef4a..47906e301f 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -57,10 +57,13 @@ typedef struct SExprNode { SDataType resType; char aliasName[TSDB_COL_NAME_LEN]; char userAlias[TSDB_COL_NAME_LEN]; + char srcTable[TSDB_TABLE_NAME_LEN]; SArray* pAssociation; bool asAlias; bool asParam; bool asPosition; + bool joinSrc; + //bool constValue; int32_t projIdx; int32_t relatedTo; int32_t bindExprID; @@ -209,6 +212,7 @@ typedef struct STableNode { char tableAlias[TSDB_TABLE_NAME_LEN]; uint8_t precision; bool singleTable; + bool inJoin; } STableNode; struct STableMeta; @@ -291,6 +295,10 @@ typedef struct SJoinTableNode { SNode* addPrimCond; bool hasSubQuery; bool isLowLevelJoin; + bool leftNoOrderedSubQuery; + bool rightNoOrderedSubQuery; + //bool condAlwaysTrue; + //bool condAlwaysFalse; SNode* pLeft; SNode* pRight; SNode* pOnCond; @@ -706,6 +714,8 @@ int32_t mergeJoinConds(SNode** ppDst, SNode** ppSrc); void rewriteExprAliasName(SExprNode* pNode, int64_t num); bool isRelatedToOtherExpr(SExprNode* pExpr); +bool nodesContainsColumn(SNode* pNode); +int32_t nodesMergeNode(SNode** pCond, SNode** pAdditionalCond); #ifdef __cplusplus } diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index d1dda544ae..3a1a14023c 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -33,6 +33,7 @@ pNode will be freed in API; */ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes); int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes); +int32_t scalarConvertOpValueNodeTs(SOperatorNode *node); /* pDst need to freed in caller diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 29e95251e9..66031f284a 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -913,8 +913,8 @@ int32_t taosGetErrSize(); #define TSDB_CODE_PAR_TRUE_FOR_UNIT TAOS_DEF_ERROR_CODE(0, 0x2688) #define TSDB_CODE_PAR_INVALID_COLS_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2689) #define TSDB_CODE_PAR_INVALID_COLS_SELECTFUNC TAOS_DEF_ERROR_CODE(0, 0x268A) -#define TSDB_CODE_INVALID_MULITI_COLS_FUNC TAOS_DEF_ERROR_CODE(0, 0x268B) -#define TSDB_CODE_INVALID_COLS_ALIAS TAOS_DEF_ERROR_CODE(0, 0x268C) +#define TSDB_CODE_PAR_INVALID_COLS_ALIAS TAOS_DEF_ERROR_CODE(0, 0x268B) +#define TSDB_CODE_PAR_PRIM_KEY_MUST_BE_TS TAOS_DEF_ERROR_CODE(0, 0x268C) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 51476757e5..bd7da3f4d6 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -170,6 +170,8 @@ static void dmSetSignalHandle() { #endif } +extern bool generateNewMeta; + static int32_t dmParseArgs(int32_t argc, char const *argv[]) { global.startTime = taosGetTimestampMs(); @@ -208,6 +210,8 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) { global.dumpSdb = true; } else if (strcmp(argv[i], "-dTxn") == 0) { global.deleteTrans = true; + } else if (strcmp(argv[i], "-r") == 0) { + generateNewMeta = true; } else if (strcmp(argv[i], "-E") == 0) { if (i < argc - 1) { if (strlen(argv[++i]) >= PATH_MAX) { diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index 15debf07f8..e0d8c66f0c 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -257,22 +257,185 @@ void vnodeGetMetaPath(SVnode *pVnode, const char *metaDir, char *fname) { snprintf(fname + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, metaDir); } +bool generateNewMeta = false; + +static int32_t metaGenerateNewMeta(SMeta **ppMeta) { + SMeta *pNewMeta = NULL; + SMeta *pMeta = *ppMeta; + SVnode *pVnode = pMeta->pVnode; + + metaInfo("vgId:%d start to generate new meta", TD_VID(pMeta->pVnode)); + + // Open a new meta for organization + int32_t code = metaOpenImpl(pMeta->pVnode, &pNewMeta, VNODE_META_TMP_DIR, false); + if (code) { + return code; + } + + code = metaBegin(pNewMeta, META_BEGIN_HEAP_NIL); + if (code) { + return code; + } + + // i == 0, scan super table + // i == 1, scan normal table and child table + for (int i = 0; i < 2; i++) { + TBC *uidCursor = NULL; + int32_t counter = 0; + + code = tdbTbcOpen(pMeta->pUidIdx, &uidCursor, NULL); + if (code) { + metaError("vgId:%d failed to open uid index cursor, reason:%s", TD_VID(pVnode), tstrerror(code)); + return code; + } + + code = tdbTbcMoveToFirst(uidCursor); + if (code) { + metaError("vgId:%d failed to move to first, reason:%s", TD_VID(pVnode), tstrerror(code)); + tdbTbcClose(uidCursor); + return code; + } + + for (;;) { + const void *pKey; + int kLen; + const void *pVal; + int vLen; + + if (tdbTbcGet(uidCursor, &pKey, &kLen, &pVal, &vLen) < 0) { + break; + } + + tb_uid_t uid = *(tb_uid_t *)pKey; + SUidIdxVal *pUidIdxVal = (SUidIdxVal *)pVal; + if ((i == 0 && (pUidIdxVal->suid && pUidIdxVal->suid == uid)) // super table + || (i == 1 && (pUidIdxVal->suid == 0 || pUidIdxVal->suid != uid)) // normal table and child table + ) { + counter++; + if (i == 0) { + metaInfo("vgId:%d counter:%d new meta handle %s table uid:%" PRId64, TD_VID(pVnode), counter, "super", uid); + } else { + metaInfo("vgId:%d counter:%d new meta handle %s table uid:%" PRId64, TD_VID(pVnode), counter, + pUidIdxVal->suid == 0 ? "normal" : "child", uid); + } + + // fetch table entry + void *value = NULL; + int valueSize = 0; + if (tdbTbGet(pMeta->pTbDb, + &(STbDbKey){ + .version = pUidIdxVal->version, + .uid = uid, + }, + sizeof(uid), &value, &valueSize) == 0) { + SDecoder dc = {0}; + SMetaEntry me = {0}; + tDecoderInit(&dc, value, valueSize); + if (metaDecodeEntry(&dc, &me) == 0) { + if (me.type == TSDB_CHILD_TABLE && + tdbTbGet(pMeta->pUidIdx, &me.ctbEntry.suid, sizeof(me.ctbEntry.suid), NULL, NULL) != 0) { + metaError("vgId:%d failed to get super table uid:%" PRId64 " for child table uid:%" PRId64, + TD_VID(pVnode), me.ctbEntry.suid, uid); + } else if (metaHandleEntry2(pNewMeta, &me) != 0) { + metaError("vgId:%d failed to handle entry, uid:%" PRId64, TD_VID(pVnode), uid); + } + } + tDecoderClear(&dc); + } + tdbFree(value); + } + + code = tdbTbcMoveToNext(uidCursor); + if (code) { + metaError("vgId:%d failed to move to next, reason:%s", TD_VID(pVnode), tstrerror(code)); + return code; + } + } + + tdbTbcClose(uidCursor); + } + + code = metaCommit(pNewMeta, pNewMeta->txn); + if (code) { + metaError("vgId:%d failed to commit, reason:%s", TD_VID(pVnode), tstrerror(code)); + return code; + } + + code = metaFinishCommit(pNewMeta, pNewMeta->txn); + if (code) { + metaError("vgId:%d failed to finish commit, reason:%s", TD_VID(pVnode), tstrerror(code)); + return code; + } + + if ((code = metaBegin(pNewMeta, META_BEGIN_HEAP_NIL)) != 0) { + metaError("vgId:%d failed to begin new meta, reason:%s", TD_VID(pVnode), tstrerror(code)); + } + metaClose(&pNewMeta); + metaInfo("vgId:%d finish to generate new meta", TD_VID(pVnode)); + + // Commit the new metadata + char metaDir[TSDB_FILENAME_LEN] = {0}; + char metaTempDir[TSDB_FILENAME_LEN] = {0}; + char metaBackupDir[TSDB_FILENAME_LEN] = {0}; + + vnodeGetMetaPath(pVnode, metaDir, VNODE_META_DIR); + vnodeGetMetaPath(pVnode, metaTempDir, VNODE_META_TMP_DIR); + vnodeGetMetaPath(pVnode, metaBackupDir, VNODE_META_BACKUP_DIR); + + metaClose(ppMeta); + if (taosRenameFile(metaDir, metaBackupDir) != 0) { + metaError("vgId:%d failed to rename old meta to backup, reason:%s", TD_VID(pVnode), tstrerror(terrno)); + return terrno; + } + + // rename the new meta to old meta + if (taosRenameFile(metaTempDir, metaDir) != 0) { + metaError("vgId:%d failed to rename new meta to old meta, reason:%s", TD_VID(pVnode), tstrerror(terrno)); + return terrno; + } + + code = metaOpenImpl(pVnode, ppMeta, VNODE_META_DIR, false); + if (code) { + metaError("vgId:%d failed to open new meta, reason:%s", TD_VID(pVnode), tstrerror(code)); + return code; + } + + metaInfo("vgId:%d successfully opened new meta", TD_VID(pVnode)); + + return 0; +} + int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) { int32_t code = TSDB_CODE_SUCCESS; char metaDir[TSDB_FILENAME_LEN] = {0}; + char metaBackupDir[TSDB_FILENAME_LEN] = {0}; char metaTempDir[TSDB_FILENAME_LEN] = {0}; vnodeGetMetaPath(pVnode, VNODE_META_DIR, metaDir); + vnodeGetMetaPath(pVnode, VNODE_META_BACKUP_DIR, metaBackupDir); vnodeGetMetaPath(pVnode, VNODE_META_TMP_DIR, metaTempDir); - // Check file states - if (!taosCheckExistFile(metaDir) && taosCheckExistFile(metaTempDir)) { + bool metaExists = taosCheckExistFile(metaDir); + bool metaBackupExists = taosCheckExistFile(metaBackupDir); + bool metaTempExists = taosCheckExistFile(metaTempDir); + + if ((!metaBackupExists && !metaExists && metaTempExists) // + || (metaBackupExists && !metaExists && !metaTempExists) // + || (metaBackupExists && metaExists && metaTempExists) // + ) { + metaError("vgId:%d, invalid meta state, please check!", TD_VID(pVnode)); + return TSDB_CODE_FAILED; + } else if (!metaBackupExists && metaExists && metaTempExists) { + taosRemoveDir(metaTempDir); + } else if (metaBackupExists && !metaExists && metaTempExists) { code = taosRenameFile(metaTempDir, metaDir); if (code) { - metaError("vgId:%d, %s failed at %s:%d since %s: rename %s to %s failed", TD_VID(pVnode), __func__, __FILE__, - __LINE__, tstrerror(code), metaTempDir, metaDir); + metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code)); return code; } + taosRemoveDir(metaBackupDir); + } else if (metaBackupExists && metaExists && !metaTempExists) { + taosRemoveDir(metaBackupDir); } // Do open meta @@ -282,6 +445,14 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) { return code; } + if (generateNewMeta) { + code = metaGenerateNewMeta(ppMeta); + if (code) { + metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code)); + return code; + } + } + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/executor/inc/mergejoin.h b/source/libs/executor/inc/mergejoin.h index ceb0037b8d..52eb264639 100755 --- a/source/libs/executor/inc/mergejoin.h +++ b/source/libs/executor/inc/mergejoin.h @@ -40,6 +40,11 @@ typedef enum EJoinTableType { E_JOIN_TB_PROBE } EJoinTableType; +typedef enum EPrimExprType { + E_PRIM_TIMETRUNCATE = 1, + E_PRIM_VALUE +} EPrimExprType; + #define MJOIN_TBTYPE(_type) (E_JOIN_TB_BUILD == (_type) ? "BUILD" : "PROBE") #define IS_FULL_OUTER_JOIN(_jtype, _stype) ((_jtype) == JOIN_TYPE_FULL && (_stype) == JOIN_STYPE_OUTER) @@ -87,9 +92,15 @@ typedef struct SMJoinNMatchCtx { // for now timetruncate only typedef struct SMJoinPrimExprCtx { - int64_t truncateUnit; - int64_t timezoneUnit; - int32_t targetSlotId; + EPrimExprType type; + + // FOR TIMETRUNCATE + int64_t truncateUnit; + int64_t timezoneUnit; + int32_t targetSlotId; + + // FOR VALUE + int64_t constTs; } SMJoinPrimExprCtx; typedef struct SMJoinTableCtx { @@ -337,6 +348,8 @@ typedef struct SMJoinOperatorInfo { #define PROBE_TS_NREACH(_asc, _pts, _bts) (((_asc) && (_pts) > (_bts)) || (!(_asc) && (_pts) < (_bts))) #define MJOIN_BUILD_BLK_OOR(_asc, _pts, _pidx, _bts, _bnum) (((_asc) && (*((int64_t*)(_pts) + (_pidx)) > *((int64_t*)(_bts) + (_bnum) - 1))) || ((!(_asc)) && (*((int64_t*)(_pts) + (_pidx)) < *((int64_t*)(_bts) + (_bnum) - 1)))) +#define MJOIN_PRIM_EXPR_GOT(_pJoin) ((_pJoin)->probe->primCtx.type > 0 || (_pJoin)->build->primCtx.type > 0) + #define GRP_REMAIN_ROWS(_grp) ((_grp)->endIdx - (_grp)->readIdx + 1) #define GRP_DONE(_grp) ((_grp)->readIdx > (_grp)->endIdx) diff --git a/source/libs/executor/src/mergejoinoperator.c b/source/libs/executor/src/mergejoinoperator.c index 3edef48ed1..d7f7f0d085 100644 --- a/source/libs/executor/src/mergejoinoperator.c +++ b/source/libs/executor/src/mergejoinoperator.c @@ -894,21 +894,7 @@ static int32_t mJoinInitFinColsInfo(SMJoinTableCtx* pTable, SNodeList* pList) { return TSDB_CODE_SUCCESS; } -static int32_t mJoinInitPrimExprCtx(SNode* pNode, SMJoinPrimExprCtx* pCtx, SMJoinTableCtx* pTable) { - if (NULL == pNode) { - pCtx->targetSlotId = pTable->primCol->srcSlot; - return TSDB_CODE_SUCCESS; - } - - if (QUERY_NODE_TARGET != nodeType(pNode)) { - return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; - } - - STargetNode* pTarget = (STargetNode*)pNode; - if (QUERY_NODE_FUNCTION != nodeType(pTarget->pExpr)) { - return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; - } - +static int32_t mJoinInitFuncPrimExprCtx(SMJoinPrimExprCtx* pCtx, STargetNode* pTarget) { SFunctionNode* pFunc = (SFunctionNode*)pTarget->pExpr; if (FUNCTION_TYPE_TIMETRUNCATE != pFunc->funcType) { return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; @@ -939,6 +925,47 @@ static int32_t mJoinInitPrimExprCtx(SNode* pNode, SMJoinPrimExprCtx* pCtx, SMJoi pCtx->timezoneUnit = offsetFromTz(varDataVal(pTimeZone->datum.p), TSDB_TICK_PER_SECOND(pFunc->node.resType.precision)); } + pCtx->type = E_PRIM_TIMETRUNCATE; + + return TSDB_CODE_SUCCESS; +} + +static int32_t mJoinInitValPrimExprCtx(SMJoinPrimExprCtx* pCtx, STargetNode* pTarget) { + SValueNode* pVal = (SValueNode*)pTarget->pExpr; + if (TSDB_DATA_TYPE_TIMESTAMP != pVal->node.resType.type) { + return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; + } + + pCtx->constTs = pVal->datum.i; + pCtx->type = E_PRIM_VALUE; + + return TSDB_CODE_SUCCESS; +} + + +static int32_t mJoinInitPrimExprCtx(SNode* pNode, SMJoinPrimExprCtx* pCtx, SMJoinTableCtx* pTable) { + if (NULL == pNode) { + pCtx->targetSlotId = pTable->primCol->srcSlot; + return TSDB_CODE_SUCCESS; + } + + if (QUERY_NODE_TARGET != nodeType(pNode)) { + qError("primary expr node is not target, type:%d", nodeType(pNode)); + return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; + } + + STargetNode* pTarget = (STargetNode*)pNode; + if (QUERY_NODE_FUNCTION != nodeType(pTarget->pExpr) && QUERY_NODE_VALUE != nodeType(pTarget->pExpr)) { + qError("Invalid primary expr node type:%d", nodeType(pTarget->pExpr)); + return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; + } + + if (QUERY_NODE_FUNCTION == nodeType(pTarget->pExpr)) { + MJ_ERR_RET(mJoinInitFuncPrimExprCtx(pCtx, pTarget)); + } else if (QUERY_NODE_VALUE == nodeType(pTarget->pExpr)) { + MJ_ERR_RET(mJoinInitValPrimExprCtx(pCtx, pTarget)); + } + pCtx->targetSlotId = pTarget->slotId; return TSDB_CODE_SUCCESS; @@ -1045,25 +1072,36 @@ int32_t mJoinLaunchPrimExpr(SSDataBlock* pBlock, SMJoinTableCtx* pTable) { return TSDB_CODE_SUCCESS; } - SMJoinPrimExprCtx* pCtx = &pTable->primCtx; - SColumnInfoData* pPrimIn = taosArrayGet(pBlock->pDataBlock, pTable->primCol->srcSlot); - if (NULL == pPrimIn) { - return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; - } - SColumnInfoData* pPrimOut = taosArrayGet(pBlock->pDataBlock, pTable->primCtx.targetSlotId); if (NULL == pPrimOut) { return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; } - if (0 != pCtx->timezoneUnit) { - for (int32_t i = 0; i < pBlock->info.rows; ++i) { - ((int64_t*)pPrimOut->pData)[i] = ((int64_t*)pPrimIn->pData)[i] - (((int64_t*)pPrimIn->pData)[i] + pCtx->timezoneUnit) % pCtx->truncateUnit; + SMJoinPrimExprCtx* pCtx = &pTable->primCtx; + switch (pCtx->type) { + case E_PRIM_TIMETRUNCATE: { + SColumnInfoData* pPrimIn = taosArrayGet(pBlock->pDataBlock, pTable->primCol->srcSlot); + if (NULL == pPrimIn) { + return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; + } + + if (0 != pCtx->timezoneUnit) { + for (int32_t i = 0; i < pBlock->info.rows; ++i) { + ((int64_t*)pPrimOut->pData)[i] = ((int64_t*)pPrimIn->pData)[i] - (((int64_t*)pPrimIn->pData)[i] + pCtx->timezoneUnit) % pCtx->truncateUnit; + } + } else { + for (int32_t i = 0; i < pBlock->info.rows; ++i) { + ((int64_t*)pPrimOut->pData)[i] = ((int64_t*)pPrimIn->pData)[i] / pCtx->truncateUnit * pCtx->truncateUnit; + } + } + break; } - } else { - for (int32_t i = 0; i < pBlock->info.rows; ++i) { - ((int64_t*)pPrimOut->pData)[i] = ((int64_t*)pPrimIn->pData)[i] / pCtx->truncateUnit * pCtx->truncateUnit; + case E_PRIM_VALUE: { + MJ_ERR_RET(colDataSetNItems(pPrimOut, 0, (char*)&pCtx->constTs, pBlock->info.rows, false)); + break; } + default: + break; } return TSDB_CODE_SUCCESS; diff --git a/source/libs/executor/src/streamcountwindowoperator.c b/source/libs/executor/src/streamcountwindowoperator.c index 37466aac8d..fb4a350950 100644 --- a/source/libs/executor/src/streamcountwindowoperator.c +++ b/source/libs/executor/src/streamcountwindowoperator.c @@ -57,7 +57,6 @@ void destroyStreamCountAggOperatorInfo(void* param) { } destroyStreamBasicInfo(&pInfo->basic); - cleanupExprSupp(&pInfo->scalarSupp); clearGroupResInfo(&pInfo->groupResInfo); taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index f25f711783..9b9b67879f 100644 --- a/source/libs/executor/src/streameventwindowoperator.c +++ b/source/libs/executor/src/streameventwindowoperator.c @@ -56,7 +56,6 @@ void destroyStreamEventOperatorInfo(void* param) { } destroyStreamBasicInfo(&pInfo->basic); - clearGroupResInfo(&pInfo->groupResInfo); taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); pInfo->pUpdated = NULL; diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index c15a9f9224..5c2bac0bd2 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -2206,7 +2206,6 @@ void destroyStreamSessionAggOperatorInfo(void* param) { } destroyStreamBasicInfo(&pInfo->basic); - cleanupExprSupp(&pInfo->scalarSupp); clearGroupResInfo(&pInfo->groupResInfo); taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); @@ -4445,7 +4444,6 @@ void destroyStreamStateOperatorInfo(void* param) { } destroyStreamBasicInfo(&pInfo->basic); - clearGroupResInfo(&pInfo->groupResInfo); taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos); pInfo->pUpdated = NULL; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index fcb39c4284..1f5155a689 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -102,9 +102,11 @@ static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { COPY_OBJECT_FIELD(resType, sizeof(SDataType)); COPY_CHAR_ARRAY_FIELD(aliasName); COPY_CHAR_ARRAY_FIELD(userAlias); + COPY_CHAR_ARRAY_FIELD(srcTable); COPY_SCALAR_FIELD(asAlias); COPY_SCALAR_FIELD(asParam); COPY_SCALAR_FIELD(asPosition); + COPY_SCALAR_FIELD(joinSrc); COPY_SCALAR_FIELD(projIdx); COPY_SCALAR_FIELD(relatedTo); COPY_SCALAR_FIELD(bindExprID); @@ -242,6 +244,7 @@ static int32_t tableNodeCopy(const STableNode* pSrc, STableNode* pDst) { COPY_CHAR_ARRAY_FIELD(tableAlias); COPY_SCALAR_FIELD(precision); COPY_SCALAR_FIELD(singleTable); + COPY_SCALAR_FIELD(inJoin); return TSDB_CODE_SUCCESS; } @@ -321,6 +324,10 @@ static int32_t joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDs CLONE_NODE_FIELD(addPrimCond); COPY_SCALAR_FIELD(hasSubQuery); COPY_SCALAR_FIELD(isLowLevelJoin); + COPY_SCALAR_FIELD(leftNoOrderedSubQuery); + COPY_SCALAR_FIELD(rightNoOrderedSubQuery); + //COPY_SCALAR_FIELD(condAlwaysTrue); + //COPY_SCALAR_FIELD(condAlwaysFalse); CLONE_NODE_FIELD(pLeft); CLONE_NODE_FIELD(pRight); CLONE_NODE_FIELD(pOnCond); @@ -542,6 +549,11 @@ static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) { COPY_SCALAR_FIELD(grpJoin); COPY_SCALAR_FIELD(hashJoinHint); COPY_SCALAR_FIELD(batchScanHint); + COPY_SCALAR_FIELD(noPrimKeyEqCond); + COPY_SCALAR_FIELD(leftConstPrimGot); + COPY_SCALAR_FIELD(rightConstPrimGot); + COPY_SCALAR_FIELD(leftNoOrderedSubQuery); + COPY_SCALAR_FIELD(rightNoOrderedSubQuery); CLONE_NODE_FIELD(pLeftOnCond); CLONE_NODE_FIELD(pRightOnCond); COPY_SCALAR_FIELD(timeRangeTarget); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 9b7d9e53bf..23f647aa16 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -3280,3 +3280,76 @@ void rewriteExprAliasName(SExprNode* pNode, int64_t num) { bool isRelatedToOtherExpr(SExprNode* pExpr) { return pExpr->relatedTo != 0; } + +typedef struct SContainsColCxt { + bool containsCol; +} SContainsColCxt; + +static EDealRes nodeContainsCol(SNode* pNode, void* pContext) { + SContainsColCxt* pCxt = pContext; + if (QUERY_NODE_COLUMN == nodeType(pNode)) { + pCxt->containsCol = true; + return DEAL_RES_END; + } + + return DEAL_RES_CONTINUE; +} + +bool nodesContainsColumn(SNode* pNode) { + if (NULL == pNode) { + return false; + } + + SContainsColCxt cxt = {0}; + nodesWalkExpr(pNode, nodeContainsCol, &cxt); + + return cxt.containsCol; +} + + + +int32_t mergeNodeToLogic(SNode** pDst, SNode** pSrc) { + SLogicConditionNode* pLogicCond = NULL; + int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond); + if (NULL == pLogicCond) { + return code; + } + pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL; + pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; + pLogicCond->condType = LOGIC_COND_TYPE_AND; + code = nodesListMakeAppend(&pLogicCond->pParameterList, *pSrc); + if (TSDB_CODE_SUCCESS == code) { + *pSrc = NULL; + code = nodesListMakeAppend(&pLogicCond->pParameterList, *pDst); + } + if (TSDB_CODE_SUCCESS == code) { + *pDst = (SNode*)pLogicCond; + } else { + nodesDestroyNode((SNode*)pLogicCond); + } + return code; +} + + +int32_t nodesMergeNode(SNode** pCond, SNode** pAdditionalCond) { + if (NULL == *pCond) { + TSWAP(*pCond, *pAdditionalCond); + return TSDB_CODE_SUCCESS; + } + + int32_t code = TSDB_CODE_SUCCESS; + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCond) && + LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCond)->condType) { + code = nodesListAppend(((SLogicConditionNode*)*pCond)->pParameterList, *pAdditionalCond); + if (TSDB_CODE_SUCCESS == code) { + *pAdditionalCond = NULL; + } + } else { + code = mergeNodeToLogic(pCond, pAdditionalCond); + } + + return code; +} + + + diff --git a/source/libs/parser/inc/parInt.h b/source/libs/parser/inc/parInt.h index 5999ada70f..4b5d106318 100644 --- a/source/libs/parser/inc/parInt.h +++ b/source/libs/parser/inc/parInt.h @@ -42,12 +42,12 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, SSDa int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock); int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock); int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues); -int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinParent); +int32_t translateTable(STranslateContext* pCxt, SNode** pTable, bool inJoin); int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput); void tfreeSParseQueryRes(void* p); #ifdef TD_ENTERPRISE -int32_t translateView(STranslateContext* pCxt, SNode** pTable, SName* pName); +int32_t translateView(STranslateContext* pCxt, SNode** pTable, SName* pName, bool inJoin); int32_t getViewMetaFromMetaCache(STranslateContext* pCxt, SName* pName, SViewMeta** ppViewMeta); #endif #ifdef __cplusplus diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 0f8c8ee034..e787ac4ba2 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -118,6 +118,39 @@ static int32_t calcConstCondition(SCalcConstContext* pCxt, SNode** pNode) { return code; } +static EDealRes rewriteCalcConstValue(SNode** pNode, void* pContext) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; + SCalcConstContext* pCtx = (SCalcConstContext*)pContext; + + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pNode)) { + return DEAL_RES_CONTINUE; + } else if (QUERY_NODE_OPERATOR == nodeType(*pNode)) { + SOperatorNode* pOp = (SOperatorNode*)*pNode; + if (OP_TYPE_EQUAL == pOp->opType && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode*)pOp->pLeft)->resType.type || TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode*)pOp->pRight)->resType.type)) { + code = calcConstNode(&pOp->pLeft); + if (TSDB_CODE_SUCCESS == code) { + code = calcConstNode(&pOp->pRight); + } + + goto _end; + } + } + + if (TSDB_CODE_SUCCESS == code) { + code = calcConstCondition(pCtx, pNode); + } + +_end: + + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + return DEAL_RES_ERROR; + } + + return DEAL_RES_IGNORE_CHILD; +} + static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTable) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pTable)) { @@ -127,13 +160,32 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab } case QUERY_NODE_JOIN_TABLE: { SJoinTableNode* pJoin = (SJoinTableNode*)pTable; + SNode* pCond = NULL; code = rewriteConditionForFromTable(pCxt, pJoin->pLeft); if (TSDB_CODE_SUCCESS == code) { code = rewriteConditionForFromTable(pCxt, pJoin->pRight); } + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { + code = rewriteCondition(pCxt, &pJoin->pOnCond); + } + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { + nodesRewriteExpr(&pJoin->pOnCond, rewriteCalcConstValue, pCxt); + } + +/* + if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { + code = nodesCloneNode(pJoin->pOnCond, &pCond); + } if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pOnCond) { code = calcConstCondition(pCxt, &pJoin->pOnCond); } + if (TSDB_CODE_SUCCESS == code && pJoin->pOnCond && QUERY_NODE_VALUE == nodeType(pJoin->pOnCond)) { + nodesDestroyNode(pJoin->pOnCond); + pJoin->pOnCond = pCond; + pCond = NULL; + } + nodesDestroyNode(pCond); +*/ // todo empty table break; } @@ -207,6 +259,7 @@ static int32_t findAndReplaceNode(SCalcConstContext* pCxt, SNode** pRoot, SNode* static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool dual, SNode** pNew) { SArray* pAssociation = NULL; + if (NULL != ((SExprNode*)pProject)->pAssociation) { pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation, NULL); if (NULL == pAssociation) { @@ -214,7 +267,7 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d } } - char aliasName[TSDB_COL_NAME_LEN] = {0}; + char aliasName[TSDB_COL_NAME_LEN] = {0}, srcTable[TSDB_TABLE_NAME_LEN] = {0}; int32_t code = TSDB_CODE_SUCCESS; if (dual) { code = scalarCalculateConstantsFromDual(pProject, pNew); @@ -227,8 +280,16 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d for (int32_t i = 0; i < size; ++i) { SAssociationNode* pAssNode = taosArrayGet(pAssociation, i); SNode** pCol = pAssNode->pPlace; + if (((SExprNode*)pAssNode->pAssociationNode)->joinSrc) { + //((SExprNode*)pAssNode->pAssociationNode)->constValue = true; + continue; + } + if (*pCol == pAssNode->pAssociationNode) { tstrncpy(aliasName, ((SExprNode*)*pCol)->aliasName, TSDB_COL_NAME_LEN); + if (QUERY_NODE_COLUMN == nodeType(*pCol)) { + tstrncpy(srcTable, ((SColumnNode*)*pCol)->tableAlias, TSDB_TABLE_NAME_LEN); + } SArray* pOrigAss = NULL; TSWAP(((SExprNode*)*pCol)->pAssociation, pOrigAss); nodesDestroyNode(*pCol); @@ -236,6 +297,9 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d code = nodesCloneNode(*pNew, pCol); if (TSDB_CODE_SUCCESS == code) { tstrncpy(((SExprNode*)*pCol)->aliasName, aliasName, TSDB_COL_NAME_LEN); + if (srcTable[0]) { + tstrncpy(((SExprNode*)*pCol)->srcTable, srcTable, TSDB_TABLE_NAME_LEN); + } TSWAP(pOrigAss, ((SExprNode*)*pCol)->pAssociation); } taosArrayDestroy(pOrigAss); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 182c5965ad..9d472fab80 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1383,7 +1383,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p pCol->numOfPKs = pTable->pMeta->tableInfo.numOfPKs; } -static int32_t setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColumnNode** pColRef) { +static int32_t setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColumnNode** pColRef, bool joinSrc) { SColumnNode* pCol = *pColRef; if (NULL == pExpr->pAssociation) { @@ -1413,6 +1413,7 @@ static int32_t setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SCo tstrncpy(pCol->node.userAlias, pExpr->userAlias, TSDB_COL_NAME_LEN); } pCol->node.resType = pExpr->resType; + pCol->node.joinSrc = pTable->table.inJoin && joinSrc; return TSDB_CODE_SUCCESS; } @@ -1494,7 +1495,7 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p code = nodesListStrictAppend(pList, (SNode*)pCol); if (TSDB_CODE_SUCCESS == code) { SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1); - code = setColumnInfoByExpr(pTempTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); + code = setColumnInfoByExpr(pTempTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode, true); } if (TSDB_CODE_SUCCESS == code) { if (!skipProjRef) @@ -1591,7 +1592,7 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, } } if (pFoundExpr) { - code = setColumnInfoByExpr(pTempTable, pFoundExpr, pColRef); + code = setColumnInfoByExpr(pTempTable, pFoundExpr, pColRef, SQL_CLAUSE_FROM != pCxt->currClause); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -4753,14 +4754,25 @@ static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTabl } } - if ((QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pLeft) && - !isGlobalTimeLineQuery(((STempTableNode*)pJoinTable->pLeft)->pSubquery)) || - (QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pRight) && - !isGlobalTimeLineQuery(((STempTableNode*)pJoinTable->pRight)->pSubquery))) { - return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, - "Join requires valid time series input"); + if (QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pLeft) && + !isGlobalTimeLineQuery(((STempTableNode*)pJoinTable->pLeft)->pSubquery)) { + if (IS_ASOF_JOIN(pJoinTable->subType) || IS_WINDOW_JOIN(pJoinTable->subType)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, + "Join requires valid time series input"); + } + pJoinTable->leftNoOrderedSubQuery = true; } + if (QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pRight) && + !isGlobalTimeLineQuery(((STempTableNode*)pJoinTable->pRight)->pSubquery)) { + if (IS_ASOF_JOIN(pJoinTable->subType) || IS_WINDOW_JOIN(pJoinTable->subType)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, + "Join requires valid time series input"); + } + pJoinTable->rightNoOrderedSubQuery = true; + } + + return TSDB_CODE_SUCCESS; } @@ -5088,9 +5100,141 @@ static int32_t setJoinTimeLineResMode(STranslateContext* pCxt) { return TSDB_CODE_SUCCESS; } -int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinParent) { +int32_t mergeInnerJoinConds(SNode** ppDst, SNode** ppSrc) { + SNode* pNew = NULL; + int32_t code = TSDB_CODE_SUCCESS; + + while (true) { + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppDst) && ((SLogicConditionNode*)*ppDst)->condType == LOGIC_COND_TYPE_AND) { + SLogicConditionNode* pLogic = (SLogicConditionNode*)*ppDst; + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppSrc) && ((SLogicConditionNode*)*ppSrc)->condType == LOGIC_COND_TYPE_AND) { + SLogicConditionNode* pSrcLogic = (SLogicConditionNode*)*ppSrc; + code = nodesListMakeStrictAppendList(&pLogic->pParameterList, pSrcLogic->pParameterList); + if (TSDB_CODE_SUCCESS == code) { + pSrcLogic->pParameterList = NULL; + nodesDestroyNode(*ppSrc); + *ppSrc = NULL; + } + } else { + code = nodesListMakeStrictAppend(&pLogic->pParameterList, *ppSrc); + if (TSDB_CODE_SUCCESS == code) { + *ppSrc = NULL; + } + } + + return code; + } + + if (TSDB_CODE_SUCCESS == code && QUERY_NODE_LOGIC_CONDITION == nodeType(*ppSrc) && ((SLogicConditionNode*)*ppSrc)->condType == LOGIC_COND_TYPE_AND) { + SNode* pTmp = *ppDst; + *ppDst = *ppSrc; + *ppSrc = pTmp; + continue; + } + + if (TSDB_CODE_SUCCESS == code) { + code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, &pNew); + } + if (TSDB_CODE_SUCCESS == code) { + SLogicConditionNode* pLogic = (SLogicConditionNode*)pNew; + pLogic->condType = LOGIC_COND_TYPE_AND; + pLogic->node.resType.type = TSDB_DATA_TYPE_BOOL; + pLogic->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; + code = nodesListMakeStrictAppend(&pLogic->pParameterList, *ppSrc); + if (TSDB_CODE_SUCCESS == code) { + *ppSrc = *ppDst; + *ppDst = pNew; + continue; + } + } + + if (code) { + break; + } + } + + return code; +} + +bool isColumnExpr(SNode* pNode) { + SExprNode* pExpr = (SExprNode*)pNode; + if (QUERY_NODE_COLUMN != nodeType(pNode) && QUERY_NODE_FUNCTION != nodeType(pNode)) { + return false; + } + if (QUERY_NODE_FUNCTION == nodeType(pNode)) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + if (FUNCTION_TYPE_TIMETRUNCATE != pFunc->funcType && strcasecmp(((SFunctionNode*)pNode)->functionName, "timetruncate")) { + return false; + } + if (!nodesContainsColumn(nodesListGetNode(pFunc->pParameterList, 0))) { + return false; + } + } + + return true; +} + +int32_t splitJoinColPrimaryCond(SNode** ppSrc, SNode** ppDst) { + if (NULL == *ppSrc) { + return TSDB_CODE_SUCCESS; + } + + int32_t code = 0; + switch (nodeType(*ppSrc)) { + case QUERY_NODE_OPERATOR: { + SOperatorNode* pOp = (SOperatorNode*)*ppSrc; + if (OP_TYPE_EQUAL != pOp->opType) { + break; + } + if (isColumnExpr(pOp->pLeft) && isColumnExpr(pOp->pRight)) { + TSWAP(*ppSrc, *ppDst); + } + break; + } + case QUERY_NODE_LOGIC_CONDITION: { + SLogicConditionNode* pLogic = (SLogicConditionNode*)*ppSrc; + if (LOGIC_COND_TYPE_AND != pLogic->condType) { + break; + } + SNode* pTmp = NULL; + SNode* pTmpRes = NULL; + WHERE_EACH(pTmp, pLogic->pParameterList) { + code = splitJoinColPrimaryCond(&pTmp, &pTmpRes); + if (code) { + break; + } + if (NULL == pTmp && NULL != pTmpRes) { + cell->pNode = NULL; + ERASE_NODE(pLogic->pParameterList); + code = nodesMergeNode(ppDst, &pTmpRes); + if (code) { + break; + } + + continue; + } + + WHERE_NEXT; + } + if (pLogic->pParameterList->length <= 0) { + nodesDestroyNode(*ppSrc); + *ppSrc = NULL; + } + break; + } + default: + break; + } + + return code; +} + +int32_t translateTable(STranslateContext* pCxt, SNode** pTable, bool inJoin) { SSelectStmt* pCurrSmt = (SSelectStmt*)(pCxt->pCurrStmt); int32_t code = TSDB_CODE_SUCCESS; + + ((STableNode*)*pTable)->inJoin = inJoin; + switch (nodeType(*pTable)) { case QUERY_NODE_REAL_TABLE: { SRealTableNode* pRealTable = (SRealTableNode*)*pTable; @@ -5106,7 +5250,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare } #ifdef TD_ENTERPRISE if (TSDB_VIEW_TABLE == pRealTable->pMeta->tableType && (!pCurrSmt->tagScan || pCxt->pParseCxt->biMode)) { - return translateView(pCxt, pTable, &name); + return translateView(pCxt, pTable, &name, inJoin); } code = translateAudit(pCxt, pRealTable, &name); #endif @@ -5163,14 +5307,27 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare SJoinTableNode* pJoinTable = (SJoinTableNode*)*pTable; code = translateJoinTable(pCxt, pJoinTable); if (TSDB_CODE_SUCCESS == code) { - code = translateTable(pCxt, &pJoinTable->pLeft, (SNode*)pJoinTable); + code = translateTable(pCxt, &pJoinTable->pLeft, true); } if (TSDB_CODE_SUCCESS == code) { - code = translateTable(pCxt, &pJoinTable->pRight, (SNode*)pJoinTable); + code = translateTable(pCxt, &pJoinTable->pRight, true); } if (TSDB_CODE_SUCCESS == code) { code = checkJoinTable(pCxt, pJoinTable); } + if (TSDB_CODE_SUCCESS == code && !inJoin && pCurrSmt->pWhere && JOIN_TYPE_INNER == pJoinTable->joinType) { + SNode* pPrimCond = NULL; + code = splitJoinColPrimaryCond(&pCurrSmt->pWhere, &pPrimCond); + if (TSDB_CODE_SUCCESS == code && pPrimCond) { + if (pJoinTable->pOnCond) { + code = mergeInnerJoinConds(&pJoinTable->pOnCond, &pPrimCond); + } else { + pJoinTable->pOnCond = pPrimCond; + pPrimCond = NULL; + } + } + nodesDestroyNode(pPrimCond); + } if (TSDB_CODE_SUCCESS == code) { pJoinTable->table.precision = calcJoinTablePrecision(pJoinTable); pJoinTable->table.singleTable = joinTableIsSingleTable(pJoinTable); @@ -7123,7 +7280,7 @@ static int32_t translateWhere(STranslateContext* pCxt, SSelectStmt* pSelect) { static int32_t translateFrom(STranslateContext* pCxt, SNode** pTable) { pCxt->currClause = SQL_CLAUSE_FROM; - return translateTable(pCxt, pTable, NULL); + return translateTable(pCxt, pTable, false); } static int32_t checkLimit(STranslateContext* pCxt, SSelectStmt* pSelect) { @@ -7555,7 +7712,7 @@ static EDealRes rewriteSingleColsFunc(SNode** pNode, void* pContext) { } if (pFunc->node.asAlias) { if (((SExprNode*)pExpr)->asAlias) { - pCxt->status = TSDB_CODE_INVALID_COLS_ALIAS; + pCxt->status = TSDB_CODE_PAR_INVALID_COLS_ALIAS; parserError("%s Invalid using alias for cols function", __func__); return DEAL_RES_ERROR; } else { @@ -7664,7 +7821,7 @@ static int32_t rewriteColsFunction(STranslateContext* pCxt, SNodeList** nodeList if (isMultiColsFuncNode(pTmpNode)) { SFunctionNode* pFunc = (SFunctionNode*)pTmpNode; if(pFunc->node.asAlias) { - code = TSDB_CODE_INVALID_COLS_ALIAS; + code = TSDB_CODE_PAR_INVALID_COLS_ALIAS; parserError("%s Invalid using alias for cols function", __func__); goto _end; } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 98b2ef341e..d88bcb6f4b 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -600,6 +600,9 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect pJoin->node.requireDataOrder = pJoin->hashJoinHint ? DATA_ORDER_LEVEL_NONE : DATA_ORDER_LEVEL_GLOBAL; pJoin->node.resultDataOrder = DATA_ORDER_LEVEL_NONE; pJoin->isLowLevelJoin = pJoinTable->isLowLevelJoin; + pJoin->leftNoOrderedSubQuery = pJoinTable->leftNoOrderedSubQuery; + pJoin->rightNoOrderedSubQuery = pJoinTable->leftNoOrderedSubQuery; + code = nodesCloneNode(pJoinTable->pWindowOffset, &pJoin->pWindowOffset); if (TSDB_CODE_SUCCESS == code) { code = nodesCloneNode(pJoinTable->pJLimit, &pJoin->pJLimit); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 367d0f4b4f..3378202274 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -20,6 +20,7 @@ #include "systable.h" #include "tglobal.h" #include "ttime.h" +#include "scalar.h" #define OPTIMIZE_FLAG_MASK(n) (1 << n) @@ -502,52 +503,12 @@ static int32_t scanPathOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub return code; } -static int32_t pdcMergeCondsToLogic(SNode** pDst, SNode** pSrc) { - SLogicConditionNode* pLogicCond = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond); - if (NULL == pLogicCond) { - return code; - } - pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL; - pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; - pLogicCond->condType = LOGIC_COND_TYPE_AND; - code = nodesListMakeAppend(&pLogicCond->pParameterList, *pSrc); - if (TSDB_CODE_SUCCESS == code) { - *pSrc = NULL; - code = nodesListMakeAppend(&pLogicCond->pParameterList, *pDst); - } - if (TSDB_CODE_SUCCESS == code) { - *pDst = (SNode*)pLogicCond; - } else { - nodesDestroyNode((SNode*)pLogicCond); - } - return code; -} - -static int32_t pdcMergeConds(SNode** pCond, SNode** pAdditionalCond) { - if (NULL == *pCond) { - TSWAP(*pCond, *pAdditionalCond); - return TSDB_CODE_SUCCESS; - } - - int32_t code = TSDB_CODE_SUCCESS; - if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCond) && - LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCond)->condType) { - code = nodesListAppend(((SLogicConditionNode*)*pCond)->pParameterList, *pAdditionalCond); - if (TSDB_CODE_SUCCESS == code) { - *pAdditionalCond = NULL; - } - } else { - code = pdcMergeCondsToLogic(pCond, pAdditionalCond); - } - return code; -} static int32_t pushDownCondOptCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, SNode** pPrimaryKeyCond, SNode** pOtherCond) { int32_t code = TSDB_CODE_SUCCESS; if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) { - code = pdcMergeConds(pOtherCond, pPrimaryKeyCond); + code = nodesMergeNode(pOtherCond, pPrimaryKeyCond); } else { bool isStrict = false; code = filterGetTimeRange(*pPrimaryKeyCond, &pScan->scanRange, &isStrict); @@ -555,7 +516,7 @@ static int32_t pushDownCondOptCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNo if (isStrict) { nodesDestroyNode(*pPrimaryKeyCond); } else { - code = pdcMergeConds(pOtherCond, pPrimaryKeyCond); + code = nodesMergeNode(pOtherCond, pPrimaryKeyCond); } *pPrimaryKeyCond = NULL; } @@ -629,8 +590,16 @@ static bool pdcJoinColInTableColList(SNode* pNode, SNodeList* pTableCols) { } static bool pdcJoinColInTableList(SNode* pCondCol, SSHashObj* pTables) { - SColumnNode* pTableCol = (SColumnNode*)pCondCol; - if (NULL == tSimpleHashGet(pTables, pTableCol->tableAlias, strlen(pTableCol->tableAlias))) { + char* pTableAlias = NULL; + if (QUERY_NODE_COLUMN == nodeType(pCondCol)) { + SColumnNode* pTableCol = (SColumnNode*)pCondCol; + pTableAlias = pTableCol->tableAlias; + } else if (QUERY_NODE_VALUE == nodeType(pCondCol)) { + SValueNode* pVal = (SValueNode*)pCondCol; + pTableAlias = pVal->node.srcTable; + } + + if (NULL == tSimpleHashGet(pTables, pTableAlias, strlen(pTableAlias))) { return false; } return true; @@ -819,15 +788,27 @@ static int32_t pdcJoinSplitCond(SJoinLogicNode* pJoin, SNode** pSrcCond, SNode** } static int32_t pdcJoinPushDownOnCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNode** pCond) { - return pdcMergeConds(&pJoin->pFullOnCond, pCond); + return nodesMergeNode(&pJoin->pFullOnCond, pCond); } static int32_t pdcPushDownCondToChild(SOptimizeContext* pCxt, SLogicNode* pChild, SNode** pCond) { - return pdcMergeConds(&pChild->pConditions, pCond); + return nodesMergeNode(&pChild->pConditions, pCond); } -static bool pdcJoinIsPrim(SNode* pNode, SSHashObj* pTables) { - if (QUERY_NODE_COLUMN != nodeType(pNode) && QUERY_NODE_FUNCTION != nodeType(pNode)) { +static bool pdcJoinIsPrim(SNode* pNode, SSHashObj* pTables, bool constAsPrim, bool* constPrimGot) { + if (QUERY_NODE_COLUMN != nodeType(pNode) && QUERY_NODE_FUNCTION != nodeType(pNode) && (!constAsPrim || QUERY_NODE_VALUE != nodeType(pNode))) { + return false; + } + + if (QUERY_NODE_VALUE == nodeType(pNode)) { + SValueNode* pVal = (SValueNode*)pNode; + if (TSDB_DATA_TYPE_NULL != pVal->node.resType.type && !pVal->isNull) { + if (pdcJoinColInTableList(pNode, pTables)) { + *constPrimGot = true; + return true; + } + } + return false; } @@ -850,7 +831,7 @@ static bool pdcJoinIsPrim(SNode* pNode, SSHashObj* pTables) { return pdcJoinColInTableList(pNode, pTables); } -static bool pdcJoinIsPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { +static bool pdcJoinIsPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond, bool constAsPrim) { if (QUERY_NODE_OPERATOR != nodeType(pCond)) { return false; } @@ -878,11 +859,14 @@ static bool pdcJoinIsPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { return code; } - bool res = false; - if (pdcJoinIsPrim(pOper->pLeft, pLeftTables)) { - res = pdcJoinIsPrim(pOper->pRight, pRightTables); - } else if (pdcJoinIsPrim(pOper->pLeft, pRightTables)) { - res = pdcJoinIsPrim(pOper->pRight, pLeftTables); + bool res = false, constGot = false; + if (pdcJoinIsPrim(pOper->pLeft, pLeftTables, constAsPrim, &pJoin->leftConstPrimGot)) { + res = pdcJoinIsPrim(pOper->pRight, pRightTables, constAsPrim, &pJoin->rightConstPrimGot); + } else if (pdcJoinIsPrim(pOper->pLeft, pRightTables, constAsPrim, &pJoin->rightConstPrimGot)) { + res = pdcJoinIsPrim(pOper->pRight, pLeftTables, constAsPrim, &pJoin->leftConstPrimGot); + if (pJoin->rightConstPrimGot || pJoin->leftConstPrimGot) { + TSWAP(pOper->pLeft, pOper->pRight); + } } tSimpleHashCleanup(pLeftTables); @@ -910,24 +894,26 @@ static bool pdcJoinHasPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond, bool* e } return hasPrimaryKeyEqualCond; } else { - return pdcJoinIsPrimEqualCond(pJoin, pCond); + return pdcJoinIsPrimEqualCond(pJoin, pCond, false); } } -static int32_t pdcJoinSplitPrimInLogicCond(SJoinLogicNode* pJoin, SNode** ppPrimEqCond, SNode** ppOnCond) { - SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(pJoin->pFullOnCond); +static int32_t pdcJoinSplitPrimInLogicCond(SJoinLogicNode* pJoin, SNode** ppInput, SNode** ppPrimEqCond, SNode** ppOnCond, bool constAsPrim) { + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(*ppInput); int32_t code = TSDB_CODE_SUCCESS; SNodeList* pOnConds = NULL; SNode* pCond = NULL; WHERE_EACH(pCond, pLogicCond->pParameterList) { SNode* pNew = NULL; - code = nodesCloneNode(pCond, &pNew); - if (TSDB_CODE_SUCCESS != code) break; - if (pdcJoinIsPrimEqualCond(pJoin, pCond) && (NULL == *ppPrimEqCond)) { + if (pdcJoinIsPrimEqualCond(pJoin, pCond, constAsPrim) && (NULL == *ppPrimEqCond) && (!constAsPrim || pJoin->leftConstPrimGot || pJoin->rightConstPrimGot)) { + code = nodesCloneNode(pCond, &pNew); + if (TSDB_CODE_SUCCESS != code) break; *ppPrimEqCond = pNew; ERASE_NODE(pLogicCond->pParameterList); } else { + code = nodesCloneNode(pCond, &pNew); + if (TSDB_CODE_SUCCESS != code) break; code = nodesListMakeAppend(&pOnConds, pNew); if (TSDB_CODE_SUCCESS != code) break; WHERE_NEXT; @@ -942,10 +928,11 @@ static int32_t pdcJoinSplitPrimInLogicCond(SJoinLogicNode* pJoin, SNode** ppPrim if (TSDB_CODE_SUCCESS == code) { if (NULL != *ppPrimEqCond) { *ppOnCond = pTempOnCond; - nodesDestroyNode(pJoin->pFullOnCond); - pJoin->pFullOnCond = NULL; + nodesDestroyNode(*ppInput); + *ppInput = NULL; return TSDB_CODE_SUCCESS; } + nodesDestroyNode(pTempOnCond); planError("no primary key equal cond found, condListNum:%d", pLogicCond->pParameterList->length); return TSDB_CODE_PLAN_INTERNAL_ERROR; } else { @@ -962,8 +949,8 @@ static int32_t pdcJoinSplitPrimEqCond(SOptimizeContext* pCxt, SJoinLogicNode* pJ if (QUERY_NODE_LOGIC_CONDITION == nodeType(pJoin->pFullOnCond) && LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)(pJoin->pFullOnCond))->condType) { - code = pdcJoinSplitPrimInLogicCond(pJoin, &pPrimKeyEqCond, &pJoinOnCond); - } else if (pdcJoinIsPrimEqualCond(pJoin, pJoin->pFullOnCond)) { + code = pdcJoinSplitPrimInLogicCond(pJoin, &pJoin->pFullOnCond, &pPrimKeyEqCond, &pJoinOnCond, false); + } else if (pdcJoinIsPrimEqualCond(pJoin, pJoin->pFullOnCond, false)) { pPrimKeyEqCond = pJoin->pFullOnCond; pJoinOnCond = NULL; } else { @@ -1412,6 +1399,37 @@ static int32_t pdcJoinAddFilterColsToTarget(SOptimizeContext* pCxt, SJoinLogicNo return code; } +static int32_t pdcJoinSplitConstPrimEqCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNode** ppCond) { + int32_t code = TSDB_CODE_SUCCESS; + SNode* pPrimKeyEqCond = NULL; + SNode* pJoinOnCond = NULL; + + if (QUERY_NODE_LOGIC_CONDITION == nodeType(*ppCond) && + LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*ppCond)->condType) { + code = pdcJoinSplitPrimInLogicCond(pJoin, ppCond, &pPrimKeyEqCond, &pJoinOnCond, true); + } else if (pdcJoinIsPrimEqualCond(pJoin, *ppCond, true) && (pJoin->leftConstPrimGot || pJoin->rightConstPrimGot)) { + pPrimKeyEqCond = *ppCond; + pJoinOnCond = NULL; + } else { + return TSDB_CODE_SUCCESS; + } + + if (TSDB_CODE_SUCCESS == code) { + pJoin->pPrimKeyEqCond = pPrimKeyEqCond; + *ppCond = pJoinOnCond; + if (pJoin->rightConstPrimGot || pJoin->leftConstPrimGot) { + code = scalarConvertOpValueNodeTs((SOperatorNode*)pJoin->pPrimKeyEqCond); + } + } else { + nodesDestroyNode(pPrimKeyEqCond); + nodesDestroyNode(pJoinOnCond); + } + + return code; +} + + + static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { if (NULL == pJoin->pFullOnCond) { if (IS_WINDOW_JOIN(pJoin->subType) || IS_ASOF_JOIN(pJoin->subType)) { @@ -1427,9 +1445,10 @@ static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin } } - SNode* pCond = pJoin->pFullOnCond ? pJoin->pFullOnCond : pJoin->node.pConditions; + SNode** ppCond = pJoin->pFullOnCond ? &pJoin->pFullOnCond : &pJoin->node.pConditions; bool errCond = false; - if (!pdcJoinHasPrimEqualCond(pJoin, pCond, &errCond)) { + bool primCondGot = pdcJoinHasPrimEqualCond(pJoin, *ppCond, &errCond); + if (!primCondGot) { if (errCond && !(IS_INNER_NONE_JOIN(pJoin->joinType, pJoin->subType) && NULL != pJoin->pFullOnCond && NULL != pJoin->node.pConditions)) { return generateUsageErrMsg(pCxt->pPlanCxt->pMsg, pCxt->pPlanCxt->msgLen, TSDB_CODE_PLAN_NOT_SUPPORT_JOIN_COND); @@ -1437,7 +1456,8 @@ static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin if (IS_INNER_NONE_JOIN(pJoin->joinType, pJoin->subType) && NULL != pJoin->pFullOnCond && NULL != pJoin->node.pConditions) { - if (pdcJoinHasPrimEqualCond(pJoin, pJoin->node.pConditions, &errCond)) { + primCondGot = pdcJoinHasPrimEqualCond(pJoin, pJoin->node.pConditions, &errCond); + if (primCondGot) { return TSDB_CODE_SUCCESS; } if (errCond) { @@ -1448,6 +1468,22 @@ static int32_t pdcJoinCheckAllCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin if (IS_WINDOW_JOIN(pJoin->subType) || IS_ASOF_JOIN(pJoin->subType)) { return TSDB_CODE_SUCCESS; } + } + + if (pJoin->leftNoOrderedSubQuery || pJoin->rightNoOrderedSubQuery || !primCondGot) { + pJoin->noPrimKeyEqCond = true; + int32_t code = pdcJoinSplitConstPrimEqCond(pCxt, pJoin, ppCond); + if (code || (pJoin->pPrimKeyEqCond)) { + return code; + } + + if (IS_INNER_NONE_JOIN(pJoin->joinType, pJoin->subType) && NULL != pJoin->pFullOnCond && + NULL != pJoin->node.pConditions) { + code = pdcJoinSplitConstPrimEqCond(pCxt, pJoin, &pJoin->node.pConditions); + if (code || pJoin->pPrimKeyEqCond) { + return code; + } + } return generateUsageErrMsg(pCxt->pPlanCxt->pMsg, pCxt->pPlanCxt->msgLen, TSDB_CODE_PLAN_EXPECTED_TS_EQUAL); } @@ -1813,6 +1849,7 @@ static int32_t pdcRewriteTypeBasedOnJoinRes(SOptimizeContext* pCxt, SJoinLogicNo return TSDB_CODE_SUCCESS; } + static int32_t pdcDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { if (OPTIMIZE_FLAG_TEST_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE)) { return TSDB_CODE_SUCCESS; @@ -1870,7 +1907,7 @@ static int32_t pdcDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) { } if (TSDB_CODE_SUCCESS == code && NULL != pJoin->pFullOnCond && !IS_WINDOW_JOIN(pJoin->subType) && - NULL == pJoin->addPrimEqCond) { + NULL == pJoin->addPrimEqCond && NULL == pJoin->pPrimKeyEqCond) { code = pdcJoinSplitPrimEqCond(pCxt, pJoin); } @@ -1993,7 +2030,7 @@ static int32_t partitionAggCond(SAggLogicNode* pAgg, SNode** ppAggFunCond, SNode } static int32_t pushCondToAggCond(SOptimizeContext* pCxt, SAggLogicNode* pAgg, SNode** pAggFuncCond) { - return pdcMergeConds(&pAgg->node.pConditions, pAggFuncCond); + return nodesMergeNode(&pAgg->node.pConditions, pAggFuncCond); } typedef struct SRewriteAggGroupKeyCondContext { @@ -2118,12 +2155,15 @@ static int32_t pdcDealProject(SOptimizeContext* pCxt, SProjectLogicNode* pProjec if (NULL != pProject->node.pLimit || NULL != pProject->node.pSlimit) { return TSDB_CODE_SUCCESS; } + SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProject->node.pChildren, 0); + if(pChild->pLimit != NULL) { + return TSDB_CODE_SUCCESS; + } int32_t code = TSDB_CODE_SUCCESS; SNode* pProjCond = NULL; code = rewriteProjectCondForPushDown(pCxt, pProject, &pProjCond); if (TSDB_CODE_SUCCESS == code) { - SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProject->node.pChildren, 0); code = pdcPushDownCondToChild(pCxt, pChild, &pProjCond); } @@ -2616,7 +2656,9 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL bool res = false; SOperatorNode* pOp = (SOperatorNode*)pJoin->pPrimKeyEqCond; - if (QUERY_NODE_COLUMN != nodeType(pOp->pLeft) || QUERY_NODE_COLUMN != nodeType(pOp->pRight)) { + + if ((QUERY_NODE_COLUMN != nodeType(pOp->pLeft) && QUERY_NODE_VALUE != nodeType(pOp->pLeft)) || + (QUERY_NODE_COLUMN != nodeType(pOp->pRight) && QUERY_NODE_VALUE != nodeType(pOp->pRight))) { return TSDB_CODE_PLAN_INTERNAL_ERROR; } @@ -2626,11 +2668,13 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL if (TSDB_CODE_SUCCESS != code) { return code; } - if (NULL != - tSimpleHashGet(pTables, ((SColumnNode*)pOp->pLeft)->tableAlias, strlen(((SColumnNode*)pOp->pLeft)->tableAlias))) { + + char* opLeftTable = (QUERY_NODE_COLUMN == nodeType(pOp->pLeft)) ? ((SColumnNode*)pOp->pLeft)->tableAlias : ((SValueNode*)pOp->pLeft)->node.srcTable; + char* opRightTable = (QUERY_NODE_COLUMN == nodeType(pOp->pRight)) ? ((SColumnNode*)pOp->pRight)->tableAlias : ((SValueNode*)pOp->pRight)->node.srcTable; + + if (NULL != tSimpleHashGet(pTables, opLeftTable, strlen(opLeftTable))) { pOrderByNode = pOp->pLeft; - } else if (NULL != tSimpleHashGet(pTables, ((SColumnNode*)pOp->pRight)->tableAlias, - strlen(((SColumnNode*)pOp->pRight)->tableAlias))) { + } else if (NULL != tSimpleHashGet(pTables, opRightTable, strlen(opRightTable))) { pOrderByNode = pOp->pRight; } @@ -2683,7 +2727,6 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL } *pChildPos = (SNode*)pSort; pSort->node.pParent = (SLogicNode*)pJoin; - ; _return: diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index e12ec77bff..11cb94683b 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -375,7 +375,7 @@ static EDealRes doSetSlotId(SNode* pNode, void* pContext) { SSetSlotIdCxt* pCxt = (SSetSlotIdCxt*)pContext; char* name = NULL; int32_t len = 0; - pCxt->errCode = getSlotKey(pNode, NULL, &name, &len, 16); + pCxt->errCode = getSlotKey(pNode, NULL, &name, &len, 64); if (TSDB_CODE_SUCCESS != pCxt->errCode) { return DEAL_RES_ERROR; } @@ -386,7 +386,10 @@ static EDealRes doSetSlotId(SNode* pNode, void* pContext) { if (!pIndex) { pIndex = taosHashGet(pCxt->pRightProdIdxHash, name, strlen(name)); } - } else { + } + + if (NULL == pIndex) { + name[len] = 0; pIndex = taosHashGet(pCxt->pLeftHash, name, len); if (NULL == pIndex) { pIndex = taosHashGet(pCxt->pRightHash, name, len); @@ -924,7 +927,7 @@ static int32_t setColEqList(SNode* pEqCond, int16_t leftBlkId, int16_t rightBlkI } static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_t leftBlkId, int16_t rightBlkId, - SSortMergeJoinPhysiNode* pJoin) { + SSortMergeJoinPhysiNode* pJoin, SJoinLogicNode* pJoinLogicNode) { int32_t code = 0; if (QUERY_NODE_OPERATOR == nodeType(pEqCond)) { SOperatorNode* pOp = (SOperatorNode*)pEqCond; @@ -947,6 +950,16 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_ } break; } + case QUERY_NODE_VALUE: { + if (pJoinLogicNode && pJoinLogicNode->leftConstPrimGot) { + pJoin->leftPrimExpr = NULL; + code = nodesCloneNode(pOp->pLeft, &pJoin->leftPrimExpr); + break; + } + + planError("value node got in prim eq left cond, rightType:%d", pOp->pRight ? nodeType(pOp->pRight) : 0); + return TSDB_CODE_PLAN_INTERNAL_ERROR; + } case QUERY_NODE_FUNCTION: { SFunctionNode* pFunc = (SFunctionNode*)pOp->pLeft; if (FUNCTION_TYPE_TIMETRUNCATE != pFunc->funcType) { @@ -995,6 +1008,16 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_ } break; } + case QUERY_NODE_VALUE: { + if (pJoinLogicNode && pJoinLogicNode->rightConstPrimGot) { + pJoin->rightPrimExpr = NULL; + code = nodesCloneNode(pOp->pRight, &pJoin->rightPrimExpr); + break; + } + + planError("value node got in prim eq right cond, leftType:%d", pOp->pLeft ? nodeType(pOp->pLeft) : 0); + return TSDB_CODE_PLAN_INTERNAL_ERROR; + } case QUERY_NODE_FUNCTION: { SFunctionNode* pFunc = (SFunctionNode*)pOp->pRight; if (FUNCTION_TYPE_TIMETRUNCATE != pFunc->funcType) { @@ -1034,6 +1057,37 @@ static int32_t setMergeJoinPrimColEqCond(SNode* pEqCond, int32_t subType, int16_ return code; } +static int32_t removePrimColFromJoinTargets(SNodeList* pTargets, SValueNode* pPrimExpr, SColumnNode** ppRemoved) { + int32_t code = TSDB_CODE_SUCCESS; + SNode* pNode = NULL; + FOREACH(pNode, pTargets) { + SColumnNode* pCol = (SColumnNode*)pNode; + if (0 == strcmp(pCol->tableAlias, pPrimExpr->node.srcTable) && 0 == strcmp(pCol->colName, pPrimExpr->node.aliasName)) { + code = nodesCloneNode(pNode, (SNode**)ppRemoved); + ERASE_NODE(pTargets); + break; + } + } + + return code; +} + +static int32_t appendPrimColToJoinTargets(SSortMergeJoinPhysiNode* pJoin, SColumnNode** ppTarget, STargetNode* primExpr, int16_t blkId) { + SColumnNode* pCol = *ppTarget; + if (TSDB_DATA_TYPE_TIMESTAMP != pCol->node.resType.type) { + planError("primary key output type is not ts, type:%d", pCol->node.resType.type); + return TSDB_CODE_PAR_PRIM_KEY_MUST_BE_TS; + } + pCol->dataBlockId = blkId; + pCol->slotId = primExpr->slotId; + int32_t code = nodesListMakeStrictAppend(&pJoin->pTargets, (SNode *)pCol); + if (TSDB_CODE_SUCCESS == code) { + *ppTarget = NULL; + } + + return code; +} + static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) { SSortMergeJoinPhysiNode* pJoin = @@ -1068,7 +1122,7 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi &pJoin->pPrimKeyCond); if (TSDB_CODE_SUCCESS == code) { code = setMergeJoinPrimColEqCond(pJoin->pPrimKeyCond, pJoin->subType, pLeftDesc->dataBlockId, - pRightDesc->dataBlockId, pJoin); + pRightDesc->dataBlockId, pJoin, pJoinLogicNode); } if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) { code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc); @@ -1084,7 +1138,7 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi &pPrimKeyCond); if (TSDB_CODE_SUCCESS == code) { code = setMergeJoinPrimColEqCond(pPrimKeyCond, pJoin->subType, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, - pJoin); + pJoin, NULL); } if (TSDB_CODE_SUCCESS == code && NULL != pJoin->leftPrimExpr) { code = addDataBlockSlot(pCxt, &pJoin->leftPrimExpr, pLeftDesc); @@ -1095,11 +1149,32 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi nodesDestroyNode(pPrimKeyCond); } + SValueNode* pLeftPrimExpr = NULL, *pRightPrimExpr = NULL; + SColumnNode* pLeftTarget = NULL, *pRightTarget = NULL; + if (TSDB_CODE_SUCCESS == code && pJoinLogicNode->leftConstPrimGot && pJoin->leftPrimExpr + && QUERY_NODE_VALUE == nodeType(((STargetNode*)pJoin->leftPrimExpr)->pExpr)) { + pLeftPrimExpr = (SValueNode*)((STargetNode*)pJoin->leftPrimExpr)->pExpr; + code = removePrimColFromJoinTargets(pJoinLogicNode->node.pTargets, pLeftPrimExpr, &pLeftTarget); + } + + if (TSDB_CODE_SUCCESS == code && pJoinLogicNode->rightConstPrimGot && pJoin->rightPrimExpr + && QUERY_NODE_VALUE == nodeType(((STargetNode*)pJoin->rightPrimExpr)->pExpr)) { + pRightPrimExpr = (SValueNode*)((STargetNode*)pJoin->rightPrimExpr)->pExpr; + code = removePrimColFromJoinTargets(pJoinLogicNode->node.pTargets, pRightPrimExpr, &pRightTarget); + } + if (TSDB_CODE_SUCCESS == code) { code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->node.pTargets, &pJoin->pTargets); } + if (TSDB_CODE_SUCCESS == code && pLeftPrimExpr && pLeftTarget) { + code = appendPrimColToJoinTargets(pJoin, &pLeftTarget, (STargetNode*)pJoin->leftPrimExpr, pLeftDesc->dataBlockId); + } + if (TSDB_CODE_SUCCESS == code && pRightPrimExpr && pRightTarget) { + code = appendPrimColToJoinTargets(pJoin, &pRightTarget, (STargetNode*)pJoin->rightPrimExpr, pRightDesc->dataBlockId); + } + if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pFullOnCond) { code = setNodeSlotId(pCxt, ((SPhysiNode*)pJoin)->pOutputDataBlockDesc->dataBlockId, -1, pJoinLogicNode->pFullOnCond, &pJoin->pFullOnCond); @@ -1151,6 +1226,8 @@ static int32_t createMergeJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi *pPhyNode = (SPhysiNode*)pJoin; } else { nodesDestroyNode((SNode*)pJoin); + nodesDestroyNode((SNode*)pLeftTarget); + nodesDestroyNode((SNode*)pRightTarget); } return code; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 9bab697772..7dd3a8e9e3 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -1133,29 +1133,7 @@ static uint8_t sclGetOpValueNodeTsPrecision(SNode *pLeft, SNode *pRight) { return 0; } -int32_t sclConvertOpValueNodeTs(SOperatorNode *node) { - if (node->pLeft && SCL_IS_VAR_VALUE_NODE(node->pLeft)) { - if (node->pRight && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pRight)->resType.type)) { - SCL_ERR_RET( - sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), (SValueNode *)node->pLeft)); - } - } else if (node->pRight && SCL_IS_NOTNULL_CONST_NODE(node->pRight)) { - if (node->pLeft && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pLeft)->resType.type)) { - if (SCL_IS_VAR_VALUE_NODE(node->pRight)) { - SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), - (SValueNode *)node->pRight)); - } else if (QUERY_NODE_NODE_LIST == node->pRight->type) { - SNode *pNode; - FOREACH(pNode, ((SNodeListNode *)node->pRight)->pNodeList) { - if (SCL_IS_VAR_VALUE_NODE(pNode)) { - SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, pNode), (SValueNode *)pNode)); - } - } - } - } - } - return TSDB_CODE_SUCCESS; -} + int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node) { if (NULL == node->pCase) { @@ -1344,7 +1322,7 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) { EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) { SOperatorNode *node = (SOperatorNode *)*pNode; - ctx->code = sclConvertOpValueNodeTs(node); + ctx->code = scalarConvertOpValueNodeTs(node); if (ctx->code) { return DEAL_RES_ERROR; } @@ -1807,6 +1785,31 @@ static int32_t sclGetBitwiseOperatorResType(SOperatorNode *pOp) { return TSDB_CODE_SUCCESS; } +int32_t scalarConvertOpValueNodeTs(SOperatorNode *node) { + if (node->pLeft && SCL_IS_VAR_VALUE_NODE(node->pLeft)) { + if (node->pRight && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pRight)->resType.type)) { + SCL_ERR_RET( + sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), (SValueNode *)node->pLeft)); + } + } else if (node->pRight && SCL_IS_NOTNULL_CONST_NODE(node->pRight)) { + if (node->pLeft && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pLeft)->resType.type)) { + if (SCL_IS_VAR_VALUE_NODE(node->pRight)) { + SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight), + (SValueNode *)node->pRight)); + } else if (QUERY_NODE_NODE_LIST == node->pRight->type) { + SNode *pNode; + FOREACH(pNode, ((SNodeListNode *)node->pRight)->pNodeList) { + if (SCL_IS_VAR_VALUE_NODE(pNode)) { + SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, pNode), (SValueNode *)pNode)); + } + } + } + } + } + return TSDB_CODE_SUCCESS; +} + + int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) { return sclCalcConstants(pNode, false, pRes); } int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes) { return sclCalcConstants(pNode, true, pRes); } diff --git a/source/os/test/osFileTests.cpp b/source/os/test/osFileTests.cpp index f9e40c2703..97e5c8493d 100644 --- a/source/os/test/osFileTests.cpp +++ b/source/os/test/osFileTests.cpp @@ -196,7 +196,7 @@ TEST(osFileTests, taosCopyFile) { retsize = taosReadFromCFile(NULL, 0, 0, NULL); EXPECT_EQ(retsize, 0); - taosRemoveFile(from); + taosRemoveFile(from); } TEST(osFileTests, taosCreateFile) { diff --git a/source/os/test/osTests.cpp b/source/os/test/osTests.cpp index f4e7eff323..1e4bcbd3d6 100644 --- a/source/os/test/osTests.cpp +++ b/source/os/test/osTests.cpp @@ -389,7 +389,7 @@ TEST(osTest, osFile) { (void)taosThreadJoin(thread2, NULL); taosThreadClear(&thread2); - // int ret = taosRemoveFile(fname); + taosRemoveFile(fname); // ASSERT_EQ(ret, 0); // printf("remove file success"); } @@ -651,6 +651,8 @@ TEST(osTest, osFilePerformance) { taosMemoryFree(writeBuffer); taosMemoryFree(readBuffer); + taosRemoveFile(fname); + (void)printf("Test Write file %d times, cost: %" PRId64 "us\n", TESTTIMES, WriteFileCost); (void)printf("Test Read file %d times, cost: %" PRId64 "us\n", TESTTIMES, ReadFileCost); (void)printf("Test OpenForWrite & Close file %d times, cost: %" PRId64 "us\n", TESTTIMES, OpenForWriteCloseFileCost); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index cbc7f4d1be..84d2416af2 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -757,9 +757,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TRUE_FOR_NEGATIVE, "True_for duration c TAOS_DEFINE_ERROR(TSDB_CODE_PAR_TRUE_FOR_UNIT, "Cannot use 'year' or 'month' as true_for duration") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COLS_FUNCTION, "Invalid cols function") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COLS_SELECTFUNC, "cols function's first param must be a select function that output a single row") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MULITI_COLS_FUNC, "Improper use of cols function with multiple output columns") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_COLS_ALIAS, "Invalid using alias for cols function") - +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COLS_ALIAS, "Invalid using alias for cols function") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_PRIM_KEY_MUST_BE_TS, "Join primary key col must be timestmap type") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTERNAL_ERROR, "Parser internal error") //planner diff --git a/tests/army/frame/caseBase.py b/tests/army/frame/caseBase.py index 98007c6d8d..a59c9a4441 100644 --- a/tests/army/frame/caseBase.py +++ b/tests/army/frame/caseBase.py @@ -18,6 +18,8 @@ import datetime import random import copy import json +import tempfile +import uuid import frame.eos import frame.etool @@ -476,4 +478,49 @@ class TBase: # print(rlist) - return rlist \ No newline at end of file + return rlist + + # generate new json file + def genNewJson(self, jsonFile, modifyFunc=None): + try: + with open(jsonFile, 'r', encoding='utf-8') as f: + data = json.load(f) + except FileNotFoundError: + tdLog.info(f"the specified json file '{jsonFile}' was not found.") + return None + except Exception as e: + tdLog.info(f"error reading the json file: {e}") + return None + + if callable(modifyFunc): + modifyFunc(data) + + tempDir = os.path.join(tempfile.gettempdir(), 'json_templates') + try: + os.makedirs(tempDir, exist_ok=True) + except PermissionError: + tdLog.info(f"no sufficient permissions to create directory at '{tempDir}'.") + return None + except Exception as e: + tdLog.info(f"error creating temporary directory: {e}") + return None + + tempPath = os.path.join(tempDir, f"temp_{uuid.uuid4().hex}.json") + + try: + with open(tempPath, 'w', encoding='utf-8') as f: + json.dump(data, f, indent=2, ensure_ascii=False) + except Exception as e: + tdLog.info(f"error writing to temporary json file: {e}") + return None + + tdLog.info(f"create temporary json file successfully, file: {tempPath}") + return tempPath + + # delete file + def deleteFile(self, filename): + try: + if os.path.exists(filename): + os.remove(filename) + except Exception as err: + raise Exception(err) diff --git a/tests/army/query/function/test_function.py b/tests/army/query/function/test_function.py index 27e54407cc..3b84583b20 100644 --- a/tests/army/query/function/test_function.py +++ b/tests/army/query/function/test_function.py @@ -42,8 +42,8 @@ class TDTestCase(TBase): tdSql.execute("insert into d0 file '%s'" % datafile) tdSql.execute("CREATE TABLE `n1` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT, co NCHAR(10))") tdSql.execute("insert into n1 values(now, 1, null, '23')") - tdSql.execute("insert into n1 values(now, null, 3, '23')") - tdSql.execute("insert into n1 values(now, 5, 3, '23')") + tdSql.execute("insert into n1 values(now+1a, null, 3, '23')") + tdSql.execute("insert into n1 values(now+2a, 5, 3, '23')") def test_normal_query_new(self, testCase): # read sql from .sql file and execute diff --git a/tests/army/query/joinConst/full_outer.today.csv b/tests/army/query/joinConst/full_outer.today.csv new file mode 100644 index 0000000000..74bb393871 --- /dev/null +++ b/tests/army/query/joinConst/full_outer.today.csv @@ -0,0 +1,763 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a full join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a full join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a full join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a full join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a full join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a full join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a full join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a full join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + a | + NU. | + a | + NU. | + a | + +taos> select b.ts from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + +taos> select b.* from a1 a full join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + a | + NU. | + a | + NU. | + a | + +taos> select b.ts from a1 a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a full join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta full join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + NU. | + a | + NU. | + a | + NU. | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + NU. | + a | + NU. | + a | + NU. | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + NULL | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/full_outer.today.in b/tests/army/query/joinConst/full_outer.today.in new file mode 100644 index 0000000000..3a151cbcf2 --- /dev/null +++ b/tests/army/query/joinConst/full_outer.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a full join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a full join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a full join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a full join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a full join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a full join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a full join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a full join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a full join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a full join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a full join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta full join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/full_outer.today_.csv b/tests/army/query/joinConst/full_outer.today_.csv new file mode 100644 index 0000000000..35e15f4dbd --- /dev/null +++ b/tests/army/query/joinConst/full_outer.today_.csv @@ -0,0 +1,763 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a full join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a full join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a full join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a full join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a full join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a full join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a full join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a full join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + a | + NU. | + a | + NU. | + a | + +taos> select b.ts from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + NULL | NULL | NULL | + +taos> select b.* from a1 a full join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + a | + NU. | + a | + NU. | + a | + +taos> select b.ts from a1 a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a full join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a full join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + __today__ 00:00:00.000 | + NULL | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta full join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta full join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta full join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + NU. | + a | + NU. | + a | + NU. | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + NU. | + a | + NU. | + a | + NU. | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b full join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + NULL | + __tomorrow__ 00:00:00.000 | + NULL | + __tomorrow__ 00:00:02.000 | + NULL | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb full join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/joinConst/inner.constts.csv b/tests/army/query/joinConst/inner.constts.csv new file mode 100644 index 0000000000..717f20b460 --- /dev/null +++ b/tests/army/query/joinConst/inner.constts.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" where tb.ts=timestamp "__today__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" where tb.ts>timestamp "__today__ 00:00:00.000"; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" where tb.ts=timestamp "__today__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" where tb.ts>timestamp "__today__ 00:00:00.000"; + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" ; + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" ; + diff --git a/tests/army/query/joinConst/inner.constts.in b/tests/army/query/joinConst/inner.constts.in new file mode 100644 index 0000000000..008630a119 --- /dev/null +++ b/tests/army/query/joinConst/inner.constts.in @@ -0,0 +1,153 @@ +use test; +select * from a1 a join (select timestamp __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a join (select timestamp __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a join (select timestamp __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select timestamp __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a join (select timestamp __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a join (select timestamp __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select timestamp __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a join (select timestamp __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select timestamp __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp __today__ where tb.ts=timestamp __today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp __today__ where tb.ts>timestamp __today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select timestamp __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select * from (select timestamp __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select a.* from (select timestamp __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select timestamp __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select b.c from (select timestamp __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select b.ts1 from (select timestamp __today__ as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select timestamp __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp __today__ where tb.ts=timestamp __today__ order by tb.val; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp __today__ where tb.ts>timestamp __today__; + + + +select * from a1 a , (select timestamp __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select * from a1 a , (select timestamp __today__ as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +select a.* from a1 a , (select timestamp __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select timestamp __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select timestamp __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select timestamp __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts1 from a1 a , (select timestamp __today__ as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +select * from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.c from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select b.ts1 from a1 a , (select timestamp __today__ as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select * from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select a.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select * from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select timestamp __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp __today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp __today__ ; + +select * from (select timestamp __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select * from (select timestamp __today__ as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; +select a.* from (select timestamp __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select timestamp __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select timestamp __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts1 from (select timestamp __today__ as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select b.ts1 from (select timestamp __today__ as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select * from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select a.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.* from (select timestamp __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.c from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select timestamp __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select * from (select timestamp __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp __today__ order by tb.val; +select * from (select timestamp __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp __today__ ; + + + diff --git a/tests/army/query/joinConst/inner.constts2.csv b/tests/army/query/joinConst/inner.constts2.csv new file mode 100644 index 0000000000..36b3fa310e --- /dev/null +++ b/tests/army/query/joinConst/inner.constts2.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select a.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 301 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 302 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 303 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 304 | 1 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 401 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 402 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 403 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__tomorrow__ 00:00:00.000" where tb.ts=timestamp "__tomorrow__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 301 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 302 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 303 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 304 | 1 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 401 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 402 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 403 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__tomorrow__ 00:00:00.000" where tb.ts>timestamp "__tomorrow__ 00:00:00.000"; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 301 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 302 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 303 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 304 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 401 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 402 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 403 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 404 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__tomorrow__ 00:00:00.000" where tb.ts=timestamp "__tomorrow__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 301 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 302 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 303 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 304 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 401 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 402 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 403 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 404 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__tomorrow__ 00:00:00.000" where tb.ts>timestamp "__tomorrow__ 00:00:00.000"; + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1013 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select a.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 301 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 302 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 303 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 304 | 1 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 401 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 402 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 403 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__tomorrow__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 301 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 302 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 303 | 1 | + __tomorrow__ 00:00:00.000 | 103 | 1 | __tomorrow__ 00:00:00.000 | 304 | 1 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 401 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 402 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 403 | 2 | + __tomorrow__ 00:00:00.000 | 203 | 2 | __tomorrow__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__tomorrow__ 00:00:00.000" ; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __tomorrow__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select b.ts1 from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __tomorrow__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select a.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __tomorrow__ 00:00:00.000 | 103 | 1013 | + +taos> select b.* from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + +taos> select b.c from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__tomorrow__ 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __tomorrow__ 00:00:00.000 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 301 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 302 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 303 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 304 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 401 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 402 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 403 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 404 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__tomorrow__ 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:00.000 | 301 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 302 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 303 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 304 | 1 | __tomorrow__ 00:00:00.000 | 103 | 1 | + __tomorrow__ 00:00:00.000 | 401 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 402 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 403 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + __tomorrow__ 00:00:00.000 | 404 | 2 | __tomorrow__ 00:00:00.000 | 203 | 2 | + +taos> select * from (select timestamp "__tomorrow__ 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__tomorrow__ 00:00:00.000" ; + diff --git a/tests/army/query/joinConst/inner.constts3.csv b/tests/army/query/joinConst/inner.constts3.csv new file mode 100644 index 0000000000..7016d37580 --- /dev/null +++ b/tests/army/query/joinConst/inner.constts3.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:01.000 | 102 | 1012 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select a.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a join (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 301 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 302 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 303 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 304 | 1 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 401 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 402 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 403 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" + 1s where tb.ts=timestamp "__today__ 00:00:00.000" + 1s order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 301 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 302 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 303 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 304 | 1 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 401 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 402 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 403 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" + 1s where tb.ts>timestamp "__today__ 00:00:00.000" + 1s; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:01.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:01.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 301 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 302 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 303 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 304 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 401 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 402 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 403 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 404 | 2 | __today__ 00:00:01.000 | 202 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" + 1s where tb.ts=timestamp "__today__ 00:00:00.000" + 1s order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 301 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 302 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 303 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 304 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 401 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 402 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 403 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 404 | 2 | __today__ 00:00:01.000 | 202 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" + 1s where tb.ts>timestamp "__today__ 00:00:00.000" + 1s; + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select b.ts1 from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select a.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from a1 order by f) a , (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 301 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 302 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 303 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 304 | 1 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 401 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 402 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 403 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" + 1s order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 301 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 302 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 303 | 1 | + __today__ 00:00:01.000 | 102 | 1 | __today__ 00:00:01.000 | 304 | 1 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 401 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 402 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 403 | 2 | + __today__ 00:00:01.000 | 202 | 2 | __today__ 00:00:01.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" + 1s ; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:01.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:01.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:01.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:01.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + +taos> select a.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + +taos> select b.* from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + +taos> select b.c from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select timestamp "__today__ 00:00:00.000" + 1s as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 301 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 302 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 303 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 304 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 401 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 402 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 403 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 404 | 2 | __today__ 00:00:01.000 | 202 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=timestamp "__today__ 00:00:00.000" + 1s order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 301 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 302 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 303 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 304 | 1 | __today__ 00:00:01.000 | 102 | 1 | + __today__ 00:00:01.000 | 401 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 402 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 403 | 2 | __today__ 00:00:01.000 | 202 | 2 | + __today__ 00:00:01.000 | 404 | 2 | __today__ 00:00:01.000 | 202 | 2 | + +taos> select * from (select timestamp "__today__ 00:00:00.000" + 1s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>timestamp "__today__ 00:00:00.000" + 1s ; + diff --git a/tests/army/query/joinConst/inner.now.csv b/tests/army/query/joinConst/inner.now.csv new file mode 100644 index 0000000000..a682ed51ef --- /dev/null +++ b/tests/army/query/joinConst/inner.now.csv @@ -0,0 +1,377 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.* from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.*, b.ts from a1 a join (select now as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select b.c from a1 a join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a join (select now as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select a.* from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select b.c from (select now as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select b.ts from (select now as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + +taos> select * from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select * from a1 a , (select now as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + +taos> select a.* from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.* from a1 a , (select now as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.c from a1 a , (select now as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts from a1 a , (select now as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts1 from a1 a , (select now as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select b.ts1 from a1 a , (select now as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a , (select now as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now ; + +taos> select * from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select * from (select now as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + +taos> select a.* from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.* from (select now as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.c from (select now as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts from (select now as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.ts1 from (select now as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now order by tb.val; + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now ; + diff --git a/tests/army/query/joinConst/inner.now.in b/tests/army/query/joinConst/inner.now.in new file mode 100644 index 0000000000..6d1f72c4a4 --- /dev/null +++ b/tests/army/query/joinConst/inner.now.in @@ -0,0 +1,143 @@ +use test; +select * from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a join (select __const__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a join (select __const__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select a.* from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __const__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __const__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select b.c from (select __const__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __const__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; + + + +select * from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +select a.* from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __const__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts1 from a1 a , (select __const__ as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select b.ts1 from a1 a , (select __const__ as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __const__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ ; + +select * from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select * from (select __const__ as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; +select a.* from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __const__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __const__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __const__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select b.ts1 from (select __const__ as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select * from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ ; + + + diff --git a/tests/army/query/joinConst/inner.now_.csv b/tests/army/query/joinConst/inner.now_.csv new file mode 100644 index 0000000000..b5c3aafdd3 --- /dev/null +++ b/tests/army/query/joinConst/inner.now_.csv @@ -0,0 +1,377 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.* from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select a.*, b.ts from a1 a join (select now() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + +taos> select b.c from a1 a join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a join (select now() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select a.* from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + +taos> select b.* from (select now() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + +taos> select b.c from (select now() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select b.ts from (select now() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + +taos> select * from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select * from a1 a , (select now() as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + +taos> select a.* from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.* from a1 a , (select now() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + +taos> select b.c from a1 a , (select now() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts from a1 a , (select now() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + +taos> select b.ts1 from a1 a , (select now() as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select b.ts1 from a1 a , (select now() as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from a1 a , (select now() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from a1 a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select now() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() ; + +taos> select * from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select * from (select now() as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + +taos> select a.* from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.* from (select now() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + +taos> select b.c from (select now() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts from (select now() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select b.ts1 from (select now() as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + +taos> select * from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.* from (select now() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() order by tb.val; + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() ; + diff --git a/tests/army/query/joinConst/inner.today.csv b/tests/army/query/joinConst/inner.today.csv new file mode 100644 index 0000000000..b836987997 --- /dev/null +++ b/tests/army/query/joinConst/inner.today.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + +taos> select * from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + diff --git a/tests/army/query/joinConst/inner.today.in b/tests/army/query/joinConst/inner.today.in new file mode 100644 index 0000000000..fcd0bee97d --- /dev/null +++ b/tests/army/query/joinConst/inner.today.in @@ -0,0 +1,153 @@ +use test; +select * from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + + +select * from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +select a.* from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts1 from a1 a , (select __today__ as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select b.ts1 from a1 a , (select __today__ as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a , (select __today__ as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a , (select __today__ as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ ; + +select * from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ ; + + + diff --git a/tests/army/query/joinConst/inner.today_.csv b/tests/army/query/joinConst/inner.today_.csv new file mode 100644 index 0000000000..67f23560c8 --- /dev/null +++ b/tests/army/query/joinConst/inner.today_.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today() as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today() as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today() as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today() as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today() as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today() as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() ; + +taos> select * from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() ; + diff --git a/tests/army/query/joinConst/inner.today_ts.csv b/tests/army/query/joinConst/inner.today_ts.csv new file mode 100644 index 0000000000..097e398e17 --- /dev/null +++ b/tests/army/query/joinConst/inner.today_ts.csv @@ -0,0 +1,811 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b on a.ts = b.ts; +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +taos> select a.*, b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:01.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:02.000 | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a join (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" where tb.ts="2025-03-04 00:00:00.000" order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" where tb.ts>"2025-03-04 00:00:00.000"; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-05 00:00:03.000 | 204 | 2 | 2025-03-05 00:00:03.000 | 404 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" where tb.ts="2025-03-04 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" where tb.ts>"2025-03-04 00:00:00.000"; + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b where a.ts = b.ts; +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b where a.ts = b.ts; +taos> select b.ts1 from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from a1 order by f) a , (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" order by tb.val; +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" ; +taos> select * from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +==================================================================================================================== + | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================== + | 301 | 3011 | a | + | 302 | 3012 | a | + | 303 | 3013 | a | + | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +============================ + | + | + | + | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select "2025-03-04 00:00:00.000" as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +============================ + | + | + | + | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +======================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select "2025-03-04 00:00:00.000" as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts="2025-03-04 00:00:00.000" order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================== + | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select "2025-03-04 00:00:00.000" ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>"2025-03-04 00:00:00.000" ; + diff --git a/tests/army/query/joinConst/inner.tomorrow_ts.csv b/tests/army/query/joinConst/inner.tomorrow_ts.csv new file mode 100644 index 0000000000..8987ed2577 --- /dev/null +++ b/tests/army/query/joinConst/inner.tomorrow_ts.csv @@ -0,0 +1,969 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:01.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:00.000 | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-05 00:00:02.000 | + +taos> select b.c from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-05 00:00:03.000 | 204 | 2 | 2025-03-05 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a , (select today as ts1, f, g, 'a' from b1) b where a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:01.000 | 102 | 1012 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-05 00:00:00.000 | 103 | 1013 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-05 00:00:02.000 | 104 | 1014 | 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1011 | 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 301 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 302 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 303 | 1 | + 2025-03-04 00:00:00.000 | 101 | 1 | 2025-03-04 00:00:00.000 | 304 | 1 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 401 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 402 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 403 | 2 | + 2025-03-04 00:00:00.000 | 201 | 2 | 2025-03-04 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + +taos> select * from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts; + ts1 | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + 2025-03-04 00:00:01.000 | 102 | 1012 | + 2025-03-05 00:00:00.000 | 103 | 1013 | + 2025-03-05 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:01.000 | 302 | 3012 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:00.000 | 303 | 3013 | a | + 2025-03-04 00:00:00.000 | 2025-03-05 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + 2025-03-04 00:00:01.000 | + 2025-03-05 00:00:00.000 | + 2025-03-05 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + 2025-03-04 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + 2025-03-04 00:00:00.000 | 2025-03-04 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + 2025-03-04 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + 2025-03-04 00:00:00.000 | 301 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 302 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 303 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 304 | 1 | 2025-03-04 00:00:00.000 | 101 | 1 | + 2025-03-04 00:00:00.000 | 401 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 402 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 403 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + 2025-03-04 00:00:00.000 | 404 | 2 | 2025-03-04 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ; + diff --git a/tests/army/query/joinConst/left_anti.today.csv b/tests/army/query/joinConst/left_anti.today.csv new file mode 100644 index 0000000000..25d63dba19 --- /dev/null +++ b/tests/army/query/joinConst/left_anti.today.csv @@ -0,0 +1,365 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left anti join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left anti join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left anti join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left anti join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left anti join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select b.ts1,a.ts from a1 a left anti join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.c from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select * from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left anti join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left anti join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + +taos> select * from (select today as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/left_anti.today.in b/tests/army/query/joinConst/left_anti.today.in new file mode 100644 index 0000000000..5fa57a29db --- /dev/null +++ b/tests/army/query/joinConst/left_anti.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a left anti join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left anti join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left anti join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left anti join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left anti join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left anti join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left anti join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left anti join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left anti join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left anti join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left anti join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/left_anti.today_.csv b/tests/army/query/joinConst/left_anti.today_.csv new file mode 100644 index 0000000000..e8595eeb7f --- /dev/null +++ b/tests/army/query/joinConst/left_anti.today_.csv @@ -0,0 +1,365 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left anti join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left anti join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left anti join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left anti join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left anti join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + +taos> select b.ts1,a.ts from a1 a left anti join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + +taos> select b.c from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select b.ts from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select * from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left anti join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left anti join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left anti join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left anti join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left anti join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left anti join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts1; + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts; + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on a.ts = b.ts; + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left anti join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left anti join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/joinConst/left_outer.now.csv b/tests/army/query/joinConst/left_outer.now.csv new file mode 100644 index 0000000000..de72e37014 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.now.csv @@ -0,0 +1,490 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select now as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a left join (select now as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + NULL | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 201 | 2 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select a.* from (select now as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.c from (select now as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.g from (select now as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + g | +============== + 3011 | + 3012 | + 3013 | + 3014 | + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.c from (select now as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts,a.* from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | ts | f | g | +================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.*,b.ts from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts | +================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | + NULL | NULL | NULL | __today__ 00:00:01.000 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.ts,b.f from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | +======================================== + __today__ 00:00:00.000 | 301 | + __today__ 00:00:01.000 | 302 | + __tomorrow__ 00:00:00.000 | 303 | + __tomorrow__ 00:00:02.000 | 304 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts, a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | ts | f | g | +================================================================================ + __today__ 00:00:00.000 | NULL | NULL | NULL | + __today__ 00:00:01.000 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | NULL | NULL | NULL | + +taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.g from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + g | +============== + 3011 | + 3012 | + 3013 | + 3014 | + +taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select tb.val,tb.tg1,ta.* from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + val | tg1 | ts | val | tg1 | +================================================================================== + 404 | 1 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + val | tg2 | ts | val | tg2 | +================================================================================== + 304 | 1 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + val | tg2 | ts | val | tg2 | +================================================================================== + 301 | 1 | NULL | NULL | NULL | + 302 | 1 | NULL | NULL | NULL | + 303 | 1 | NULL | NULL | NULL | + 304 | 1 | NULL | NULL | NULL | + 401 | 2 | NULL | NULL | NULL | + 402 | 2 | NULL | NULL | NULL | + 403 | 2 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now where tb.ts=now order by tb.val; + val | tg2 | ts | val | tg2 | +================================================================================== + 301 | 1 | NULL | NULL | NULL | + 302 | 1 | NULL | NULL | NULL | + 303 | 1 | NULL | NULL | NULL | + 304 | 1 | NULL | NULL | NULL | + 401 | 2 | NULL | NULL | NULL | + 402 | 2 | NULL | NULL | NULL | + 403 | 2 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now where tb.ts>now; + diff --git a/tests/army/query/joinConst/left_outer.now.in b/tests/army/query/joinConst/left_outer.now.in new file mode 100644 index 0000000000..38279c0403 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.now.in @@ -0,0 +1,67 @@ +use test; +select * from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left join (select __const__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left join (select __const__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select a.* from (select __const__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.c from (select __const__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.g from (select __const__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select b.c from (select __const__ as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.ts,a.* from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select a.*,b.ts from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts,b.f from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts, a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.g from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select tb.val,tb.tg1,ta.* from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select tb.val,tb.tg2,ta.* from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select tb.val,tb.tg2,ta.* from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; +select tb.val,tb.tg2,ta.* from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val; +select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__; + + diff --git a/tests/army/query/joinConst/left_outer.now_.csv b/tests/army/query/joinConst/left_outer.now_.csv new file mode 100644 index 0000000000..2d5115143b --- /dev/null +++ b/tests/army/query/joinConst/left_outer.now_.csv @@ -0,0 +1,490 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select now() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select now() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.ts1,a.ts from a1 a left join (select now() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + NULL | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select now() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + NU. | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 201 | 2 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select a.* from (select now() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.c from (select now() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.g from (select now() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + g | +============== + 3011 | + 3012 | + 3013 | + 3014 | + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.c from (select now() as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts,a.* from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | ts | f | g | +================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.*,b.ts from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts | +================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | + NULL | NULL | NULL | __today__ 00:00:01.000 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.ts,b.f from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | +======================================== + __today__ 00:00:00.000 | 301 | + __today__ 00:00:01.000 | 302 | + __tomorrow__ 00:00:00.000 | 303 | + __tomorrow__ 00:00:02.000 | 304 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts, a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | ts | f | g | +================================================================================ + __today__ 00:00:00.000 | NULL | NULL | NULL | + __today__ 00:00:01.000 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | NULL | NULL | NULL | + +taos> select a.* from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.g from (select now() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + g | +============== + 3011 | + 3012 | + 3013 | + 3014 | + +taos> select b.c from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select now() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select tb.val,tb.tg1,ta.* from (select now() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + val | tg1 | ts | val | tg1 | +================================================================================== + 404 | 1 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + val | tg2 | ts | val | tg2 | +================================================================================== + 304 | 1 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val; + val | tg2 | ts | val | tg2 | +================================================================================== + 301 | 1 | NULL | NULL | NULL | + 302 | 1 | NULL | NULL | NULL | + 303 | 1 | NULL | NULL | NULL | + 304 | 1 | NULL | NULL | NULL | + 401 | 2 | NULL | NULL | NULL | + 402 | 2 | NULL | NULL | NULL | + 403 | 2 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select tb.val,tb.tg2,ta.* from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=now() where tb.ts=now() order by tb.val; + val | tg2 | ts | val | tg2 | +================================================================================== + 301 | 1 | NULL | NULL | NULL | + 302 | 1 | NULL | NULL | NULL | + 303 | 1 | NULL | NULL | NULL | + 304 | 1 | NULL | NULL | NULL | + 401 | 2 | NULL | NULL | NULL | + 402 | 2 | NULL | NULL | NULL | + 403 | 2 | NULL | NULL | NULL | + 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select now() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>now() where tb.ts>now(); + diff --git a/tests/army/query/joinConst/left_outer.today.csv b/tests/army/query/joinConst/left_outer.today.csv new file mode 100644 index 0000000000..998fef2b48 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today.csv @@ -0,0 +1,641 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/left_outer.today.in b/tests/army/query/joinConst/left_outer.today.in new file mode 100644 index 0000000000..193b976a62 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/left_outer.today_.csv b/tests/army/query/joinConst/left_outer.today_.csv new file mode 100644 index 0000000000..11319d4ca1 --- /dev/null +++ b/tests/army/query/joinConst/left_outer.today_.csv @@ -0,0 +1,641 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select * from a1 a left join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from a1 a left join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select a.*, b.ts from a1 a left join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + __today__ 00:00:01.000 | 102 | 1012 | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | + +taos> select b.c from a1 a left join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + NULL | __today__ 00:00:01.000 | + NULL | __tomorrow__ 00:00:00.000 | + NULL | __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | + __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | + +taos> select a.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from a1 a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + NULL | + NULL | + NULL | + NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | + __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | + __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/joinConst/left_semi.today.csv b/tests/army/query/joinConst/left_semi.today.csv new file mode 100644 index 0000000000..d11a8fe4df --- /dev/null +++ b/tests/army/query/joinConst/left_semi.today.csv @@ -0,0 +1,455 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left semi join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select * from a1 a left semi join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.* from a1 a left semi join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.*, b.ts from a1 a left semi join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + +taos> select b.c from a1 a left semi join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left semi join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left semi join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left semi join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/left_semi.today.in b/tests/army/query/joinConst/left_semi.today.in new file mode 100644 index 0000000000..72a4a7867c --- /dev/null +++ b/tests/army/query/joinConst/left_semi.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a left semi join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a left semi join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a left semi join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left semi join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left semi join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a left semi join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a left semi join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left semi join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a left semi join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a left semi join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left semi join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/left_semi.today_.csv b/tests/army/query/joinConst/left_semi.today_.csv new file mode 100644 index 0000000000..45c9e7c4db --- /dev/null +++ b/tests/army/query/joinConst/left_semi.today_.csv @@ -0,0 +1,455 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a left semi join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select * from a1 a left semi join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.* from a1 a left semi join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.*, b.ts from a1 a left semi join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + +taos> select b.c from a1 a left semi join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a left semi join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select a.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a left semi join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from a1 a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a left semi join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a left semi join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left semi join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left semi join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left semi join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b left semi join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left semi join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/joinConst/right_outer.today.csv b/tests/army/query/joinConst/right_outer.today.csv new file mode 100644 index 0000000000..e44401dc75 --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today.csv @@ -0,0 +1,638 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a right join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a right join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a right join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a right join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a right join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a right join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select * from (select today as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from (select today as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today; + diff --git a/tests/army/query/joinConst/right_outer.today.in b/tests/army/query/joinConst/right_outer.today.in new file mode 100644 index 0000000000..62d2b80e53 --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today.in @@ -0,0 +1,79 @@ +use test; +select * from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.* from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; +select a.*, b.ts from a1 a right join (select __today__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; +select b.c from a1 a right join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; +select b.ts1,a.ts from a1 a right join (select __today__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; +select * from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select a.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.* from a1 a right join (select __today__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.c from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from a1 a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select __today__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; +select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select __today__ + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + +select * from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; +select a.* from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; +select b.c from (select __today__ as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; +select b.ts1 from (select __today__ as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; +select * from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select a.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.* from (select __today__ as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.c from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select b.ts from (select __today__ as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; +select * from (select __today__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__today__ where tb.ts=__today__ order by tb.val; +select * from (select __today__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__today__ where tb.ts>__today__; + + diff --git a/tests/army/query/joinConst/right_outer.today_.csv b/tests/army/query/joinConst/right_outer.today_.csv new file mode 100644 index 0000000000..9dbbf595bc --- /dev/null +++ b/tests/army/query/joinConst/right_outer.today_.csv @@ -0,0 +1,638 @@ + +taos> use test; +Database changed. + +taos> select * from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select * from a1 a right join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts1 | f | g | 'a' | +================================================================================================================== + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a right join (select today() as ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select b.* from a1 a right join (select today() as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + +taos> select a.*, b.ts from a1 a right join (select today() as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; + ts | f | g | ts | +================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | + __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | + +taos> select b.c from a1 a right join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today() as ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | ts1 | ts | f | g | c | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; + ts1 | ts | f | g | c | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.ts1,a.ts from a1 a right join (select today() as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; + ts1 | ts | +==================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + __today__ 00:00:00.000 | __today__ 00:00:00.000 | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | ts1 | ts | f | g | 'a' | +============================================================================================================================================ + __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select a.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | + NULL | NULL | NULL | + NULL | NULL | NULL | + +taos> select b.* from a1 a right join (select today() as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from a1 a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta right join (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | + NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.ts, ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | + __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | + __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta right join (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + +taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta right join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | + __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | + +taos> select * from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select * from (select today() as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | ts | f | g | +================================================================================================================== + __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.* from (select today() as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; + ts1 | f | g | 'a' | +============================================================ + __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | 304 | 3014 | a | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today() as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; + c | +====== + a | + a | + a | + a | + NU. | + NU. | + NU. | + +taos> select b.ts1 from (select today() as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; + ts1 | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | + __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + c | +====== + a | + a | + a | + a | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + __today__ 00:00:01.000 | + __tomorrow__ 00:00:00.000 | + __tomorrow__ 00:00:02.000 | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | ts | f | g | +============================================================================================================================================ + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | + NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | + NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select a.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | f | g | +====================================================== + __today__ 00:00:00.000 | 101 | 1011 | + __today__ 00:00:01.000 | 102 | 1012 | + __tomorrow__ 00:00:00.000 | 103 | 1013 | + __tomorrow__ 00:00:02.000 | 104 | 1014 | + +taos> select b.* from (select today() as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts1 | ts | f | g | 'a' | +====================================================================================== + __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + NULL | NULL | NULL | NULL | NU. | + +taos> select b.c from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + c | +====== + a | + NU. | + NU. | + NU. | + +taos> select b.ts from (select today() as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; + ts | +========================== + __today__ 00:00:00.000 | + NULL | + NULL | + NULL | + +taos> select * from (select today() ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1; + ts | val | tg1 | ts | val | tg1 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val, tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | + NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | + NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today() where tb.ts=today() order by tb.val; + ts | val | tg2 | ts | val | tg2 | +============================================================================================================ + __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | + __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | + __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | + +taos> select * from (select today() ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb right join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today() where tb.ts>today(); + diff --git a/tests/army/query/test_join_const.py b/tests/army/query/test_join_const.py new file mode 100644 index 0000000000..2e0d698cc3 --- /dev/null +++ b/tests/army/query/test_join_const.py @@ -0,0 +1,191 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from frame import etool +from frame.etool import * +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.common import * + +class TDTestCase(TBase): + updatecfgDict = { + "slowLogScope": "none" + } + + today_ts = "" + tomorrow_ts = "" + + def insert_data(self): + tdLog.printNoPrefix("==========step1:create table") + + tdSql.execute("drop database if exists test") + tdSql.execute("create database test keep 36500") + tdSql.execute("use test") + tdSql.execute("create table sta(ts timestamp, f int, g int) tags (tg1 int, tg2 int, tg3 int);") + tdSql.execute("create table stb(ts timestamp, f int, g int) tags (tg1 int, tg2 int, tg3 int);") + tdSql.query("select today();") + self.today_ts = tdSql.res[0][0].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + self.today_date = tdSql.res[0][0].strftime('%Y-%m-%d') + tdSql.query("select today() + 1d;") + self.tomorrow_ts = tdSql.res[0][0].strftime('%Y-%m-%d %H:%M:%S.%f')[:-3] + self.tomorrow_date = tdSql.res[0][0].strftime('%Y-%m-%d') + + tdLog.printNoPrefix("==========step2:insert data") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.today_ts}', 101, 1011);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.today_ts}' + 1s, 102, 1012);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.tomorrow_ts}', 103, 1013);") + tdSql.execute(f"insert into a1 using sta tags(1, 1, 1) values('{self.tomorrow_ts}' + 2s, 104, 1014);") + + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.today_ts}', 201, 2011);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.today_ts}' + 1s, 202, 2012);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.tomorrow_ts}', 203, 2013);") + tdSql.execute(f"insert into a2 using sta tags(1, 2, 2) values('{self.tomorrow_ts}' + 3s, 204, 2014);") + + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.today_ts}', 301, 3011);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.today_ts}' + 1s, 302, 3012);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.tomorrow_ts}', 303, 3013);") + tdSql.execute(f"insert into b1 using stb tags(1, 1, 3) values('{self.tomorrow_ts}' + 2s, 304, 3014);") + + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.today_ts}', 401, 4011);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.today_ts}' + 1s, 402, 4012);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.tomorrow_ts}', 403, 4013);") + tdSql.execute(f"insert into b2 using stb tags(1, 2, 4) values('{self.tomorrow_ts}' + 3s, 404, 4014);") + + def replace_string(self, input_file, output_file, old_str, new_str): + script_dir = os.path.dirname(os.path.abspath(__file__)) + with open(f"{script_dir}/joinConst/{input_file}", 'r') as f_in, open(f"{script_dir}/joinConst/{output_file}", 'w') as f_out: + for line in f_in: + modified_line = line.replace(old_str, new_str) + f_out.write(modified_line) + + def replace_string2(self, input_file, output_file, old_str, new_str): + script_dir = os.path.dirname(os.path.abspath(__file__)) + with open(f"{script_dir}/joinConst/{input_file}", 'r') as f_in, open(f"{script_dir}/joinConst/{output_file}", 'w', newline="\r\n") as f_out: + for line in f_in: + modified_line = line.replace(old_str, new_str) + f_out.write(modified_line) + + def test_today_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + today() test") + self.replace_string(f'{testCase}.today.in', f'{testCase}.today_.in.tmp1', '__today__', 'today()') + self.replace_string(f'{testCase}.today_.csv', f'{testCase}.today_.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.today_.csv.tmp1', f'{testCase}.today_.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.today_.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today_.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + today test") + self.replace_string(f'{testCase}.today.in', f'{testCase}.today.in.tmp1', '__today__', 'today') + self.replace_string(f'{testCase}.today.csv', f'{testCase}.today.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.today.csv.tmp1', f'{testCase}.today.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.today.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.today.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + def test_now_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + now() test") + self.replace_string(f'{testCase}.now.in', f'{testCase}.now_.in.tmp1', '__const__', 'now()') + self.replace_string(f'{testCase}.now_.csv', f'{testCase}.now_.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.now_.csv.tmp1', f'{testCase}.now_.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.now_.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.now_.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + now test") + self.replace_string(f'{testCase}.now.in', f'{testCase}.now.in.tmp1', '__const__', 'now') + self.replace_string(f'{testCase}.now.csv', f'{testCase}.now.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.now.csv.tmp1', f'{testCase}.now.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.now.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.now.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + def test_constts_case(self, testCase): + tdLog.printNoPrefix(f"==========step:{testCase} + ts:{self.today_ts} test") + self.replace_string(f'{testCase}.constts.in', f'{testCase}.constts.in.tmp1', '__today__', f'"{self.today_ts}"') + self.replace_string(f'{testCase}.constts.csv', f'{testCase}.constts.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.constts.csv.tmp1', f'{testCase}.constts.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.constts.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.constts.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + ts:{self.tomorrow_ts} test") + self.replace_string(f'{testCase}.constts.in', f'{testCase}.constts2.in.tmp2', '__today__', f'"{self.tomorrow_ts}"') + self.replace_string(f'{testCase}.constts2.csv', f'{testCase}.constts2.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.constts2.csv.tmp1', f'{testCase}.constts2.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.constts2.in.tmp2") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.constts2.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + tdLog.printNoPrefix(f"==========step:{testCase} + ts:{self.today_ts} + 1s test") + self.replace_string(f'{testCase}.constts.in', f'{testCase}.constts3.in.tmp1', '__today__', f'"{self.today_ts}" + 1s') + self.replace_string(f'{testCase}.constts3.csv', f'{testCase}.constts3.csv.tmp1', '__today__', f'{self.today_date}') + self.replace_string2(f'{testCase}.constts3.csv.tmp1', f'{testCase}.constts3.csv.tmp2', '__tomorrow__', f'{self.tomorrow_date}') + # read sql from .sql file and execute + self.sqlFile = etool.curFile(__file__, f"joinConst/{testCase}.constts3.in.tmp1") + self.ansFile = etool.curFile(__file__, f"joinConst/{testCase}.constts3.csv.tmp2") + tdCom.compare_testcase_result(self.sqlFile, self.ansFile, testCase) + + + def test_nocheck_case(self): + tdLog.printNoPrefix(f"==========step:nocheck test") + tdSql.execute("select * from a1 a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + tdSql.execute("select * from a1 a join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + tdSql.execute("select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + tdSql.execute("select * from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts;") + tdSql.execute("select b.* from a1 a join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts;") + tdSql.execute("select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;") + tdSql.execute("select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;") + tdSql.execute("select * from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts;") + tdSql.execute("select b.* from a1 a , (select __const__ as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts;") + tdSql.execute("select * from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;") + tdSql.execute("select b.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;") + + def test_abnormal_case(self): + tdLog.printNoPrefix(f"==========step:abnormal case test") + tdSql.error(f"select * from a1 a join (select '{self.today_ts}' as ts from b1) b on a.ts = b.ts;") + tdSql.error(f"select * from a1 a join (select '{self.today_ts}' + 1s as ts from b1) b on a.ts = b.ts;") + tdSql.error(f"select * from a1 a left asof join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;") + tdSql.error(f"select * from a1 a left window join (select now as ts1, ts, f, g, 'a' c from b1) b window_offset(-1s, 1s);") + + def run(self): + tdLog.debug(f"start to excute {__file__}") + + self.insert_data() + + self.test_today_case("inner") + self.test_now_case("inner") + self.test_constts_case("inner") + + self.test_today_case("left_outer") + self.test_now_case("left_outer") + self.test_today_case("right_outer") + + self.test_today_case("full_outer") + self.test_today_case("left_semi") + self.test_today_case("left_anti") + + self.test_abnormal_case() + + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/army/tools/benchmark/basic/csv-export.py b/tests/army/tools/benchmark/basic/csv-export.py index 65ffb3e541..0bc2f3b106 100644 --- a/tests/army/tools/benchmark/basic/csv-export.py +++ b/tests/army/tools/benchmark/basic/csv-export.py @@ -121,20 +121,21 @@ class TDTestCase(TBase): else: # switch to another child table if batch != interlace_rows: - tdLog.exit(f"interlace_rows invalid. tbName={name} actual={batch} expected={interlace_rows} i={count} csv_file_name={csv_file_name}") + tdLog.exit(f"interlace rows is not as expected. tbname={name}, actual: {batch}, expected: {interlace_rows}, count: {count}, csv_file_name: {csv_file_name}") batch = 1 name = row[tbname_idx] # count ++ count += 1 # batch if batch != interlace_rows: - tdLog.exit(f"interlace_rows invalid. tbName={name} actual={batch} expected={interlace_rows} i={count} csv_file_name={csv_file_name}") + tdLog.exit(f"interlace rows is not as expected. tbname={name}, actual: {batch}, expected: {interlace_rows}, count: {count}, csv_file_name: {csv_file_name}") + # check all rows if count != all_rows: - tdLog.exit(f"all_rows invalid. actual={count} expected={all_rows} csv_file_name={csv_file_name}") + tdLog.exit(f"total rows is not as expected. actual: {count}, expected: {all_rows}, csv_file_name: {csv_file_name}") - tdLog.info(f"Check generate csv file successfully. csv_file_name={csv_file_name} count={count} interlace_rows={batch}") + tdLog.info(f"check generate csv file successfully. csv_file_name: {csv_file_name}, count: {count}, interlace_rows: {interlace_rows}") # check correct @@ -194,9 +195,9 @@ class TDTestCase(TBase): # check result - def check_result(self, jsonFile): + def check_result(self, json_file): # csv - with open(jsonFile) as file: + with open(json_file) as file: data = json.load(file) # read json @@ -208,25 +209,175 @@ class TDTestCase(TBase): self.check_stb_correct(data, database, stable) - def check_export_csv(self, benchmark, jsonFile, options=""): + def exec_benchmark(self, benchmark, json_file, options=""): + cmd = f"{benchmark} {options} -f {json_file}" + eos.exe(cmd) + + + def check_export_csv_main(self, benchmark, json_file, options=""): # clear self.clear_directory() # exec - cmd = f"{benchmark} {options} -f {jsonFile}" - eos.exe(cmd) + self.exec_benchmark(benchmark, json_file, options) # check result - self.check_result(jsonFile) + self.check_result(json_file) + def check_export_csv_others(self, benchmark, json_file, options=""): + # clear + self.clear_directory() + + # file ts interval second + new_json_file = self.genNewJson(json_file, self.func_csv_ts_interval_second) + self.exec_benchmark(benchmark, new_json_file, options) + self.check_file_line_count("./csv/data_20231115061320_20231115061321.csv", 10001) + self.deleteFile(new_json_file) + + # file ts interval minute + new_json_file = self.genNewJson(json_file, self.func_csv_ts_interval_minute) + self.exec_benchmark(benchmark, new_json_file, options) + self.check_file_line_count("./csv/data_202311150613_202311150614.csv", 10001) + self.deleteFile(new_json_file) + + # file ts interval hour + new_json_file = self.genNewJson(json_file, self.func_csv_ts_interval_hour) + self.exec_benchmark(benchmark, new_json_file, options) + self.check_file_line_count("./csv/data_2023111506_2023111507.csv", 10001) + self.deleteFile(new_json_file) + + # db precision us + new_json_file = self.genNewJson(json_file, self.func_db_precision_us) + self.exec_benchmark(benchmark, new_json_file, options) + self.check_file_line_count("./csv/data_20231115_20231116.csv", 10001) + self.deleteFile(new_json_file) + + # db precision ns + new_json_file = self.genNewJson(json_file, self.func_db_precision_ns) + self.exec_benchmark(benchmark, new_json_file, options) + self.check_file_line_count("./csv/data_20231115_20231116.csv", 10001) + self.deleteFile(new_json_file) + + # thread num + new_json_file = self.genNewJson(json_file, self.func_thread_num) + self.exec_benchmark(benchmark, new_json_file, options) + self.check_file_line_count("./csv/data_10.csv", 1001) + self.deleteFile(new_json_file) + + # create sql + new_json_file = self.genNewJson(json_file, self.func_create_sql) + self.exec_benchmark(benchmark, new_json_file, options) + self.check_file_line_count("./csv/create_stmt.txt", 2) + self.deleteFile(new_json_file) + + # gzip + new_json_file = self.genNewJson(json_file, self.func_gzip) + self.exec_benchmark(benchmark, new_json_file, options) + eos.exe("gunzip ./csv/data.csv.gz") + self.check_file_line_count("./csv/data.csv", 10001) + self.deleteFile(new_json_file) + + + def func_csv_ts_interval_second(self, data): + db = data['databases'][0] + stb = db["super_tables"][0] + stb['timestamp_step'] = '10' + stb['csv_ts_format'] = '%Y%m%d%H%M%S' + stb['csv_ts_interval'] = '1s' + + + def func_csv_ts_interval_minute(self, data): + db = data['databases'][0] + stb = db["super_tables"][0] + stb['timestamp_step'] = '600' + stb['csv_ts_format'] = '%Y%m%d%H%M' + stb['csv_ts_interval'] = '1m' + + + def func_csv_ts_interval_hour(self, data): + db = data['databases'][0] + stb = db["super_tables"][0] + stb['timestamp_step'] = '36000' + stb['csv_ts_format'] = '%Y%m%d%H' + stb['csv_ts_interval'] = '1h' + + + def func_db_precision_us(self, data): + db = data['databases'][0] + db['dbinfo']['precision'] = 'us' + stb = db["super_tables"][0] + stb['start_timestamp'] = 1700000000000000 + + + def func_db_precision_ns(self, data): + db = data['databases'][0] + db['dbinfo']['precision'] = 'ns' + stb = db["super_tables"][0] + stb['start_timestamp'] = 1700000000000000000 + + + def func_thread_num(self, data): + data['thread_count'] = 12 + db = data['databases'][0] + stb = db["super_tables"][0] + stb.pop('interlace_rows', None) + stb.pop('csv_ts_format', None) + stb.pop('csv_ts_interval', None) + + + def func_create_sql(self, data): + db = data['databases'][0] + dbinfo = db['dbinfo'] + dbinfo['buffer'] = 256 + dbinfo['cachemode'] = 'none' + stb = db["super_tables"][0] + stb['primary_key'] = 1 + stb['columns'][0] = { "type": "bool", "name": "bc", "encode": 'simple8b', 'compress': 'lz4', 'level': 'medium'} + stb['comment'] = "csv export sample" + stb['delay'] = 10 + stb['file_factor'] = 20 + stb['rollup'] = 'min' + stb['max_delay'] = '300s' + stb['watermark'] = '10m' + stb['columns'][1] = { "type": "float", "name": "fc", "min": 1, "sma": "yes"} + stb['columns'][2] = { "type": "double", "name": "dc", "min":10, "max":10, "sma": "yes"} + + + def func_gzip(self, data): + db = data['databases'][0] + stb = db["super_tables"][0] + stb.pop('csv_ts_format', None) + stb.pop('csv_ts_interval', None) + stb['csv_compress_level'] = "fast" + + + def check_file_line_count(self, filename, expected_lines): + try: + with open(filename, 'r', encoding='utf-8') as file: + actual_lines = sum(1 for line in file) + + if expected_lines >= 0: + is_correct = actual_lines == expected_lines + if not is_correct: + tdLog.exit(f"check csv data failed, actual: {actual_lines}, expected: {expected_lines}, filename: {filename}") + + except FileNotFoundError: + tdLog.exit(f"check csv data failed, file not exists. filename: {filename}") + + def run(self): # path benchmark = etool.benchMarkFile() - # do check interlace normal - json = "tools/benchmark/basic/json/csv-export.json" - self.check_export_csv(benchmark, json) + # check normal + json_file = "tools/benchmark/basic/json/csv-export.json" + self.check_export_csv_main(benchmark, json_file) + + # check others + json_file = "tools/benchmark/basic/json/csv-export-template.json" + self.check_export_csv_others(benchmark, json_file) + def stop(self): tdSql.close() diff --git a/tests/army/tools/benchmark/basic/json/csv-export-template.json b/tests/army/tools/benchmark/basic/json/csv-export-template.json new file mode 100644 index 0000000000..bcb810007f --- /dev/null +++ b/tests/army/tools/benchmark/basic/json/csv-export-template.json @@ -0,0 +1,54 @@ +{ + "filetype": "csvfile", + "output_dir": "./csv", + "databases": [ + { + "dbinfo": { + "name": "csvdb", + "precision": "ms" + }, + "super_tables": [ + { + "name": "stb", + "childtable_count": 1010, + "insert_rows": 1000, + "interlace_rows": 1, + "childtable_prefix": "d", + "timestamp_step": 1000000, + "start_timestamp":1700000000000, + "childtable_from": 1000, + "childtable_to": 1010, + "csv_file_prefix": "data", + "csv_ts_format": "%Y%m%d", + "csv_ts_interval": "1d", + "csv_output_header": "yes", + "csv_tbname_alias": "device_id", + "csv_compress_level": "none", + "columns": [ + { "type": "bool", "name": "bc"}, + { "type": "float", "name": "fc", "min": 1}, + { "type": "double", "name": "dc", "min":10, "max":10}, + { "type": "tinyint", "name": "ti"}, + { "type": "smallint", "name": "si"}, + { "type": "int", "name": "ic", "fillNull":"false"}, + { "type": "bigint", "name": "bi"}, + { "type": "utinyint", "name": "uti"}, + { "type": "usmallint", "name": "usi", "min":100, "max":120}, + { "type": "uint", "name": "ui"}, + { "type": "ubigint", "name": "ubi"}, + { "type": "binary", "name": "bin", "len": 16}, + { "type": "nchar", "name": "nch", "len": 16} + ], + "tags": [ + {"type": "tinyint", "name": "groupid","max": 10,"min": 1}, + {"type": "binary", "name": "location", "len": 16, + "values": ["San Francisco", "Los Angles", "San Diego", + "San Jose", "Palo Alto", "Campbell", "Mountain View", + "Sunnyvale", "Santa Clara", "Cupertino"] + } + ] + } + ] + } + ] +} diff --git a/tests/army/tools/benchmark/basic/json/queryErrorBatchNoMix.json b/tests/army/tools/benchmark/basic/json/queryErrorBatchNoMix.json new file mode 100644 index 0000000000..97b542b789 --- /dev/null +++ b/tests/army/tools/benchmark/basic/json/queryErrorBatchNoMix.json @@ -0,0 +1,36 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "test", + "query_times": 5, + "query_mode": "taosc", + "specified_table_query": { + "concurrent": 5, + "query_interval": 0, + "mixed_query": "no", + "batch_query": "yes", + "sqls": [ + { + "sql": "select last_row(*) from test.meters" + }, + { + "sql": "select count(*) from test.meters" + }, + { + "sql": "select * from test.d0", + "result": "./query_res1.txt" + }, + { + "sql": "select count(*) from test.d1" + }, + { + "sql": "select * from test.d2" + } + ] + } +} diff --git a/tests/army/tools/benchmark/basic/json/queryErrorBatchRest.json b/tests/army/tools/benchmark/basic/json/queryErrorBatchRest.json new file mode 100644 index 0000000000..d47ce55ae4 --- /dev/null +++ b/tests/army/tools/benchmark/basic/json/queryErrorBatchRest.json @@ -0,0 +1,36 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "test", + "query_times": 5, + "query_mode": "rest", + "specified_table_query": { + "concurrent": 5, + "query_interval": 1000, + "mixed_query": "yes", + "batch_query": "yes", + "sqls": [ + { + "sql": "select last_row(*) from test.meters" + }, + { + "sql": "select count(*) from test.meters" + }, + { + "sql": "select * from test.d0", + "result": "./query_res1.txt" + }, + { + "sql": "select count(*) from test.d1" + }, + { + "sql": "select * from test.d2" + } + ] + } +} diff --git a/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatch.json b/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatch.json new file mode 100644 index 0000000000..6740c585c3 --- /dev/null +++ b/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatch.json @@ -0,0 +1,36 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "test", + "query_times": 5, + "query_mode": "taosc", + "specified_table_query": { + "concurrent": 5, + "query_interval": 1000, + "mixed_query": "yes", + "batch_query": "yes", + "sqls": [ + { + "sql": "select last_row(*) from test.meters" + }, + { + "sql": "select count(*) from test.meters" + }, + { + "sql": "select * from test.d0", + "result": "./query_res1.txt" + }, + { + "sql": "select count(*) from test.d1" + }, + { + "sql": "select * from test.d2" + } + ] + } +} diff --git a/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatchRest.json b/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatchRest.json new file mode 100644 index 0000000000..b2ffbe1434 --- /dev/null +++ b/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatchRest.json @@ -0,0 +1,36 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "test", + "query_times": 5, + "query_mode": "taosc", + "specified_table_query": { + "concurrent": 5, + "query_interval": 100, + "mixed_query": "yes", + "batch_query": "no", + "sqls": [ + { + "sql": "select last_row(*) from test.meters" + }, + { + "sql": "select count(*) from test.meters" + }, + { + "sql": "select * from test.d0", + "result": "./query_res1.txt" + }, + { + "sql": "select count(*) from test.d1" + }, + { + "sql": "select * from test.d2" + } + ] + } +} diff --git a/tests/army/tools/benchmark/basic/queryMain.py b/tests/army/tools/benchmark/basic/queryMain.py index bd6fa9ca31..2c7f45c975 100644 --- a/tests/army/tools/benchmark/basic/queryMain.py +++ b/tests/army/tools/benchmark/basic/queryMain.py @@ -90,15 +90,15 @@ class TDTestCase(TBase): fval = float(value) # compare if equal and fval != expect: - tdLog.exit(f"check not expect. expect:{expect} real:{fval}, key:{key} end:{end} output:\n{output}") + tdLog.exit(f"check not expect. expect:{expect} real:{fval}, key:'{key}' end:'{end}' output:\n{output}") elif equal == False and fval <= expect: - tdLog.exit(f"failed because {fval} <= {expect}, key:{key} end:{end} output:\n{output}") + tdLog.exit(f"failed because {fval} <= {expect}, key:'{key}' end:'{end}' output:\n{output}") else: # succ if equal: - tdLog.info(f"check successfully. key:{key} expect:{expect} real:{fval}") + tdLog.info(f"check successfully. key:'{key}' expect:{expect} real:{fval}") else: - tdLog.info(f"check successfully. key:{key} {fval} > {expect}") + tdLog.info(f"check successfully. key:'{key}' {fval} > {expect}") def checkAfterRun(self, benchmark, jsonFile, specMode, tbCnt): @@ -128,16 +128,24 @@ class TDTestCase(TBase): sqls = data[label]["sqls"] - # mix + # batch_query + try: + batchQuery = data[label]["batch_query"] + except: + batchQuery = "no" + + # mixed_query try: mixedQuery = data[label]["mixed_query"] except: mixedQuery = "no" - tdLog.info(f"queryTimes={queryTimes} concurrent={concurrent} mixedQuery={mixedQuery} len(sqls)={len(sqls)} label={label}\n") + tdLog.info(f"queryTimes={queryTimes} concurrent={concurrent} mixedQuery={mixedQuery} " + f"batchQuery={batchQuery} len(sqls)={len(sqls)} label={label}\n") - totalQueries = 0 + totalQueries = 0 threadQueries = 0 + QPS = 10 if continueIfFail.lower() == "yes": allEnd = " " @@ -154,13 +162,20 @@ class TDTestCase(TBase): minKey = "min:" else: # spec mixed or super + if specMode: - # spec totalQueries = queryTimes * len(sqls) + # spec mixed + if batchQuery.lower() == "yes": + # batch + threadQueries = len(sqls) + QPS = 2 + else: + threadQueries = totalQueries else: # super totalQueries = queryTimes * len(sqls) * tbCnt - threadQueries = totalQueries + threadQueries = totalQueries nSql = len(sqls) if specMode and nSql < concurrent : @@ -182,7 +197,7 @@ class TDTestCase(TBase): ["p99: ", "s", 0, False], ["INFO: Spend ", " ", 0, False], ["completed total queries: ", ",", totalQueries, True], - ["the QPS of all threads:", allEnd, 10 , False] # all qps need > 5 + ["the QPS of all threads:", allEnd, QPS , False] # all qps need > 5 ] # check @@ -196,6 +211,7 @@ class TDTestCase(TBase): args = [ ["./tools/benchmark/basic/json/queryModeSpec", True], ["./tools/benchmark/basic/json/queryModeSpecMix", True], + ["./tools/benchmark/basic/json/queryModeSpecMixBatch", True], ["./tools/benchmark/basic/json/queryModeSuper", False] ] @@ -222,8 +238,9 @@ class TDTestCase(TBase): self.expectFailed(f"{benchmark} -f ./tools/benchmark/basic/json/queryErrorBothSpecSuper.json") # json format error self.expectFailed(f"{benchmark} -f ./tools/benchmark/basic/json/queryErrorFormat.json") - - + # batch query + self.expectFailed(f"{benchmark} -f ./tools/benchmark/basic/json/queryErrorBatchNoMix.json") + self.expectFailed(f"{benchmark} -f ./tools/benchmark/basic/json/queryErrorBatchRest.json") def run(self): tbCnt = 10 diff --git a/tests/system-test/2-query/limit.py b/tests/system-test/2-query/limit.py index e6736704f7..34944a1282 100644 --- a/tests/system-test/2-query/limit.py +++ b/tests/system-test/2-query/limit.py @@ -360,7 +360,19 @@ class TDTestCase: tdSql.checkRows(0) tdLog.info("check db1 vgroups 1 limit 1 offset 100 successfully!") - + def ts6080(self): + tdLog.printNoPrefix("======== test case 6080: ") + tdSql.execute("create database db6080 vgroups 1;") + tdSql.execute("use db6080;") + tdSql.execute("create table db6080.st(ts timestamp, age int) tags(area int);") + tdSql.execute("create table db6080.t1 using db6080.st tags(1);") + + tdSql.Execute("insert into db6080.t1 values(1537146000000, 1);") + tdSql.Execute("insert into db6080.t1 values(1537146000001, 2);") + + tdSql.query("select ts, age from (select ts, age from db6080.t1 order by ts limit 1) where ts > 1537146000000;") + tdSql.checkRows(0) + def run(self): # tdSql.prepare() self.prepareTestEnv() @@ -368,6 +380,7 @@ class TDTestCase: # one vgroup diff more than one vgroup check self.checkVGroups() + def stop(self): diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1ee2bc4ce6..110a644e90 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -19,8 +19,7 @@ IF(TD_WEBSOCKET) PATCH_COMMAND COMMAND git clean -f -d BUILD_COMMAND - COMMAND cargo update - COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features rustls + COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release --locked -p taos-ws-sys --features rustls INSTALL_COMMAND COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include @@ -38,8 +37,7 @@ IF(TD_WEBSOCKET) PATCH_COMMAND COMMAND git clean -f -d BUILD_COMMAND - COMMAND cargo update - COMMAND cargo build --release -p taos-ws-sys --features rustls + COMMAND cargo build --release --locked -p taos-ws-sys --features rustls INSTALL_COMMAND COMMAND cp target/release/taosws.dll ${CMAKE_BINARY_DIR}/build/lib COMMAND cp target/release/taosws.dll.lib ${CMAKE_BINARY_DIR}/build/lib/taosws.lib @@ -58,8 +56,7 @@ IF(TD_WEBSOCKET) PATCH_COMMAND COMMAND git clean -f -d BUILD_COMMAND - COMMAND cargo update - COMMAND cargo build --release -p taos-ws-sys --features rustls + COMMAND cargo build --release --locked -p taos-ws-sys --features rustls INSTALL_COMMAND COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include diff --git a/tools/taos-tools/inc/bench.h b/tools/taos-tools/inc/bench.h index c413d953b7..dfb543cb89 100644 --- a/tools/taos-tools/inc/bench.h +++ b/tools/taos-tools/inc/bench.h @@ -665,6 +665,7 @@ typedef struct SpecifiedQueryInfo_S { TAOS_RES *res[MAX_QUERY_SQL_COUNT]; uint64_t totalQueried; bool mixed_query; + bool batchQuery; // mixed query have batch and no batch query // error rate uint64_t totalFail; } SpecifiedQueryInfo; diff --git a/tools/taos-tools/src/benchCsv.c b/tools/taos-tools/src/benchCsv.c index f8c43dbb97..5ad532d4a8 100644 --- a/tools/taos-tools/src/benchCsv.c +++ b/tools/taos-tools/src/benchCsv.c @@ -355,11 +355,6 @@ int csvGenCreateDbSql(SDataBase* db, char* buf, int size) { pos += snprintf(buf + pos, size - pos, g_arguments->escape_character ? "`%s`" : "%s", db->dbName); if (pos <= 0 || pos >= size) return -1; - if (-1 != g_arguments->inputted_vgroups) { - pos += snprintf(buf + pos, size - pos, " VGROUPS %d", g_arguments->inputted_vgroups); - if (pos <= 0 || pos >= size) return -1; - } - if (db->cfgs) { for (size_t i = 0; i < db->cfgs->size; ++i) { SDbCfg* cfg = benchArrayGet(db->cfgs, i); diff --git a/tools/taos-tools/src/benchJsonOpt.c b/tools/taos-tools/src/benchJsonOpt.c index 5b992b388e..9bbecebe65 100644 --- a/tools/taos-tools/src/benchJsonOpt.c +++ b/tools/taos-tools/src/benchJsonOpt.c @@ -1860,6 +1860,23 @@ int32_t readSpecQueryJson(tools_cJSON * specifiedQuery) { } } + // batchQuery + tools_cJSON *batchQueryObj = + tools_cJSON_GetObjectItem(specifiedQuery, "batch_query"); + if (tools_cJSON_IsString(batchQueryObj)) { + if (0 == strcasecmp(batchQueryObj->valuestring, "yes")) { + g_queryInfo.specifiedQueryInfo.batchQuery = true; + infoPrint("%s\n","batch_query is True"); + } else if (0 == strcasecmp(batchQueryObj->valuestring, "no")) { + g_queryInfo.specifiedQueryInfo.batchQuery = false; + infoPrint("%s\n","batch_query is False"); + } else { + errorPrint("Invalid batch_query value: %s\n", + batchQueryObj->valuestring); + return -1; + } + } + tools_cJSON *concurrent = tools_cJSON_GetObjectItem(specifiedQuery, "concurrent"); if (tools_cJSON_IsNumber(concurrent)) { diff --git a/tools/taos-tools/src/benchMain.c b/tools/taos-tools/src/benchMain.c index e82da29468..16b3e3a617 100644 --- a/tools/taos-tools/src/benchMain.c +++ b/tools/taos-tools/src/benchMain.c @@ -47,7 +47,7 @@ void* benchCancelHandler(void* arg) { } #endif -void checkArgumentValid() { +int checkArgumentValid() { // check prepared_rand valid if(g_arguments->prepared_rand < g_arguments->reqPerReq) { infoPrint("prepared_rand(%"PRIu64") < num_of_records_per_req(%d), so set num_of_records_per_req = prepared_rand\n", @@ -64,13 +64,32 @@ void checkArgumentValid() { false, 1)) { errorPrint("%s", "Failed to convert server address\n"); - return; + return -1; } encodeAuthBase64(); g_arguments->rest_server_ver_major = getServerVersionRest(g_arguments->port); } + // check batch query + if (g_arguments->test_mode == QUERY_TEST) { + if (g_queryInfo.specifiedQueryInfo.batchQuery) { + // batch_query = yes + if (!g_queryInfo.specifiedQueryInfo.mixed_query) { + // mixed_query = no + errorPrint("%s\n", "batch_query = yes require mixed_query is yes"); + return -1; + } + + // rest not support + if (g_queryInfo.iface == REST_IFACE) { + errorPrint("%s\n", "batch_query = yes not support restful."); + return -1; + } + } + } + + return 0; } int main(int argc, char* argv[]) { @@ -144,7 +163,11 @@ int main(int argc, char* argv[]) { } infoPrint("client version: %s\n", taos_get_client_info()); - checkArgumentValid(); + if (checkArgumentValid()) { + errorPrint("failed to readJsonConfig %s\n", g_arguments->metaFile); + exitLog(); + return -1; + } if (g_arguments->test_mode == INSERT_TEST) { if (insertTestProcess()) { diff --git a/tools/taos-tools/src/benchQuery.c b/tools/taos-tools/src/benchQuery.c index 0de71d8b18..8be8bf9f6c 100644 --- a/tools/taos-tools/src/benchQuery.c +++ b/tools/taos-tools/src/benchQuery.c @@ -80,10 +80,15 @@ int selectAndGetResult(qThreadInfo *pThreadInfo, char *command, bool record) { } // interlligent sleep -void autoSleep(uint64_t interval, uint64_t delay ) { +int32_t autoSleep(uint64_t interval, uint64_t delay ) { + int32_t msleep = 0; if (delay < interval * 1000) { - toolsMsleep((int32_t)(interval * 1000 - delay)); // ms + msleep = (int32_t)((interval - delay/1000)); + infoPrint("do sleep %dms ...\n", msleep); + toolsMsleep(msleep); // ms + debugPrint("%s\n","do sleep end"); } + return msleep; } // reset @@ -140,10 +145,13 @@ static void *specQueryMixThread(void *sarg) { int64_t st = 0; int64_t et = 0; - int64_t startTs = toolsGetTimestampMs(); - int64_t lastPrintTime = startTs; - uint64_t queryTimes = g_queryInfo.specifiedQueryInfo.queryTimes; - uint64_t interval = g_queryInfo.specifiedQueryInfo.queryInterval; + int64_t startTs = toolsGetTimestampMs(); + int64_t lastPrintTime = startTs; + // batchQuery + bool batchQuery = g_queryInfo.specifiedQueryInfo.batchQuery; + uint64_t queryTimes = batchQuery ? 1 : g_queryInfo.specifiedQueryInfo.queryTimes; + uint64_t interval = batchQuery ? 0 : g_queryInfo.specifiedQueryInfo.queryInterval; + pThreadInfo->query_delay_list = benchArrayInit(queryTimes, sizeof(int64_t)); for (int i = pThreadInfo->start_sql; i <= pThreadInfo->end_sql; ++i) { SSQL * sql = benchArrayGet(g_queryInfo.specifiedQueryInfo.sqls, i); @@ -382,7 +390,7 @@ static void *stbQueryThread(void *sarg) { // --------------------------------- firse level function ------------------------------ // -void totalChildQuery(qThreadInfo* infos, int threadCnt, int64_t spend) { +void totalChildQuery(qThreadInfo* infos, int threadCnt, int64_t spend, BArray *pDelays) { // valid check if (infos == NULL || threadCnt == 0) { return ; @@ -444,9 +452,11 @@ void totalChildQuery(qThreadInfo* infos, int threadCnt, int64_t spend) { (int32_t)(delay_list->size * 0.99)))/1E6, *(int64_t *)(benchArrayGet(delay_list, (int32_t)(delay_list->size - 1)))/1E6); - } else { - errorPrint("%s() LN%d, delay_list size: %"PRId64"\n", - __func__, __LINE__, (int64_t)delay_list->size); + } + + // copy to another + if (pDelays) { + benchArrayAddBatch(pDelays, delay_list->pData, delay_list->size, false); } benchArrayDestroy(delay_list); } @@ -547,7 +557,7 @@ static int stbQuery(uint16_t iface, char* dbName) { } // total show - totalChildQuery(threadInfos, threadCnt, end - start); + totalChildQuery(threadInfos, threadCnt, end - start, NULL); ret = 0; @@ -825,7 +835,7 @@ static int specQueryMix(uint16_t iface, char* dbName) { } // statistic - totalChildQuery(infos, threadCnt, end - start); + totalChildQuery(infos, threadCnt, end - start, NULL); ret = 0; OVER: @@ -838,6 +848,206 @@ OVER: return ret; } +void totalBatchQuery(int32_t allSleep, BArray *pDelays) { + // sort + qsort(pDelays->pData, pDelays->size, pDelays->elemSize, compare); + + // total delays + double totalDelays = 0; + for (size_t i = 0; i < pDelays->size; i++) { + int64_t *delay = benchArrayGet(pDelays, i); + totalDelays += *delay; + } + + printf("\n"); + // show sleep times + if (allSleep > 0) { + infoPrint("All sleep spend: %.3fs\n", (float)allSleep/1000); + } + + // show P90 ... + if (pDelays->size) { + infoPrint( + "Total delay: " + "min delay: %.6fs, " + "avg delay: %.6fs, " + "p90: %.6fs, " + "p95: %.6fs, " + "p99: %.6fs, " + "max: %.6fs\n", + *(int64_t *)(benchArrayGet(pDelays, 0))/1E6, + (double)totalDelays/pDelays->size/1E6, + *(int64_t *)(benchArrayGet(pDelays, + (int32_t)(pDelays->size * 0.9)))/1E6, + *(int64_t *)(benchArrayGet(pDelays, + (int32_t)(pDelays->size * 0.95)))/1E6, + *(int64_t *)(benchArrayGet(pDelays, + (int32_t)(pDelays->size * 0.99)))/1E6, + *(int64_t *)(benchArrayGet(pDelays, + (int32_t)(pDelays->size - 1)))/1E6); + } +} + +// +// specQuery Mix Batch +// +static int specQueryBatch(uint16_t iface, char* dbName) { + // init + BArray *pDelays = NULL; + int ret = -1; + int nConcurrent = g_queryInfo.specifiedQueryInfo.concurrent; + uint64_t interval = g_queryInfo.specifiedQueryInfo.queryInterval; + pthread_t * pids = benchCalloc(nConcurrent, sizeof(pthread_t), true); + qThreadInfo *infos = benchCalloc(nConcurrent, sizeof(qThreadInfo), true); + infoPrint("start batch query, sleep interval:%" PRIu64 "ms query times:%" PRIu64 " thread:%d \n", + interval, g_queryInfo.query_times, nConcurrent); + + // concurent calc + int total_sql_num = g_queryInfo.specifiedQueryInfo.sqls->size; + int start_sql = 0; + int a = total_sql_num / nConcurrent; + if (a < 1) { + warnPrint("sqls num:%d < concurent:%d, set concurrent %d\n", total_sql_num, nConcurrent, nConcurrent); + nConcurrent = total_sql_num; + a = 1; + } + int b = 0; + if (nConcurrent != 0) { + b = total_sql_num % nConcurrent; + } + + // + // connect + // + int connCnt = 0; + for (int i = 0; i < nConcurrent; ++i) { + qThreadInfo *pThreadInfo = infos + i; + // create conn + if (initQueryConn(pThreadInfo, iface)){ + ret = -1; + goto OVER; + } + + connCnt ++; + } + + + // reset total + g_queryInfo.specifiedQueryInfo.totalQueried = 0; + g_queryInfo.specifiedQueryInfo.totalFail = 0; + + // + // running + // + int threadCnt = 0; + int allSleep = 0; + pDelays = benchArrayInit(10, sizeof(int64_t)); + for (int m = 0; m < g_queryInfo.query_times; ++m) { + // reset + threadCnt = 0; + start_sql = 0; + + // create thread + for (int i = 0; i < nConcurrent; ++i) { + qThreadInfo *pThreadInfo = infos + i; + pThreadInfo->threadID = i; + pThreadInfo->start_sql = start_sql; + pThreadInfo->end_sql = i < b ? start_sql + a : start_sql + a - 1; + start_sql = pThreadInfo->end_sql + 1; + pThreadInfo->total_delay = 0; + // total zero + pThreadInfo->nSucc = 0; + pThreadInfo->nFail = 0; + + // main run + int code = pthread_create(pids + i, NULL, specQueryMixThread, pThreadInfo); + if (code != 0) { + errorPrint("failed specQueryBatchThread create. error code =%d \n", code); + break; + } + + threadCnt ++; + } + + bool needExit = false; + if (threadCnt != nConcurrent) { + // if failed, set termainte flag true like ctrl+c exit + needExit = true; + g_arguments->terminate = true; + } + + // wait thread finished + int64_t start = toolsGetTimestampUs(); + for (int i = 0; i < threadCnt; ++i) { + pthread_join(pids[i], NULL); + qThreadInfo *pThreadInfo = infos + i; + // total queries + g_queryInfo.specifiedQueryInfo.totalQueried += pThreadInfo->nSucc; + if (g_arguments->continueIfFail == YES_IF_FAILED) { + // yes need add failed count + g_queryInfo.specifiedQueryInfo.totalQueried += pThreadInfo->nFail; + g_queryInfo.specifiedQueryInfo.totalFail += pThreadInfo->nFail; + } + + // destory + if (needExit) { + benchArrayDestroy(pThreadInfo->query_delay_list); + pThreadInfo->query_delay_list = NULL; + } + } + int64_t end = toolsGetTimestampUs(); + + // create + if (needExit) { + errorPrint("failed to create thread. expect nConcurrent=%d real threadCnt=%d, exit testing.\n", nConcurrent, threadCnt); + goto OVER; + } + + // batch total + printf("\n"); + totalChildQuery(infos, threadCnt, end - start, pDelays); + + // show batch total + int64_t delay = end - start; + infoPrint("count:%d execute batch spend: %" PRId64 "ms\n", m + 1, delay/1000); + + // sleep + if ( g_queryInfo.specifiedQueryInfo.batchQuery && interval > 0) { + allSleep += autoSleep(interval, delay); + } + + // check cancel + if(g_arguments->terminate) { + break; + } + } + ret = 0; + + // all total + totalBatchQuery(allSleep, pDelays); + +OVER: + // close conn + for (int i = 0; i < connCnt; ++i) { + qThreadInfo *pThreadInfo = infos + i; + closeQueryConn(pThreadInfo, iface); + } + + // free threads + tmfree(pids); + tmfree(infos); + + // free sqls + freeSpecialQueryInfo(); + + // free delays + if (pDelays) { + benchArrayDestroy(pDelays); + } + + return ret; +} + // total query for end void totalQuery(int64_t spends) { // total QPS @@ -903,14 +1113,19 @@ int queryTestProcess() { // start running // - uint64_t startTs = toolsGetTimestampMs(); if(g_queryInfo.specifiedQueryInfo.sqls && g_queryInfo.specifiedQueryInfo.sqls->size > 0) { // specified table if (g_queryInfo.specifiedQueryInfo.mixed_query) { // mixed - if (specQueryMix(g_queryInfo.iface, g_queryInfo.dbName)) { - return -1; + if(g_queryInfo.specifiedQueryInfo.batchQuery) { + if (specQueryBatch(g_queryInfo.iface, g_queryInfo.dbName)) { + return -1; + } + } else { + if (specQueryMix(g_queryInfo.iface, g_queryInfo.dbName)) { + return -1; + } } } else { // no mixied diff --git a/tools/tdgpt/README.md b/tools/tdgpt/README.md index 0b61f8bcef..d67c6e2f91 100644 --- a/tools/tdgpt/README.md +++ b/tools/tdgpt/README.md @@ -14,7 +14,8 @@ 1. [Contributing](#12-contributing) # 1. Introduction -tdanalytics: an analytic platform for tdengine + +TDgpt: an analytic platform for TDengine # 2. Documentation @@ -70,7 +71,7 @@ cd script && ./release.sh After the packaging is completed, you will find the tarball in the `release` directory. ```bash -ls -lht /root/tdanalytics/release +ls -lht release -rw-rw-r-- 1 root root 74K Feb 21 17:04 TDengine-enterprise-anode-1.0.1.tar.gz ``` @@ -111,16 +112,16 @@ http = 127.0.0.1:6090 The command `rmtaosanode` will remove the installed taosanode from your system. Note that the python environment won't removed by this script, you need to remove it mannually. # 8. Testing -we use github Actions to run the test suit. Please refer to the file [.github/workflows/python-package.yml](https://github.com/taosdata/tdanalytics/.github/workflows/python-package.yml) for more details. +We use Github Actions to run the test suite. Please refer to the workflow definition yaml file in [.github/workflows](../../.github/workflows/) for details. # 9 Releasing + For the complete list of taosanode Releases, please see Releases. # 10 CI/CD -We use github Actions for CI/CD workflow configuration. Please refer to the file .github/workflows/python-package.yml for more details. - +We use Github Actions for CI/CD workflow configuration. Please refer to the workflow definition yaml file in [.github/workflows](../../.github/workflows/) for details. # 11 Coverage diff --git a/tools/tdgpt/script/release.sh b/tools/tdgpt/script/release.sh index c143357eb1..0114d60ecd 100755 --- a/tools/tdgpt/script/release.sh +++ b/tools/tdgpt/script/release.sh @@ -1,15 +1,33 @@ #!/bin/bash -# Generate install package for all os system + +# Generate install package for Linux Platform set -e -# set -x + +while getopts "e:v:" opt; do + case "$opt" in + e) edition="$OPTARG" ;; # -e enterprise/community + v) version="$OPTARG" ;; # -v version + *) echo "Usage: $0 -e edition -v version"; exit 1 ;; + esac +done + +if [ -z "$edition" ] || [ -z "$version" ]; then + echo "Usage: $0 -e edition -v version" + exit 1 +fi +if [ "$edition" == "enterprise" ]; then + productName="TDengine-enterprise-anode" +fi + +if [ "$edition" == "community" ]; then + productName="TDengine-community-anode" +fi + +echo start to build release package, edition: ${edition}, version: ${version} curr_dir=$(pwd) compile_dir=$1 -version="1.0.1" -osType= -pagMode= -productName="TDengine-enterprise-anode" script_dir="$(dirname $(readlink -f $0))" top_dir="$(readlink -f ${script_dir}/..)" @@ -45,18 +63,17 @@ fi # python files mkdir -p ${install_dir}/bin && mkdir -p ${install_dir}/lib +# remove cache files generated by Python interpreter +TARGET_PATTERN="__pycache__" +find "${top_dir}/taosanalytics/" -type d -name "$TARGET_PATTERN" -exec rm -rf {} + + # script to control start/stop/uninstall process -rm -r ${top_dir}/taosanalytics/*.pyc || : cp -r ${top_dir}/taosanalytics/ ${install_dir}/lib/ && chmod a+x ${install_dir}/lib/ || : cp -r ${top_dir}/script/st*.sh ${install_dir}/bin/ && chmod a+x ${install_dir}/bin/* || : cp -r ${top_dir}/script/uninstall.sh ${install_dir}/bin/ && chmod a+x ${install_dir}/bin/* || : cd ${install_dir} -#if [ "$osType" != "Darwin" ]; then -# tar -zcv -f ${tarName} ./bin/* || : -# rm -rf ${install_dir}/bin || : -#else tar -zcv -f ${tarName} ./lib/* || : if [ ! -z "${install_dir}" ]; then