diff --git a/.github/workflows/devops-test.yml b/.github/workflows/devops-test.yml new file mode 100644 index 00000000000..d139c0f8bdc --- /dev/null +++ b/.github/workflows/devops-test.yml @@ -0,0 +1,196 @@ +name: DEVOPS-TEST + +on: + workflow_dispatch: + inputs: + PRE_UPGRADE_VERSION: + description: 'version before upgrade' + required: false + default: '' + EXEC_TEST_TYPE: + description: 'Which tests need to be executed? The options are all, upgrade, node_failure, node_expansion' + required: true + default: 'all' + +env: + GIT_SUBMODULE_STRATEGY: recursive + HYBRIDSE_SOURCE: local + +jobs: + node-failure-test-cluster: + if: ${{ github.event.inputs.EXEC_TEST_TYPE == 'all' || github.event.inputs.EXEC_TEST_TYPE == 'node_failure' }} + runs-on: ubuntu-latest + container: + image: ghcr.io/4paradigm/hybridsql:latest + env: + OS: linux + steps: + - uses: actions/checkout@v2 + - name: build jsdk and package + run: | + make configure CMAKE_INSTALL_PREFIX=openmldb-linux + make SQL_JAVASDK_ENABLE=ON && make SQL_JAVASDK_ENABLE=ON install + tar -zcvf openmldb-linux.tar.gz openmldb-linux + echo "openmldb-pkg:" + ls -al + - name: test + run: source /root/.bashrc && bash test/steps/openmldb-devops-test.sh -c test_cluster.xml -t node_failure + - name: TEST Results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-devops-test/target/surefire-reports/TEST-*.xml + check_name: "node-failure-test-cluster Report" + comment_title: "node-failure-test-cluster Report" + + node-failure-test-single: + if: ${{ github.event.inputs.EXEC_TEST_TYPE == 'all' || github.event.inputs.EXEC_TEST_TYPE == 'node_failure' }} + runs-on: ubuntu-latest + container: + image: ghcr.io/4paradigm/hybridsql:latest + env: + OS: linux + steps: + - uses: actions/checkout@v2 + - name: build jsdk and package + run: | + make configure CMAKE_INSTALL_PREFIX=openmldb-linux + make SQL_JAVASDK_ENABLE=ON && make SQL_JAVASDK_ENABLE=ON install + tar -zcvf openmldb-linux.tar.gz openmldb-linux + echo "openmldb-pkg:" + ls -al + - name: test + run: source /root/.bashrc && bash test/steps/openmldb-devops-test.sh -c test_single.xml -t node_failure + - name: TEST Results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-devops-test/target/surefire-reports/TEST-*.xml + check_name: "node-failure-test-single Report" + comment_title: "node-failure-test-single Report" + + node-expansion-test-cluster: + if: ${{ github.event.inputs.EXEC_TEST_TYPE == 'all' || github.event.inputs.EXEC_TEST_TYPE == 'node_expansion' }} + runs-on: ubuntu-latest + container: + image: ghcr.io/4paradigm/hybridsql:latest + env: + OS: linux + steps: + - uses: actions/checkout@v2 + - name: build jsdk and package + run: | + make configure CMAKE_INSTALL_PREFIX=openmldb-linux + make SQL_JAVASDK_ENABLE=ON && make SQL_JAVASDK_ENABLE=ON install + tar -zcvf openmldb-linux.tar.gz openmldb-linux + echo "openmldb-pkg:" + ls -al + - name: test + run: source /root/.bashrc && bash test/steps/openmldb-devops-test.sh -c test_node_expansion.xml -t node_expansion + - name: TEST Results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-devops-test/target/surefire-reports/TEST-*.xml + check_name: "node-expansion-test-cluster Report" + comment_title: "node-expansion-test-cluster Report" + + upgrade-test-cluster: + if: ${{ github.event.inputs.EXEC_TEST_TYPE == 'all' || github.event.inputs.EXEC_TEST_TYPE == 'upgrade' }} + runs-on: ubuntu-latest + container: + image: ghcr.io/4paradigm/hybridsql:latest + env: + OS: linux + steps: + - uses: actions/checkout@v2 + - name: build jsdk and package + run: | + make configure CMAKE_INSTALL_PREFIX=openmldb-linux + make SQL_JAVASDK_ENABLE=ON && make SQL_JAVASDK_ENABLE=ON install + tar -zcvf openmldb-linux.tar.gz openmldb-linux + echo "openmldb-pkg:" + ls -al + - name: test-memory + run: source /root/.bashrc && bash test/steps/openmldb-devops-test.sh -v ${{ github.event.inputs.PRE_UPGRADE_VERSION }} -c test_upgrade.xml -t upgrade -s "memory" + - name: upgrade results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-devops-test/target/surefire-reports/TEST-*.xml + check_name: "upgrade-test-cluster Report" + comment_title: "upgrade-test-cluster Report" + - name: sdk results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/TEST-*.xml + check_name: "java-sdk-cluster-memory-0 Report" + comment_title: "java-sdk-cluster-memory-0 Report" + upgrade-test-single: + if: ${{ github.event.inputs.EXEC_TEST_TYPE == 'all' || github.event.inputs.EXEC_TEST_TYPE == 'upgrade' }} + runs-on: ubuntu-latest + container: + image: ghcr.io/4paradigm/hybridsql:latest + env: + OS: linux + steps: + - uses: actions/checkout@v2 + - name: build jsdk and package + run: | + make configure CMAKE_INSTALL_PREFIX=openmldb-linux + make SQL_JAVASDK_ENABLE=ON && make SQL_JAVASDK_ENABLE=ON install + tar -zcvf openmldb-linux.tar.gz openmldb-linux + echo "openmldb-pkg:" + ls -al + - name: test-memory + run: source /root/.bashrc && bash test/steps/openmldb-devops-test.sh -v ${{ github.event.inputs.PRE_UPGRADE_VERSION }} -c test_upgrade_single.xml -t upgrade -s "memory" + - name: upgrade results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-devops-test/target/surefire-reports/TEST-*.xml + check_name: "upgrade-test-single Report" + comment_title: "upgrade-test-single Report" + - name: sdk results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/TEST-*.xml + check_name: "single-java-sdk-cluster-memory-0 Report" + comment_title: "single-java-sdk-cluster-memory-0 Report" + upgrade-test-cluster-SSD: + if: ${{ github.event.inputs.EXEC_TEST_TYPE == 'all' || github.event.inputs.EXEC_TEST_TYPE == 'upgrade' }} + runs-on: ubuntu-latest + container: + image: ghcr.io/4paradigm/hybridsql:latest + env: + OS: linux + steps: + - uses: actions/checkout@v2 + - name: build jsdk and package + run: | + make configure CMAKE_INSTALL_PREFIX=openmldb-linux + make SQL_JAVASDK_ENABLE=ON && make SQL_JAVASDK_ENABLE=ON install + tar -zcvf openmldb-linux.tar.gz openmldb-linux + echo "openmldb-pkg:" + ls -al + - name: test-memory + run: source /root/.bashrc && bash test/steps/openmldb-devops-test.sh -v ${{ github.event.inputs.PRE_UPGRADE_VERSION }} -c test_upgrade.xml -t upgrade -s "ssd" + - name: upgrade results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-devops-test/target/surefire-reports/TEST-*.xml + check_name: "upgrade-test-cluster ssd Report" + comment_title: "upgrade-test-cluster ssd Report" + - name: sdk results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/TEST-*.xml + check_name: "java-sdk-cluster-ssd-0 Report" + comment_title: "java-sdk-cluster-ssd-0 Report" + + + diff --git a/.github/workflows/integration-test-src.yml b/.github/workflows/integration-test-src.yml index 6e90af9f2ca..2668b16179b 100644 --- a/.github/workflows/integration-test-src.yml +++ b/.github/workflows/integration-test-src.yml @@ -86,7 +86,6 @@ jobs: uses: EnricoMi/publish-unit-test-result-action@v1 with: files: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/TEST-*.xml - comment_mode: "create new" check_name: "SRC java-sdk-cluster-memory-0 Report" comment_title: "SRC java-sdk-cluster-memory-0 Report" - name: tar test report @@ -173,7 +172,6 @@ jobs: uses: EnricoMi/publish-unit-test-result-action@v1 with: files: test/integration-test/openmldb-test-java/openmldb-sdk-test/target/surefire-reports/TEST-*.xml - comment_mode: "create new" check_name: "SRC java-sdk-cluster-ssd-0 Report" comment_title: "SRC java-sdk-cluster-ssd-0 Report" - name: tar test report diff --git a/cases/function/dml/test_delete.yaml b/cases/function/dml/test_delete.yaml index 2db00c73e7d..51e0a39736f 100644 --- a/cases/function/dml/test_delete.yaml +++ b/cases/function/dml/test_delete.yaml @@ -71,7 +71,7 @@ cases: - delete from {0} where c1='aa' or c1='cc'; expect: success: false - msg: failed + msg: fail - id: 3 desc: delete 两个索引的两个key @@ -88,10 +88,11 @@ cases: - delete from {0} where c1='aa' or c2=1; expect: success: false - msg: failed + msg: fail - id: 4 desc: 两个索引 delete 其中一个 + mode: cluster-unsupport inputs: - columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] @@ -99,18 +100,18 @@ cases: rows: - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] - - [4,"aa",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + - [3,"aa",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [4,"aa",1,2,3,1.1,2.1,1590738991000,"2020-05-01",true] sqls: - delete from {0} where c2=2; - - select * from {0}; + sql: SELECT id, c2, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); expect: - columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + columns: ["id int","c2 smallint","w1_c4_count bigint"] order: id rows: - - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [1,1,1] + - [2,1,2] + - [4,1,3] - id: 5 desc: delete 不是索引列 @@ -127,7 +128,7 @@ cases: - delete from {0} where c2=1; expect: success: false - msg: failed + msg: fail - id: 6 desc: delete key不存在 @@ -144,6 +145,7 @@ cases: - select * from {0}; expect: columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id rows: - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] @@ -160,7 +162,7 @@ cases: - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - [3,null,1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] sqls: - - delete from {0} where c1 is null; + - delete from {0} where c1=null; - select * from {0}; expect: columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] @@ -200,6 +202,7 @@ cases: - select * from {0}; expect: columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id rows: - [1,"aa",2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] @@ -255,6 +258,7 @@ cases: - select * from {0}; expect: columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id rows: - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] @@ -316,6 +320,7 @@ cases: - id: 17 desc: 两次delete 不同的index + mode: cluster-unsupport inputs: - columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] @@ -323,17 +328,21 @@ cases: rows: - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] - - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [3,"aa",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] - [4,"cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] sqls: - delete from {0} where c1='aa'; - - delete from {0} where c2=1; - - select * from {0}; + - delete from {0} where c2=2; + sql: | + SELECT id, c2, count(c4) OVER w1 as w1_c4_count, count(c5) OVER w2 as w2_c5_count FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); expect: - columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + columns: ["id int","c2 smallint","w1_c4_count bigint","w2_c5_count bigint"] order: id rows: - - [4,"cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + - [1,1,1,1] + - [2,1,1,2] - id: 18 desc: delete过期数据 @@ -367,7 +376,7 @@ cases: sql: delete from {0}1 where c1='aa'; expect: success: false - msg: failed + msg: fail - id: 20 desc: delete列不存在 @@ -384,7 +393,7 @@ cases: - delete from {0} where c11=1; expect: success: false - msg: failed + msg: fail - id: 21 desc: delete 其他库的数据 @@ -446,6 +455,7 @@ cases: - id: 24 desc: 两个索引,一个索引数据过期,删除另一个索引 + mode: cluster-unsupport inputs: - columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] @@ -458,13 +468,13 @@ cases: - [5,"cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] sqls: - delete from {0} where c2=1; - - select * from {0}; + sql: SELECT id, c2, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); expect: - columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + columns: ["id int","c2 smallint","w1_c4_count bigint"] order: id rows: - - [4,"cc",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] - - [5,"cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + - [4,2,1] + - [5,2,2] - id: 25 desc: 数据过期,delete其他pk @@ -496,11 +506,9 @@ cases: - [3,"cc",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] sqls: - delete from {0} where c1!='cc'; - - select * from {0}; expect: - columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] - rows: - - [3,"cc",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + success: false + msg: fail - id: 27 desc: 比较运算符删除 @@ -514,11 +522,9 @@ cases: - [3,"aa",3,2,3,1.1,2.1,1590738990000,"2020-05-01",true] sqls: - delete from {0} where c2>=2; - - select * from {0}; expect: - columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] - rows: - - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + success: false + msg: fail - id: 28 desc: 表名为job delete @@ -538,3 +544,54 @@ cases: columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] rows: - [2,"bb",2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 29 + desc: delete空表 + inputs: + - + name: job + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - delete from {0} where c1='aa'; + expect: + success: true + - + id: 30 + desc: 组合key有一个是null + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1|c2:c7"] + rows: + - [1,null,2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,null,1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1=null and c2=2; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,null,1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - + id: 31 + desc: 组合key有一个是空串 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1|c2:c7"] + rows: + - [1,"",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1='' and c2=2; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + diff --git a/cases/function/long_window/test_count_where.yaml b/cases/function/long_window/test_count_where.yaml index c9aa6091206..84740eaa889 100644 --- a/cases/function/long_window/test_count_where.yaml +++ b/cases/function/long_window/test_count_where.yaml @@ -13,88 +13,528 @@ # limitations under the License. db: test_zw -debugs: [] +debugs: ["长窗口count_where,date类型","长窗口count_where,rows"] cases: - id: 0 desc: 长窗口count_where,date类型 + longWindow: w1:2 inputs: - - columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] - indexs: ["index1:c1:c7"] + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] rows: - - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01",true] - - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02",true] - - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03",true] - - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04",true] - - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05",false] - dataProvider: - - ["ROWS","ROWS_RANGE"] + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,2,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,3,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,4,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,5,34,1.5,2.5,1590738990004,"2020-05-05",false] sql: | - deploy {0} options(long_windows='w1:2') SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 6 PRECEDING AND CURRENT ROW); + SELECT id, c1, count_where(c8,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); expect: - success: true + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 0-1 + desc: 长窗口count_where,rows + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 1 desc: 长窗口count_where,smallint类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c2,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 2 desc: 长窗口count_where,int类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c3,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 3 desc: 长窗口count_where,bigint类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c4,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 4 desc: 长窗口count_where,string类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c1,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 5 desc: 长窗口count_where,timestamp类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c7,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 6 desc: 长窗口count_where,row类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(*,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 7 desc: 长窗口count_where,bool类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c9,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 8 desc: 长窗口count_where,float类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c5,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 9 desc: 长窗口count_where,double类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c6,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 10 desc: 长窗口count_where,第二个参数使用bool列 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,c9) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail - id: 11 desc: 长窗口count_where,第二个参数使用= + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,c2=4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",0] + - [2,"aa",0] + - [3,"aa",0] + - [4,"aa",1] + - [5,"aa",1] - id: 12 desc: 长窗口count_where,第二个参数使用!= + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,c2!=4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",2] - id: 13 desc: 长窗口count_where,第二个参数使用>= + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,c2>=2) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",0] + - [2,"aa",1] + - [3,"aa",2] + - [4,"aa",3] + - [5,"aa",3] - id: 14 desc: 长窗口count_where,第二个参数使用<= + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,c2<=3) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] - id: 15 desc: 长窗口count_where,第二个参数使用> - - - id: 16 - desc: 长窗口count_where,第二个参数使用< + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,c2>1) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",0] + - [2,"aa",1] + - [3,"aa",2] + - [4,"aa",3] + - [5,"aa",3] - id: 17 desc: 长窗口count_where,第二个参数使用and + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,c2<4 and c2>1) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail - id: 18 desc: 长窗口count_where,第二个参数使用两个列 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,c3>c2) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail - id: 19 desc: 长窗口count_where,第二个参数使用嵌套 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,if_null(c2,0)>4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail - id: 20 desc: 长窗口count_where,第二个参数常量在前 - + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738990001,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738990002,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738990003,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738990004,"2020-05-05",false] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count_where(c8,4>c2) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] diff --git a/cases/function/multiple_databases/test_multiple_databases.yaml b/cases/function/multiple_databases/test_multiple_databases.yaml index 9d1c399d75a..208270b4ae5 100644 --- a/cases/function/multiple_databases/test_multiple_databases.yaml +++ b/cases/function/multiple_databases/test_multiple_databases.yaml @@ -33,7 +33,7 @@ cases: - [ "aa",2,13,1590738989000 ] - [ "bb",21,131,1590738990000 ] - [ "cc",41,151,1590738992000 ] - sql: select {0}.c1,{0}.c2,db2.{1}.c3,db2.{1}.c4 from {0} last join db2.{1} ORDER BY db2.{1}.c3 on {0}.c1=db2.{1}.c1; + sql: select db1.{0}.c1,db1.{0}.c2,db2.{1}.c3,db2.{1}.c4 from db1.{0} last join db2.{1} ORDER BY db2.{1}.c3 on db1.{0}.c1=db2.{1}.c1; expect: order: c1 columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] @@ -114,7 +114,7 @@ cases: success: false - id: 4 desc: 全部使用默认库 - db: db + db: test_zw inputs: - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] indexs: [ "index1:c1:c4" ] @@ -138,7 +138,7 @@ cases: - [ "cc",41,151,1590738992000 ] - id: 5 desc: 指定当前库查询 - db: db + db: test_zw inputs: - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] indexs: [ "index1:c1:c4" ] @@ -152,7 +152,7 @@ cases: - [ "aa",2,13,1590738989000 ] - [ "bb",21,131,1590738990000 ] - [ "cc",41,151,1590738992000 ] - sql: select db.{0}.c1,db.{0}.c2,db.{1}.c3,db.{1}.c4 from db.{0} last join db.{1} ORDER BY db.{1}.c3 on db.{0}.c1=db.{1}.c1; + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1; expect: order: c1 columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] @@ -162,7 +162,7 @@ cases: - [ "cc",41,151,1590738992000 ] - id: 6 desc: 查询使用其他库 - db: db + db: test_zw inputs: - columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] diff --git a/cases/integration_test/cluster/test_cluster_batch.yaml b/cases/integration_test/cluster/test_cluster_batch.yaml new file mode 100644 index 00000000000..329fc9d170d --- /dev/null +++ b/cases/integration_test/cluster/test_cluster_batch.yaml @@ -0,0 +1,199 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: SELECT columns + inputs: + - + columns: ["id int", "c1 string","c6 double","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa", 1.0, 1590738990000] + - [2, "aa", 2.0, 1590738991000] + - [3, "aa", 3.0, 1590738992000] + - [4, "aa", 4.0, 1590738993000] + - [5, "bb", 5.0, 1590738994000] + - [6, "bb", 6.0, 1590738995000] + - [7, "bb", 7.0, 1590738996000] + - [8, "bb", 8.0, 1590738997000] + - [9, "bb", 9.0, 1590738998000] + - [10, "cc", 1.0, 1590738993000] + - [11, "cc", 2.0, 1590738994000 ] + - [12, "cc", 3.0, 1590738995000 ] + - [13, "cc", 4.0, 1590738996000 ] + - [14, "cc", 5.0, 1590738997000 ] + - [15, "dd", 6.0, 1590738998000 ] + - [16, "dd", 7.0, 1590738999000 ] + sql: | + SELECT id, c1, c6, c7 FROM {0}; + expect: + order: id + columns: ["id int", "c1 string", "c6 double", "c7 timestamp"] + rows: + - [ 1, "aa", 1.0, 1590738990000] + - [ 2, "aa", 2.0, 1590738991000] + - [ 3, "aa", 3.0, 1590738992000] + - [ 4, "aa", 4.0, 1590738993000] + - [ 5, "bb", 5.0, 1590738994000] + - [ 6, "bb", 6.0, 1590738995000] + - [ 7, "bb", 7.0, 1590738996000] + - [ 8, "bb", 8.0, 1590738997000] + - [ 9, "bb", 9.0, 1590738998000] + - [ 10, "cc", 1.0, 1590738993000] + - [ 11, "cc", 2.0, 1590738994000] + - [ 12, "cc", 3.0, 1590738995000] + - [ 13, "cc", 4.0, 1590738996000] + - [ 14, "cc", 5.0, 1590738997000] + - [ 15, "dd", 6.0, 1590738998000] + - [ 16, "dd", 7.0, 1590738999000] + + - + id: 1 + desc: SELECT columns, some tablet result set is empty + inputs: + - + columns: ["id int", "c1 string","c6 double","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa", 1.0, 1590738990000] + - [2, "aa", 2.0, 1590738991000] + - [3, "aa", 3.0, 1590738992000] + - [4, "aa", 4.0, 1590738993000] + - [15, "dd", 6.0, 1590738998000 ] + - [16, "dd", 7.0, 1590738999000 ] + sql: | + SELECT id, c1, c6, c7 FROM {0}; + expect: + order: id + columns: ["id int", "c1 string", "c6 double", "c7 timestamp"] + rows: + - [ 1, "aa", 1.0, 1590738990000] + - [ 2, "aa", 2.0, 1590738991000] + - [ 3, "aa", 3.0, 1590738992000] + - [ 4, "aa", 4.0, 1590738993000] + - [ 15, "dd", 6.0, 1590738998000] + - [ 16, "dd", 7.0, 1590738999000] + - + id: 2 + desc: SELECT simple expression + inputs: + - + columns: ["id int", "c1 string","c6 double","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa", 1.0, 1590738990000] + - [2, "aa", 2.0, 1590738991000] + - [3, "aa", 3.0, 1590738992000] + - [4, "aa", 4.0, 1590738993000] + - [5, "bb", 5.0, 1590738994000] + - [6, "bb", 6.0, 1590738995000] + - [7, "bb", 7.0, 1590738996000] + - [8, "bb", 8.0, 1590738997000] + - [9, "bb", 9.0, 1590738998000] + - [10, "cc", 1.0, 1590738993000] + - [11, "cc", 2.0, 1590738994000 ] + - [12, "cc", 3.0, 1590738995000 ] + - [13, "cc", 4.0, 1590738996000 ] + - [14, "cc", 5.0, 1590738997000 ] + - [15, "dd", 6.0, 1590738998000 ] + - [16, "dd", 7.0, 1590738999000 ] + sql: | + SELECT id, c1, c6+1.0 as f1, c7, year(c7) as f2 FROM {0}; + expect: + order: id + columns: ["id int", "c1 string", "f1 double", "c7 timestamp", "f2 int"] + rows: + - [ 1, "aa", 2.0, 1590738990000, 2020] + - [ 2, "aa", 3.0, 1590738991000, 2020] + - [ 3, "aa", 4.0, 1590738992000, 2020] + - [ 4, "aa", 5.0, 1590738993000, 2020] + - [ 5, "bb", 6.0, 1590738994000, 2020] + - [ 6, "bb", 7.0, 1590738995000, 2020] + - [ 7, "bb", 8.0, 1590738996000, 2020] + - [ 8, "bb", 9.0, 1590738997000, 2020] + - [ 9, "bb", 10.0, 1590738998000, 2020] + - [ 10, "cc", 2.0, 1590738993000, 2020] + - [ 11, "cc", 3.0, 1590738994000, 2020] + - [ 12, "cc", 4.0, 1590738995000, 2020] + - [ 13, "cc", 5.0, 1590738996000, 2020] + - [ 14, "cc", 6.0, 1590738997000, 2020] + - [ 15, "dd", 7.0, 1590738998000, 2020] + - [ 16, "dd", 8.0, 1590738999000, 2020] + + - + id: 3 + desc: SELECT simple expression LIMIT 10 + mode: request-unsupport + inputs: + - + columns: ["id int", "c1 string","c6 double","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa", 1.0, 1590738990000] + - [2, "aa", 2.0, 1590738991000] + - [3, "aa", 3.0, 1590738992000] + - [4, "aa", 4.0, 1590738993000] + - [5, "bb", 5.0, 1590738994000] + - [6, "bb", 6.0, 1590738995000] + - [7, "bb", 7.0, 1590738996000] + - [8, "bb", 8.0, 1590738997000] + - [9, "bb", 9.0, 1590738998000] + - [10, "cc", 1.0, 1590738993000] + - [11, "cc", 2.0, 1590738994000 ] + - [12, "cc", 3.0, 1590738995000 ] + - [13, "cc", 4.0, 1590738996000 ] + - [14, "cc", 5.0, 1590738997000 ] + - [15, "dd", 6.0, 1590738998000 ] + - [16, "dd", 7.0, 1590738999000 ] + sql: | + SELECT id, c1, c6+1.0 as f1, c7, year(c7) as f2 FROM {0} LIMIT 10; + expect: + order: id + columns: ["id int", "c1 string", "f1 double", "c7 timestamp", "f2 int"] + count: 10 + - + id: 4 + desc: SELECT simple expression LIMIT 3 + mode: request-unsupport + inputs: + - + columns: ["id int", "c1 string","c6 double","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa", 1.0, 1590738990000] + - [2, "aa", 2.0, 1590738991000] + - [3, "aa", 3.0, 1590738992000] + - [4, "aa", 4.0, 1590738993000] + - [5, "bb", 5.0, 1590738994000] + - [6, "bb", 6.0, 1590738995000] + - [7, "bb", 7.0, 1590738996000] + - [8, "bb", 8.0, 1590738997000] + - [9, "bb", 9.0, 1590738998000] + - [10, "cc", 1.0, 1590738993000] + - [11, "cc", 2.0, 1590738994000 ] + - [12, "cc", 3.0, 1590738995000 ] + - [13, "cc", 4.0, 1590738996000 ] + - [14, "cc", 5.0, 1590738997000 ] + - [15, "dd", 6.0, 1590738998000 ] + - [16, "dd", 7.0, 1590738999000 ] + sql: | + SELECT id, c1, c6+1.0 as f1, c7, year(c7) as f2 FROM {0} LIMIT 3; + expect: + order: id + columns: ["id int", "c1 string", "f1 double", "c7 timestamp", "f2 int"] + count: 3 \ No newline at end of file diff --git a/cases/integration_test/cluster/test_window_row.yaml b/cases/integration_test/cluster/test_window_row.yaml new file mode 100644 index 00000000000..35f200af520 --- /dev/null +++ b/cases/integration_test/cluster/test_window_row.yaml @@ -0,0 +1,216 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 简单rows window + inputs: + - + columns: ["id int", "c1 string","c6 double","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa", 1.0, 1590738990000] + - [2, "aa", 2.0, 1590738991000] + - [3, "aa", 3.0, 1590738992000] + - [4, "aa", 4.0, 1590738993000] + - [5, "bb", 5.0, 1590738994000] + - [6, "bb", 6.0, 1590738995000] + - [7, "bb", 7.0, 1590738996000] + - [8, "bb", 8.0, 1590738997000] + - [9, "bb", 9.0, 1590738998000] + - [10, "cc", 1.0, 1590738993000] + - [11, "cc", 2.0, 1590738994000 ] + - [12, "cc", 3.0, 1590738995000 ] + - [13, "cc", 4.0, 1590738996000 ] + - [14, "cc", 5.0, 1590738997000 ] + - [15, "dd", 6.0, 1590738998000 ] + - [16, "dd", 7.0, 1590738999000 ] + sql: | + SELECT id, c1, c6, c7, min(c6) OVER w1 as w1_c6_min, count(id) OVER w1 as w1_cnt FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int", "c1 string", "c6 double", "c7 timestamp", "w1_c6_min double","w1_cnt bigint"] + rows: + - [ 1, "aa", 1.0, 1590738990000, 1.0, 1] + - [ 2, "aa", 2.0, 1590738991000, 1.0, 2] + - [ 3, "aa", 3.0, 1590738992000, 1.0, 3] + - [ 4, "aa", 4.0, 1590738993000, 2.0, 3] + - [ 5, "bb", 5.0, 1590738994000, 5.0, 1] + - [ 6, "bb", 6.0, 1590738995000, 5.0, 2] + - [ 7, "bb", 7.0, 1590738996000, 5.0, 3] + - [ 8, "bb", 8.0, 1590738997000, 6.0, 3] + - [ 9, "bb", 9.0, 1590738998000, 7.0, 3] + - [ 10, "cc", 1.0, 1590738993000, 1.0, 1] + - [ 11, "cc", 2.0, 1590738994000, 1.0, 2] + - [ 12, "cc", 3.0, 1590738995000, 1.0, 3] + - [ 13, "cc", 4.0, 1590738996000, 2.0, 3] + - [ 14, "cc", 5.0, 1590738997000, 3.0, 3] + - [ 15, "dd", 6.0, 1590738998000, 6.0, 1] + - [ 16, "dd", 7.0, 1590738999000, 6.0, 2] + - + id: 1 + desc: 简单rows window, union副表 + mode: cluster-unsupport + inputs: + - columns: [ "id int", "c1 string","c6 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1, "aa", 1.0, 1590738990000 ] + - [ 2, "aa", 4.0, 1590738993000 ] + - [ 3, "bb", 5.0, 1590738994000 ] + - [ 4, "bb", 9.0, 1590738998000 ] + - [ 5, "cc", 1.0, 1590738993000 ] + - [ 6, "cc", 5.0, 1590738997000 ] + - [ 7, "dd", 7.0, 1590738999000 ] + - + columns: ["x1 string","x6 double","x7 timestamp"] + indexs: ["index1:x1:x7"] + rows: + - ["aa", 2.0, 1590738991000] + - ["aa", 3.0, 1590738992000] + - ["bb", 6.0, 1590738995000] + - ["bb", 7.0, 1590738996000] + - ["bb", 8.0, 1590738997000] + - ["cc", 2.0, 1590738994000 ] + - ["cc", 3.0, 1590738995000 ] + - ["cc", 4.0, 1590738996000 ] + - ["dd", 6.0, 1590738998000 ] + sql: | + SELECT id, c1, c6, c7, min(c6) OVER w1 as w1_c6_min, count(id) OVER w1 as w1_cnt FROM {0} WINDOW + w1 AS (UNION (select 0 as id, x1 as c1, x6 as c6, x7 as c7 from {1}) as t2 PARTITION BY c1 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int", "c1 string", "c6 double", "c7 timestamp", "w1_c6_min double","w1_cnt bigint"] + rows: + - [ 1, "aa", 1.0, 1590738990000, 1.0, 1] + - [ 2, "aa", 4.0, 1590738993000, 2.0, 3] + - [ 3, "bb", 5.0, 1590738994000, 5.0, 1] + - [ 4, "bb", 9.0, 1590738998000, 7.0, 3] + - [ 5, "cc", 1.0, 1590738993000, 1.0, 1] + - [ 6, "cc", 5.0, 1590738997000, 3.0, 3] + - [ 7, "dd", 7.0, 1590738999000, 6.0, 2] + - + id: 2 + desc: 2 window,pk不同 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c7 timestamp"] + indexs: ["index1:c1:c7", "index3:c3:c7"] + rows: + - [1,"aa",20,30,1590738990000] + - [2,"aa",20,31,1590738991000] + - [3,"bb",20,32,1590738992000] + - [4,"bb",20,33,1590738993000] + - [5,"cc",21,34,1590738994000] + - [6,"aa",21,35,1590738995000] + - [7,"aa",21,36,1590738996000] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY c3 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY c1 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"aa",20,61,2] + - [3,"bb",20,93,1] + - [4,"bb",20,96,2] + - [5,"cc",21,34,1] + - [6,"aa",21,69,3] + - [7,"aa",21,105,3] + - + id: 3 + desc: 3 window,pk不同 + inputs: + - + columns : ["id int","c1 string", "c2 string", "c3 int","c4 bigint","c7 timestamp"] + indexs: ["index1:c1:c7", "index2:c2:c7", "index3:c3:c7"] + rows: + - [1,"aa", "1", 20,30,1590738990000] + - [2,"aa", "2", 20,31,1590738991000] + - [3,"bb", "1", 20,32,1590738992000] + - [4,"bb", "2", 20,33,1590738993000] + - [5,"cc", "1", 21,34,1590738994000] + - [6,"aa", "1", 21,35,1590738995000] + - [7,"aa", "1", 21,36,1590738996000] + sql: | + SELECT id, c1, c2, c3, + count(id) OVER w1 as w1_count, + count(id) OVER w2 as w2_count, + sum(c4) OVER w3 as w3_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY c1 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY c2 ORDER BY c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW), + w3 AS (PARTITION BY c3 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string", "c2 string", "c3 int","w1_count bigint","w2_count bigint", "w3_c4_sum bigint"] + rows: + - [1,"aa", "1", 20, 1, 1, 30] + - [2,"aa", "2", 20, 2, 1, 61] + - [3,"bb", "1", 20, 1, 2, 93] + - [4,"bb", "2", 20, 2, 2, 96] + - [5,"cc", "1", 21, 1, 3, 34] + - [6,"aa", "1", 21, 3, 4, 69] + - [7,"aa", "1", 21, 3, 4, 105] + + - id: 4 + desc: 简单rows window, union副表, 主表不进入窗口 40w + tags: ["TODO", "@baoxinqi, batch request unsupport"] + inputs: + - columns: [ "id int", "c1 string","c6 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 2, "aa", 4.0, 1590738993000 ] + - columns: [ "x1 string","x6 double","x7 timestamp" ] + indexs: [ "index1:x1:x7" ] + repeat: 400 + rows: + - [ "aa", 2.0, 1590738991000 ] + + sql: | + SELECT id, c1, c6, c7, count(id) OVER w1 as w1_cnt, distinct_count(id) OVER w1 as w1_dis_cnt FROM {0} WINDOW + w1 AS (UNION (select 0 as id, x1 as c1, x6 as c6, x7 as c7 from {1}) as t2 PARTITION BY c1 ORDER BY c7 ROWS BETWEEN 400000 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int", "c1 string", "c6 double", "c7 timestamp", "w1_cnt bigint", "w1_dis_cnt bigint" ] + rows: + - [ 2, "aa", 4.0, 1590738993000, 400001, 2 ] + - id: 5 + desc: 简单rows window, union副表, 主表不进入窗口3 4w + mode: batch-request-unsupport, cli-unsupport + inputs: + - columns: [ "id int", "c1 string","c6 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 2, "aa", 4.0, 1590738993000 ] + - columns: [ "x1 string","x6 double","x7 timestamp" ] + indexs: [ "index1:x1:x7" ] + repeat: 400 + rows: + - [ "aa", 2.0, 1590738991000 ] + + sql: | + SELECT id, c1, c6, c7, min(c6) OVER w1 as w1_min_c6, count(id) OVER w1 as w1_cnt FROM {0} WINDOW + w1 AS (UNION (select 0 as id, x1 as c1, x6 as c6, x7 as c7 from {1}) as t2 PARTITION BY c1 ORDER BY c7 ROWS BETWEEN 400000 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int", "c1 string", "c6 double", "c7 timestamp", "w1_min_c6 double", "w1_cnt bigint" ] + rows: + - [ 2, "aa", 4.0, 1590738993000, 2.0, 401 ] diff --git a/cases/integration_test/cluster/test_window_row_range.yaml b/cases/integration_test/cluster/test_window_row_range.yaml new file mode 100644 index 00000000000..476336fe4c0 --- /dev/null +++ b/cases/integration_test/cluster/test_window_row_range.yaml @@ -0,0 +1,172 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 简单rows window + inputs: + - + columns: ["id int", "c1 string","c6 double","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa", 1.0, 1590738990000] + - [2, "aa", 2.0, 1590738991000] + - [3, "aa", 3.0, 1590738992000] + - [4, "aa", 4.0, 1590738993000] + - [5, "bb", 5.0, 1590738994000] + - [6, "bb", 6.0, 1590738995000] + - [7, "bb", 7.0, 1590738996000] + - [8, "bb", 8.0, 1590738997000] + - [9, "bb", 9.0, 1590738998000] + - [10, "cc", 1.0, 1590738993000] + - [11, "cc", 2.0, 1590738994000 ] + - [12, "cc", 3.0, 1590738995000 ] + - [13, "cc", 4.0, 1590738996000 ] + - [14, "cc", 5.0, 1590738997000 ] + - [15, "dd", 6.0, 1590738998000 ] + - [16, "dd", 7.0, 1590738999000 ] + sql: | + SELECT id, c1, c6, c7, min(c6) OVER w1 as w1_c6_min, count(id) OVER w1 as w1_cnt FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int", "c1 string", "c6 double", "c7 timestamp", "w1_c6_min double","w1_cnt bigint"] + rows: + - [ 1, "aa", 1.0, 1590738990000, 1.0, 1] + - [ 2, "aa", 2.0, 1590738991000, 1.0, 2] + - [ 3, "aa", 3.0, 1590738992000, 1.0, 3] + - [ 4, "aa", 4.0, 1590738993000, 2.0, 3] + - [ 5, "bb", 5.0, 1590738994000, 5.0, 1] + - [ 6, "bb", 6.0, 1590738995000, 5.0, 2] + - [ 7, "bb", 7.0, 1590738996000, 5.0, 3] + - [ 8, "bb", 8.0, 1590738997000, 6.0, 3] + - [ 9, "bb", 9.0, 1590738998000, 7.0, 3] + - [ 10, "cc", 1.0, 1590738993000, 1.0, 1] + - [ 11, "cc", 2.0, 1590738994000, 1.0, 2] + - [ 12, "cc", 3.0, 1590738995000, 1.0, 3] + - [ 13, "cc", 4.0, 1590738996000, 2.0, 3] + - [ 14, "cc", 5.0, 1590738997000, 3.0, 3] + - [ 15, "dd", 6.0, 1590738998000, 6.0, 1] + - [ 16, "dd", 7.0, 1590738999000, 6.0, 2] + - + id: 1 + desc: 简单rows window, union副表, 主表进入窗口 + mode: cluster-unsupport + inputs: + - columns: [ "id int", "c1 string","c6 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1, "aa", 1.0, 1590738990000 ] + - [ 2, "aa", 4.0, 1590738993000 ] + - [ 3, "bb", 5.0, 1590738994000 ] + - [ 4, "bb", 9.0, 1590738998000 ] + - [ 5, "cc", 1.0, 1590738993000 ] + - [ 6, "cc", 5.0, 1590738997000 ] + - [ 7, "dd", 7.0, 1590738999000 ] + - + columns: ["x1 string","x6 double","x7 timestamp"] + indexs: ["index1:x1:x7"] + rows: + - ["aa", 2.0, 1590738991000] + - ["aa", 3.0, 1590738992000] + - ["bb", 6.0, 1590738995000] + - ["bb", 7.0, 1590738996000] + - ["bb", 8.0, 1590738997000] + - ["cc", 2.0, 1590738994000 ] + - ["cc", 3.0, 1590738995000 ] + - ["cc", 4.0, 1590738996000 ] + - ["dd", 6.0, 1590738998000 ] + sql: | + SELECT id, c1, c6, c7, min(c6) OVER w1 as w1_c6_min, count(id) OVER w1 as w1_cnt FROM {0} WINDOW + w1 AS (UNION (select 0 as id, x1 as c1, x6 as c6, x7 as c7 from {1}) as t2 PARTITION BY c1 ORDER BY c7 ROWS_RANGE + BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int", "c1 string", "c6 double", "c7 timestamp", "w1_c6_min double","w1_cnt bigint"] + rows: + - [ 1, "aa", 1.0, 1590738990000, 1.0, 1] + - [ 2, "aa", 4.0, 1590738993000, 2.0, 3] + - [ 3, "bb", 5.0, 1590738994000, 5.0, 1] + - [ 4, "bb", 9.0, 1590738998000, 7.0, 3] + - [ 5, "cc", 1.0, 1590738993000, 1.0, 1] + - [ 6, "cc", 5.0, 1590738997000, 3.0, 3] + - [ 7, "dd", 7.0, 1590738999000, 6.0, 2] + - + id: 2 + desc: 2 window,pk不同 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c7 timestamp"] + indexs: ["index1:c1:c7", "index3:c3:c7"] + rows: + - [1,"aa",20,30,1590738990000] + - [2,"aa",20,31,1590738991000] + - [3,"bb",20,32,1590738992000] + - [4,"bb",20,33,1590738993000] + - [5,"cc",21,34,1590738994000] + - [6,"aa",21,35,1590738995000] + - [7,"aa",21,36,1590738996000] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY c3 ORDER BY c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY c1 ORDER BY c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"aa",20,61,2] + - [3,"bb",20,93,1] + - [4,"bb",20,96,2] + - [5,"cc",21,34,1] + - [6,"aa",21,69,1] + - [7,"aa",21,105,2] + - + id: 3 + desc: 3 window,pk不同 + inputs: + - + columns : ["id int","c1 string", "c2 string", "c3 int","c4 bigint","c7 timestamp"] + indexs: ["index1:c1:c7", "index2:c2:c7", "index3:c3:c7"] + rows: + - [1,"aa", "1", 20,30,1590738990000] + - [2,"aa", "2", 20,31,1590738991000] + - [3,"bb", "1", 20,32,1590738992000] + - [4,"bb", "2", 20,33,1590738993000] + - [5,"cc", "1", 21,34,1590738994000] + - [6,"aa", "1", 21,35,1590738995000] + - [7,"aa", "1", 21,36,1590738996000] + sql: | + SELECT id, c1, c2, c3, + count(id) OVER w1 as w1_count, + count(id) OVER w2 as w2_count, + sum(c4) OVER w3 as w3_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY c1 ORDER BY c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY c2 ORDER BY c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW), + w3 AS (PARTITION BY c3 ORDER BY c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string", "c2 string", "c3 int","w1_count bigint","w2_count bigint", "w3_c4_sum bigint"] + rows: + - [1,"aa", "1", 20, 1, 1, 30] + - [2,"aa", "2", 20, 2, 1, 61] + - [3,"bb", "1", 20, 1, 2, 93] + - [4,"bb", "2", 20, 2, 2, 96] + - [5,"cc", "1", 21, 1, 2, 34] + - [6,"aa", "1", 21, 1, 3, 69] + - [7,"aa", "1", 21, 2, 3, 105] diff --git a/cases/integration_test/cluster/window_and_lastjoin.yaml b/cases/integration_test/cluster/window_and_lastjoin.yaml new file mode 100644 index 00000000000..c20e6e070ee --- /dev/null +++ b/cases/integration_test/cluster/window_and_lastjoin.yaml @@ -0,0 +1,620 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 简单拼表 + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, 1590738990000, 2.2] + - [3, "bb",2, 1590738990000, 3.3] + - [4, "cc",3, 1590738990000, 4.0] + - [5, "cc",3, 1590738991000, 5.0] + - [6, "cc",3, 1590738992000, 6.0] + - [7, "cc",2, 1590738993000, 7.0] + - + columns : ["crd_lst_isu_dte timestamp", "merchant_nbr int"] + indexs: ["index2:merchant_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, 1] + - [1590738990000, 1] + - [1590738991000, 2] + - [1590738989000, 3] + - [1590738992000, 3] + sql: | + select id, card_no, merchant_id, trx_time, crd_lst_isu_dte, merchant_nbr from {0} + last join {1} order by {1}.crd_lst_isu_dte on {0}.merchant_id = {1}.merchant_nbr and {0}.trx_time >= {1}.crd_lst_isu_dte; + expect: + columns: ["id int", "card_no string", "merchant_id int", "trx_time timestamp", + "crd_lst_isu_dte timestamp", "merchant_nbr int"] + order: id + rows: + - [1, "aaaaaaaaaa", 1, 1590738989000, 1590738988000, 1] + - [2, "aaaaaaaaaa", 1, 1590738990000, 1590738990000, 1] + - [3, "bb", 2, 1590738990000, null, null] + - [4, "cc", 3, 1590738990000, 1590738989000, 3] + - [5, "cc", 3, 1590738991000, 1590738989000, 3] + - [6, "cc", 3, 1590738992000, 1590738992000, 3] + - [7, "cc", 2, 1590738993000, 1590738991000, 2] + - + id: 1 + desc: 三表拼表 + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "user string", "trx_time timestamp", "trx_amt float"] + + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, "user1", 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, "user2", 1590738990000, 2.2] + - [3, "bb",2, "user3", 1590738990000, 3.3] + - [4, "cc",3, "user4", 1590738990000, 4.0] + - [5, "cc",3, "user5", 1590738991000, 5.0] + - [6, "cc",3, "user6", 1590738992000, 6.0] + - [7, "cc",2, "user7", 1590738993000, 7.0] + - + columns : ["crd_lst_isu_dte timestamp", "merchant_nbr int"] + indexs: ["index2:merchant_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, 1] + - [1590738990000, 1] + - [1590738991000, 2] + - [1590738989000, 3] + - [1590738992000, 3] + - columns: [ "std_ts timestamp", "username string" ] + indexs: [ "index2:username:std_ts" ] + rows: + - [ 1590738988000, "user1"] + - [ 1590738990000, "user1"] + - [ 1590738991000, "user2"] + - [ 1590738989000, "user2"] + - [ 1590738992000, "user3" ] + sql: | + select id, card_no, merchant_id, user, trx_time, crd_lst_isu_dte, merchant_nbr, std_ts, username from {0} + last join {1} order by {1}.crd_lst_isu_dte on {0}.merchant_id = {1}.merchant_nbr and {0}.trx_time >= {1}.crd_lst_isu_dte + last join {2} order by {2}.std_ts on {0}.user = {2}.username; + expect: + columns: ["id int", "card_no string", "merchant_id int", "user string", "trx_time timestamp", + "crd_lst_isu_dte timestamp", "merchant_nbr int", "std_ts timestamp", "username string"] + order: id + rows: + - [1, "aaaaaaaaaa", 1, "user1", 1590738989000, 1590738988000, 1, 1590738990000, "user1"] + - [2, "aaaaaaaaaa", 1, "user2", 1590738990000, 1590738990000, 1, 1590738991000, "user2"] + - [3, "bb", 2, "user3", 1590738990000, null, null, 1590738992000, "user3", ] + - [4, "cc", 3, "user4", 1590738990000, 1590738989000, 3, null, null] + - [5, "cc", 3, "user5", 1590738991000, 1590738989000, 3, null, null] + - [6, "cc", 3, "user6", 1590738992000, 1590738992000, 3, null, null] + - [7, "cc", 2, "user7", 1590738993000, 1590738991000, 2, null, null] + - + id: 2 + desc: 三表拼表2 + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "user string", "trx_time timestamp", "trx_amt float"] + + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, "user1", 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, "user2", 1590738990000, 2.2] + - [3, "bb",2, "user3", 1590738990000, 3.3] + - [4, "cc",3, "user4", 1590738990000, 4.0] + - [5, "cc",3, "user5", 1590738991000, 5.0] + - [6, "cc",3, "user6", 1590738992000, 6.0] + - [7, "cc",2, "user7", 1590738993000, 7.0] + - + columns : ["crd_lst_isu_dte timestamp", "merchant_nbr int", "product_nbr bigint"] + indexs: ["index2:merchant_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, 1, 1001] + - [1590738990000, 1, 1002] + - [1590738991000, 2, 1003] + - [1590738989000, 3, 1004] + - [1590738992000, 3, 1005] + - columns: [ "std_ts timestamp", "product_id bigint" ] + indexs: [ "index2:product_id:std_ts" ] + rows: + - [ 1590738988000, 1001] + - [ 1590738990000, 1001] + - [ 1590738991000, 1001] + - [ 1590738989000, 1002] + - [ 1590738992000, 1002] + - [ 1590738993000, 1005] + sql: | + select id, card_no, merchant_id, user, trx_time, crd_lst_isu_dte, merchant_nbr, product_nbr, std_ts, product_id from {0} + last join {1} order by {1}.crd_lst_isu_dte on {0}.merchant_id = {1}.merchant_nbr and {0}.trx_time >= {1}.crd_lst_isu_dte + last join {2} order by {2}.std_ts on {1}.product_nbr = {2}.product_id; + expect: + columns: ["id int", "card_no string", "merchant_id int", "user string", "trx_time timestamp", + "crd_lst_isu_dte timestamp", "merchant_nbr int", "product_nbr bigint", "std_ts timestamp", "product_id bigint"] + order: id + rows: + - [1, "aaaaaaaaaa", 1, "user1", 1590738989000, 1590738988000, 1, 1001, 1590738991000, 1001] + - [2, "aaaaaaaaaa", 1, "user2", 1590738990000, 1590738990000, 1, 1002, 1590738992000, 1002] + - [3, "bb", 2, "user3", 1590738990000, null, null, null, null, null] + - [4, "cc", 3, "user4", 1590738990000, 1590738989000, 3, 1004, null, null] + - [5, "cc", 3, "user5", 1590738991000, 1590738989000, 3, 1004, null, null] + - [6, "cc", 3, "user6", 1590738992000, 1590738992000, 3, 1005, 1590738993000, 1005] + - [7, "cc", 2, "user7", 1590738993000, 1590738991000, 2, 1003, null, null] + - + id: 3 + desc: 窗口特征拼接副表 + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, 1590738990000, 2.2] + - [3, "bb",2, 1590738990000, 3.3] + - [4, "cc",3, 1590738990000, 4.0] + - [5, "cc",3, 1590738991000, 5.0] + - [6, "cc",3, 1590738992000, 6.0] + - [7, "cc",2, 1590738993000, 7.0] + - + columns : ["crd_lst_isu_dte timestamp", "merchant_nbr int"] + indexs: ["index2:merchant_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, 1] + - [1590738990000, 1] + - [1590738991000, 2] + - [1590738989000, 3] + - [1590738992000, 3] + sql: select * from + (select + id, + card_no, + merchant_id, + trx_time, + sum(trx_amt) over w30d as sum_trx_amt, + count(merchant_id) over w10d as count_merchant_id + from {0} + window w30d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 30d PRECEDING AND CURRENT ROW), + w10d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW)) as trx_fe + last join {1} order by {1}.crd_lst_isu_dte on trx_fe.merchant_id = {1}.merchant_nbr and trx_fe.trx_time >= {1}.crd_lst_isu_dte; + expect: + columns: ["id int", "card_no string", "merchant_id int", "trx_time timestamp", + "sum_trx_amt float", "count_merchant_id int64", "crd_lst_isu_dte timestamp", + "merchant_nbr int"] + order: id + rows: + - [1, "aaaaaaaaaa", 1, 1590738989000, 1.1, 1, 1590738988000, 1] + - [2, "aaaaaaaaaa", 1, 1590738990000, 3.3, 2, 1590738990000, 1] + - [3, "bb", 2, 1590738990000, 3.3, 1, null, null] + - [4, "cc", 3, 1590738990000, 4.0, 1, 1590738989000, 3] + - [5, "cc", 3, 1590738991000, 9.0, 2, 1590738989000, 3] + - [6, "cc", 3, 1590738992000, 15.0, 3, 1590738992000, 3] + - [7, "cc", 2, 1590738993000, 22.0, 4, 1590738991000, 2] + - + id: 4 + desc: 3组窗口特征ID拼接 + inputs: + - + columns : ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp"] + indexs: ["index1:c1:c7", "index2:c2:c7", "index3:c3:c7", "index4:c4:c7"] + rows: + - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000] + - [ 2, "a", "aa", "aaa", "aaaa", "1.0", 1590738991000] + - [ 3, "a", "aa", "aaa", "bbbb", "1.0", 1590738992000] + - [ 4, "a", "aa", "aaa", "bbbb", "1.0", 1590738993000] + - [ 5, "a", "aa", "bbb", "bbbb", "1.0", 1590738994000] + - [ 6, "a", "aa", "bbb", "bbbb", "1.0", 1590738995000] + - [ 7, "a", "bb", "bbb", "bbbb", "1.0", 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", "1.0", 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", "1.0", 1590739998000 ] + - [10, "b", "bb", "bbb", "bbbb", "1.0", 1590739999000 ] + sql: | + select * from + ( + select id as out1_id, c1, c6 from {0} + ) as out1 last join + ( + select id as out2_id, c2, sum(c6) over w2 as w2_sum_c6 from {0} + window w2 as (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as out2 on out1_id=out2_id last join + ( + select id as out3_id, c3, sum(c6) over w3 as w3_sum_c6 from {0} + window w3 as (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as out3 on out1_id=out3_id last join + ( + select id as out4_id, c4, sum(c6) over w4 as w4_sum_c6 from {0} + window w4 as (PARTITION BY {0}.c4 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as out4 on out1_id=out4_id; + expect: + columns: ["out1_id int", "c1 string", "c6 double", + "out2_id int", "c2 string", "w2_sum_c6 double", + "out3_id int", "c3 string", "w3_sum_c6 double", + "out4_id int", "c4 string", "w4_sum_c6 double",] + order: out1_id + rows: + - [ 1, "a", 1.0, 1, "aa", 1.0, 1, "aaa", 1.0, 1, "aaaa", 1.0] + - [ 2, "a", 1.0, 2, "aa", 2.0, 2, "aaa", 2.0, 2, "aaaa", 2.0] + - [ 3, "a", 1.0, 3, "aa", 3.0, 3, "aaa", 3.0, 3, "bbbb", 1.0] + - [ 4, "a", 1.0, 4, "aa", 4.0, 4, "aaa", 4.0, 4, "bbbb", 2.0] + - [ 5, "a", 1.0, 5, "aa", 5.0, 5, "bbb", 1.0, 5, "bbbb", 3.0] + - [ 6, "a", 1.0, 6, "aa", 6.0, 6, "bbb", 2.0, 6, "bbbb", 4.0] + - [ 7, "a", 1.0, 7, "bb", 1.0, 7, "bbb", 3.0, 7, "bbbb", 5.0] + - [ 8, "a", 1.0, 8, "bb", 2.0, 8, "bbb", 4.0, 8, "bbbb", 6.0] + - [ 9, "b", 1.0, 9, "bb", 3.0, 9, "bbb", 5.0, 9, "bbbb", 7.0] + - [10, "b", 1.0, 10, "bb", 4.0, 10, "bbb", 6.0, 10, "bbbb", 8.0] + - + id: 5 + desc: 4组窗口特征ID拼接 + inputs: + - + columns : ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp"] + indexs: ["index1:c1:c7", "index2:c2:c7", "index3:c3:c7", "index4:c4:c7"] + rows: + - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000] + - [ 2, "a", "aa", "aaa", "aaaa", "1.0", 1590738991000] + - [ 3, "a", "aa", "aaa", "bbbb", "1.0", 1590738992000] + - [ 4, "a", "aa", "aaa", "bbbb", "1.0", 1590738993000] + - [ 5, "a", "aa", "bbb", "bbbb", "1.0", 1590738994000] + - [ 6, "a", "aa", "bbb", "bbbb", "1.0", 1590738995000] + - [ 7, "a", "bb", "bbb", "bbbb", "1.0", 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", "1.0", 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", "1.0", 1590739998000 ] + - [10, "b", "bb", "bbb", "bbbb", "1.0", 1590739999000 ] + sql: | + select * from + ( + select id as out1_id, c1, sum(c6) over w1 as w1_sum_c6 from {0} + window w1 as (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as out1 last join + ( + select id as out2_id, c2, sum(c6) over w2 as w2_sum_c6 from {0} + window w2 as (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as out2 on out1_id=out2_id last join + ( + select id as out3_id, c3, sum(c6) over w3 as w3_sum_c6 from {0} + window w3 as (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as out3 on out1_id=out3_id last join + ( + select id as out4_id, c4, sum(c6) over w4 as w4_sum_c6 from {0} + window w4 as (PARTITION BY {0}.c4 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as out4 on out1_id=out4_id; + request_plan: | + SIMPLE_PROJECT(sources=(out1_id, c1, w1_sum_c6, out2_id, c2, w2_sum_c6, out3_id, c3, w3_sum_c6, out4.out4_id, out4.c4, out4.w4_sum_c6)) + REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out4_id), index_keys=) + REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out3_id), index_keys=) + REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out2_id), index_keys=) + RENAME(name=out1) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + RENAME(name=out2) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c2)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index2) + RENAME(name=out3) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c3)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index3) + RENAME(name=out4) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c4)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index4) + + cluster_request_plan: | + SIMPLE_PROJECT(sources=(out1_id, c1, w1_sum_c6, out2_id, c2, w2_sum_c6, out3_id, c3, w3_sum_c6, out4.out4_id, out4.c4, out4.w4_sum_c6)) + REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out4_id), index_keys=) + REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out3_id), index_keys=) + REQUEST_JOIN(type=LastJoin, condition=, left_keys=(out1_id), right_keys=(out2_id), index_keys=) + RENAME(name=out1) + SIMPLE_PROJECT(sources=(out1_id, c1, w1_sum_c6)) + REQUEST_JOIN(type=kJoinTypeConcat) + SIMPLE_PROJECT(sources=(id -> out1_id, c1)) + DATA_PROVIDER(request=auto_t0) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + RENAME(name=out2) + SIMPLE_PROJECT(sources=(out2_id, c2, w2_sum_c6)) + REQUEST_JOIN(type=kJoinTypeConcat) + SIMPLE_PROJECT(sources=(id -> out2_id, c2)) + DATA_PROVIDER(request=auto_t0) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c2)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index2) + RENAME(name=out3) + SIMPLE_PROJECT(sources=(out3_id, c3, w3_sum_c6)) + REQUEST_JOIN(type=kJoinTypeConcat) + SIMPLE_PROJECT(sources=(id -> out3_id, c3)) + DATA_PROVIDER(request=auto_t0) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c3)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index3) + RENAME(name=out4) + SIMPLE_PROJECT(sources=(out4_id, c4, w4_sum_c6)) + REQUEST_JOIN(type=kJoinTypeConcat) + SIMPLE_PROJECT(sources=(id -> out4_id, c4)) + DATA_PROVIDER(request=auto_t0) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c4)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index4) + expect: + columns: ["out1_id int", "c1 string", "w1_sum_c6 double", + "out2_id int", "c2 string", "w2_sum_c6 double", + "out3_id int", "c3 string", "w3_sum_c6 double", + "out4_id int", "c4 string", "w4_sum_c6 double",] + order: out1_id + rows: + - [ 1, "a", 1.0, 1, "aa", 1.0, 1, "aaa", 1.0, 1, "aaaa", 1.0] + - [ 2, "a", 2.0, 2, "aa", 2.0, 2, "aaa", 2.0, 2, "aaaa", 2.0] + - [ 3, "a", 3.0, 3, "aa", 3.0, 3, "aaa", 3.0, 3, "bbbb", 1.0] + - [ 4, "a", 4.0, 4, "aa", 4.0, 4, "aaa", 4.0, 4, "bbbb", 2.0] + - [ 5, "a", 5.0, 5, "aa", 5.0, 5, "bbb", 1.0, 5, "bbbb", 3.0] + - [ 6, "a", 6.0, 6, "aa", 6.0, 6, "bbb", 2.0, 6, "bbbb", 4.0] + - [ 7, "a", 7.0, 7, "bb", 1.0, 7, "bbb", 3.0, 7, "bbbb", 5.0] + - [ 8, "a", 8.0, 8, "bb", 2.0, 8, "bbb", 4.0, 8, "bbbb", 6.0] + - [ 9, "b", 1.0, 9, "bb", 3.0, 9, "bbb", 5.0, 9, "bbbb", 7.0] + - [10, "b", 2.0, 10, "bb", 4.0, 10, "bbb", 6.0, 10, "bbbb", 8.0] + - + id: 6 + desc: 窗口特征拼接多张副表, last join 条件表达式1 + inputs: + - + columns : ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000] + - [ 2, "a", "aa", "aaa", "aaaa", "2.0", 1590738991000] + - [ 3, "a", "aa", "aaa", "bbbb", "3.0", 1590738992000] + - [ 4, "a", "aa", "aaa", "bbbb", "4.0", 1590738993000] + - [ 5, "a", "aa", "bbb", "bbbb", "5.0", 1590738994000] + - [ 6, "a", "aa", "bbb", "bbbb", "6.0", 1590738995000] + - [ 7, "a", "bb", "bbb", "bbbb", "7.0", 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", "8.0", 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", "9.0", 1590738998000 ] + - [10, "b", "bb", "bbb", "bbbb", "10.0", 1590738999000 ] + - columns: ["rid int", "x1 string", "x2 string", "x3 string", "x4 string", "x6 double", "x7 timestamp"] + indexs: ["index1:x1:x7", "index2:x2:x7", "index3:x3:x7", "index4:x4:x7", ] + rows: + - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000 ] + - [ 2, "a", "aa", "aaa", "aaaa", "1.0", 1590738991000 ] + - [ 3, "a", "aa", "aaa", "bbbb", "1.0", 1590738992000 ] + - [ 4, "a", "aa", "aaa", "bbbb", "1.0", 1590738993000 ] + - [ 5, "a", "aa", "bbb", "bbbb", "1.0", 1590738994000 ] + - [ 6, "a", "aa", "bbb", "bbbb", "1.0", 1590738995000 ] + - [ 7, "a", "bb", "bbb", "bbbb", "1.0", 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", "1.0", 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", "1.0", 1590738998000 ] + - [ 10, "b", "bb", "bbb", "bbbb", "1.0",1590738999000 ] + sql: | + select id, c1, c2, c3, c4, c6, c7, cur_hour, today + , w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6 + , t1.rid as t1_rid, t2.rid as t2_rid, t3.rid as t3_rid, t4.rid as t4_rid + from + ( + select id, c1, c2, c3, c4, c6, c7, hour(c7) as cur_hour, day(c7) as today + , sum(c6) over w1 as w1_sum_c6 + , max(c6) over w1 as w1_max_c6 + , min(c6) over w1 as w1_min_c6 + , avg(c6) over w1 as w1_avg_c6 + , count(c6) over w1 as w1_cnt_c6 + from {0} + window w1 as (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as w_out last join {1} as t1 order by t1.x7 on c1 = t1.x1 and c7 - 1000 >= t1.x7 + last join {1} as t2 order by t2.x7 on c2 = t2.x2 and c7 - 2000 >= t2.x7 + last join {1} as t3 order by t3.x7 on c3 = t3.x3 and c7 - 3000 >= t3.x7 + last join {1} as t4 order by t4.x7 on c4 = t4.x4 and c7 - 4000 >= t4.x7; + request_plan: | + SIMPLE_PROJECT(sources=(id, c1, c2, c3, c4, c6, c7, cur_hour, today, w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6, t1.rid -> t1_rid, t2.rid -> t2_rid, t3.rid -> t3_rid, t4.rid -> t4_rid)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=c7 - 4000 >= t4.x7, left_keys=(), right_keys=(), index_keys=(c4)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=c7 - 3000 >= t3.x7, left_keys=(), right_keys=(), index_keys=(c3)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=c7 - 2000 >= t2.x7, left_keys=(), right_keys=(), index_keys=(c2)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=c7 - 1000 >= t1.x7, left_keys=(), right_keys=(), index_keys=(c1)) + RENAME(name=w_out) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index1) + RENAME(name=t2) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index2) + RENAME(name=t3) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index3) + RENAME(name=t4) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index4) + cluster_request_plan: | + SIMPLE_PROJECT(sources=(id, c1, c2, c3, c4, c6, c7, cur_hour, today, w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6, t1.rid -> t1_rid, t2.rid -> t2_rid, t3.rid -> t3_rid, t4.rid -> t4_rid)) + REQUEST_JOIN(type=kJoinTypeConcat) + REQUEST_JOIN(type=kJoinTypeConcat) + REQUEST_JOIN(type=kJoinTypeConcat) + REQUEST_JOIN(type=kJoinTypeConcat) + RENAME(name=w_out) + SIMPLE_PROJECT(sources=(id, c1, c2, c3, c4, c6, c7, cur_hour, today, w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=RowProject) + DATA_PROVIDER(request=auto_t0) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + REQUEST_JOIN(OUTPUT_RIGHT_ONLY, type=LastJoin, right_sort=(ASC), condition=#14 - 1000 >= #35, left_keys=(), right_keys=(), index_keys=(#9)) + SIMPLE_PROJECT(sources=(#9 -> c1, #14 -> c7)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index1) + REQUEST_JOIN(OUTPUT_RIGHT_ONLY, type=LastJoin, right_sort=(ASC), condition=#14 - 2000 >= #35, left_keys=(), right_keys=(), index_keys=(#10)) + SIMPLE_PROJECT(sources=(#10 -> c2, #14 -> c7)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t2) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index2) + REQUEST_JOIN(OUTPUT_RIGHT_ONLY, type=LastJoin, right_sort=(ASC), condition=#14 - 3000 >= #35, left_keys=(), right_keys=(), index_keys=(#11)) + SIMPLE_PROJECT(sources=(#11 -> c3, #14 -> c7)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t3) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index3) + REQUEST_JOIN(OUTPUT_RIGHT_ONLY, type=LastJoin, right_sort=(ASC), condition=#14 - 4000 >= #35, left_keys=(), right_keys=(), index_keys=(#12)) + SIMPLE_PROJECT(sources=(#12 -> c4, #14 -> c7)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t4) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index4) + expect: + columns: ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp", + "cur_hour int32", "today int32", "w1_sum_c6 double", "w1_max_c6 double", + "w1_min_c6 double", "w1_avg_c6 double", "w1_cnt_c6 bigint", + "t1_rid int32", "t2_rid int32", "t3_rid int32", "t4_rid int32"] + order: id + rows: + - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000, 15, 29, 1.0, 1.0, 1.0, 1.0, 1, NULL, NULL, NULL, NULL] + - [ 2, "a", "aa", "aaa", "aaaa", "2.0", 1590738991000, 15, 29, 3.0, 2.0, 1.0, 1.5, 2, 1, NULL, NULL, NULL ] + - [ 3, "a", "aa", "aaa", "bbbb", "3.0", 1590738992000, 15, 29, 6.0, 3.0, 1.0, 2.0, 3, 2 , 1, NULL, NULL] + - [ 4, "a", "aa", "aaa", "bbbb", "4.0", 1590738993000, 15, 29, 10.0, 4.0, 1.0, 2.5, 4, 3 , 2, 1, NULL] + - [ 5, "a", "aa", "bbb", "bbbb", "5.0", 1590738994000, 15, 29, 15.0, 5.0, 1.0, 3.0, 5, 4 , 3, NULL, NULL] + - [ 6, "a", "aa", "bbb", "bbbb", "6.0", 1590738995000, 15, 29, 21.0, 6.0, 1.0, 3.5, 6, 5 , 4, NULL, NULL] + - [ 7, "a", "bb", "bbb", "bbbb", "7.0", 1590738996000, 15, 29, 28.0, 7.0, 1.0, 4.0, 7, 6 , NULL, NULL, 3] + - [ 8, "a", "bb", "bbb", "bbbb", "8.0", 1590738997000, 15, 29, 36.0, 8.0, 1.0, 4.5, 8, 7 , NULL, 5, 4] + - [ 9, "b", "bb", "bbb", "bbbb", "9.0", 1590738998000, 15, 29, 9.0, 9.0, 9.0, 9.0, 1, NULL , 7, 6, 5] + - [ 10, "b", "bb", "bbb", "bbbb", "10.0",1590738999000,15, 29, 19.0, 10.0, 9.0, 9.5, 2, 9, 8, 7, 6] + + + - + id: 7 + desc: 窗口特征拼接多张副表, last join 条件表达式2 + inputs: + - + columns : ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000] + - [ 2, "a", "aa", "aaa", "aaaa", "2.0", 1590738991000] + - [ 3, "a", "aa", "aaa", "bbbb", "3.0", 1590738992000] + - [ 4, "a", "aa", "aaa", "bbbb", "4.0", 1590738993000] + - [ 5, "a", "aa", "bbb", "bbbb", "5.0", 1590738994000] + - [ 6, "a", "aa", "bbb", "bbbb", "6.0", 1590738995000] + - [ 7, "a", "bb", "bbb", "bbbb", "7.0", 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", "8.0", 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", "9.0", 1590738998000 ] + - [10, "b", "bb", "bbb", "bbbb", "10.0", 1590738999000 ] + - columns: ["rid int", "x1 string", "x2 string", "x3 string", "x4 string", "x6 double", "x7 timestamp"] + indexs: ["index1:x1:x7", "index2:x2:x7", "index3:x3:x7", "index4:x4:x7", ] + rows: + - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000 ] + - [ 2, "a", "aa", "aaa", "aaaa", "1.0", 1590738991000 ] + - [ 3, "a", "aa", "aaa", "bbbb", "1.0", 1590738992000 ] + - [ 4, "a", "aa", "aaa", "bbbb", "1.0", 1590738993000 ] + - [ 5, "a", "aa", "bbb", "bbbb", "1.0", 1590738994000 ] + - [ 6, "a", "aa", "bbb", "bbbb", "1.0", 1590738995000 ] + - [ 7, "a", "bb", "bbb", "bbbb", "1.0", 1590738996000 ] + - [ 8, "a", "bb", "bbb", "bbbb", "1.0", 1590738997000 ] + - [ 9, "b", "bb", "bbb", "bbbb", "1.0", 1590738998000 ] + - [ 10, "b", "bb", "bbb", "bbbb", "1.0",1590738999000 ] + sql: | + select id, c1, c2, c3, c4, c6, c7, cur_hour, today + , w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6 + , t1.rid as t1_rid, t2.rid as t2_rid, t3.rid as t3_rid, t4.rid as t4_rid + from + ( + select id, c1, c2, c3, c4, c6, c7, hour(c7) as cur_hour, day(c7) as today + , sum(c6) over w1 as w1_sum_c6 + , max(c6) over w1 as w1_max_c6 + , min(c6) over w1 as w1_min_c6 + , avg(c6) over w1 as w1_avg_c6 + , count(c6) over w1 as w1_cnt_c6 + from {0} + window w1 as (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) as w_out last join {1} as t1 order by t1.x7 on c1 = t1.x1 and c7 - 1000 >= t1.x7 + last join {1} as t2 order by t2.x7 on w_out.c2 = t2.x2 and c7 - 2000 >= t2.x7 + last join {1} as t3 order by t3.x7 on w_out.c3 = t3.x3 and c7 - 3000 >= t3.x7 + last join {1} as t4 order by t4.x7 on w_out.c4 = t4.x4 and c7 - 4000 >= t4.x7; + request_plan: | + SIMPLE_PROJECT(sources=(id, c1, c2, c3, c4, c6, c7, cur_hour, today, w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6, t1.rid -> t1_rid, t2.rid -> t2_rid, t3.rid -> t3_rid, t4.rid -> t4_rid)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=c7 - 4000 >= t4.x7, left_keys=(), right_keys=(), index_keys=(w_out.c4)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=c7 - 3000 >= t3.x7, left_keys=(), right_keys=(), index_keys=(w_out.c3)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=c7 - 2000 >= t2.x7, left_keys=(), right_keys=(), index_keys=(w_out.c2)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=c7 - 1000 >= t1.x7, left_keys=(), right_keys=(), index_keys=(c1)) + RENAME(name=w_out) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index1) + RENAME(name=t2) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index2) + RENAME(name=t3) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index3) + RENAME(name=t4) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index4) + cluster_request_plan: | + SIMPLE_PROJECT(sources=(id, c1, c2, c3, c4, c6, c7, cur_hour, today, w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6, t1.rid -> t1_rid, t2.rid -> t2_rid, t3.rid -> t3_rid, t4.rid -> t4_rid)) + REQUEST_JOIN(type=kJoinTypeConcat) + REQUEST_JOIN(type=kJoinTypeConcat) + REQUEST_JOIN(type=kJoinTypeConcat) + REQUEST_JOIN(type=kJoinTypeConcat) + RENAME(name=w_out) + SIMPLE_PROJECT(sources=(id, c1, c2, c3, c4, c6, c7, cur_hour, today, w1_sum_c6, w1_max_c6, w1_min_c6, w1_avg_c6, w1_cnt_c6)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=RowProject) + DATA_PROVIDER(request=auto_t0) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 864000000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + REQUEST_JOIN(OUTPUT_RIGHT_ONLY, type=LastJoin, right_sort=(ASC), condition=#14 - 1000 >= #35, left_keys=(), right_keys=(), index_keys=(#9)) + SIMPLE_PROJECT(sources=(#9 -> c1, #14 -> c7)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index1) + REQUEST_JOIN(OUTPUT_RIGHT_ONLY, type=LastJoin, right_sort=(ASC), condition=#14 - 2000 >= #35, left_keys=(), right_keys=(), index_keys=(#10)) + SIMPLE_PROJECT(sources=(#10 -> w_out.c2, #14 -> c7)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t2) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index2) + REQUEST_JOIN(OUTPUT_RIGHT_ONLY, type=LastJoin, right_sort=(ASC), condition=#14 - 3000 >= #35, left_keys=(), right_keys=(), index_keys=(#11)) + SIMPLE_PROJECT(sources=(#11 -> w_out.c3, #14 -> c7)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t3) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index3) + REQUEST_JOIN(OUTPUT_RIGHT_ONLY, type=LastJoin, right_sort=(ASC), condition=#14 - 4000 >= #35, left_keys=(), right_keys=(), index_keys=(#12)) + SIMPLE_PROJECT(sources=(#12 -> w_out.c4, #14 -> c7)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t4) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index4) + expect: + columns: ["id int", "c1 string", "c2 string", "c3 string", "c4 string", "c6 double", "c7 timestamp", + "cur_hour int32", "today int32", "w1_sum_c6 double", "w1_max_c6 double", + "w1_min_c6 double", "w1_avg_c6 double", "w1_cnt_c6 bigint", + "t1_rid int32", "t2_rid int32", "t3_rid int32", "t4_rid int32"] + order: id + rows: + - [ 1, "a", "aa", "aaa", "aaaa", "1.0", 1590738990000, 15, 29, 1.0, 1.0, 1.0, 1.0, 1, NULL, NULL, NULL, NULL] + - [ 2, "a", "aa", "aaa", "aaaa", "2.0", 1590738991000, 15, 29, 3.0, 2.0, 1.0, 1.5, 2, 1, NULL, NULL, NULL ] + - [ 3, "a", "aa", "aaa", "bbbb", "3.0", 1590738992000, 15, 29, 6.0, 3.0, 1.0, 2.0, 3, 2 , 1, NULL, NULL] + - [ 4, "a", "aa", "aaa", "bbbb", "4.0", 1590738993000, 15, 29, 10.0, 4.0, 1.0, 2.5, 4, 3 , 2, 1, NULL] + - [ 5, "a", "aa", "bbb", "bbbb", "5.0", 1590738994000, 15, 29, 15.0, 5.0, 1.0, 3.0, 5, 4 , 3, NULL, NULL] + - [ 6, "a", "aa", "bbb", "bbbb", "6.0", 1590738995000, 15, 29, 21.0, 6.0, 1.0, 3.5, 6, 5 , 4, NULL, NULL] + - [ 7, "a", "bb", "bbb", "bbbb", "7.0", 1590738996000, 15, 29, 28.0, 7.0, 1.0, 4.0, 7, 6 , NULL, NULL, 3] + - [ 8, "a", "bb", "bbb", "bbbb", "8.0", 1590738997000, 15, 29, 36.0, 8.0, 1.0, 4.5, 8, 7 , NULL, 5, 4] + - [ 9, "b", "bb", "bbb", "bbbb", "9.0", 1590738998000, 15, 29, 9.0, 9.0, 9.0, 9.0, 1, NULL , 7, 6, 5] + - [ 10, "b", "bb", "bbb", "bbbb", "10.0",1590738999000,15, 29, 19.0, 10.0, 9.0, 9.5, 2, 9, 8, 7, 6] diff --git a/cases/integration_test/data_expiration/test_data_expiration.yaml b/cases/integration_test/data_expiration/test_data_expiration.yaml new file mode 100644 index 00000000000..d686692bd92 --- /dev/null +++ b/cases/integration_test/data_expiration/test_data_expiration.yaml @@ -0,0 +1,70 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: +- id: 0 + desc: ttl_type=latest,ttl=4,insert 10 + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4:4:latest"] + rows: + - ["bb", 2, 3, 1590738989000] + - ["bb", 4, 5, 1590738990000] + - ["bb", 6, 7, 1590738991000] + - ["bb", 8, 9, 1590738992000] + - ["bb", 10, 11, 1590738993000] + - ["bb", 12, 13, 1590738994000] + - ["bb", 14, 15, 1590738995000] + - ["bb", 16, 17, 1590738996000] + - ["bb", 18, 19, 1590738997000] + - ["bb", 20, 21, 1590738998000] + sql: select c1,c2,c3 from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint"] + rows: + - ["bb", 20, 21] + - ["bb", 18, 19] + - ["bb", 16, 17] + - ["bb", 14, 15] + +- id: 16 + desc: 创建磁盘表,ttl_type=absolute,ttl=10m, insert 10 + mode: request-unsupport + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4:10m:absolute"] + storage: hdd + rows: + - ["bb", 2, 3, "{currentTime}-100"] + - ["bb", 4, 5, "{currentTime}-200"] + - ["bb", 6, 7, "{currentTime}-599000"] + - ["bb", 8, 9, "{currentTime}-600000"] + - ["bb", 10, 11, "{currentTime}-600005"] + - ["bb", 12, 13, "{currentTime}-600006"] + - ["bb", 14, 15, "{currentTime}-600007"] + - ["bb", 16, 17, "{currentTime}-600008"] + - ["bb", 18, 19, "{currentTime}-600009"] + - ["bb", 20, 21, "{currentTime}-600010"] + sql: select c1,c2,c3 from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint"] + rows: + - ["bb", 2, 3] + - ["bb", 4, 5] + - ["bb", 6, 7] \ No newline at end of file diff --git a/cases/integration_test/ddl/test_create.yaml b/cases/integration_test/ddl/test_create.yaml new file mode 100644 index 00000000000..c877221404e --- /dev/null +++ b/cases/integration_test/ddl/test_create.yaml @@ -0,0 +1,559 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 创建所有类型的表 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 1 + desc: 创建两个相同时间列的索引的表 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( + c1 string, + c2 int, + c3 timestamp, + c4 timestamp, + index(key=(c1),ts=c4), + index(key=(c2),ts=c4)); + insert: | + insert into {0} values ("aa", 1, 1590738990000, 1590738989000); + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + rows: + - ["aa", 1, 1590738990000, 1590738989000] + - + id: 2 + desc: 创建两个不同时间列的索引的表 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4","index2:c2:c3"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + rows: + - [aa,1,1590738990000,1590738989000] + - + id: 3 + desc: 创建一个联合索引的表 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1|c2:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + rows: + - [aa,1,1590738990000,1590738989000] + - + id: 4 + desc: NotNull的列为index + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["c1 string NOT NULL","c2 int","c3 timestamp","c4 timestamp"] + create: | + create table {0} ( + c1 string NOT NULL, + c2 int, + c3 timestamp, + c4 timestamp, + index(key=(c1),ts=c4)); + insert: | + insert into {0} values ("aa", 1, 1590738990000, 1590738989000); + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + rows: + - [aa,1,1590738990000,1590738989000] + - + id: 5 + desc: 表名以数字开头 + sqlDialect: ["HybridSQL"] + sql: create table 1aaa(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: false + - + id: 6-1 + desc: 表名为保留关键字 + sqlDialect: ["HybridSQL"] + sql: create table order(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: false + - + id: 6-2 + desc: 表名为非保留关键字 + sqlDialect: ["HybridSQL"] + inputs: + - name: table + sql: create table table(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: true + - + id: 7 + desc: 列名以数字开头 + sqlDialect: ["HybridSQL"] + sql: create table {auto}(1c string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: false + - + id: 8 + desc: 列名为保留关键字 + sqlDialect: ["HybridSQL"] + sql: create table {auto}(use string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: false + - + id: 9 + desc: 语句缺少分号 + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: true + - + id: 10 + desc: 列的类型不存在 + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 varchar2 NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: false + - + id: 11 + desc: index指定的col不存在 + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c5),ts=c4,ttl=0m)); + expect: + success: false + - + id: 12 + desc: index指定的ts不存在 + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c5,ttl=0m)); + expect: + success: false + - + id: 13 + desc: 创建的index不指定ts + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1))); + expect: + success: true + - + id: 14 + desc: 创建index不指定col + mode: standalone-unsupport + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(ts=c4,ttl=0m)); + expect: + success: true + - + id: 15 + desc: ts边界-指定的ts为string + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 string,c3 timestamp,c4 timestamp,index(key=(c1),ts=c2,ttl=0m)); + expect: + success: false + - + id: 16 + desc: ts边界-指定的ts为int + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c2,ttl=0m)); + expect: + success: false + - + id: 17 + desc: ts边界-指定的ts为smallint + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 smallint,c3 timestamp,c4 timestamp,index(key=(c1),ts=c2,ttl=0m)); + expect: + success: false + - + id: 18 + desc: ts边界-指定的ts为date + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 date,c3 timestamp,c4 timestamp,index(key=(c1),ts=c2,ttl=0m)); + expect: + success: false + - + id: 19 + desc: ts边界-指定的ts为float + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 float,c3 timestamp,c4 timestamp,index(key=(c1),ts=c2,ttl=0m)); + expect: + success: false + - + id: 20 + desc: ts边界-指定的ts为double + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 double,c3 timestamp,c4 timestamp,index(key=(c1),ts=c2,ttl=0m)); + expect: + success: false + - + id: 21 + desc: ts边界-指定的ts为bool + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1 string NOT NULL,c2 bool,c3 timestamp,c4 timestamp,index(key=(c1),ts=c2,ttl=0m)); + expect: + success: false + - + id: 22 + desc: 表名使用特殊字符 + sqlDialect: ["HybridSQL"] + sql: create table auto$#kJKytImk(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: false + - + id: 23 + desc: 列名使用特殊字符 + sqlDialect: ["HybridSQL"] + sql: create table {auto}(c1$# string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: false + - + id: 24 + desc: 指定的ts为bigint + inputs: + - + columns : ["c1 string","c2 bigint","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c2"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: select * from {0}; + expect: + columns: ["c1 string","c2 bigint","c3 timestamp","c4 timestamp"] + - + id: 25 + desc: 指定的ts为bigint+ttl + sqlDialect: ["HybridSQL"] + inputs: + - + create: create table {0} (c1 string NOT NULL,c2 bigint,c3 timestamp, c4 timestamp,index(key=(c1),ts=c2,ttl=0m)); + insert: insert into {0} values ("aa", 1, 1590738990000, 1590738989000); + sql: select * from {0}; + expect: + columns: ["c1 string","c2 bigint","c3 timestamp","c4 timestamp"] + - + id: 26 + desc: 创建已经存在的表 + inputs: + - + columns : ["c1 string","c2 bigint","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + sql: create table {0}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: false + - + id: 27 + desc: key边界-bigint为索引列 + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c4:c7"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + - + id: 28 + desc: key边界-int为索引列 + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + - + id: 29 + desc: key边界-timestamp为索引列 + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c7:c4"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + - + id: 30 + desc: key边界-date为索引列 + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c8),ts=c7)); + expect: + success: true + - + id: 31 + desc: key边界-float为索引列 + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c5),ts=c7)); + expect: + success: false + - + id: 32 + desc: key边界-double为索引列 + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c6),ts=c7)); + expect: + success: false + - + id: 33 + desc: key边界-smallint为索引列 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c2:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 34 + desc: key边界-bool类型为索引列 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c9:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 35 + desc: key边界-key和ts为同一列 + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c4),ts=c4)); + expect: + success: true + - id: 36 + desc: create col with __prefix + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + __c1 string, __c3 int, __ts bigint, + index(key=__c1, ts=__ts)); + expect: + success: true + - + id: 37 + desc: create with replica num + sqlDialect: ["HybridSQL"] + mode: standalone-unsupport + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3), ts=c4)) + options ( + replicanum = 2 + ); + expect: + success: true + - + id: 38 + desc: create with replica num and distribution + mode: standalone-unsupport + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3),ts=c4)) + options ( + replicanum = 2, + distribution = [ ('{tb_endpoint_0}', ['{tb_endpoint_1}'])] + ); + expect: + success: true + - + id: 39 + desc: create with replica num and distribution + mode: standalone-unsupport + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3),ts=c4)) + options ( + replicanum = 3, + distribution = [ ('{tb_endpoint_0}', ['{tb_endpoint_1}'])] + ); + expect: + success: false + - + id: 40 + desc: create with replica num and distribution + mode: standalone-unsupport + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3),ts=c4)) + options ( + replicanum = 2, + distribution = [ ('{tb_endpoint_0}', ['{tb_endpoint_0}'])] + ); + expect: + success: false + - + id: 41 + desc: create with partition num + sqlDialect: ["HybridSQL"] +# mode: standalone-unsupport + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3), ts=c4)) + options ( + partitionnum = 8 + ); + expect: + success: true + - + id: 42 + desc: create with partition num + sqlDialect: ["HybridSQL"] + mode: standalone-unsupport + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3), ts=c4)) + options ( + replicanum = 2, + partitionnum = 8 + ); + expect: + success: true + - + id: 43 + desc: no index + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date); + expect: + success: true + - + id: 44 + desc: bool-insert-1 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",1] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 45 + desc: create with two no ts index + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3), ttl=(10m,10), ttl_type=absorlat), + index(key=(c4), ttl=(10m,10), ttl_type=absorlat)); + expect: + success: true + - + id: 46 + desc: one has ts and another has not + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3), ttl=(10m,10), ttl_type=absorlat), + index(key=(c4), ts=c4, ttl=(10m,10), ttl_type=absorlat)); + expect: + success: true + - + id: 47 + desc: create with only key + sqlDialect: ["HybridSQL"] + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c3)), + index(key=(c4))); + expect: + success: true + - + id: 48 + desc: insert min int and max int + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( + id int64, + order_0_timestamp timestamp, + c_2_int32 int32, + index(key=(id),ts=order_0_timestamp)); + insert: | + insert into {0} values + (0,1538443518561,-2147483648); + sql: select * from {0}; + expect: + success: true diff --git a/cases/integration_test/ddl/test_create_index.yaml b/cases/integration_test/ddl/test_create_index.yaml new file mode 100644 index 00000000000..6d4ce9e14cd --- /dev/null +++ b/cases/integration_test/ddl/test_create_index.yaml @@ -0,0 +1,761 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 冒烟测试 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=100m, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 100min + ttlType: kAbsoluteTime + - + id: 1 + desc: 指定多个列 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c1,c2) OPTIONS (ts=c4, ttl=100m, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c1","c2"] + ts: "c4" + ttl: 100min + ttlType: kAbsoluteTime + - + id: 2 + desc: 不指定ts + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: CREATE INDEX index1 ON {0} (c1,c2) OPTIONS (ttl=100, ttl_type=absolute); + expect: + success: false + - + id: 3 + desc: 不指定ttl + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 4 + desc: 不指定ttl_type + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=100m); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 100min + ttlType: kAbsoluteTime + - + id: 5 + desc: ttl_type=latest,ttl=1d + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=1d, ttl_type=latest); + expect: + success: false + - + id: 6 + desc: ttl_type=absolute,ttl=1d + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=1d, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 1440min + ttlType: kAbsoluteTime + - + id: 7 + desc: ttl_type=absolute,ttl=1h + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=1h, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 60min + ttlType: kAbsoluteTime + - + id: 8 + desc: ttl_type=absolute,ttl=1m + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=1m, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 1min + ttlType: kAbsoluteTime + - + id: 9 + desc: ttl_type=absolute,ttl=1s + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=1s, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 1min + ttlType: kAbsoluteTime + - + id: 10 + desc: ttl_type=absolute,ttl=1 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=1, ttl_type=absolute); + expect: + success: false + - + id: 11 + desc: ttl_type=absolute,ttl=0 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=0, ttl_type=absolute); + expect: + success: false + - + id: 12 + desc: ttl_type=absolute,ttl=0m + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=0m, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 13 + desc: ttl_type=latest,ttl=0 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=0, ttl_type=latest); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 0 + ttlType: kLatestTime + - + id: 14 + desc: ttl_type=latest,ttl=100 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=100, ttl_type=latest); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 100 + ttlType: kLatestTime + - + id: 15 + desc: ttl_type=absandlat,ttl=(10m,10) + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,10), ttl_type=absandlat); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 10min&&10 + ttlType: kAbsAndLat + - + id: 16 + desc: ttl_type=absorlat,ttl=(10m,10) + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,10), ttl_type=absorlat); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c4" + ttl: 10min||10 + ttlType: kAbsOrLat + - + id: 17 + desc: ttl_type=absandlat,ttl=(10,10m) + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10,10m), ttl_type=absandlat); + expect: + success: false + - + id: 18 + desc: ttl_type=absorlat,ttl=(10,10m) + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10,10m), ttl_type=absorlat); + expect: + success: false + - + id: 19 + desc: ttl_type为其他字符 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=1, ttl_type=test); + expect: + success: false + - + id: 20 + desc: ttl为字符 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sql: CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=aaa, ttl_type=absolute); + expect: + success: false + - + id: 21 + desc: 指定ttl_type=absolute,数据过期 + mode: standalone-unsupport + tags: ["单机版bug,添加索引后,select结果错误,@denglong,https://github.com/4paradigm/OpenMLDB/issues/708"] + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 3, 1590738990000,"{currentTime}-60"] + - [4,"aa", 1, 1590738990000,"{currentTime}"] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=10m, ttl_type=absolute); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [4,"aa", 1, 1590738990000] + - + id: 22 + desc: 指定ttl_type=latest,部分数据过期 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,1590738990000] + - [2,"aa", 1, 1590738990000,1590738991000] + - [3,"aa", 3, 1590738990000,1590738992000] + - [4,"aa", 1, 1590738990000,1590738993000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=2, ttl_type=latest); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [2,"aa", 1, 1590738990000] + - [4,"aa", 1, 1590738990000] + - + id: 23 + desc: 指定ttl_type=absandlat,部分数据过期 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,1590738990000] + - [2,"aa", 1, 1590738990000,1590738991000] + - [3,"aa", 1, 1590738990000,1590738992000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,2), ttl_type=absandlat); + - select * from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp","c4 timestamp"] + order: id + rows: + - [2,"aa", 1, 1590738990000,1590738991000] + - [3,"aa", 1, 1590738990000,1590738992000] + - + id: 24 + desc: 指定ttl_type=absorlat,部分数据过期 + inputs: + - + columns: ["c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:(10m,2):absorlat"] + rows: + - ["aa", 1, 1590738990000,1590738990000] + - ["aa", 1, 1590738990000,1590738990000] + - ["aa", 1, 1590738990000,1590738990000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,2), ttl_type=absorlat); + - select * from {0} where c2 = 1; + expect: + count: 0 + - + id: 25 + desc: 指定ttl_type=absandlat,部分数据过期-边界 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [4,"aa", 1, 1590738990000,"{currentTime}"] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,2), ttl_type=absandlat); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [3,"aa", 1, 1590738990000] + - [4,"aa", 1, 1590738990000] + - + id: 26 + desc: 指定ttl_type=absandlat,部分数据过期-边界2 + mode: standalone-unsupport + tags: ["单机版bug,添加索引后,select结果错误,@denglong,https://github.com/4paradigm/OpenMLDB/issues/708"] + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 1, 1590738990000,"{currentTime}-500000"] + - [3,"aa", 1, 1590738990000,"{currentTime}-500000"] + - [4,"aa", 1, 1590738990000,"{currentTime}"] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,1), ttl_type=absandlat); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [2,"aa", 1, 1590738990000] + - [3,"aa", 1, 1590738990000] + - [4,"aa", 1, 1590738990000] + - + id: 27 + desc: 指定ttl_type=absorlat,部分数据过期-边界 + mode: standalone-unsupport + tags: ["单机版bug,添加索引后,select结果错误,@denglong,https://github.com/4paradigm/OpenMLDB/issues/708"] + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 1, 1590738990000,"{currentTime}-500000"] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,2), ttl_type=absorlat); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [3,"aa", 1, 1590738990000] + - + id: 28 + desc: 指定ttl_type=absorlat,部分数据过期-边界2 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 1, 1590738990000,"{currentTime}-500000"] + - [4,"aa", 1, 1590738990000,"{currentTime}-400000"] + - [5,"aa", 1, 1590738990000,"{currentTime}"] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,2), ttl_type=absorlat); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [4,"aa", 1, 1590738990000] + - [5,"aa", 1, 1590738990000] + - + id: 29 + desc: 先创建索引,在插入数据,测试过期-absolute + mode: standalone-unsupport + tags: ["单机版bug,添加索引后,select结果错误,@denglong,https://github.com/4paradigm/OpenMLDB/issues/708"] + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 3, 1590738990000,"{currentTime}-60"] + - [4,"aa", 1, 1590738990000,"{currentTime}"] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=10m, ttl_type=absolute); + - insert into {0} values (5,'aa',1,1590738990000L,1590738990000L); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [4,"aa", 1, 1590738990000] + - + id: 30 + desc: 先创建索引,在插入数据,测试过期-latest + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,1590738990000] + - [2,"aa", 1, 1590738990000,1590738991000] + - [3,"aa", 3, 1590738990000,1590738992000] + - [4,"aa", 1, 1590738990000,1590738993000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=2, ttl_type=latest); + - insert into {0} values (5,'aa',1,1590738990000L,1590738994000L); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [4,"aa", 1, 1590738990000] + - [5,"aa", 1, 1590738990000] + - + id: 31 + desc: 先创建索引,在插入数据,测试过期-absandlat + mode: standalone-unsupport + tags: ["单机版bug,添加索引后,select结果错误,@denglong,https://github.com/4paradigm/OpenMLDB/issues/708"] + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 1, 1590738990000,"{currentTime}-500000"] + - [3,"aa", 1, 1590738990000,"{currentTime}-500000"] + - [4,"aa", 1, 1590738990000,"{currentTime}"] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,1), ttl_type=absandlat); + - insert into {0} values (5,'aa',1,1590738990000L,1590738994000L); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [2,"aa", 1, 1590738990000] + - [3,"aa", 1, 1590738990000] + - [4,"aa", 1, 1590738990000] + - + id: 32 + desc: 先创建索引,在插入数据,测试过期-absorlat + mode: standalone-unsupport + tags: ["单机版bug,添加索引后,select结果错误,@denglong,https://github.com/4paradigm/OpenMLDB/issues/708"] + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 1, 1590738990000,"{currentTime}-500000"] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c4, ttl=(10m,2), ttl_type=absorlat); + - insert into {0} values (5,'aa',1,1590738990000L,1590738994000L); + - select id,c1,c2,c3 from {0} where c2 = 1; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [3,"aa", 1, 1590738990000] + - + id: 33 + desc: key和ts相同 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c1) OPTIONS (ts=c4, ttl=100m, ttl_type=absolute); + expect: + success: false + - + id: 34 + desc: 创建索引,ts为一个新的列 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ts=c3, ttl=100m, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "c3" + ttl: 100min + ttlType: kAbsoluteTime + - + id: 35 + desc: 创建一个没有ts的索引 + inputs: + - + columns : ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [aa,1,1590738990000,1590738989000] + sqls: + - CREATE INDEX index1 ON {0} (c2) OPTIONS (ttl=100m, ttl_type=absolute); + - desc {0}; + expect: + success: true + idxs: + - + keys: ["c1"] + ts: "c4" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c2"] + ts: "-" + ttl: 100min + ttlType: kAbsoluteTime \ No newline at end of file diff --git a/cases/integration_test/ddl/test_create_no_index.yaml b/cases/integration_test/ddl/test_create_no_index.yaml new file mode 100644 index 00000000000..603d53498b3 --- /dev/null +++ b/cases/integration_test/ddl/test_create_no_index.yaml @@ -0,0 +1,283 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 创建表不指定索引 + inputs: + - columns: [ "id int not null","c1 int not null","c2 smallint not null","c3 float not null","c4 double not null","c5 bigint not null","c6 string not null","c7 timestamp not null","c8 date not null","c9 bool not null" ] + rows: + - [ 1, 1, 2, 3.3, 4.4, 5, "aa", 12345678, "2020-05-21", true ] + sql: desc {0}; + expect: + idxs: + - + keys: ["id"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 1 + desc: 第一列为smallint + inputs: + - + create: | + create table {0} ( + c2 smallint not null, + c3 float not null, + c4 double not null, + c5 bigint not null, + c6 string not null, + c7 timestamp not null, + c8 date not null, + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c2"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 2 + desc: 第一列为int + inputs: + - + create: | + create table {0} ( + c1 int not null, + c2 smallint not null, + c3 float not null, + c4 double not null, + c5 bigint not null, + c6 string not null, + c7 timestamp not null, + c8 date not null, + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c1"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 3 + desc: 第一列为long + inputs: + - + create: | + create table {0} ( + c5 bigint not null, + c6 string not null, + c7 timestamp not null, + c8 date not null, + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c5"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 4 + desc: 第一列为float + inputs: + - + create: | + create table {0} ( + c3 float not null, + c4 double not null, + c5 bigint not null, + c6 string not null, + c7 timestamp not null, + c8 date not null, + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c5"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 5 + desc: 第一列为double + inputs: + - + create: | + create table {0} ( + c4 double not null, + c5 bigint not null, + c6 string not null, + c7 timestamp not null, + c8 date not null, + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c5"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 6 + desc: 第一列为string + inputs: + - + create: | + create table {0} ( + c6 string not null, + c7 timestamp not null, + c8 date not null, + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c6"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 7 + desc: 第一列为timestamp + inputs: + - + create: | + create table {0} ( + c7 timestamp not null, + c8 date not null, + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c7"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 8 + desc: 第一列为date + inputs: + - + create: | + create table {0} ( + c8 date not null, + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c8"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 9 + desc: 第一列为bool + inputs: + - + create: | + create table {0} ( + c9 bool not null + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c9"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 10 + desc: 只有一列 + inputs: + - + create: | + create table {0} ( + c7 timestamp + ); + sql: desc {0}; + expect: + idxs: + - + keys: ["c7"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + id: 11 + desc: 不指定索引创建表,然后增加索引 + inputs: + - + create: | + create table {0} ( + c5 bigint not null, + c6 string not null, + c7 timestamp not null, + c8 date not null, + c9 bool not null + ); + sqls: + - "CREATE INDEX index1 ON {0} (c6) OPTIONS (ts=c7, ttl=100m, ttl_type=absolute);" + - "desc {0};" + expect: + idxs: + - + keys: ["c5"] + ts: "-" + ttl: 0min + ttlType: kAbsoluteTime + - + keys: ["c6"] + ts: "c7" + ttl: 100min + ttlType: kAbsoluteTime + - + id: 16 + desc: 创建表指定索引,没有默认索引 + inputs: + - columns: [ "id int not null","c1 int not null","c2 smallint not null","c3 float not null","c4 double not null","c5 bigint not null","c6 string not null","c7 timestamp not null","c8 date not null","c9 bool not null" ] + rows: + - [ 1, 1, 2, 3.3, 4.4, 5, "aa", 12345678, "2020-05-21", true ] + indexs: ["index1:c1:c5"] + sql: desc {0}; + expect: + idxs: + - + keys: ["c1"] + ts: "c5" + ttl: 0min + ttlType: kAbsoluteTime diff --git a/cases/integration_test/ddl/test_options.yaml b/cases/integration_test/ddl/test_options.yaml new file mode 100644 index 00000000000..d35fb6bec31 --- /dev/null +++ b/cases/integration_test/ddl/test_options.yaml @@ -0,0 +1,455 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 创建表时没有options + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + expect: + success: true + - + id: 1 + desc: 冒烟测试 + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 3, + distribution = [ ('{tb_endpoint_1}', [ '{tb_endpoint_0}','{tb_endpoint_2}' ])] + ); + expect: + name: t3 + success: true + options: + partitionNum: 1 + replicaNum: 3 + - + id: 2 + desc: 创建表时没有partitionnum + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + replicanum = 1, + distribution = [ ('{tb_endpoint_0}',[])] + ); + expect: + name: t3 + success: true + options: + partitionNum: 1 + replicaNum: 1 + - + id: 3 + desc: 创建表时没有replicanum + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + distribution = [ ('{tb_endpoint_0}',['{tb_endpoint_1}','{tb_endpoint_2}'])] + ); + expect: + name: t3 + success: true + options: + partitionNum: 1 + replicaNum: 3 + - + id: 4 + desc: 创建表时没有distribution + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 3 + ); + expect: + name: t3 + success: true + options: + partitionNum: 1 + replicaNum: 3 + - + id: 5 + desc: distribution多个 + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 2, + replicanum = 3, + distribution = [ ('{tb_endpoint_0}', [ '{tb_endpoint_1}','{tb_endpoint_2}' ]),('{tb_endpoint_0}', [ '{tb_endpoint_1}','{tb_endpoint_2}' ])] + ); + expect: + name: t3 + success: true + options: + partitionNum: 2 + replicaNum: 3 + - + id: 6 + desc: partitionnum=0,指定distribution + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 0, + replicanum = 3, + distribution = [ ('{tb_endpoint_0}', [ '{tb_endpoint_1}','{tb_endpoint_2}' ])] + ); + expect: + success: false + - + id: 7 + desc: partitionnum=10 + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 10, + replicanum = 3 + ); + expect: + name: t3 + success: true + options: + partitionNum: 10 + replicaNum: 3 + - + id: 8 + desc: replicanum=0 + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 0, + distribution = [ ('{tb_endpoint_0}',[])] + ); + expect: + success: false + - + id: 9 + desc: replicanum=1 + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 1, + distribution = [ ('{tb_endpoint_0}',[])] + ); + expect: + name: t3 + success: true + options: + partitionNum: 1 + replicaNum: 1 + - + id: 10 + desc: replicanum=4 + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 4, + distribution = [ ('{tb_endpoint_0}',[])] + ); + expect: + success: false + - + id: 11 + desc: distribution小于replicanum + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 2, + distribution = [ ('{tb_endpoint_0}')] + ); + expect: + success: false + - + id: 12 + desc: distribution大于replicanum + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 1, + distribution = [ ('{tb_endpoint_0}',['{tb_endpoint_1}'])] + ); + expect: + success: false + - + id: 13 + desc: distribution的个数和partitionnum对不上 + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 1, + distribution = [ ('{tb_endpoint_0}',[]),('{tb_endpoint_1}',[])] + ); + expect: + success: false + - + id: 14 + desc: distribution=[] + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 1, + distribution = [] + ); + expect: + success: false + - + id: 15 + desc: partitionnum为字符 + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = a, + replicanum = 1, + distribution = [ ('{tb_endpoint_0}',[])] + ); + expect: + success: false + - + id: 16 + desc: replicanum为字符 + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = a, + distribution = [ ('{tb_endpoint_0}',[])] + ); + expect: + success: false + - + id: 17 + desc: 只有partitionnum + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1 + ); + expect: + name: t3 + success: true + options: + partitionNum: 1 + replicaNum: 3 + - + id: 18 + desc: 只有replicanum + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + replicanum = 1 + ); + expect: + name: t3 + success: true + options: + partitionNum: 8 + replicaNum: 1 + - + id: 19 + desc: 没有replicaNum,distribution的个数和tablet数量不一致 + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + distribution = [ ('{tb_endpoint_0}', [])] + ); + expect: + name: t3 + success: true + options: + partitionNum: 1 + replicaNum: 1 + - + id: 20 + desc: distribution指定的tablet不存在 + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 1, + distribution = [ ('{tb_endpoint_0}1',[])] + ); + expect: + success: false + - + id: 21 + desc: partitionnum大于distribution的个数 + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 4, + replicanum = 1, + distribution = [ ('{tb_endpoint_0}',[])] + ); + expect: + success: false + - + id: 22 + desc: test-case + mode: standalone-unsupport + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + replicaNum: 3 + partitionNum: 1 + distribution: + - leader: "{tb_endpoint_1}" + followers: [ "{tb_endpoint_0}","{tb_endpoint_2}" ] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + sql: select * from {0}; + expect: + name: "{0}" + success: true + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + options: + partitionNum: 1 + replicaNum: 3 + - + id: 23 + desc: partitionnum=0,没有指定distribution + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 0, + replicanum = 3 + ); + expect: + success: false + - + id: 24 + desc: 没有partitionnum和replicanum,指定distribution + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + distribution = [ ('{tb_endpoint_0}', [ '{tb_endpoint_1}','{tb_endpoint_2}' ])] + ); + expect: + name: t3 + success: true + options: + partitionNum: 1 + replicaNum: 3 + - + id: 25 + desc: distribution多于partitionnum + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 1, + replicanum = 3, + distribution = [ ('{tb_endpoint_0}', [ '{tb_endpoint_1}','{tb_endpoint_2}' ]),('{tb_endpoint_0}', [ '{tb_endpoint_1}','{tb_endpoint_2}' ])] + ); + expect: + success: false + - + id: 26 + desc: distribution小于partitionnum + mode: standalone-unsupport + inputs: + - name: t3 + sql: | + create table t3 (c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0m)) + options ( + partitionnum = 3, + replicanum = 3, + distribution = [ ('{tb_endpoint_0}', [ '{tb_endpoint_1}','{tb_endpoint_2}' ]),('{tb_endpoint_0}', [ '{tb_endpoint_1}','{tb_endpoint_2}' ])] + ); + expect: + success: false + + + + + + + + + + + + diff --git a/cases/integration_test/ddl/test_ttl.yaml b/cases/integration_test/ddl/test_ttl.yaml new file mode 100644 index 00000000000..510b7e9a408 --- /dev/null +++ b/cases/integration_test/ddl/test_ttl.yaml @@ -0,0 +1,317 @@ +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 指定ttl-单位d + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=3650d)); + expect: + success: true + - + id: 1 + desc: 指定ttl-单位h + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=3650h)); + expect: + success: true + - + id: 2 + desc: 指定ttl-单位m + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=3650m)); + expect: + success: true + - + id: 3 + desc: 指定ttl-没有单位 + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=3650)); + expect: + success: false + - + id: 4 + desc: ttl_type=absolute-没有单位 + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=3650,ttl_type=absolute)); + expect: + success: false + - + id: 5 + desc: ttl_type=latest-带单位 + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=3650m,ttl_type=latest)); + expect: + success: false + - + id: 6 + desc: ttl_type=absolute-ttl=(3650m) + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=(3650m),ttl_type=absolute)); + expect: + success: true + - + id: 7 + desc: ttl_type=latest-ttl=(3650) + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=(3650),ttl_type=latest)); + expect: + success: false + - + id: 8 + desc: ttl=0m + inputs: + - + create: create table {0} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=0m)); + insert: insert into {0} values ("aa", 1, 1590738990000, 1590738989000); + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + rows: + - ["aa",1,1590738990000,1590738989000] + - + id: 9 + desc: ttl为字符 + sql: create table {auto}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=aa)); + expect: + success: false + - + id: 10 + desc: 指定ttl_type=absolute + inputs: + - + create: create table {0} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=0m, ttl_type=absolute)); + insert: insert into {0} values ("aa", 1, 1590738990000, 1590738989000); + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + rows: + - ["aa",1,1590738990000,1590738989000] + - + id: 11 + desc: 指定ttl_type=latest + inputs: + - + create: create table {0} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=0, ttl_type=latest)); + insert: insert into {0} values ("aa", 1, 1590738990000, 1590738989000); + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + rows: + - ["aa",1,1590738990000,1590738989000] + - + id: 12 + desc: 指定ttl_type为其他字符 + sql: create table {auto}(c1 string NOT NULL,c2 int,c3 timestamp,c4 timestamp,index(key=(c1),ts=c4,ttl=0,ttl_type=aaa)); + expect: + success: false + - + id: 13 + desc: ttl_type=absorlat + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c4),ts=c7, ttl=(10m,10), ttl_type=absorlat)); + expect: + success: true + - + id: 14 + desc: ttl_type=absorlat,ttl=(10,10m) + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c4),ts=c7, ttl=(10,10m), ttl_type=absandlat)); + expect: + success: false + - + id: 15 + desc: ttl_type=absandlat + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c4),ts=c7, ttl=(10m,10), ttl_type=absandlat)); + expect: + success: true + - + id: 16 + desc: ttl_type=absandlat,ttl=(10,10m) + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c4),ts=c7, ttl=(10,10m), ttl_type=absandlat)); + expect: + success: false + - + id: 17 + desc: ttl_type=latest,ttl带单位 + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c4),ts=c7, ttl=10m, ttl_type=latest)); + expect: + success: false + - + id: 18 + desc: ttl_type=latest,ttl=(10m,10) + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c4),ts=c7, ttl=(10m,10), ttl_type=latest)); + expect: + success: false + - + id: 19 + desc: ttl_type=absolute,ttl=(10m,10) + sql: | + create table {auto} ( + c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c4),ts=c7, ttl=(10m,10), ttl_type=absolute)); + expect: + success: false + - + id: 20 + desc: 指定ttl_type=absolute,数据过期 + inputs: + - + create: create table {0} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=10m, ttl_type=absolute)); + insert: insert into {0} values ("aa", 1, 1590738990000, 1614672180000); + sql: select * from {0}; + expect: + count: 0 + - + id: 21 + desc: 指定ttl_type=latest,部分数据过期 + inputs: + - + columns: ["c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:1:latest"] + rows: + - ["aa", 1, 1590738990000,1590738990000] + - ["aa", 2, 1590738990000,1590738990000] + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp","c4 timestamp"] + rows: + - ["aa", 2, 1590738990000,1590738990000] + - + id: 22 + desc: 指定ttl_type=absandlat,部分数据过期 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:(10m,2):absandlat"] + rows: + - [1,"aa", 1, 1590738990000,1590738990000] + - [2,"aa", 2, 1590738990000,1590738991000] + - [3,"aa", 3, 1590738990000,1590738992000] + sql: select * from {0}; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp","c4 timestamp"] + order: id + rows: + - [2,"aa", 2, 1590738990000,1590738991000] + - [3,"aa", 3, 1590738990000,1590738992000] + - + id: 23 + desc: 指定ttl_type=absorlat,部分数据过期 + inputs: + - + columns: ["c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:(10m,2):absorlat"] + rows: + - ["aa", 1, 1590738990000,1590738990000] + - ["aa", 1, 1590738990000,1590738990000] + - ["aa", 1, 1590738990000,1590738990000] + sql: select * from {0}; + expect: + count: 0 + - + id: 24 + desc: 指定ttl_type=absolute,部分数据过期 + inputs: + - + columns: ["c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:10m:absolute"] + rows: + - ["aa", 1, 1590738990000, "{currentTime}-600001"] + - ["bb", 1, 1590738990000, "{currentTime}"] + sql: select c1,c2,c3 from {0}; + expect: + columns: ["c1 string","c2 int","c3 timestamp"] + rows: + - ["bb", 1, 1590738990000] + - + id: 25 + desc: 指定ttl_type=absandlat,部分数据过期-边界 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:(10m,2):absandlat"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 2, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 3, 1590738990000,"{currentTime}-600001"] + - [4,"aa", 4, 1590738990000,"{currentTime}"] + sql: select id,c1,c2,c3 from {0}; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [3,"aa", 3, 1590738990000] + - [4,"aa", 4, 1590738990000] + - + id: 26 + desc: 指定ttl_type=absandlat,部分数据过期-边界2 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:(10m,2):absandlat"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 2, 1590738990000,"{currentTime}-500000"] + - [3,"aa", 3, 1590738990000,"{currentTime}-500000"] + - [4,"aa", 4, 1590738990000,"{currentTime}"] + sql: select id,c1,c2,c3 from {0}; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [2,"aa", 2, 1590738990000] + - [3,"aa", 3, 1590738990000] + - [4,"aa", 4, 1590738990000] + - + id: 27 + desc: 指定ttl_type=absorlat,部分数据过期-边界 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:(10m,2):absorlat"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 2, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 3, 1590738990000,"{currentTime}-500000"] + sql: select id,c1,c2,c3 from {0}; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [3,"aa", 3, 1590738990000] + - + id: 28 + desc: 指定ttl_type=absorlat,部分数据过期-边界2 + inputs: + - + columns: ["id int","c1 string","c2 int","c3 timestamp", "c4 timestamp"] + indexs: ["index1:c1:c4:(10m,2):absorlat"] + rows: + - [1,"aa", 1, 1590738990000,"{currentTime}-600001"] + - [2,"aa", 2, 1590738990000,"{currentTime}-600001"] + - [3,"aa", 3, 1590738990000,"{currentTime}-500000"] + - [4,"aa", 4, 1590738990000,"{currentTime}-400000"] + - [5,"aa", 5, 1590738990000,"{currentTime}"] + sql: select id,c1,c2,c3 from {0}; + expect: + columns: ["id int","c1 string","c2 int","c3 timestamp"] + order: id + rows: + - [4,"aa", 4, 1590738990000] + - [5,"aa", 5, 1590738990000] + - + id: 29 + desc: ttl_type=latest-ttl=(10) + sql: create table {auto} (c1 string NOT NULL,c2 int,c3 timestamp, c4 timestamp,index(key=(c1),ts=c4,ttl=(10),ttl_type=latest)); + expect: + success: true diff --git a/cases/integration_test/deploy/test_create_deploy.yaml b/cases/integration_test/deploy/test_create_deploy.yaml new file mode 100644 index 00000000000..bc90cdaccf2 --- /dev/null +++ b/cases/integration_test/deploy/test_create_deploy.yaml @@ -0,0 +1,621 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +cases: + - + id: 0 + desc: 冒烟测试-正常deploy + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sqls: + - deploy deploy_{0} select * from {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + deployment : + name: deploy_{0} + dbName: test_zw + sql: | + DEPLOY deploy_{0} SELECT + * + FROM + {0} + ; + inColumns: + - 1,c1,kVarchar,NO + - 2,c2,kInt16,NO + - 3,c3,kInt32,NO + - 4,c4,kInt64,NO + - 5,c5,kFloat,NO + - 6,c6,kDouble,NO + - 7,c7,kTimestamp,NO + - 8,c8,kDate,NO + outColumns: + - 1,c1,kVarchar,NO + - 2,c2,kInt16,NO + - 3,c3,kInt32,NO + - 4,c4,kInt64,NO + - 5,c5,kFloat,NO + - 6,c6,kDouble,NO + - 7,c7,kTimestamp,NO + - 8,c8,kDate,NO + + - id: 1 + desc: deploy一个lastjoin + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + sqls: + - deploy deploy_{0} select {0}.c1,{0}.c2,{1}.c4,{2}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1 last join {2} order by {2}.c4 on {0}.c1={2}.c1; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + deployment : + name: deploy_{0} + dbName: test_zw + sql: | + DEPLOY deploy_{0} SELECT + {0}.c1, + {0}.c2, + {1}.c4, + {2}.c4 + FROM + {0} + LAST JOIN + {1} + ORDER BY {1}.c4 + ON {0}.c1 = {1}.c1 + LAST JOIN + {2} + ORDER BY {2}.c4 + ON {0}.c1 = {2}.c1 + ; + inColumns: + - 1,c1,kVarchar,NO + - 2,c2,kInt32,NO + - 3,c3,kInt64,NO + - 4,c4,kTimestamp,NO + outColumns: + - 1,c1,kVarchar,NO + - 2,c2,kInt32,NO + - 3,c4,kTimestamp,NO + - 4,c4,kTimestamp,NO + - + id: 2 + desc: deploy一个window-ROWS + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + deployment : + name: deploy_{0} + dbName: test_zw + sql: | + DEPLOY deploy_{0} SELECT + id, + c1, + sum(c4) OVER (w1) AS w1_c4_sum + FROM + {0} + WINDOW w1 AS (PARTITION BY {0}.c1 + ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) + ; + inColumns: + - 1,id,kInt32,NO + - 2,c1,kVarchar,NO + - 3,c3,kInt32,NO + - 4,c4,kInt64,NO + - 5,c5,kFloat,NO + - 6,c6,kDouble,NO + - 7,c7,kTimestamp,NO + - 8,c8,kDate,NO + outColumns: + - 1,id,kInt32,NO + - 2,c1,kVarchar,NO + - 3,w1_c4_sum,kInt64,NO + - + id: 3 + desc: deploy一个window-ROWS_RANGE + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + deployment : + name: deploy_{0} + dbName: test_zw + sql: | + DEPLOY deploy_{0} SELECT + id, + c1, + sum(c4) OVER (w1) AS w1_c4_sum + FROM + {0} + WINDOW w1 AS (PARTITION BY {0}.c1 + ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) + ; + inColumns: + - 1,id,kInt32,NO + - 2,c1,kVarchar,NO + - 3,c3,kInt32,NO + - 4,c4,kInt64,NO + - 5,c5,kFloat,NO + - 6,c6,kDouble,NO + - 7,c7,kTimestamp,NO + - 8,c8,kDate,NO + outColumns: + - 1,id,kInt32,NO + - 2,c1,kVarchar,NO + - 3,w1_c4_sum,kInt64,NO + - + id: 4 + desc: deploy一个子查询 + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sqls: + - deploy deploy_{0} select v2,v3 from (select c2+1 as v2,c3+1 as v3 from {0}) as t; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + deployment : + name: deploy_{0} + dbName: test_zw + sql: | + DEPLOY deploy_{0} SELECT + v2, + v3 + FROM + ( + SELECT + c2 + 1 AS v2, + c3 + 1 AS v3 + FROM + {0} + ) AS t + ; + inColumns: + - 1,c1,kVarchar,NO + - 2,c2,kInt32,NO + - 3,c3,kInt64,NO + - 4,c4,kTimestamp,NO + outColumns: + - 1,v2,kInt32,NO + - 2,v3,kInt64,NO + - + id: 5 + desc: deploy一个子查询、window、lastjoin + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, 1590738990000, 2.2] + - [3, "bb",10, 1590738990000, 3.3] + - + columns : ["crd_lst_isu_dte timestamp", "crd_nbr string"] + indexs: ["index2:crd_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, "aaaaaaaaaa"] + - [1590738990000, "aaaaaaaaaa"] + - [1590738989000, "cc"] + - [1590738992000, "cc"] + sqls: + - deploy deploy_{0} select * from(select + id,card_no,trx_time,substr(card_no, 1, 6) as card_no_prefix,sum(trx_amt) over w30d as sum_trx_amt,count(merchant_id) over w10d as count_merchant_id from {0} + window w30d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 30d PRECEDING AND CURRENT ROW), + w10d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW)) as trx_fe + last join {1} order by {1}.crd_lst_isu_dte on trx_fe.card_no = {1}.crd_nbr and trx_fe.trx_time >= {1}.crd_lst_isu_dte; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + deployment : + name: deploy_{0} + dbName: test_zw + sql: | + DEPLOY deploy_{0} SELECT + * + FROM + ( + SELECT + id, + card_no, + trx_time, + substr(card_no, 1, 6) AS card_no_prefix, + sum(trx_amt) OVER (w30d) AS sum_trx_amt, + count(merchant_id) OVER (w10d) AS count_merchant_id + FROM + {0} + WINDOW w30d AS (PARTITION BY {0}.card_no + ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 30d PRECEDING AND CURRENT ROW), w10d AS (PARTITION BY {0}.card_no + ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW) + ) AS trx_fe + LAST JOIN + {1} + ORDER BY {1}.crd_lst_isu_dte + ON trx_fe.card_no = {1}.crd_nbr AND trx_fe.trx_time >= {1}.crd_lst_isu_dte + ; + inColumns: + - 1,id,kInt32,NO + - 2,card_no,kVarchar,NO + - 3,merchant_id,kInt32,NO + - 4,trx_time,kTimestamp,NO + - 5,trx_amt,kFloat,NO + outColumns: + - 1,id,kInt32,NO + - 2,card_no,kVarchar,NO + - 3,trx_time,kTimestamp,NO + - 4,card_no_prefix,kVarchar,NO + - 5,sum_trx_amt,kFloat,NO + - 6,count_merchant_id,kInt64,NO + - 7,crd_lst_isu_dte,kTimestamp,NO + - 8,crd_nbr,kVarchar,NO + - + id: 6 + desc: deploy的sql中指定其他库 + db: db + inputs: + - db: db1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - db: db2 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sqls: + - deploy deploy_{0} select db1.{0}.c1, db1.{0}.c2,db2.{1}.c3,db2.{1}.c4 from db1.{0} last join db2.{1} ORDER BY db2.{1}.c3 on db1.{0}.c1=db2.{1}.c1; + expect: + success: false + - + id: 7 + desc: deploy sql错误 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: deploy deploy_{0} select * from {0}11; + expect: + success: false + - + id: 8 + desc: deploy 同名service + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sqls: + - deploy deploy_{0} select * from {0}; + - deploy deploy_{0} select * from {0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: false + - + id: 9 + desc: deploy 语法错误 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: deploy deployment deploy_{0} select * from {0}; + expect: + success: false + - + id: 10 + desc: deploy 一个insert + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: deploy deploy_{0} insert into {0} values('aa',1,2,3,1.1,2.1,1590738989000,'2020-05-01'); + expect: + success: false + - + id: 11 + desc: deploy 和表名重复 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sqls: + - deploy {0} select * from {0}; + - show deployment {0}; + tearDown: + - drop deployment {0}; + expect: + success: true + - + id: 12 + desc: 表没有索引,deploy一个window + inputs: + - + create: | + create table {0} ( + id int not null, + c1 int not null, + c7 timestamp not null + ); + dataProvider: + - ["ROWS","ROWS_RANGE"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c1) OVER w1 as w1_c1_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND 1 PRECEDING); + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 13 + desc: 表已经有索引,deploy一个window,使用另一个索引,列和ts都不同 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c4"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND 1 PRECEDING); + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 14 + desc: 表已经有索引,deploy一个window,索引的column相同,ts不同 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c4"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND 1 PRECEDING); + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 15 + desc: 表已经有索引,deploy一个window,索引的column不同,ts相同,ROWS + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); + - desc {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 16 + desc: 表已经有索引,deploy一个window,索引的column不同,ts相同,ROWS_RANGE + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); + - desc {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 17 + desc: 表已经有索引,deploy一个window,索引的column不同,ts相同,rows_range带单位 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 rows_range BETWEEN 2h PRECEDING AND 1h PRECEDING); + - desc {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 18 + desc: deploy的sql中指定其他库,其中一个表使用默认库 + db: db1 + inputs: + - db: db1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - db: db2 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sqls: + - deploy deploy_{0} select db1.{0}.c1, db1.{0}.c2,db2.{1}.c3,db2.{1}.c4 from db1.{0} last join db2.{1} ORDER BY db2.{1}.c3 on db1.{0}.c1=db2.{1}.c1; + expect: + success: false + - + id: 19 + desc: 多个window + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c4:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY c3 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY c1 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + - desc {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 20 + desc: 组合索引-ROWS + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1|c3:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); + - desc {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 21 + desc: 组合索引-ROWS_RANGE + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1|c3:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); + - desc {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 22 + desc: 表已经有索引,deploy一个window,索引的column相同和ts都相同 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); + - desc {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 23 + desc: 组合索引-索引相同 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1|c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); + - desc {0}; + - show deployment deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true + - + id: 24 + desc: 表有数据,deploy创建新索引 + tags: ["TODO","cicd大概率失败,@denglong,https://github.com/4paradigm/OpenMLDB/issues/1116"] + mode: standalone-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); + expect: + success: false \ No newline at end of file diff --git a/cases/integration_test/deploy/test_drop_deploy.yaml b/cases/integration_test/deploy/test_drop_deploy.yaml new file mode 100644 index 00000000000..7e40d4214df --- /dev/null +++ b/cases/integration_test/deploy/test_drop_deploy.yaml @@ -0,0 +1,85 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +cases: + - + id: 0 + desc: 正常删除service + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); + - drop deployment deploy_{0}; + - show deployments; + expect: + deploymentCount: 0 + - + id: 1 + desc: service不存在 + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sqls: + - deploy deploy_{0} select v2,v3 from (select c2+1 as v2,c3+1 as v3 from {0}) as t; + - drop deployment deploy_{0}11; + tearDown: + - drop deployment deploy_{0}; + expect: + success: false + - + id: 2 + desc: 语法错误 + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sqls: + - deploy deploy_{0} select v2,v3 from (select c2+1 as v2,c3+1 as v3 from {0}) as t; + - drop deployments deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: false + - + id: 3 + desc: 删除其他库的service + db: db + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sqls: + - deploy deploy_{0} select v2,v3 from (select c2+1 as v2,c3+1 as v3 from {0}) as t; + - drop deployment db.deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: false \ No newline at end of file diff --git a/cases/integration_test/deploy/test_show_deploy.yaml b/cases/integration_test/deploy/test_show_deploy.yaml new file mode 100644 index 00000000000..32d3c27d89f --- /dev/null +++ b/cases/integration_test/deploy/test_show_deploy.yaml @@ -0,0 +1,88 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +cases: + - + id: 0 + desc: 查看所有deployment + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + sqls: + - deploy deploy_{0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); + - deploy {0} SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c4 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); + - show deployments; + tearDown: + - drop deployment deploy_{0}; + - drop deployment {0}; + expect: + deploymentCount: 2 + - + id: 1 + desc: service不存在 + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sqls: + - deploy deploy_{0} select v2,v3 from (select c2+1 as v2,c3+1 as v3 from {0}) as t; + - show deployment deploy_{0}11; + tearDown: + - drop deployment deploy_{0}; + expect: + success: false + - + id: 2 + desc: 语法错误 + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sqls: + - deploy deploy_{0} select v2,v3 from (select c2+1 as v2,c3+1 as v3 from {0}) as t; + - show deployments deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: false + - + id: 3 + desc: 查看其他库的service + db: db + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sqls: + - deploy deploy_{0} select v2,v3 from (select c2+1 as v2,c3+1 as v3 from {0}) as t; + - show deployment db.deploy_{0}; + tearDown: + - drop deployment deploy_{0}; + expect: + success: true \ No newline at end of file diff --git a/cases/integration_test/disk_table/disk_table.yaml b/cases/integration_test/disk_table/disk_table.yaml new file mode 100644 index 00000000000..33c0b45e0be --- /dev/null +++ b/cases/integration_test/disk_table/disk_table.yaml @@ -0,0 +1,486 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 创建SSD表,插入多条数据,查询 + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: SSD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + id: 1 + desc: 创建HDD表,插入多条数据,查询 + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: HDD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + + - + id: 2 + desc: ssd和内存表,join + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: SSD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: memory + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + id: 3 + desc: hdd和内存表,join + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: HDD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: memory + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + id: 4 + desc: 内存表和ssd,join + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: memory + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: SSD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + id: 5 + desc: 内存表和hdd,join + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: memory + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: HDD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + id: 6 + desc: hdd和ssd,join + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: SSD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: HDD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + id: 7 + desc: hdd和ssd,join + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: memory + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: SSD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: HDD + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + sql: select {1}.c1,{1}.c2,{2}.c3,{0}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1 last join {2} on {0}.c1 = {2}.c1; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - ["bb", 21, 31, 1590738990000] + - ["cc", 41, 51, 1590738991000] + + - id: 8 + desc: ssd union 内存表 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + storage: SSD + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + storage: memory + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 9 + desc: hdd union 内存表 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + storage: HDD + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + storage: memory + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 10 + desc: 内存表 union ssd + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + storage: memory + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + storage: SSD + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 11 + desc: 内存表 union hdd + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + storage: memory + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + storage: HDD + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 12 + desc: SSD 插入索引和ts 一样的数据 + mode: request-unsupport + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: SSD + rows: + - ["aa", 2, 3, 1590738989000] + - ["aa", 2, 3, 1590738989000] + - ["aa", 2, 3, 1590738989000] + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - id: 13 + desc: HDD 插入索引和ts 一样的数据 + mode: request-unsupport + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + storage: HDD + rows: + - ["aa", 2, 3, 1590738989000] + - ["aa", 2, 3, 1590738989000] + - ["aa", 2, 3, 1590738989000] + sql: select * from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa", 2, 3, 1590738989000] + - id: 14 + desc: storage_mode=其他字符 + mode: request-unsupport + sql: | + create table auto_MDYewbTv( + c1 string, + c2 int, + c3 bigint, + c4 timestamp, + index(key=(c1),ts=c4))options(partitionnum=1,replicanum=1,storage_mode="hdp"); + expect: + success: false + + - id: 15 + desc: 创建磁盘表,ttl_type=latest,ttl=4,insert 10 + mode: request-unsupport + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4:4:latest"] + storage: SSD + rows: + - ["bb", 2, 3, 1590738989000] + - ["bb", 4, 5, 1590738990000] + - ["bb", 6, 7, 1590738991000] + - ["bb", 8, 9, 1590738992000] + - ["bb", 10, 11, 1590738993000] + - ["bb", 12, 13, 1590738994000] + - ["bb", 14, 15, 1590738995000] + - ["bb", 16, 17, 1590738996000] + - ["bb", 18, 19, 1590738997000] + - ["bb", 20, 21, 1590738998000] + sql: select c1,c2,c3 from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint"] + rows: + - ["bb", 20, 21] + - ["bb", 18, 19] + - ["bb", 16, 17] + - ["bb", 14, 15] + + - id: 16 + desc: 创建磁盘表,ttl_type=absolute,ttl=10m, insert 10 + mode: request-unsupport + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4:10m:absolute"] + storage: hdd + rows: + - ["bb", 2, 3, "{currentTime}-100"] + - ["bb", 4, 5, "{currentTime}-200"] + - ["bb", 6, 7, "{currentTime}-599000"] + - ["bb", 8, 9, "{currentTime}-600000"] + - ["bb", 10, 11, "{currentTime}-600005"] + - ["bb", 12, 13, "{currentTime}-600006"] + - ["bb", 14, 15, "{currentTime}-600007"] + - ["bb", 16, 17, "{currentTime}-600008"] + - ["bb", 18, 19, "{currentTime}-600009"] + - ["bb", 20, 21, "{currentTime}-600010"] + sql: select c1,c2,c3 from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint"] + rows: + - ["bb", 2, 3] + - ["bb", 4, 5] + - ["bb", 6, 7] + + - id: 17 + desc: 创建磁盘表,有两个索引,分别为latest和absolute,insert=10 + mode: request-unsupport + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index2:c2:c4:4:latest","index1:c1:c4:10m:absolute"] + storage: hdd + rows: + - ["bb", 2, 3, "{currentTime}-100"] + - ["bb", 2, 5, "{currentTime}-200"] + - ["bb", 2, 7, "{currentTime}-59"] + - ["bb", 2, 9, "{currentTime}-600"] + - ["bb", 2, 11, "{currentTime}-602"] + - ["bb", 2, 13, "{currentTime}-600006"] + - ["bb", 2, 15, "{currentTime}-600007"] + - ["bb", 2, 17, "{currentTime}-600008"] + - ["bb", 2, 19, "{currentTime}-600009"] + - ["bb", 2, 21, "{currentTime}-600010"] + sql: select c1,c2,c3 from {0}; + expect: + columns: ["c1 string","c2 int","c3 bigint"] + rows: + - ["bb", 2, 7] + - ["bb", 2, 3] + - ["bb", 2, 5] + - ["bb", 2, 9] + + - id: 18 + desc: 创建磁盘表,有两个索引,分别为latest和absolute,insert=10 ,where条件 + mode: request-unsupport + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index2:c2:c4:4:latest","index1:c1:c4:10m:absolute"] + storage: hdd + rows: + - ["bb", 2, 3, "{currentTime}-100"] + - ["bb", 2, 5, "{currentTime}-200"] + - ["bb", 2, 7, "{currentTime}-59"] + - ["bb", 2, 9, "{currentTime}-600"] + - ["bb", 2, 11, "{currentTime}-602"] + - ["bb", 2, 13, "{currentTime}-600006"] + - ["bb", 2, 15, "{currentTime}-600007"] + - ["bb", 2, 17, "{currentTime}-600008"] + - ["bb", 2, 19, "{currentTime}-600009"] + - ["bb", 2, 21, "{currentTime}-600010"] + sql: select c1,c2,c3 from {0} where c1 = "bb"; + expect: + columns: ["c1 string","c2 int","c3 bigint"] + rows: + - ["bb", 2, 7] + - ["bb", 2, 3] + - ["bb", 2, 5] + - ["bb", 2, 9] + - ["bb", 2, 11] diff --git a/cases/integration_test/dml/multi_insert.yaml b/cases/integration_test/dml/multi_insert.yaml new file mode 100644 index 00000000000..1f606089abe --- /dev/null +++ b/cases/integration_test/dml/multi_insert.yaml @@ -0,0 +1,287 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +db: multi_insert_db +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: 简单INSERT + inputs: + - + create: | + create table {0} ( + col0 string not null, + col1 int not null, + col2 smallint not null, + col3 float not null, + col4 double not null, + col5 bigint not null, + col6 string not null, + col7 timestamp not null, + col8 date not null, + col9 bool not null, + index(key=(col2), ts=col5) + ); + insert: insert into {0} values("hello", 1, 2, 3.3f, 4.4, 5L, "world", 12345678L, "2020-05-21", true); + sql: select * from {0}; + expect: + columns: ["col0 string", "col1 int32", "col2 int16", "col3 float", "col4 double", "col5 int64", + "col6 string", "col7 timestamp", "col8 date", "col9 bool"] + order: col1 + rows: + - [hello, 1, 2, 3.3, 4.4, 5, world, 12345678, "2020-05-21", true] + - id: 1 + desc: 简单INSERT 多行 + inputs: + - + create: | + create table {0} ( + col0 string not null, + col1 int not null, + col2 smallint not null, + col3 float not null, + col4 double not null, + col5 bigint not null, + col6 string not null, + index(key=(col2), ts=col5) + ); + insert: | + insert into {0} values + ("hello", 1, 2, 3.3, 4.4, 5, "world"), + ("hello", 11, 22, 33.3, 44.4, 55, "fesql"); + + sql: select * from {0}; + expect: + columns: [ "col0 string", "col1 int32", "col2 int16", "col3 float", "col4 double", "col5 int64", + "col6 string"] + order: col1 + rows: + - [hello, 1, 2, 3.3, 4.4, 5, world] + - [hello, 11, 22, 33.3, 44.4, 55, fesql] + + - id: 2 + desc: 简单INSERT timestamp + inputs: + - create: | + create table {0} ( + col1 int not null, + col5 bigint not null, + std_ts timestamp not null, + index(key=(col1), ts=col5) + ); + insert: | + insert into {0} values + (1, 10000L, 1590738987000L), + (2, 20000L, 1590738988000L); + sql: select * from {0}; + expect: + columns: ["col1 int", "col5 bigint", "std_ts timestamp"] + order: col1 + rows: + - [1, 10000, 1590738987000] + - [2, 20000, 1590738988000] + + - id: 3 + desc: insert 指定列,其他列默认为NULL + inputs: + - + create: | + create table {0} ( + col1 int not null, + col2 smallint, + col3 float, + col4 double, + col5 bigint not null, + std_ts timestamp not null, + str string, + index(key=(col1), ts=col5) + ); + insert: | + insert into {0} (col1, col5, std_ts) values + (1, 10000L, 1590738987000L), + (2, 20000L, 1590738988000L); + sql: select * from {0}; + expect: + columns: ["col1 int", "col2 int16", "col3 float", "col4 double", "col5 bigint", "std_ts timestamp", "str string"] + order: col1 + rows: + - [1, NULL, NULL, NULL, 10000, 1590738987000, NULL] + - [2, NULL, NULL, NULL, 20000, 1590738988000, NULL] + - id: 4 + desc: Insert date + inputs: + - create: | + create table {0} ( + col1 int not null, + col2 smallint, + col3 float, + col4 double, + col5 bigint not null, + std_date date not null, + str string, + index(key=(col1), ts=col5) + ); + insert: | + insert into {0} (col1, col5, std_date) values + (1, 10000L, '2020-05-27'), + (2, 20000L, '2020-05-28'); + + sql: select * from {0}; + expect: + columns: [ "col1 int", "col2 int16", "col3 float", "col4 double", "col5 bigint", "std_date date", "str string" ] + order: col1 + rows: + - [1, NULL, NULL, NULL, 10000, "2020-05-27", NULL] + - [2, NULL, NULL, NULL, 20000, "2020-05-28", NULL] + - id: 5 + desc: 简单INSERT NULL value + inputs: + - + create: | + create table {0} ( + col0 string not null, + col1 int not null, + col2 smallint, + col3 float not null, + col4 double not null, + col5 bigint not null, + col6 string not null, + index(key=(col2), ts=col5) + ); + insert: | + insert into {0} values ("hello", 1, NULL, 3.3f, 4.4, 5L, "world"), + ("hi", 2, NULL, 33.3f, 44.4, 55L, "db"); + sql: select * from {0}; + expect: + columns: [ "col0 string", "col1 int", "col2 int16", "col3 float", "col4 double", "col5 bigint", "col6 string" ] + order: col1 + rows: + - [hello, 1, NULL, 3.3, 4.4, 5, world] + - [hi, 2, NULL, 33.3, 44.4, 55, db] + - + id: 6 + desc: 所有列插入多条 + inputs: + - + create: | + create table {0} ( + id int not null, + c1 int not null, + c2 smallint not null, + c3 float not null, + c4 double not null, + c5 bigint not null, + c6 string not null, + c7 timestamp not null, + c8 date not null, + c9 bool not null, + index(key=(c1), ts=c5) + ); + insert: | + insert into {0} values + (1, 1, 2, 3.3f, 4.4, 5L, "aa", 12345678L, "2020-05-21", true), + (2, 10, 20, 3.31f, 4.41, 50L, "bb", 12345679L, "2020-05-22", false); + sql: select * from {0}; + expect: + columns : ["id int","c1 int","c2 smallint","c3 float","c4 double","c5 bigint","c6 string","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,1,2,3.3,4.4,5,"aa",12345678,"2020-05-21",true] + - [2,10,20,3.31,4.41,50,"bb",12345679,"2020-05-22",false] + - + id: 7 + desc: 其中一条数据类型不兼容 + inputs: + - + create: | + create table {0} ( + id int, + c1 int, + c2 smallint, + c3 float, + c5 bigint, + index(key=(c1), ts=c5) + ); + sql: | + insert into {0} (id,c3,c5)values + (1, 3.3,12345678), + (2, "aa",12345679); + expect: + success: false + - + id: 8 + desc: 插入多条空串 + mode: cli-unsupport + inputs: + - + create: | + create table {0} ( + id int, + c1 int, + c2 string, + c3 float, + c5 bigint, + index(key=(c1), ts=c5) + ); + insert: | + insert into {0} (id,c2,c3,c5)values + (1, "",null,12345678), + (2, "",null,12345679); + sql: select * from {0}; + expect: + columns : ["id int","c1 int","c2 string","c3 float","c5 bigint"] + order: id + rows: + - [1,null,"",null,12345678] + - [2,null,"",null,12345679] + - + id: 9 + desc: 插入数据和列的数量不匹配 + inputs: + - + create: | + create table {0} ( + id int, + c1 int, + c2 smallint, + c3 float, + c5 bigint, + index(key=(c1), ts=c5) + ); + sql: | + insert into {0} (id,c3,c5)values + (1,12345678), + (2,12345679); + expect: + success: false + - + id: 10 + desc: 其中一条数据少一列 + inputs: + - + create: | + create table {0} ( + id int, + c1 int, + c2 smallint, + c3 float, + c5 bigint, + index(key=(c1), ts=c5) + ); + sql: | + insert into {0} (id,c3,c5)values + (1, 3.3,12345678), + (2,12345679); + expect: + success: false \ No newline at end of file diff --git a/cases/integration_test/dml/test_delete.yaml b/cases/integration_test/dml/test_delete.yaml new file mode 100644 index 00000000000..d73709145d5 --- /dev/null +++ b/cases/integration_test/dml/test_delete.yaml @@ -0,0 +1,598 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.6.0 +cases: + - + id: 0 + desc: delete 一个key + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa'; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 1 + desc: delete 组合索引 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1|c2:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [4,"aa",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa' and c2=1; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [4,"aa",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + - + id: 2 + desc: delete 一个索引的两个key + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - ["cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa' or c1='cc'; + expect: + success: false + msg: fail + - + id: 3 + desc: delete 两个索引的两个key + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7","index2:c2:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - ["cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa' or c2=1; + expect: + success: false + msg: fail + - + id: 4 + desc: 两个索引 delete 其中一个 + mode: cluster-unsupport + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7","index2:c2:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [4,"aa",1,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c2=2; + sql: SELECT id, c2, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + columns: ["id int","c2 smallint","w1_c4_count bigint"] + order: id + rows: + - [1,1,1] + - [2,1,2] + - [4,1,3] + - + id: 5 + desc: delete 不是索引列 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - ["cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c2=1; + expect: + success: false + msg: fail + - + id: 6 + desc: delete key不存在 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1='cc'; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - + id: 7 + desc: delete null + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,null,1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,null,1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1=null; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 8 + desc: delete 空串 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1=''; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 10 + desc: delete int + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,3,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c3=3; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 11 + desc: delete smallint + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c2:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c2=1; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 12 + desc: delete bigint + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c4:c7"] + rows: + - [1,"aa",1,2,4,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,4,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c4=4; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - + id: 13 + desc: delete date + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c8:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-02",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c8='2020-05-02'; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - + id: 14 + desc: delete timestamp + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c7:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c7=1590738989000; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - + id: 15 + desc: delete bool + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c9:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",false] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c9=true; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",false] + - + id: 16 + desc: 两次delete相同index 不同的key + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"cc",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa'; + - delete from {0} where c1='cc'; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 17 + desc: 两次delete 不同的index + mode: cluster-unsupport + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7","index1:c2:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [4,"cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa'; + - delete from {0} where c2=2; + sql: | + SELECT id, c2, count(c4) OVER w1 as w1_c4_count, count(c5) OVER w2 as w2_c5_count FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + columns: ["id int","c2 smallint","w1_c4_count bigint","w2_c5_count bigint"] + order: id + rows: + - [1,1,1,1] + - [2,1,1,2] + - + id: 18 + desc: delete过期数据 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7:1:latest"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa'; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 19 + desc: delete表不存在 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - ["cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sql: delete from {0}1 where c1='aa'; + expect: + success: false + msg: fail + - + id: 20 + desc: delete列不存在 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - ["aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - ["cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c11=1; + expect: + success: false + msg: fail + - + id: 21 + desc: delete 其他库的数据 + inputs: + - + db: d1 + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from d1.{0} where c1='aa'; + - select * from d1.{0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 22 + desc: 两个index中key相同 delete 一个key + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7","index2:c1:c4:1:latest"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [4,"cc",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [5,"cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa'; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [4,"cc",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [5,"cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + - + id: 23 + desc: delete全部数据 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c2:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c2=1; + - select * from {0}; + expect: + count: 0 + - + id: 24 + desc: 两个索引,一个索引数据过期,删除另一个索引 + mode: cluster-unsupport + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7:1:latest","index2:c2:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [4,"cc",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - [5,"cc",2,2,3,1.1,2.1,1590738991000,"2020-05-01",true] + sqls: + - delete from {0} where c2=1; + sql: SELECT id, c2, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + columns: ["id int","c2 smallint","w1_c4_count bigint"] + order: id + rows: + - [4,2,1] + - [5,2,2] + - + id: 25 + desc: 数据过期,delete其他pk + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7:1:latest"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1='bb'; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [3,"aa",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - + id: 26 + desc: 不等式删除 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"cc",1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1!='cc'; + expect: + success: false + msg: fail + - + id: 27 + desc: 比较运算符删除 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c2:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",3,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c2>=2; + expect: + success: false + msg: fail + - + id: 28 + desc: 表名为job delete + inputs: + - + name: job + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"aa",3,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1='aa'; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [2,"bb",2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 29 + desc: delete空表 + inputs: + - + name: job + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - delete from {0} where c1='aa'; + expect: + success: true + - + id: 30 + desc: 组合key有一个是null + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1|c2:c7"] + rows: + - [1,null,2,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,null,1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1=null and c2=2; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,null,1,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + - + id: 31 + desc: 组合key有一个是空串 + inputs: + - + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1|c2:c7"] + rows: + - [1,"",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [3,"",2,2,3,1.1,2.1,1590738990000,"2020-05-01",true] + sqls: + - delete from {0} where c1='' and c2=2; + - select * from {0}; + expect: + columns: ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + diff --git a/cases/integration_test/dml/test_insert.yaml b/cases/integration_test/dml/test_insert.yaml new file mode 100644 index 00000000000..36ae56ca82b --- /dev/null +++ b/cases/integration_test/dml/test_insert.yaml @@ -0,0 +1,207 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 插入所有类型的数据 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - + id: 1 + desc: 插入所有列的数据 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} (c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c1), ts=c7)); + insert: insert into {0} values('aa',2,3,1.1,2.1,1590738989000L,'2020-05-01'); + sql: select * from {0}; + expect: + columns : ["c1 string", "c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + - + id: 2 + desc: 插入部分列数据 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} (c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c1), ts=c7)); + insert: insert into {0} (c1,c4,c7) values('aa',2,1590738989000L); + sql: select * from {0}; + expect: + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",null,2,null,null,1590738989000,null] + - + id: 3 + desc: 没有指定NotNull的列插入null + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} (c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c1), ts=c7)); + insert: insert into {0} (c1,c3,c4,c5,c6,c7,c8) values('aa',2,NULL,NULL,NULL,1590738989000L,NULL); + sql: select * from {0}; + expect: + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,null,null,null,1590738989000,null] + - + id: 4 + desc: NotNull的列插入null + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( c1 string NOT NULL, c2 timestamp, + index(key=(c1), ts=c2)); + sql: insert into {0} (c1,c2,c3) values(NULL,1590738989000L); + expect: + success: false + - + id: 5 + desc: 字符串类型插入空串 + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( c1 string NOT NULL, c2 timestamp, + index(key=(c1), ts=c2)); + insert: insert into {0} (c1,c2) values('',1590738989000L); + sql: select * from {0}; + expect: + columns : ["c1 string","c2 timestamp"] + rows: + - ["",1590738989000] + - + id: 6 + desc: 表名不存在 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( c1 string NOT NULL, c2 timestamp, + index(key=(c1), ts=c2)); + sql: insert into {0}1 (c1,c2) values('aa',1590738989000L); + expect: + success: false + - + id: 7 + desc: 列名不存在 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( c1 string NOT NULL, c2 timestamp, + index(key=(c1), ts=c2)); + sql: insert into {0} (c1,c3) values('aa',1590738989000L); + expect: + success: false + - + id: 8 + desc: 没有指定NotNull的列 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( c1 string, c2 timestamp, c3 string NOT NULL, + index(key=(c1), ts=c2)); + sql: insert into {0} (c1,c2) values('aa',1590738989000L); + expect: + success: false + - + id: 9 + desc: 插入的字符串没有引号 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( c1 string, c2 timestamp, + index(key=(c1), ts=c2)); + sql: insert into {0} (c1,c2) values(aa,1590738989000L); + expect: + success: false + - + id: 10 + desc: 相同时间戳数据 + mode: disk-unsupport + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",2,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",3,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",4,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",5,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",6,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",7,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",8,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",9,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",10,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",11,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",12,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",13,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",14,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",15,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",16,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",17,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",18,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",19,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",20,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + order: c2 + rows: + - [ "aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",2,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",3,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",4,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",5,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",6,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",7,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",8,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",9,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",10,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",11,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",12,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",13,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",14,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",15,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",16,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",17,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",18,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",19,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",20,2,3,1.1,2.1,1590738989000,"2020-05-01" ] diff --git a/cases/integration_test/dml/test_insert_prepared.yaml b/cases/integration_test/dml/test_insert_prepared.yaml new file mode 100644 index 00000000000..f43f5662094 --- /dev/null +++ b/cases/integration_test/dml/test_insert_prepared.yaml @@ -0,0 +1,280 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 插入所有类型的数据 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - + id: 1 + desc: 插入所有列的数据 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} (c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c1), ts=c7)); + insert: insert into {0} values(?,?,?,?,?,?,?); + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns : ["c1 string", "c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + - + id: 2 + desc: 插入部分列数据 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} (c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c1), ts=c7)); + insert: insert into {0} (c1,c4,c7) values(?,?,?); + rows: + - ["aa",2,1590738989000] + sql: select * from {0}; + expect: + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",null,2,null,null,1590738989000,null] + - + id: 3 + desc: 没有指定NotNull的列插入null + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} (c1 string, c3 int, c4 bigint, c5 float, c6 double, c7 timestamp, c8 date, + index(key=(c1), ts=c7)); + insert: insert into {0} (c1,c3,c4,c5,c6,c7,c8) values(?,?,?,?,?,?,?); + rows: + - ["aa",2,null,null,null,1590738989000,null] + sql: select * from {0}; + expect: + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,null,null,null,1590738989000,null] + - + id: 4 + desc: 字符串类型插入空串 + sqlDialect: ["HybridSQL"] + inputs: + - + create: | + create table {0} ( c1 string NOT NULL, c2 timestamp, + index(key=(c1), ts=c2)); + insert: insert into {0} (c1,c2) values(?,?); + rows: + - ["",1590738989000] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 timestamp"] + rows: + - ["",1590738989000] + - + id: 5 + desc: 相同时间戳数据 + mode: disk-unsupport + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",2,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",3,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",4,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",5,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",6,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",7,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",8,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",9,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",10,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",11,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",12,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",13,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",14,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",15,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",16,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",17,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",18,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",19,2,3,1.1,2.1,1590738989000,"2020-05-01"] + - ["aa",20,2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + order: c2 + rows: + - [ "aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",2,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",3,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",4,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",5,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",6,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",7,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",8,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",9,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",10,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",11,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",12,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",13,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",14,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",15,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",16,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",17,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",18,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",19,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - [ "aa",20,2,3,1.1,2.1,1590738989000,"2020-05-01" ] + - + id: 6 + desc: 时间年初 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"2020-01-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"2020-01-01"] + - + id: 7 + desc: 时间年末 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"2020-12-31"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"2020-12-31"] + - + id: 8 + desc: 时间月初 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"2020-12-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"2020-12-01"] + - + id: 9 + desc: 时间月末 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"2020-11-30"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"2020-11-30"] + - + id: 10 + desc: 时间2月末 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"2020-02-28"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"2020-02-28"] + - + id: 11 + desc: 时间3月初 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"2020-03-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"2020-03-01"] + - + id: 12 + desc: 时间1970-01-01 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"1970-01-01"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"1970-01-01"] + - + id: 13 + desc: 时间1969-12-31 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"1969-12-31"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"1969-12-31"] + - + id: 14 + desc: 时间-0330 + inputs: + - + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",1,2,1590738989000,"2020-03-30"] + sql: select * from {0}; + expect: + columns : ["c1 string","c2 smallint","c3 int","c7 timestamp","c8 date"] + rows: + - ["aa",1,2,1590738989000,"2020-03-30"] diff --git a/cases/integration_test/ecosystem/test_kafka.yaml b/cases/integration_test/ecosystem/test_kafka.yaml new file mode 100644 index 00000000000..a4852ae1938 --- /dev/null +++ b/cases/integration_test/ecosystem/test_kafka.yaml @@ -0,0 +1,25 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + json: {"data":[{"c1":"aa","c2":1,"c3":2,"c4":3,"c5":1.1,"c6":2.2,"c7":1590738989000,"c8":1659512628000,"c9":true}],"type":"INSERT"} + sql: select * from {table} + expect: + columns : ["c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - ["aa",1,2,3,1.1,2.1,1590738989000,"2022-08-03",true] \ No newline at end of file diff --git a/cases/integration_test/expression/test_arithmetic.yaml b/cases/integration_test/expression/test_arithmetic.yaml new file mode 100644 index 00000000000..d90c7422c60 --- /dev/null +++ b/cases/integration_test/expression/test_arithmetic.yaml @@ -0,0 +1,686 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +sqlDialect: ["HybridSQL"] +cases: + - id: 0 + desc: "smallint_[%/MOD/*]_整型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["%","MOD","*","-","/"] + sql: select {0}.c2 d[0] {1}.c2 as b2,{0}.c2 d[0] {1}.c3 as b3,{0}.c2 d[0] {1}.c4 as b4,{0}.c2 d[0] {1}.c5 as b5,{0}.c2 d[0] {1}.c6 as b6,{0}.c2 d[0] {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b9 smallint"] + expectProvider: + 0: + rows: + - [0,10,0,7.8,5.8,0] + 1: + rows: + - [0,10,0,7.8,5.8,0] + 2: + rows: + - [0,600,900,333,363,30] + 3: + rows: + - [30,10,0,18.9,17.9,29] + 4: + columns: ["b2 double","b3 double","b4 double","b5 double","b6 double","b9 double"] + rows: + - [Infinity,1.5,1.0,2.7027026098198896,2.479338842975207,30.0] + - id: 1 + desc: "int_算术运算_整型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["%","MOD","*","-","/"] + sql: select {0}.c3 d[0] {1}.c2 as b2,{0}.c3 d[0] {1}.c3 as b3,{0}.c3 d[0] {1}.c4 as b4,{0}.c3 d[0] {1}.c5 as b5,{0}.c3 d[0] {1}.c6 as b6,{0}.c3 d[0] {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b2 int","b3 int","b4 bigint","b5 float","b6 double","b9 int"] + expectProvider: + 0: + rows: + - [0,10,0,7.8,5.8,0] + 1: + rows: + - [0,10,0,7.8,5.8,0] + 2: + rows: + - [0,600,900,333,363,30] + 3: + rows: + - [30,10,0,18.9,17.9,29] + 4: + columns: ["b2 double","b3 double","b4 double","b5 double","b6 double","b9 double"] + rows: + - [Infinity,1.5,1.0,2.7027026098198896,2.479338842975207,30.0] + - id: 2 + desc: "bigint_算术运算_整型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["%","MOD","*","-","/"] + sql: select {0}.c4 d[0] {1}.c2 as b2,{0}.c4 d[0] {1}.c3 as b3,{0}.c4 d[0] {1}.c4 as b4,{0}.c4 d[0] {1}.c5 as b5,{0}.c4 d[0] {1}.c6 as b6,{0}.c4 d[0] {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b2 bigint","b3 bigint","b4 bigint","b5 float","b6 double","b9 bigint"] + expectProvider: + 0: + rows: + - [0,10,0,7.8,5.8,0] + 1: + rows: + - [0,10,0,7.8,5.8,0] + 2: + rows: + - [0,600,900,333,363,30] + 3: + rows: + - [30,10,0,18.9,17.9,29] + 4: + columns: ["b2 double","b3 double","b4 double","b5 double","b6 double","b9 double"] + rows: + - [Infinity,1.5,1.0,2.7027026098198896,2.479338842975207,30.0] + - id: 3 + desc: "float_算术运算_整型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["%","MOD","*","-","/"] + sql: select {0}.c5 d[0] {1}.c2 as b2,{0}.c5 d[0] {1}.c3 as b3,{0}.c5 d[0] {1}.c4 as b4,{0}.c5 d[0] {1}.c5 as b5,{0}.c5 d[0] {1}.c6 as b6,{0}.c5 d[0] {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b2 float","b3 float","b4 float","b5 float","b6 double","b9 float"] + expectProvider: + 0: + rows: + - [NAN,10,0,7.8,5.8,0] + 1: + rows: + - [NAN,10,0,7.8,5.8,0] + 2: + rows: + - [0,600,900,333,363,30] + 3: + rows: + - [30,10,0,18.9,17.9,29] + 4: + columns: ["b2 double","b3 double","b4 double","b5 double","b6 double","b9 double"] + rows: + - [Infinity,1.5,1.0,2.7027026098198896,2.479338842975207,30.0] + - id: 4 + desc: "double_算术运算_整型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["%","MOD","*","-","/"] + sql: select {0}.c6 d[0] {1}.c2 as b2,{0}.c6 d[0] {1}.c3 as b3,{0}.c6 d[0] {1}.c4 as b4,{0}.c6 d[0] {1}.c5 as b5,{0}.c6 d[0] {1}.c6 as b6,{0}.c6 d[0] {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b2 double","b3 double","b4 double","b5 double","b6 double","b9 double"] + expectProvider: + 0: + rows: + - [NAN,10,0,7.7999992370605469,5.8,0] + 1: + rows: + - [NAN,10,0,7.7999992370605469,5.8,0] + 2: + rows: + - [0,600,900,333.0000114440918,363,30] + 3: + rows: + - [30,10,0,18.899999618530273,17.9,29] + 4: + columns: ["b2 double","b3 double","b4 double","b5 double","b6 double","b9 double"] + rows: + - [Infinity,1.5,1.0,2.7027026098198896,2.479338842975207,30.0] + - id: 5 + desc: "+_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c9"] + sql: select d[0] + {1}.c2 as b2,d[0] + {1}.c3 as b3,d[0] + {1}.c4 as b4,d[0] + {1}.c5 as b5,d[0] + {1}.c6 as b6,d[0] + {1}.c7 as b7,d[0] + {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expectProvider: + 0: + columns: ["b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b7 timestamp","b9 smallint"] + rows: + - [30,50,60,41.1,42.1,1590738989031,31] + 1: + columns: ["b2 int","b3 int","b4 bigint","b5 float","b6 double","b7 timestamp","b9 int"] + rows: + - [30,50,60,41.1,42.1,1590738989031,31] + 2: + columns: ["b2 bigint","b3 bigint","b4 bigint","b5 float","b6 double","b7 timestamp","b9 bigint"] + rows: + - [30,50,60,41.1,42.1,1590738989031,31] + 3: + columns: ["b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b7 timestamp","b9 bool"] + rows: + - [0,20,30,11.1,12.1,1590738989001,true] + - id: 6 + desc: "浮点型+_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["{0}.c5","{0}.c6"] + sql: select d[0] + {1}.c2 as b2,d[0] + {1}.c3 as b3,d[0] + {1}.c4 as b4,d[0] + {1}.c5 as b5,d[0] + {1}.c6 as b6,d[0] + {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expectProvider: + 0: + columns: ["b2 float","b3 float","b4 float","b5 float","b6 double","b9 float"] + rows: + - [30,50,60,41.100000381469727,42.1,31] + 1: + columns: ["b2 double","b3 double","b4 double","b5 double","b6 double","b9 double"] + rows: + - [30,50,60,41.100000381469727,42.1,31] + - id: 7 + desc: "timestamp+_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["{0}.c7"] + sql: select d[0] + {1}.c2 as b2,d[0] + {1}.c3 as b3,d[0] + {1}.c4 as b4,d[0] + {1}.c7 as b7,d[0] + {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expectProvider: + 0: + columns: ["b2 timestamp","b3 timestamp","b4 timestamp","b7 timestamp","b9 timestamp"] + rows: + - [1590738989000,1590738989020,1590738989030,3181477978001,1590738989001] + - id: 8 + desc: "timestamp_-_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["-"] + sql: select {0}.c7 d[0] {1}.c2 as b2,{0}.c7 d[0] {1}.c3 as b3,{0}.c7 d[0] {1}.c4 as b4,{0}.c7 d[0] {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expectProvider: + 0: + columns: ["b2 timestamp","b3 timestamp","b4 timestamp","b9 timestamp"] + rows: + - [1590738989000,1590738988980,1590738988970,1590738988999] + - id: 9 + desc: "整型_[%MOD*-/]_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["%","MOD","*","-","/"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c9"] + - ["{1}.c7","{1}.c8","{1}.c1"] + sql: select d[1] d[0] d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 10 + desc: "整型_+_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["+"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c9"] + - ["{1}.c8","{1}.c1"] + sql: select d[1] d[0] d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 11 + desc: "各种类型_[%MOD*/]_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["%","MOD","*","/"] + - ["{0}.c7","{0}.c8","{0}.c1"] + - ["{1}.c1","{1}.c2","{1}.c3","{1}.c4","{1}.c5","{1}.c6","{1}.c7","{1}.c8","{1}.c9"] + sql: select d[1] d[0] d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 12 + desc: "timetamp_-_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["-"] + - ["{0}.c7"] + - ["{1}.c1","{1}.c7","{1}.c8"] + sql: select d[1] d[0] d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 13 + desc: "timetamp_+_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["+"] + - ["{0}.c7"] + - ["{1}.c1","{1}.c8"] + sql: select d[1] d[0] d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 14 + desc: "date/string_[+-]_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["+","-"] + - ["{0}.c8","{0}.c1"] + - ["{1}.c1","{1}.c2","{1}.c3","{1}.c4","{1}.c5","{1}.c6","{1}.c7","{1}.c8","{1}.c9"] + sql: select d[1] d[0] d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 15 + desc: "-_整型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",true] + - [2,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",false] + sql: select id, - {0}.c2 as b2,- {0}.c3 as b3,- {0}.c4 as b4,- {0}.c5 as b5,- {0}.c6 as b6,- {0}.c9 as b9 from {0}; + expect: + order: id + columns: ["id bigint", "b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b9 bool"] + rows: + - [1,-30,30,-30,-30,-30,true] + - [2,-30,30,-30,-30,-30,false] + - id: 16 + desc: "-_其他类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",true] + - [1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",false] + sql: select - d[0] as b2 from {0}; + dataProvider: + - ["{0}.c7","{0}.c8","{0}.c1"] + expect: + success: false + - id: 17 + desc: "int_DIV_int_正确" + tags: ["TODO","bug,@baoxinqi,DIV 0有问题"] + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",false] + dataProvider: + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c9"] + sql: select d[0] DIV {1}.c2 as b2,d[0] DIV {1}.c3 as b3,d[0] DIV {1}.c4 as b4,d[0] DIV {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expectProvider: + 0: + columns: ["b2 smallint","b3 int","b4 bigint","b9 smallint"] + rows: + - [Infinity,1,1,Infinity] + 1: + columns: ["b2 int","b3 int","b4 bigint","b9 int"] + rows: + - [Infinity,1,1,Infinity] + 2: + columns: ["b2 bigint","b3 bigint","b4 bigint","b9 bigint"] + rows: + - [Infinity,0,0,Infinity] + 3: + columns: ["b2 smallint","b3 int","b4 bigint","b9 smallint"] + rows: + - [Infinity,1,1,Infinity] + - id: 18 + desc: "int_DIV_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["DIV"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c9"] + - ["{1}.c1","{1}.c5","{1}.c6","{1}.c7","{1}.c8"] + sql: select d[1] d[0] d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 19 + desc: "各种类型_DIV_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["DIV"] + - ["{1}.c1","{1}.c5","{1}.c6","{1}.c7","{1}.c8"] + - ["{1}.c1","{1}.c2","{1}.c3","{1}.c4","{1}.c5","{1}.c6","{1}.c7","{1}.c8","{1}.c9"] + sql: select d[1] d[0] d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + + - id: 19 + desc: 算数表达式操作数为null时返回null + inputs: + - columns: ["c1 int16","c2 int32","c3 bigint", + "c4 float","c5 double", "c6 timestamp", "c7 bool", "nullcol int32"] + indexs: ["index1:c3:c6"] + rows: + - [1, 911, 1024, 3.14, 0.99, 1590738989000, true, NULL] + sql: select + c1 + nullcol as r1, c1 - nullcol as r2, c1 * nullcol as r3, c1 / nullcol as r4, c1 % nullcol as r5, c1 DIV nullcol as r6, + c2 + nullcol as r7, c2 - nullcol as r8, c2 * nullcol as r9, c2 / nullcol as r10, c2 % nullcol as r11, c2 DIV nullcol as r12, + c3 + nullcol as r13, c3 - nullcol as r14, c3 * nullcol as r15, c3 / nullcol as r16, c3 % nullcol as r17, c3 DIV nullcol as r18, + c4 + nullcol as r19, c4 - nullcol as r20, c4 * nullcol as r21, c4 / nullcol as r22, c4 % nullcol as r23, + c5 + nullcol as r25, c5 - nullcol as r26, c5 * nullcol as r27, c5 / nullcol as r28, c5 % nullcol as r29, + year(c6) + nullcol as r31, year(c6) - nullcol as r32, year(c6) * nullcol as r33, year(c6) / nullcol as r34, year(c6) % nullcol as r35, year(c6) DIV nullcol as r36, + -nullcol as r37, + c7 + nullcol as r38, c7 - nullcol as r39, c7 * nullcol as r40, c7 / nullcol as r41, c7 % nullcol as r42 + from {0}; + expect: + columns: ["r1 int32", "r2 int32", "r3 int32", "r4 double", "r5 int32", "r6 int32", + "r7 int32", "r8 int32", "r9 int32", "r10 double", "r11 int32", "r12 int32", + "r13 bigint", "r14 bigint", "r15 bigint", "r16 double", "r17 bigint", "r18 bigint", + "r19 float", "r20 float", "r21 float", "r22 double", "r23 float", + "r25 double", "r26 double", "r27 double", "r28 double", "r29 double", + "r31 int32", "r32 int32", "r33 int32", "r34 double", "r35 int32", "r36 int32", "r37 int32", + "r38 int32", "r39 int32", "r40 int32","r41 double","r42 int32"] + rows: + - [NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL] + - id: 20 + desc: 算数表达式操作数为const null时返回null-left + inputs: + - columns: ["c1 int16","c2 int32","c3 bigint", + "c4 float","c5 double", "c6 timestamp", "c7 bool", "colnull int32"] + indexs: ["index1:c3:c6"] + rows: + - [1, 911, 1024, 3.14, 0.99, 1590738989000, true, NULL] + sql: select + NULL + c1 as r1, NULL - c1 as r2, NULL * c1 as r3, NULL / c1 as r4, NULL % c1 as r5, NULL DIV c1 as r6, + NULL + c2 as r7, NULL - c2 as r8, NULL * c2 as r9, NULL / c2 as r10, NULL % c2 as r11, NULL DIV c2 as r12, + NULL + c3 as r13, NULL - c3 as r14, NULL * c3 as r15, NULL / c3 as r16, NULL % c3 as r17, NULL DIV c3 as r18, + NULL + c4 as r19, NULL - c4 as r20, NULL * c4 as r21, NULL / c4 as r22, NULL % c4 as r23, + NULL + c5 as r25, NULL - c5 as r26, NULL * c5 as r27, NULL / c5 as r28, NULL % c5 as r29, + year(c6) + NULL as r31, year(c6) - NULL as r32, year(c6) * NULL as r33, year(c6) / NULL as r34, year(c6) % NULL as r35, year(c6) DIV NULL as r36, + NULL as r37, + c7 + NULL as r38, c7 - NULL as r39, c7 * NULL as r40, c7 / NULL as r41, c7 % NULL as r42 + from {0}; + expect: + columns: ["r1 int16", "r2 int16", "r3 int16", "r4 double", "r5 int16", "r6 int16", + "r7 int32", "r8 int32", "r9 int32", "r10 double", "r11 int32", "r12 int32", + "r13 bigint", "r14 bigint", "r15 bigint", "r16 double", "r17 bigint", "r18 bigint", + "r19 float", "r20 float", "r21 float", "r22 double", "r23 float", + "r25 double", "r26 double", "r27 double", "r28 double", "r29 double", + "r31 int32", "r32 int32", "r33 int32", "r34 double", "r35 int32", "r36 int32", "r37 bool", + "r38 bool", "r39 bool", "r40 bool","r41 double","r42 bool"] + rows: + - [NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL] + - id: bitwise_operators + desc: bitwise and/or/xor + inputs: + - columns: ["c1 int16","c2 int32","c3 bigint", "c6 timestamp"] + indexs: ["index1:c3:c6"] + rows: + - [3, 6, 12, 1590738989000] + dataProvider: + - ['&', '|', '^'] + sql: | + select c1 d[0] c1 as r11, c1 d[0] c2 as r12, c1 d[0] c3 as r13, c2 d[0] c2 as r22, c2 d[0] c3 as r23, c3 d[0] c3 as r33 from {0}; + expect: + columns: [ 'r11 int16', 'r12 int32', 'r13 bigint', 'r22 int32', 'r23 bigint', 'r33 bigint' ] + expectProvider: + 0: + rows: + - [ 3, 2, 0, 6, 4, 12 ] + 1: + rows: + - [ 3, 7, 15, 6, 14, 12 ] + 2: + rows: + - [ 0, 5, 15, 0, 10, 0 ] + - id: bitwise_operators_fail + desc: bitwise and/or/xor, fail on non-integral operands + inputs: + - columns: [ "c0 int", "c1 bool", "c2 float", "c3 double", "c4 string", "c5 date", "c6 timestamp" ] + indexs: ["index1:c0:c6"] + rows: + - [1, true, 1.0, 2.0, "abc", "2012-8-11", 1590738989000] + sql: | + select d[1] d[0] 10 as r1 from {0}; + dataProvider: + - ['&', '|', '^'] + - [ '{0}.c1', '{0}.c2', '{0}.c3', '{0}.c4', '{0}.c5', '{0}.c6' ] + expect: + success: false + - id: bitwise_operators_not + desc: bitwise not + inputs: + - columns: ["c1 int16","c2 int32","c3 bigint", "c6 timestamp"] + indexs: ["index1:c3:c6"] + rows: + - [3, 6, 12, 1590738989000] + sql: | + select ~c1 as r1, ~c2 as r2, ~c3 as r3 from {0}; + expect: + columns: [ 'r1 int16', 'r2 int32', 'r3 bigint'] + rows: + - [ -4, -7, -13 ] + - id: bitwise_not_fail + desc: bitwise not, fail on non-integral operand + inputs: + - columns: [ "c0 int", "c1 bool", "c2 float", "c3 double", "c4 string", "c5 date", "c6 timestamp" ] + indexs: ["index1:c0:c6"] + rows: + - [1, true, 1.0, 2.0, "abc", "2012-8-11", 1590738989000] + sql: | + select d[0] d[1] as r1 from {0}; + dataProvider: + - ['~'] + - [ '{0}.c1', '{0}.c2', '{0}.c3', '{0}.c4', '{0}.c5', '{0}.c6' ] + expect: + success: false + - id: bitwise_null_operands + desc: bitwise operation return null if any of operands is null + inputs: + - columns: ["c1 int16","c2 int32","c3 bigint", "c4 int16", "c6 timestamp"] + indexs: ["index1:c3:c6"] + rows: + - [3, 6, 12, NULL, 1590738989000] + sql: | + select {0}.c1 & {0}.c4 as r1, {0}.c2 | {0}.c4 as r2, {0}.c3 ^ {0}.c4 as r3, ~ {0}.c4 as r4 from {0}; + expect: + columns: [ 'r1 int16', 'r2 int32', 'r3 int64', 'r4 int16' ] + rows: + - [ NULL, NULL, NULL, NULL ] + - id: bitwise_const_null_operands + desc: bitwise operation return null if any of operands is null + inputs: + - columns: ["c1 int16","c2 int32","c3 bigint", "c4 int", "c6 timestamp"] + indexs: ["index1:c3:c6"] + rows: + - [3, 6, 12, NULL, 1590738989000] + sql: | + select {0}.c1 & NULL as r1, {0}.c2 | NULL as r2, {0}.c3 ^ NULL as r3, ~ NULL as r4 from {0}; + expect: + columns: [ 'r1 int16', 'r2 int32', 'r3 int64', 'r4 bool' ] + rows: + - [ NULL, NULL, NULL, NULL ] diff --git a/cases/integration_test/expression/test_condition.yaml b/cases/integration_test/expression/test_condition.yaml new file mode 100644 index 00000000000..54d1dd4ad4d --- /dev/null +++ b/cases/integration_test/expression/test_condition.yaml @@ -0,0 +1,400 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: SIMPLE CASE WHEN 表达式 + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, "cc",1590738989000] + - [3, "bb",1590738989000] + - [4, "dd",1590738989000] + sql: | + select col1, col2, case col2 + when 'aa' then 'apple' + else 'nothing' + end as case_f1 from {0}; + expect: + columns: ["col1 int", "col2 string", "case_f1 string"] + order: col1 + rows: + - [1, "aa", "apple"] + - [2, "cc", "nothing"] + - [3, "bb", "nothing"] + - [4, "dd", "nothing"] + - id: 1 + desc: SIMPLE CASE WHEN 表达式无ELSE + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, "cc",1590738989000] + - [3, "bb",1590738989000] + - [4, "dd",1590738989000] + sql: | + select col1, col2, case col2 + when 'aa' then 'apple' + end as case_f1 from {0}; + expect: + columns: ["col1 int", "col2 string", "case_f1 string"] + order: col1 + rows: + - [1, "aa", "apple"] + - [2, "cc", null] + - [3, "bb", null] + - [4, "dd", null] + - id: 2 + desc: SIMPLE CASE WHEN 表达式 ELSE NULL + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, "cc",1590738989000] + - [3, "bb",1590738989000] + - [4, "dd",1590738989000] + sql: | + select col1, col2, case col2 + when 'aa' then 'apple' + else NULL + end as case_f1 from {0}; + expect: + columns: ["col1 int", "col2 string", "case_f1 string"] + order: col1 + rows: + - [1, "aa", "apple"] + - [2, "cc", null] + - [3, "bb", null] + - [4, "dd", null] + - id: 3 + desc: SIMPLE CASE WHEN 表达式 THEN NULL + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, "cc",1590738989000] + - [3, "bb",1590738989000] + - [4, "dd",1590738989000] + - [5, null ,1590738989000] + sql: | + select col1, col2, case col2 + when 'aa' then 'apple' + when 'bb' then NULL + when 'cc' then 'cake' + else 'nothing' + end as case_f1 from {0}; + expect: + columns: ["col1 int", "col2 string", "case_f1 string"] + order: col1 + rows: + - [1, "aa", "apple"] + - [2, "cc", "cake"] + - [3, "bb", null] + - [4, "dd", "nothing"] + - [5, null, "nothing"] + - id: 4 + desc: SEARCHED CASE WHEN 表达式 + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, "cc",1590738989000] + - [3, "bb",1590738989000] + - [4, "dd",1590738989000] + sql: | + select col1, col2, case + when col2='aa' then 'apple' + when col2='bb' then 'banana' + when col2='cc' then 'cake' + else 'nothing' + end as case_f1 from {0}; + expect: + columns: ["col1 int", "col2 string", "case_f1 string"] + order: col1 + rows: + - [1, "aa", "apple"] + - [2, "cc", "cake"] + - [3, "bb", "banana"] + - [4, "dd", "nothing"] + - id: 5 + desc: SEARCHED CASE WHEN 表达式无 ELSE + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, "cc",1590738989000] + - [3, "bb",1590738989000] + - [4, "dd",1590738989000] + sql: | + select col1, col2, case + when col2='aa' then 'apple' + end as case_f1 from {0}; + expect: + columns: ["col1 int", "col2 string", "case_f1 string"] + order: col1 + rows: + - [1, "aa", "apple"] + - [2, "cc", null] + - [3, "bb", null] + - [4, "dd", null] + - id: 6 + desc: SEARCHED CASE WHEN 表达式 ELSE + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, "cc",1590738989000] + - [3, "bb",1590738989000] + - [4, "dd",1590738989000] + sql: | + select col1, col2, case + when col2='aa' then 'apple' + when col2='bb' then 'banana' + when col2='cc' then 'cake' + else 'nothing' + end as case_f1 from {0}; + expect: + columns: ["col1 int", "col2 string", "case_f1 string"] + order: col1 + rows: + - [1, "aa", "apple"] + - [2, "cc", "cake"] + - [3, "bb", "banana"] + - [4, "dd", "nothing"] + - id: 7 + desc: 条件表达式null测试 + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["id int64", "c1 bool", "c2 string", "c3 string"] + indexs: ["index1:c1:id"] + rows: + - [1, true, "xxx", "aaa"] + - [2, true, "xxx", NULL] + - [3, true, NULL, "aaa"] + - [4, true, NULL, NULL] + - [5, false, "xxx", "aaa"] + - [6, false, "xxx", NULL] + - [7, false, NULL, "aaa"] + - [8, false, NULL, NULL] + - [9, NULL, "xxx", "aaa"] + - [10, NULL, "xxx", NULL] + - [11, NULL, NULL, "aaa"] + - [12, NULL, NULL, NULL] + sql: select id, case when c1 then c2 else c3 end as result from {0}; + expect: + columns: ["id int64", "result string"] + order: id + rows: + - [1, "xxx"] + - [2, "xxx"] + - [3, NULL] + - [4, NULL] + - [5, "aaa"] + - [6, NULL] + - [7, "aaa"] + - [8, NULL] + - [9, "aaa"] + - [10, NULL] + - [11, "aaa"] + - [12, NULL] + - id: 8 + desc: IFNULL + sqlDialect: ["HybridSQL"] + mode: cli-unsupport + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, null,1590738989000] + - [3, "",1590738989000] + sql: | + select col1,ifnull(col2,"abc") as e1 from {0}; + expect: + columns: ["col1 int", "e1 string"] + order: col1 + rows: + - [1, "aa"] + - [2, "abc"] + - [3, ""] + - id: 9 + desc: IFNULL-不同类型 + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["col1 int","col2 int", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1,ifnull(col2,"abc") as e1 from {0}; + expect: + success: false + - id: 10 + desc: IFNULL-表达式 + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["col1 int","col2 int", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1,ifnull(col2,100) as e1,ifnull(col2+1,100) as e2 from {0}; + expect: + columns: ["col1 int", "e1 int", "e2 int"] + order: col1 + rows: + - [1, 0,1] + - [2, 100,100] + - [3, 1,2] + - id: 11-1 + desc: IFNULL-表达式-/0 + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["col1 int","col2 int", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1,ifnull(col2 /0 ,100) as e3 from {0}; + expect: + success: false + - id: 11-2 + mode: cli-unsupport + desc: NVL is synonyms to ifnull + inputs: + - columns: ["col1 int","col2 string", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, "aa",1590738989000] + - [2, null,1590738989000] + - [3, "",1590738989000] + sql: | + select col1,nvl(col2,"abc") as e1 from {0}; + expect: + columns: ["col1 int", "e1 string"] + order: col1 + rows: + - [1, "aa"] + - [2, "abc"] + - [3, ""] + - id: 11-3 + desc: NVL-表达式-/0 + inputs: + - columns: ["col1 int","col2 int", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1,nvl(col2 /0 ,100) as e3 from {0}; + expect: + success: false + - id: 12 + desc: IFNULL-兼容类型 + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["col1 int","col2 bigint", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1,ifnull(col2,100) as e1 from {0}; + expect: + success: false + - id: 13 + desc: IFNULL-浮点型 + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["col1 int","col2 bigint", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1,ifnull(col2,1.1) as e2 from {0}; + expect: + success: false + + - id: NVL2-1 + desc: NVL2 + inputs: + - columns: ["col1 int","col2 int", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1,nvl2(col2, "abc", "def") as e1 from {0}; + expect: + columns: ["col1 int", "e1 string"] + order: col1 + rows: + - [1, "abc"] + - [2, "def"] + - [3, "abc"] + + - id: NVL2-2 + desc: NVL2, type not match + inputs: + - columns: ["col1 int","col2 int", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1,nvl2(col2, "abc", col1 + 1) as e1 from {0}; + expect: + success: false + + - id: NVL2-3 + desc: NVL2, sub expression + inputs: + - columns: ["col1 int","col2 int", "col4 timestamp"] + indexs: ["index1:col1:col4"] + rows: + - [1, 0,1590738989000] + - [2, null,1590738989000] + - [3, 1,1590738989000] + sql: | + select col1, nvl2(col2, col1 * col1, col1 + 1) as e1 from {0}; + expect: + columns: ["col1 int", "e1 int"] + order: col1 + rows: + - [1, 1] + - [2, 3] + - [3, 9] \ No newline at end of file diff --git a/cases/integration_test/expression/test_like.yaml b/cases/integration_test/expression/test_like.yaml new file mode 100644 index 00000000000..d47bb57b616 --- /dev/null +++ b/cases/integration_test/expression/test_like.yaml @@ -0,0 +1,1138 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +sqlDialect: ["HybridSQL"] +version: 0.5.0 +cases: + - id: 0 + desc: "使用_" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"a_b",30,30,30,30.0,30.0,1590738990000,"2020-05-01",false] + - [2,"aab",30,30,30,30.0,30.0,1590738991000,"2020-05-01",false] + - [3,"a%b",30,30,30,30.0,30.0,1590738992000,"2020-05-01",false] + - [4,"b_c",30,30,30,30.0,30.0,1590738993000,"2020-05-01",false] + - [5,"abc",30,30,30,30.0,30.0,1590738994000,"2020-05-01",false] + - [6,"A0b",30,30,30,30.0,30.0,1590738995000,"2020-05-01",false] + - [7,"a#B",30,30,30,30.0,30.0,1590738996000,"2020-05-01",false] + - [8,"aaab",30,30,30,30.0,30.0,1590738991000,"2020-05-01",false] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] 'a_b' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"a_b",true] + - [2,"aab",true] + - [3,"a%b",true] + - [4,"b_c",false] + - [5,"abc",false] + - [6,"A0b",false] + - [7,"a#B",false] + - [8,"aaab",false] + 1: + rows: + - [1,"a_b",false] + - [2,"aab",false] + - [3,"a%b",false] + - [4,"b_c",true] + - [5,"abc",true] + - [6,"A0b",true] + - [7,"a#B",true] + - [8,"aaab",true] + 2: + rows: + - [1,"a_b",true] + - [2,"aab",true] + - [3,"a%b",true] + - [4,"b_c",false] + - [5,"abc",false] + - [6,"A0b",true] + - [7,"a#B",true] + - [8,"aaab",false] + 3: + rows: + - [1,"a_b",false] + - [2,"aab",false] + - [3,"a%b",false] + - [4,"b_c",true] + - [5,"abc",true] + - [6,"A0b",false] + - [7,"a#B",false] + - [8,"aaab",true] + - id: 1 + desc: "使用%" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"a%_b",1590738992000] + - [4,"b_c",1590738993000] + - [5,"abc",1590738994000] + - [6,"A0b",1590738995000] + - [7,"a#B",1590738996000] + - [8,"aaab",1590738997000] + - [9,"ab",1590738998000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] 'a%b' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"a_b",true] + - [2,"aabb",true] + - [3,"a%_b",true] + - [4,"b_c",false] + - [5,"abc",false] + - [6,"A0b",false] + - [7,"a#B",false] + - [8,"aaab",true] + - [9,"ab",true] + 1: + rows: + - [1,"a_b",false] + - [2,"aabb",false] + - [3,"a%_b",false] + - [4,"b_c",true] + - [5,"abc",true] + - [6,"A0b",true] + - [7,"a#B",true] + - [8,"aaab",false] + - [9,"ab",false] + 2: + rows: + - [1,"a_b",true] + - [2,"aabb",true] + - [3,"a%_b",true] + - [4,"b_c",false] + - [5,"abc",false] + - [6,"A0b",true] + - [7,"a#B",true] + - [8,"aaab",true] + - [9,"ab",true] + 3: + rows: + - [1,"a_b",false] + - [2,"aabb",false] + - [3,"a%_b",false] + - [4,"b_c",true] + - [5,"abc",true] + - [6,"A0b",false] + - [7,"a#B",false] + - [8,"aaab",false] + - [9,"ab",false] + - id: 2 + desc: "同时使用%和_" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"aa#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] '_a%b' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"aa#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"aa#0B",true] + 2: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",true] + - [7,"aa#0B",true] + 3: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",false] + - [7,"aa#0B",false] + - id: 3 + desc: "使用默认的escape" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] "\\_a%b" ESCAPE "\\" as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"_a#0B",true] + 2: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",true] + 3: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"_a#0B",false] + - id: 4 + desc: "指定escape为#" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] '#_a%b' ESCAPE '#' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"_a#0B",true] + 2: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",true] + 3: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"_a#0B",false] + - id: 5 + desc: "指定escape为_" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] '__a%b' ESCAPE '_' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"_a#0B",true] + 2: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",true] + 3: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"_a#0B",false] + - id: 6 + desc: "指定escape为%" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA%b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] '_a%%b' ESCAPE '%' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA%b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA%b",true] + - [7,"_a#0B",true] + 2: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA%b",true] + - [7,"_a#0B",false] + 3: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA%b",false] + - [7,"_a#0B",true] + - id: 7 + desc: "escape不指定" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] "\\_a%b" as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"_a#0B",true] + 2: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",true] + 3: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"_a#0B",false] + - id: 8 + desc: "escape为空串,使用\\" + mode: cluster-unsupport + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,'\\\%a_b',1590738990000] + - [2,'\\\aabb',1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,'\\\bA0b',1590738995000] + - [7,'\\\_a#0B',1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] "\\_a%b" escape "" as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,'\%a_b',true] + - [2,'\aabb',true] + - [3,'_a%_b',false] + - [4,'ba_c',false] + - [5,"abb",false] + - [6,'\bA0b',false] + - [7,'\_a#0B',false] + 1: + rows: + - [1,'\%a_b',false] + - [2,'\aabb',false] + - [3,"_a%_b",true] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,'\bA0b',true] + - [7,'\_a#0B',true] + 2: + rows: + - [1,'\%a_b',true] + - [2,'\aabb',true] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,'\bA0b',true] + - [7,'\_a#0B',true] + 3: + rows: + - [1,'\%a_b',false] + - [2,'\aabb',false] + - [3,"_a%_b",true] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,'\bA0b',false] + - [7,'\_a#0B',false] + - id: 9 + desc: "使用两个%" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"a%_b%0",1590738992000] + - [4,"b_c",1590738993000] + - [5,"abc",1590738994000] + - [6,"A0b",1590738995000] + - [7,"a#Bb",1590738996000] + - [8,"aaabbcc",1590738991000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] 'a%b%' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"a_b",true] + - [2,"aabb",true] + - [3,"a%_b%0",true] + - [4,"b_c",false] + - [5,"abc",true] + - [6,"A0b",false] + - [7,"a#Bb",true] + - [8,"aaabbcc",true] + 1: + rows: + - [1,"a_b",false] + - [2,"aabb",false] + - [3,"a%_b%0",false] + - [4,"b_c",true] + - [5,"abc",false] + - [6,"A0b",true] + - [7,"a#Bb",false] + - [8,"aaabbcc",false] + 2: + rows: + - [1,"a_b",true] + - [2,"aabb",true] + - [3,"a%_b%0",true] + - [4,"b_c",false] + - [5,"abc",true] + - [6,"A0b",true] + - [7,"a#Bb",true] + - [8,"aaabbcc",true] + 3: + rows: + - [1,"a_b",false] + - [2,"aabb",false] + - [3,"a%_b%0",false] + - [4,"b_c",true] + - [5,"abc",false] + - [6,"A0b",false] + - [7,"a#Bb",false] + - [8,"aaabbcc",false] + - id: 10 + desc: "使用两个_" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"aa#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] '_a_b' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"aa#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",true] + - [7,"aa#0B",true] + 2: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",true] + - [7,"aa#0B",false] + 3: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA0b",false] + - [7,"aa#0B",true] + - id: 11 + desc: "使用两个%,其中一个被转义" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"a_b",1590738990000] + - [2,"aab%",1590738991000] + - [3,"a%_b%0",1590738992000] + - [4,"b_c",1590738993000] + - [5,"ab%",1590738994000] + - [6,"A0b",1590738995000] + - [7,"a#B%",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] 'a%b#%' escape '#' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"a_b",false] + - [2,"aab%",true] + - [3,"a%_b%0",false] + - [4,"b_c",false] + - [5,"ab%",true] + - [6,"A0b",false] + - [7,"a#B%",false] + 1: + rows: + - [1,"a_b",true] + - [2,"aab%",false] + - [3,"a%_b%0",true] + - [4,"b_c",true] + - [5,"ab%",false] + - [6,"A0b",true] + - [7,"a#B%",true] + 2: + rows: + - [1,"a_b",false] + - [2,"aab%",true] + - [3,"a%_b%0",false] + - [4,"b_c",false] + - [5,"ab%",true] + - [6,"A0b",false] + - [7,"a#B%",true] + 3: + rows: + - [1,"a_b",true] + - [2,"aab%",false] + - [3,"a%_b%0",true] + - [4,"b_c",true] + - [5,"ab%",false] + - [6,"A0b",true] + - [7,"a#B%",false] + - id: 12 + desc: "使用两个_,其中一个被转义" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"_A0b",1590738995000] + - [7,"aa#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] '#_a_b' escape '#' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"_A0b",false] + - [7,"aa#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"_A0b",true] + - [7,"aa#0B",true] + 2: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"_A0b",true] + - [7,"aa#0B",false] + 3: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"_A0b",false] + - [7,"aa#0B",true] + - id: 13 + desc: "同时使用%和_,其中_被转义" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"_A0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] '#_a%b' escape '#' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"_A0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"_A0b",true] + - [7,"_a#0B",true] + 2: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"_A0b",true] + - [7,"_a#0B",true] + 3: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"_A0b",false] + - [7,"_a#0B",false] + - id: 14 + desc: "同时使用%和_,其中%被转义" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a%b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA%b",1590738995000] + - [7,"aa#0B",1590738996000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1,c1 d[0] '_a#%b' escape '#' as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a%b",true] + - [2,"aabb",false] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA%b",false] + - [7,"aa#0B",false] + 1: + rows: + - [1,"%a%b",false] + - [2,"aabb",true] + - [3,"_a%_b",true] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA%b",true] + - [7,"aa#0B",true] + 2: + rows: + - [1,"%a%b",true] + - [2,"aabb",false] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA%b",true] + - [7,"aa#0B",false] + 3: + rows: + - [1,"%a%b",false] + - [2,"aabb",true] + - [3,"_a%_b",true] + - [4,"ba_c",true] + - [5,"abb",true] + - [6,"bA%b",false] + - [7,"aa#0B",true] + - id: 15 + desc: "列中有null和空串" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,null,1590738991000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] 'a%b' as v1 from {0}; + expect: + order: id + columns: ["id bigint","v1 bool"] + rows: + - [1,false] + - [2,null] + expectProvider: + 1: + rows: + - [1,true] + - [2,null] + 3: + rows: + - [1,true] + - [2,null] + - id: 16 + desc: "使用空串" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,"aa",1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '' as v1 from {0}; + expect: + order: id + columns: ["id bigint","v1 bool"] + rows: + - [1,true] + - [2,false] + expectProvider: + 1: + rows: + - [1,false] + - [2,true] + 3: + rows: + - [1,false] + - [2,true] + - id: 17 + desc: "使用null" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,"aa",1590738991000] + - [3,null,1590738992000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] null as v1 from {0}; + expect: + success: false + - id: 18 + desc: "escape使用null" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,"aa",1590738991000] + - [3,null,1590738992000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] 'a%' escape null as v1 from {0}; + expect: + success: false + - id: 19 + desc: "int类型" + inputs: + - + columns : ["id bigint","c1 int","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12,1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 20 + desc: "bigint类型" + inputs: + - + columns : ["id bigint","c1 bigint","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12,1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 21 + desc: "smallint类型" + inputs: + - + columns : ["id bigint","c1 smallint","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12,1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 22 + desc: "float类型" + inputs: + - + columns : ["id bigint","c1 float","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12.0,1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 23 + desc: "double类型" + inputs: + - + columns : ["id bigint","c1 double","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12.0,1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 24 + desc: "timestamp类型" + inputs: + - + columns : ["id bigint","c1 timestamp","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12,1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 25 + desc: "date类型" + inputs: + - + columns : ["id bigint","c1 date","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"2012-05-01",1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 26 + desc: "bool类型" + inputs: + - + columns : ["id bigint","c1 bool","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,true,1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 27 + desc: "列不存在" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",1590738990000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c2 d[0] '1%' as v1 from {0}; + expect: + success: false + - id: 28 + desc: "escape为多个字符" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,"aa",1590738991000] + - [3,null,1590738992000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] 'a%' escape '<>' as v1 from {0}; + expect: + success: false + - id: 29 + desc: "pattern以escape character结尾" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"ab#",1590738990000] + - [2,"aa",1590738991000] + dataProvider: + - ["like","not like","ilike","not ilike"] + sql: select id,c1 d[0] 'a%#' escape '#' as v1 from {0}; + expect: + success: true + columns : ["id bigint","v1 bool"] + rows: + - [1,false] + - [2,false] + expectProvider: + 1: + rows: + - [1,true] + - [2,true] + 3: + rows: + - [1,true] + - [2,true] diff --git a/cases/integration_test/expression/test_logic.yaml b/cases/integration_test/expression/test_logic.yaml new file mode 100644 index 00000000000..d1ce41b7825 --- /dev/null +++ b/cases/integration_test/expression/test_logic.yaml @@ -0,0 +1,135 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +sqlDialect: ["HybridSQL"] +cases: + - id: 0 + desc: "各种类型_逻辑运算_各种类型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",true] + - [2,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",true] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",false] + - [2,"",0,0,0,0.0,0.0,0,null,true] + dataProvider: + - ["AND","OR","XOR"] + - ["{0}.c1","{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c7","{0}.c8","{0}.c9"] + sql: select d[1] d[0] {1}.c1 as b1,d[1] d[0] {1}.c2 as b2,d[1] d[0] {1}.c3 as b3,d[1] d[0] {1}.c4 as b4,d[1] d[0] {1}.c5 as b5,d[1] d[0] {1}.c6 as b6,d[1] d[0] {1}.c7 as b7,d[1] d[0] {1}.c8 as b8,d[1] d[0] {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b1 bool","b2 bool","b3 bool","b4 bool","b5 bool","b6 bool","b7 bool","b8 bool","b9 bool"] + expectProvider: + 0: + rows: + - [true,true,true,true,true,true,true,true,false] + - [false,false,false,false,false,false,false,null,true] + 1: + rows: + - [true,true,true,true,true,true,true,true,true] + - [true,true,true,true,true,true,true,true,true] + 2: + rows: + - [false,false,false,false,false,false,false,false,true] + - [true,true,true,true,true,true,true,null,false] + - id: 1 + desc: "各种类型_逻辑非_各种类型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",false] + - [2,"",0,0,0,0.0,0.0,0,null,true] + dataProvider: + - ["NOT","!"] + sql: select d[0] {0}.c1 as b1,d[0] {0}.c2 as b2,d[0] {0}.c3 as b3,d[0] {0}.c4 as b4,d[0] {0}.c5 as b5,d[0] {0}.c6 as b6,d[0] {0}.c7 as b7,d[0] {0}.c8 as b8,d[0] {0}.c9 as b9 from {0}; + expect: + columns: ["b1 bool","b2 bool","b3 bool","b4 bool","b5 bool","b6 bool","b7 bool","b8 bool","b9 bool"] + rows: + - [false,false,false,false,false,false,false,false,true] + - [true,true,true,true,true,true,true,null,false] + - id: 2 + desc: 三值bool逻辑 + inputs: + - columns: ["id int64", "tt int64", "c1 bool", "c2 bool"] + indexs: ["index1:id:tt"] + rows: + - [1, 1, true, true] + - [2, 2, true, false] + - [3, 3, true, NULL] + - [4, 4, false, true] + - [5, 5, false, false] + - [6, 6, false, NULL] + - [7, 7, NULL, true] + - [8, 8, NULL, false] + - [9, 9, NULL, NULL] + sql: select id, c1, c2, c1 and c2 as c_and, c1 or c2 as c_or, c1 xor c2 as c_xor, not c1 as c_not from {0}; + expect: + order: id + columns: ["id int64", "c1 bool", "c2 bool", "c_and bool", "c_or bool", "c_xor bool", "c_not bool"] + rows: + - [1, true, true, true, true, false, false] + - [2, true, false, false, true, true, false] + - [3, true, NULL, NULL, true, NULL, false] + - [4, false, true, false, true, true, true] + - [5, false, false, false, false, false, true] + - [6, false, NULL, false, NULL, NULL, true] + - [7, NULL, true, NULL, true, NULL, NULL] + - [8, NULL, false, false, NULL, NULL, NULL] + - [9, NULL, NULL, NULL, NULL, NULL, NULL] + - id: 3 + desc: 逻辑表达式不使用布尔表达式 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp","c5 date"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000,"2020-05-01"] + sql: select c2=2 and (c2-1) as f1 from {0}; + expect: + columns: ["f1 bool"] + rows: + - [true] + - id: 4 + desc: 逻辑表达式不使用布尔表达式! + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp","c5 date"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000,"2020-05-01"] + sql: select !c2 as not_c2 from {0}; + expect: + columns: ["not_c2 bool"] + rows: + - [false] + - id: 5 + desc: 逻辑表达式不使用布尔表达式-常量 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp","c5 date"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000,"2020-05-01"] + sql: select c2==2 and false as flag1,!true as flag2 from {0}; + expect: + columns: ["flag1 bool", "flag2 bool"] + rows: + - [false,false] diff --git a/cases/integration_test/expression/test_predicate.yaml b/cases/integration_test/expression/test_predicate.yaml new file mode 100644 index 00000000000..db183a878e7 --- /dev/null +++ b/cases/integration_test/expression/test_predicate.yaml @@ -0,0 +1,778 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +sqlDialect: ["HybridSQL"] +cases: + - id: 0 + desc: "string_比较运算_各种类型" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"10",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",false] + dataProvider: + - [">",">=","<","<=","<>","!=","=","=="] + sql: select {0}.c1 d[0] {1}.c1 as b1,{0}.c1 d[0] {1}.c2 as b2,{0}.c1 d[0] {1}.c3 as b3,{0}.c1 d[0] {1}.c4 as b4,{0}.c1 d[0] {1}.c5 as b5,{0}.c1 d[0] {1}.c6 as b6,{0}.c1 d[0] {1}.c7 as b7,{0}.c1 d[0] {1}.c8 as b8,{0}.c1 d[0] {1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b1 bool","b2 bool","b3 bool","b4 bool","b5 bool","b6 bool", "b7 bool", "b8 bool", "b9 bool"] + expectProvider: + 0: + rows: + - [false,false,false,false,false,false,false,false,false] + 1: + rows: + - [false,true,false,false,false,false,false,false,false] + 2: + rows: + - [true,false,true,true,true,true,true,true,true] + 3: + rows: + - [true,true,true,true,true,true,true,true,true] + 4: + rows: + - [true,false,true,true,true,true,true,true,true] + 5: + rows: + - [true,false,true,true,true,true,true,true,true] + 6: + rows: + - [false,true,false,false,false,false,false,false,false] + 7: + rows: + - [false,true,false,false,false,false,false,false,false] + - id: 1 + desc: "整型_比较运算_各种类型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - [">",">=","<","<=","<>","!=","=","=="] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6"] + sql: select d[1]d[0]{1}.c1 as b1,d[1]d[0]{1}.c2 as b2,d[1]d[0]{1}.c3 as b3,d[1]d[0]{1}.c4 as b4,d[1]d[0]{1}.c5 as b5,d[1]d[0]{1}.c6 as b6,d[1]d[0]{1}.c9 as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b1 bool","b2 bool","b3 bool","b4 bool","b5 bool","b6 bool","b9 bool"] + expectProvider: + 0: + rows: + - [false,false,false,false,false,false,true] + 1: + rows: + - [false,true,false,false,false,false,true] + 2: + rows: + - [true,false,true,true,true,true,false] + 3: + rows: + - [true,true,true,true,true,true,false] + 4: + rows: + - [true,false,true,true,true,true,true] + 5: + rows: + - [true,false,true,true,true,true,true] + 6: + rows: + - [false,true,false,false,false,false,false] + 7: + rows: + - [false,true,false,false,false,false,false] + - id: 2 + desc: "整型_比较运算_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - [">",">=","<","<=","<>","!=","=","=="] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c9"] + - ["{1}.c7","{1}.c8"] + sql: select d[1]d[0]d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 3 + desc: "时间类型_比较运算_各种类型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"10",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"10",1,2,3,1.1,2.1,1590738989001,"2020-05-02",true] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"2020-05-29 15:56:29",10,20,30,11.1,12.1,1590738989001,"2020-05-02",false] + - [2,"2020-05-02",10,20,30,11.1,12.1,1590738989001,"2020-05-02",false] + dataProvider: + - [">",">=","<","<=","<>","!=","=","=="] + sql: select {0}.c8 d[0] {1}.c1 as b1,{0}.c8 d[0] {1}.c8 as b2,{0}.c7 d[0] {1}.c1 as b3,{0}.c7 d[0] {1}.c7 as b4 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b1 bool","b2 bool","b3 bool","b4 bool"] + expectProvider: + 0: + rows: + - [false,false,false,false] + - [false,false,true,false] + 1: + rows: + - [false,false,true,false] + - [true,true,true,true] + 2: + rows: + - [true,true,false,true] + - [false,false,false,false] + 3: + rows: + - [true,true,true,true] + - [true,true,false,true] + 4: + rows: + - [true,true,false,true] + - [false,false,true,false] + 5: + rows: + - [true,true,false,true] + - [false,false,true,false] + 6: + rows: + - [false,false,true,false] + - [true,true,false,true] + 7: + rows: + - [false,false,true,false] + - [true,true,false,true] + - id: 4 + desc: "timestamp_比较运算_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - [">",">=","<","<=","<>","!=","=","=="] + - ["{1}.c7"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c9","{1}.c8"] + sql: select d[1]d[0]d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 5 + desc: "date_比较运算_各种类型_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",10,10,10,10.0,10.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",10,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - [">",">=","<","<=","<>","!=","=","=="] + - ["{1}.c8"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c9","{1}.c7"] + sql: select d[1]d[0]d[2] as b1 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + success: false + - id: 6 + desc: "bool_比较运算_各种类型" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"10",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool","c10 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"1",1,20,30,11.1,12.1,1590738989001,"2020-05-02",false,true] + dataProvider: + - [">",">=","<","<=","<>","!=","=","=="] + sql: select {0}.c9 d[0] {1}.c1 as b1,{0}.c9 d[0] {1}.c2 as b2,{0}.c9 d[0] {1}.c3 as b3,{0}.c9 d[0] {1}.c4 as b4,{0}.c9 d[0] {1}.c5 as b5,{0}.c9 d[0] {1}.c6 as b6,{0}.c9 d[0] {1}.c9 as b9,{0}.c9 d[0] {1}.c10 as b10 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b1 bool","b2 bool","b3 bool","b4 bool","b5 bool","b6 bool", "b9 bool","b10 bool"] + expectProvider: + 0: + rows: + - [true,false,false,false,false,false,true,false] + 1: + rows: + - [true,true,false,false,false,false,true,true] + 2: + rows: + - [false,false,true,true,true,true,false,false] + 3: + rows: + - [false,true,true,true,true,true,false,true] + 4: + rows: + - [true,false,true,true,true,true,true,false] + 5: + rows: + - [true,false,true,true,true,true,true,false] + 6: + rows: + - [false,true,false,false,false,false,false,true] + 7: + rows: + - [false,true,false,false,false,false,false,true] + - id: 7 + desc: "IS_NULL_各种类型" + tags: ["TODO","目前不支持"] + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"10",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["c1","c2","c3","c4","c5","c6","c7","c8","c9"] + sql: select * from {0} where d[0] is null; + expect: + columns: ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + rows: + - [1,"10",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - id: 8 + desc: "ISNULL()" + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"10",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + sql: select isnull(c1) as b1,isnull(c2) as b2,isnull(c3) as b3,isnull(c4) as b4,isnull(c5) as b5,isnull(c6) as b6,isnull(c7) as b7,isnull(c8) as b8,isnull(c9) as b9 from {0}; + expect: + order: id + columns: ["b1 bool","b2 bool","b3 bool","b4 bool","b5 bool","b6 bool", "b7 bool", "b8 bool", "b9 bool"] + rows: + - [false,false,false,false,false,false,false,false,false] + - [true,true,true,true,true,true,true,true,true] + - id: 9 + desc: 直接和NULL比较返回NULL + inputs: + - columns: ["c1 int16","c2 int32","c3 bigint", + "c4 float","c5 double", "c6 timestamp", "c7 string", + "nullcol int32", "nulltime timestamp", "nullstr string"] + indexs: ["index1:c3:c6"] + rows: + - [1, 911, 1024, 3.14, 0.99, 1590738989000, "str", NULL, NULL, NULL] + sql: select + c1 > nullcol as r1, c1 >= nullcol as r2, c1 < nullcol as r3, c1 <= nullcol as r4, c1 = nullcol as r5, c1 != nullcol as r6, + c2 > nullcol as r7, c2 >= nullcol as r8, c2 < nullcol as r9, c2 <= nullcol as r10, c2 = nullcol as r11, c2 != nullcol as r12, + c3 > nullcol as r13, c3 >= nullcol as r14, c3 < nullcol as r15, c3 <= nullcol as r16, c3 = nullcol as r17, c3 != nullcol as r18, + c4 > nullcol as r19, c4 >= nullcol as r20, c4 < nullcol as r21, c4 <= nullcol as r22, c4 = nullcol as r23, c4 != nullcol as r24, + c5 > nullcol as r25, c5 >= nullcol as r26, c5 < nullcol as r27, c5 <= nullcol as r28, c5 = nullcol as r29, c5 != nullcol as r30, + c6 > nulltime as r31, c6 >= nulltime as r32, c6 < nulltime as r33, c6 <= nulltime as r34, c6 = nulltime as r35, c6 != nulltime as r36, + c7 > nullstr as r37, c7 >= nullstr as r38, c7 < nullstr as r39, c7 <= nullstr as r40, c7 = nullstr as r41, c7 != nullstr as r42, + nullstr > nullstr as r43, nullstr >= nullstr as r44, nullstr < nullstr as r45, + nullstr <= nullstr as r46, nullstr = nullstr as r47, nullstr != nullstr as r48 + from {0}; + expect: + columns: ["r1 bool", "r2 bool", "r3 bool", "r4 bool", "r5 bool", "r6 bool", "r7 bool", "r8 bool", + "r9 bool", "r10 bool", "r11 bool", "r12 bool", "r13 bool", "r14 bool", "r15 bool", "r16 bool", + "r17 bool", "r18 bool", "r19 bool", "r20 bool", "r21 bool", "r22 bool", "r23 bool", "r24 bool", + "r25 bool", "r26 bool", "r27 bool", "r28 bool", "r29 bool", "r30 bool", "r31 bool", "r32 bool", + "r33 bool", "r34 bool", "r35 bool", "r36 bool", "r37 bool", "r38 bool", "r39 bool", "r40 bool", + "r41 bool", "r42 bool", "r43 bool", "r44 bool", "r45 bool", "r46 bool", "r47 bool", "r48 bool"] + rows: + - [NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL] + - id: 10 + desc: 直接和Const NULL比较返回NULL + inputs: + - columns: ["c1 int16","c2 int32","c3 bigint", + "c4 float","c5 double", "c6 timestamp", "c7 string", + "nullcol int32", "nulltime timestamp", "nullstr string"] + indexs: ["index1:c3:c6"] + rows: + - [1, 911, 1024, 3.14, 0.99, 1590738989000, "str", NULL, NULL, NULL] + sql: select + c1 > NULL as r1, c1 >= NULL as r2, c1 < NULL as r3, c1 <= NULL as r4, c1 = NULL as r5, c1 != NULL as r6, + c2 > NULL as r7, c2 >= NULL as r8, c2 < NULL as r9, c2 <= NULL as r10, c2 = NULL as r11, c2 != NULL as r12, + c3 > NULL as r13, c3 >= NULL as r14, c3 < NULL as r15, c3 <= NULL as r16, c3 = NULL as r17, c3 != NULL as r18, + c4 > NULL as r19, c4 >= NULL as r20, c4 < NULL as r21, c4 <= NULL as r22, c4 = NULL as r23, c4 != NULL as r24, + c5 > NULL as r25, c5 >= NULL as r26, c5 < NULL as r27, c5 <= NULL as r28, c5 = NULL as r29, c5 != NULL as r30, + c6 > NULL as r31, c6 >= NULL as r32, c6 < NULL as r33, c6 <= NULL as r34, c6 = NULL as r35, c6 != NULL as r36, + c7 > NULL as r37, c7 >= NULL as r38, c7 < NULL as r39, c7 <= NULL as r40, c7 = NULL as r41, c7 != NULL as r42, + NULL > NULL as r43, NULL >= NULL as r44, NULL < NULL as r45, + NULL <= NULL as r46, NULL = NULL as r47, NULL != NULL as r48 + from {0}; + expect: + columns: ["r1 bool", "r2 bool", "r3 bool", "r4 bool", "r5 bool", "r6 bool", "r7 bool", "r8 bool", + "r9 bool", "r10 bool", "r11 bool", "r12 bool", "r13 bool", "r14 bool", "r15 bool", "r16 bool", + "r17 bool", "r18 bool", "r19 bool", "r20 bool", "r21 bool", "r22 bool", "r23 bool", "r24 bool", + "r25 bool", "r26 bool", "r27 bool", "r28 bool", "r29 bool", "r30 bool", "r31 bool", "r32 bool", + "r33 bool", "r34 bool", "r35 bool", "r36 bool", "r37 bool", "r38 bool", "r39 bool", "r40 bool", + "r41 bool", "r42 bool", "r43 bool", "r44 bool", "r45 bool", "r46 bool", "r47 bool", "r48 bool"] + rows: + - [NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL] + + - id: between_predicate_1 + desc: between predicate, numberic between + inputs: + - columns: [ "id bigint", "name string", "code string", "ctime bigint", "cdate date" ] + indexs: [ "index1:id:ctime" ] + rows: + - [1, Lucy, A, 1609459201000, 2021-1-1] + - [2, Zoey, B, 1609545841000, 2021-1-2] + - columns: [ "id bigint", "std_ts bigint", "score int" ] + indexs: ["index1:id:std_ts"] + rows: + - [1, 1609459201000, 10] + - [2, 1609459202000, 100] + - [3, 1609459203000, 20] + - [4, 1609459204000, 30] + - [5, 1609459205000, 50] + sql: | + SELECT {0}.id, {0}.name, {1}.score FROM {0} LAST JOIN {1} ORDER BY {1}.std_ts ON {0}.id = {1}.id AND {0}.id BETWEEN 1 AND 4; + expect: + columns: ["id bigint", "name string", "score int"] + rows: + - [1, Lucy, 10] + - [2, Zoey, 100] + - id: between_predicate_2 + desc: between predicate, string between + inputs: + - columns: [ "id bigint", "name string", "code string", "ctime timestamp", "cdate date" ] + indexs: [ "index1:id:ctime" ] + rows: + - [1, Lucy, ABC, 1609459201000, 2021-1-1] + - [2, Zoey, BBC, 1609545841000, 2021-1-2] + - columns: [ "id bigint", "std_ts bigint", "score int" ] + indexs: ["index1:id:std_ts"] + rows: + - [1, 1609459201000, 10] + - [2, 1609459202000, 100] + - [3, 1609459203000, 20] + - [4, 1609459204000, 30] + - [5, 1609459205000, 50] + sql: | + SELECT {0}.id, {0}.name, {0}.code, {1}.score FROM {0} LAST JOIN {1} ORDER BY {1}.std_ts ON {0}.id = {1}.id AND {0}.code NOT BETWEEN 'BBB' AND 'CCC'; + expect: + columns: ["id bigint", "name string", "code string", "score int"] + rows: + - [1, Lucy, ABC, 10] + - [2, Zoey, BBC, NULL] + - id: between_predicate_3 + desc: between predicate, timestamp between + inputs: + - columns: [ "id bigint", "name string", "code string", "ctime timestamp", "cdate date" ] + indexs: [ "index1:id:ctime" ] + rows: + - [1, Lucy, A, 1609459201000, 2021-1-1] + - [2, Zoey, B, 1633265330000, 2021-10-3] + - columns: [ "id bigint", "std_ts bigint", "score int" ] + indexs: ["index1:id:std_ts"] + rows: + - [1, 1609459201000, 10] + - [2, 1609459202000, 100] + - [3, 1609459203000, 20] + - [4, 1609459204000, 30] + - [5, 1609459205000, 50] + sql: | + SELECT {0}.id, {0}.name, {1}.score FROM {0} LAST JOIN {1} ORDER BY {1}.std_ts + ON {0}.id = {1}.id AND {0}.ctime BETWEEN timestamp("2021-01-01") AND timestamp("2021-01-30"); + expect: + columns: ["id bigint", "name string", "score int"] + rows: + - [1, Lucy, 10] + - [2, Zoey, NULL] + - id: between_predicate_4 + desc: between predicate with aggregation function + sql: | + SELECT id, col1, std_ts, + sum(id) OVER w1 BETWEEN 2 AND 6 as w1_id + FROM {0} + WINDOW w1 AS (PARTITION BY col1 ORDER BY std_ts ROWS BETWEEN 1 PRECEDING AND CURRENT ROW); + inputs: + - columns: ["id bigint", "col1 int32", "std_ts timestamp"] + indexs: ["index1:id:std_ts", "index2:col1:std_ts"] + rows: + - [1, 1, 1590115420000] + - [3, 1, 1590115430000] + - [5, 1, 1590115440000] + - [7, 1, 1590115450000] + - [9, 1, 1590115460000] + expect: + columns: ["id bigint", "col1 int32", "std_ts timestamp", "w1_id bool"] + rows: + - [1, 1, 1590115420000, false] + - [3, 1, 1590115430000, true] + - [5, 1, 1590115440000, false] + - [7, 1, 1590115450000, false] + - [9, 1, 1590115460000, false] + - id: in_predicate_normal + desc: normal in predicates + mode: hybridse-only + sql: | + SELECT {0}.id, {0}.name, {0}.code, {1}.score FROM {0} LAST JOIN {1} ORDER BY {1}.std_ts + ON {0}.id = {1}.id AND {0}.code d[0] ('A', 'B'); + inputs: + - columns: [ "id bigint", "name string", "code string", "ctime timestamp", "cdate date" ] + indexs: [ "index1:id:ctime" ] + rows: + - [1, Lucy, A, 1609459201000, 2021-1-1] + - [2, Zoey, B, 1633265330000, 2021-10-3] + - columns: [ "id bigint", "std_ts bigint", "score int" ] + indexs: ["index1:id:std_ts"] + rows: + - [1, 1609459201000, 10] + - [2, 1609459202000, 100] + - [3, 1609459203000, 20] + - [4, 1609459204000, 30] + - [5, 1609459205000, 50] + dataProvider: + - ["in", "not in"] + expect: + columns: ["id:bigint", "name:string", "code:string", "score:int"] + expectProvider: + 0: + rows: + - [ 1, Lucy, A, 10 ] + - [ 2, Zoey, B, 100 ] + 1: + rows: + - [ 1, Lucy, A, NULL ] + - [ 2, Zoey, B, NULL ] + - id: in_predicate_type_conversion + desc: type conversion occurred between lhs and in_list + mode: hybridse-only + sql: | + SELECT {0}.id, {0}.name, {0}.code, {1}.score FROM {0} LAST JOIN {1} ORDER BY {1}.std_ts + ON {0}.id = {1}.id AND {0}.id d[0] ('1', 3.0); + inputs: + - columns: [ "id bigint", "name string", "code string", "ctime timestamp", "cdate date" ] + indexs: [ "index1:id:ctime" ] + rows: + - [1, Lucy, A, 1609459201000, 2021-1-1] + - [2, Zoey, B, 1633265330000, 2021-10-3] + - columns: [ "id bigint", "std_ts bigint", "score int" ] + indexs: ["index1:id:std_ts"] + rows: + - [1, 1609459201000, 10] + - [2, 1609459202000, 100] + - [3, 1609459203000, 20] + - [4, 1609459204000, 30] + - [5, 1609459205000, 50] + dataProvider: + - ["in", "not in"] + expect: + columns: ["id:bigint", "name:string", "code:string", "score:int"] + expectProvider: + 0: + rows: + - [1, Lucy, A, 10] + - [2, Zoey, B, NULL] + 1: + rows: + - [1, Lucy, A, NULL] + - [2, Zoey, B, 100] + - id: in_predicate_subexpr + desc: sub expr in in list + mode: hybridse-only + sql: | + SELECT {0}.id, {0}.name, {0}.code, {1}.score FROM {0} LAST JOIN {1} ORDER BY {1}.std_ts + ON {0}.id = {1}.id AND {0}.id d[0] ( {1}.score / 10, {1}.score ); + inputs: + - columns: [ "id bigint", "name string", "code string", "ctime timestamp", "cdate date" ] + indexs: [ "index1:id:ctime" ] + rows: + - [1, Lucy, A, 1609459201000, 2021-1-1] + - [2, Zoey, B, 1633265330000, 2021-10-3] + - columns: [ "id bigint", "std_ts bigint", "score int" ] + indexs: ["index1:id:std_ts"] + rows: + - [1, 1609459201000, 10] + - [2, 1609459202000, 100] + - [3, 1609459203000, 20] + - [4, 1609459204000, 30] + - [5, 1609459205000, 50] + dataProvider: + - ["in", "not in"] + expect: + columns: ["id:bigint", "name:string", "code:string", "score:int"] + expectProvider: + 0: + rows: + - [1, Lucy, A, 10] + - [2, Zoey, B, NULL] + 1: + rows: + - [1, Lucy, A, NULL] + - [2, Zoey, B, 100] + - id: in_predicate_with_window + desc: test_expresion refers window + mode: hybridse-only + sql: | + SELECT id, col1, std_ts, + sum(id) OVER w1 d[0] ( 4, 8, 12 ) as w1_id + FROM {0} + WINDOW w1 AS (PARTITION BY col1 ORDER BY std_ts ROWS BETWEEN 1 PRECEDING AND CURRENT ROW); + dataProvider: + - ["in", "not in"] + inputs: + - columns: ["id bigint", "col1 int32", "std_ts timestamp"] + indexs: ["index1:id:std_ts", "index2:col1:std_ts"] + rows: + - [1, 1, 1590115420000] + - [3, 1, 1590115430000] + - [5, 1, 1590115440000] + - [7, 1, 1590115450000] + - [9, 1, 1590115460000] + expect: + columns: ["id bigint", "col1 int32", "std_ts timestamp", "w1_id bool"] + expectProvider: + 0: + rows: + - [1, 1, 1590115420000, false] + - [3, 1, 1590115430000, true] + - [5, 1, 1590115440000, true] + - [7, 1, 1590115450000, true] + - [9, 1, 1590115460000, false] + 1: + rows: + - [1, 1, 1590115420000, true] + - [3, 1, 1590115430000, false] + - [5, 1, 1590115440000, false] + - [7, 1, 1590115450000, false] + - [9, 1, 1590115460000, true] +# - id: like_predicate_1 +# desc: like predicate without escape +# inputs: +# - columns: ["id int", "std_ts timestamp"] +# indexs: ["index1:id:std_ts"] +# rows: +# - [1, 1590115420000 ] +# - [2, 1590115430000 ] +# - [3, 1590115440000 ] +# - [4, 1590115450000 ] +# - [5, 1590115460000 ] +# - [6, 1590115470000 ] +# - columns: ["id int", "ts timestamp", "col2 string"] +# indexs: ["idx:id:ts"] +# rows: +# - [1, 1590115420000, John] +# - [2, 1590115430000, Mary] +# - [3, 1590115440000, mike] +# - [4, 1590115450000, Dan] +# - [5, 1590115460000, Evan_W] +# - [6, 1590115470000, M] +# dataProvider: +# - ["LIKE", "NOT LIKE", "ILIKE", "NOT ILIKE"] # LIKE / NOT LIKE +# - ["m%", "M_ry" ] # match pattern +# sql: | +# select {0}.id, col2 from {0} last join {1} ON {0}.id = {1}.id AND col2 d[0] 'd[1]'; +# expect: +# columns: ["id int", "col2 string"] +# order: id +# expectProvider: +# 0: +# 0: +# rows: +# - [1, null] +# - [2, null] +# - [3, mike] +# - [4, null] +# - [5, null] +# - [6, null] +# 1: +# rows: +# - [1, null] +# - [2, Mary] +# - [3, null] +# - [4, null] +# - [5, null] +# - [6, null] +# 1: +# 0: +# rows: +# - [1, John] +# - [2, Mary] +# - [3, null] +# - [4, Dan] +# - [5, Evan_W] +# - [6, M] +# 1: +# rows: +# - [1, John] +# - [2, null] +# - [3, mike] +# - [4, Dan] +# - [5, Evan_W] +# - [6, M] +# 2: +# 0: +# rows: +# - [1, null] +# - [2, Mary] +# - [3, mike] +# - [4, null] +# - [5, null] +# - [6, M] +# 1: +# rows: +# - [1, null] +# - [2, Mary] +# - [3, null] +# - [4, null] +# - [5, null] +# - [6, null] +# 3: +# 0: +# rows: +# - [1, John] +# - [2, null] +# - [3, null] +# - [4, Dan] +# - [5, Evan_W] +# - [6, null] +# 1: +# rows: +# - [1, John] +# - [2, null] +# - [3, mike] +# - [4, Dan] +# - [5, Evan_W] +# - [6, M] +# - id: like_predicate_2 +# desc: like predicate with escape +# inputs: +# - columns: ["id int", "std_ts timestamp"] +# indexs: ["index1:id:std_ts"] +# rows: +# - [1, 1590115420000 ] +# - [2, 1590115430000 ] +# - [3, 1590115440000 ] +# - [4, 1590115450000 ] +# - [5, 1590115460000 ] +# - [6, 1590115470000 ] +# - columns: ["id int", "ts timestamp", "col2 string"] +# indexs: ["idx:id:ts"] +# rows: +# - [1, 1590115420000, a*_b] +# - [2, 1590115430000, a*mb] +# - [3, 1590115440000, "%a_%b"] +# - [4, 1590115450000, "Ta_sub"] +# - [5, 1590115460000, "lamrb"] +# - [6, 1590115470000, "%a*_%b"] +# dataProvider: +# - ["LIKE", "NOT ILIKE"] +# - ["%", "*", ""] # escape with % or disable +# sql: | +# select {0}.id, col2 from {0} last join {1} ON {0}.id = {1}.id AND col2 d[0] '%a*_%b' ESCAPE 'd[1]'; +# expect: +# columns: ["id int", "col2 string"] +# order: id +# expectProvider: +# 0: +# 0: +# rows: +# - [1, a*_b] +# - [2, a*mb] +# - [3, null] +# - [4, null] +# - [5, null] +# - [6, null] +# 1: +# rows: +# - [1, null] +# - [2, null] +# - [3, "%a_%b"] +# - [4, Ta_sub] +# - [5, null] +# - [6, null] +# 2: +# rows: +# - [1, a*_b] +# - [2, a*mb] +# - [3, null] +# - [4, null] +# - [5, null] +# - [6, "%a*_%b"] +# 1: +# 0: +# rows: +# - [1, null] +# - [2, null] +# - [3, "%a_%b"] +# - [4, "Ta_sub"] +# - [5, "lamrb"] +# - [6, "%a*_%b"] +# 1: +# rows: +# - [1, a*_b] +# - [2, a*mb] +# - [3, null] +# - [4, null] +# - [5, "lamrb"] +# - [6, "%a*_%b"] +# 2: +# rows: +# - [1, null] +# - [2, null] +# - [3, "%a_%b"] +# - [4, "Ta_sub"] +# - [5, "lamrb"] +# - [6, null] diff --git a/cases/integration_test/expression/test_type.yaml b/cases/integration_test/expression/test_type.yaml new file mode 100644 index 00000000000..45aac74cf8b --- /dev/null +++ b/cases/integration_test/expression/test_type.yaml @@ -0,0 +1,674 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +sqlDialect: ["HybridSQL"] +cases: + - id: 0 + mode: "offline-unsupport" + desc: "cast_各种类型_正确" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + dataProvider: + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c9"] + sql: select cast(d[0] as bool) as b1,cast(d[0] as smallint) as b2,cast(d[0] as int) as b3,cast(d[0] as bigint) as b4,cast(d[0] as float) as b5,cast(d[0] as double) as b6,cast(d[0] as timestamp) as b7,cast(d[0] as string) as b9 from {0}; + expect: + columns: ["b1 bool","b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b7 timestamp","b9 string"] + expectProvider: + 0: + rows: + - [true,30,30,30,30.0,30.0,30,"30"] + 1: + rows: + - [true,30,30,30,30.0,30.0,30,"30"] + 2: + rows: + - [true,30,30,30,30.0,30.0,30,"30"] + 3: + rows: + - [true,30,30,30,30.0,30.0,30,"30"] + 4: + rows: + - [true,30,30,30,30.0,30.0,30,"30"] + 5: + rows: + - [false,0,0,0,0.0,0.0,0,"false"] + - id: 1 + desc: "cast_timestamp/string_正确" + tags: ["TODO","本地成功,CICD失败,原因待定位"] + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + dataProvider: + - ["{0}.c1","{0}.c7"] + sql: select cast(d[0] as bool) as b1,cast(d[0] as smallint) as b2,cast(d[0] as int) as b3,cast(d[0] as bigint) as b4,cast(d[0] as float) as b5,cast(d[0] as double) as b6,cast(d[0] as timestamp) as b7,cast(d[0] as date) as b8,cast(d[0] as string) as b9 from {0}; + expect: + columns: ["b1 bool","b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b7 timestamp","b8 date","b9 string"] + expectProvider: + 0: + rows: + - [true,null,null,null,null,null,null,null,aa] + 1: + rows: + - [true,-20536,1601089480,1590738989000,1590738989000,1590738989000,1590738989000,"2020-05-29","2020-05-29 15:56:29"] + - id: 2 + desc: "cast_string_正确" + tags: ["TODO","本地成功,CICD失败,原因待定位"] + inputs: + - + columns : ["id bigint","c1 string","c2 string","c3 string","c4 string","c5 string","c6 string","c7 string","c8 string","c9 string","ts1 timestamp"] + indexs: ["index1:id:ts1"] + rows: + - [1,"aa","30","30","30","30.0","30.0","1590738989000","2020-05-01","false",1590738989000] + sql: select cast(c9 as bool) as b1,cast(c2 as smallint) as b2,cast(c3 as int) as b3,cast(c4 as bigint) as b4,cast(c5 as float) as b5,cast(c6 as double) as b6,cast(c7 as timestamp) as b7,cast(c8 as date) as b8,cast(c1 as string) as b9 from {0}; + expect: + columns: ["b1 bool","b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b7 timestamp","b8 date","b9 string"] + expectProvider: + 0: + rows: + - [false,30,30,30,30.0,30.0,1590738989000,"2020-05-01",aa] + - id: 3 + desc: "cast_date_正确" + tags: ["TODO","本地成功,CICD失败,原因待定位"] + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + dataProvider: + - ["{0}.c8"] + sql: select cast(d[0] as bool) as b1,cast(d[0] as timestamp) as b7,cast(d[0] as date) as b8,cast(d[0] as string) as b9 from {0}; + expect: + columns: ["b1 bool","b7 timestamp","b8 date","b9 string"] + expectProvider: + 0: + rows: + - [true,1588262400000,"2020-05-01","2020-05-01"] + - id: 4 + desc: "cast_其他类型_date_错误" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + dataProvider: + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6"] + sql: select cast(d[0] as date) as b1 from {0}; + expect: + success: false + - id: 5 + desc: "cast_date_其他类型_错误" + level: 5 + tags: ["TODO", "bug"] + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + dataProvider: + - ["smallint","nit","bigint","float","double"] + sql: select cast(c8 as d[0]) as b1 from {0}; + expect: + success: false + - id: 6 + desc: SQL标准Cast语法-Cast(常量 as type) + inputs: + - columns: ["c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, 1.0, 1590115420000] + sql: | + select cast(1 as int) as f1, cast(2 as bigint) as f2, cast(1 as float) as f3, + cast(1 as double) as f4, cast(1 as bool) as f5, cast(1590115420000 as timestamp) as f6, + cast(1 as string) as f7 , cast("2020-05-20" as date) as f8 from {0}; + expect: + columns: ["f1 int", "f2 bigint", "f3 float", "f4 double", "f5 bool", "f6 timestamp", + "f7 string", "f8 date"] + rows: + - [1, 2, 1.0, 1.0, true, 1590115420000, "1", "2020-05-20"] + - id: 7 + desc: SQL标准Cast语法-Cast(表达式 as type) + inputs: + - columns: ["c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, 1.0, 1590115420000] + sql: | + select cast(c2 as int) as f1, cast(c1+c2 as bigint) as f2, cast(c1 as float) as f3, + cast(c1 as double) as f4, cast(c1 as bool) as f5, cast(c5 as timestamp) as f6, + cast(c1 as string) as f7 from {0}; + expect: + columns: ["f1 int", "f2 bigint", "f3 float", "f4 double", "f5 bool", "f6 timestamp", + "f7 string"] + rows: + - [1, 2, 1.0, 1.0, true, 1590115420000, "1"] + - id: 8 + desc: cast函数 + inputs: + - columns: ["c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, 1.0, 1590115420000] + sql: | + select int(1) as f1, bigint(2) as f2, float(1) as f3, + double(1) as f4, bool(1) as f5, timestamp(1590115420000) as f6, + string(1) as f7 from {0}; + expect: + columns: ["f1 int", "f2 bigint", "f3 float", "f4 double", "f5 bool", "f6 timestamp", + "f7 string"] + rows: + - [1, 2, 1.0, 1.0, true, 1590115420000, "1"] + - id: 9 + desc: SQL标准Cast语法-Cast(表达式 as type) + inputs: + - columns: ["c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, 1.0, 1590115420000] + sql: | + select int(c1) as f1, bigint(c1+c2) as f2, float(c1) as f3, + double(c1) as f4, bool(c1) as f5, timestamp(c5) as f6, + string(c1) as f7 from {0}; + expect: + columns: ["f1 int", "f2 bigint", "f3 float", "f4 double", "f5 bool", "f6 timestamp", + "f7 string"] + rows: + - [1, 2, 1.0, 1.0, true, 1590115420000, "1"] + - id: 10 + desc: SQL标准Cast语法-Cast(表达式 as type) + inputs: + - columns: ["c0 string", "std_ts bigint", "c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c0:std_ts"] + rows: + - ["pk", 1, NULL, NULL, NULL] + sql: | + select cast(c2 as int) as f1, cast(c1+c2 as bigint) as f2, cast(c1 as float) as f3, + cast(c1 as double) as f4, cast(c1 as bool) as f5, cast(c5 as timestamp) as f6, + cast(c1 as string) as f7 from {0}; + expect: + columns: ["f1 int", "f2 bigint", "f3 float", "f4 double", "f5 bool", "f6 timestamp", + "f7 string"] + rows: + - [NULL, NULL, NULL, NULL, NULL, NULL, NULL] + - id: 11 + desc: SQL标准Cast语法-Cast(NULL as type) + inputs: + - columns: ["c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, 1.0, 1590115420000] + sql: | + select cast(NULL as int) as f1, cast(NULL as bigint) as f2, cast(NULL as float) as f3, + cast(NULL as double) as f4, cast(NULL as bool) as f5, cast(NULL as timestamp) as f6, + cast(NULL as date) as f7 from {0}; + expect: + columns: ["f1 int", "f2 bigint", "f3 float", "f4 double", "f5 bool", "f6 timestamp", + "f7 date"] + rows: + - [NULL, NULL, NULL, NULL, NULL, NULL, NULL] + - id: 12 + tags: ["TODO", "@chenjing, @baoxinqi: encode处理常量NULL string"] + desc: SQL标准Cast语法-Cast(NULL as string) + inputs: + - columns: ["c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, 1.0, 1590115420000] + sql: | + select cast(NULL as string) as f1 from {0}; + expect: + columns: ["f1 string"] + rows: + - [NULL] + - id: 13 + desc: cast函数多层子查询 + mode: "offline-unsupport" + tags: ["离线有时差问题"] + inputs: + - columns: ["c1 int", "c2 string", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, "2020-05-22 10:43:40", 1] + sql: | + select c1, bigint(c2) DIV 1000 as c2_sec from (select c1, timestamp(c2) as c2 from {0}); + expect: + columns: ["c1 int", "c2_sec bigint"] + rows: + - [1, 1590115420] + - id: 14 + desc: cast as int + mode: offline-unsupport + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + int(c1) as int_c1, int(c2) as int_c2, int(c3) as int_c3, int(c4) as int_c4, + int(c5) as int_c5, int(c6) as int_c6, int(c8) as int_c8, int(c9) as int_c9, int(c10) as int_c10 + from {0}; + expect: + order: id + columns: ["id int32", "int_c1 int", "int_c2 int", "int_c3 int", "int_c4 int", "int_c5 int", "int_c6 int", + "int_c8 int", "int_c9 int", "int_c10 int"] + rows: + - [1, 1, 1, 1, 1, 1, NULL, 977520480, 1, 1] + - [2, -1, -1, -1, -1, -1, NULL, 977520480, 0, -1] + - [3, -1, -1, -1, -1, -1, NULL, 977520480, 0, NULL] + - id: 15 + desc: cast as smallint + mode: offline-unsupport + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + smallint(c1) as smallint_c1, smallint(c2) as smallint_c2, smallint(c3) as smallint_c3, smallint(c4) as smallint_c4, + smallint(c5) as smallint_c5, smallint(c6) as smallint_c6, smallint(c8) as smallint_c8, smallint(c9) as smallint_c9, + smallint(c10) as smallint_c10 + from {0}; + expect: + order: id + columns: ["id int32", "smallint_c1 smallint", "smallint_c2 smallint", "smallint_c3 smallint", "smallint_c4 smallint", "smallint_c5 smallint", + "smallint_c6 smallint", "smallint_c8 smallint", "smallint_c9 smallint", "smallint_c10 smallint"] + rows: + - [1, 1, 1, 1, 1, 1, NULL, -14496, 1, 1] + - [2, -1, -1, -1, -1, -1, NULL, -14496, 0, -1] + - [3, -1, -1, -1, -1, -1, NULL, -14496, 0, NULL] + - id: 16 + desc: cast as bigint + mode: offline-unsupport + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + bigint(c1) as bigint_c1, bigint(c2) as bigint_c2, bigint(c3) as bigint_c3, bigint(c4) as bigint_c4, + bigint(c5) as bigint_c5, bigint(c6) as bigint_c6, bigint(c8) as bigint_c8, bigint(c9) as bigint_c9, + bigint(c10) as bigint_c10 + from {0}; + expect: + order: id + columns: ["id int32", "bigint_c1 bigint", "bigint_c2 bigint", "bigint_c3 bigint", "bigint_c4 bigint", "bigint_c5 bigint", + "bigint_c6 bigint", "bigint_c8 bigint", "bigint_c9 bigint", "bigint_c10 bigint"] + rows: + - [1, 1, 1, 1, 1, 1, NULL, 1590115420000, 1, 1] + - [2, -1, -1, -1, -1, -1, NULL, 1590115420000, 0, -1] + - [3, -1, -1, -1, -1, -1, NULL, 1590115420000, 0, NULL] + - id: 17 + desc: cast as float + mode: offline-unsupport, python-unsupport + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + float(c1) as float_c1, float(c2) as float_c2, float(c3) as float_c3, float(c4) as float_c4, float(c5) as float_c5, + float(c6) as float_c6, float(c8) as float_c8, float(c9) as float_c9, float(c10) as float_c10 + from {0}; + expect: + order: id + columns: ["id int32", "float_c1 float", "float_c2 float", "float_c3 float", "float_c4 float", "float_c5 float", + "float_c6 float", "float_c8 float", "float_c9 float", "float_c10 float"] + rows: + - [1, 1.0, 1.0, 1.0, 1.0, 1.0, NULL, 1590115420000.0, 1.0, 1.0] + - [2, -1.0, -1.0, -1.0, -1.0, -1.0, NULL, 1590115420000.0, 0.0, -1.0] + - [3, -1.0, -1.0, -1.0, -1.0, -1.0, NULL, 1590115420000.0, 0.0, NULL] + - id: 18 + desc: cast as double + mode: offline-unsupport + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + double(c1) as double_c1, double(c2) as double_c2, double(c3) as double_c3, double(c4) as double_c4, double(c5) as double_c5, + double(c6) as double_c6, double(c8) as double_c8, double(c9) as double_c9, double(c10) as double_c10 + from {0}; + expect: + order: id + columns: ["id int32", "double_c1 double", "double_c2 double", "double_c3 double", "double_c4 double", "double_c5 double", + "double_c6 double", "double_c8 double", "double_c9 double", "double_c10 double"] + rows: + - [1, 1.0, 1.0, 1.0, 1.0, 1.0, NULL, 1590115420000.0, 1.0, 1.0] + - [2, -1.0, -1.0, -1.0, -1.0, -1.0, NULL, 1590115420000.0, 0.0, -1.0] + - [3, -1.0, -1.0, -1.0, -1.0, -1.0, NULL, 1590115420000.0, 0.0, NULL] + - id: 19 + desc: cast as string + mode: offline-unsupport,cli-unsupport + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + string(c1) as string_c1, string(c2) as string_c2, string(c3) as string_c3, string(c4) as string_c4, + string(c5) as string_c5, string(c6) as string_c6, string(c7) as string_c7, string(c8) as string_c8, string(c9) as string_c9, + string(c10) as string_c10 + from {0}; + expect: + order: id + columns: ["id int32", "string_c1 string", "string_c2 string", "string_c3 string", "string_c4 string", "string_c5 string", + "string_c6 string", "string_c7 string", "string_c8 string", "string_c9 string", "string_c10 string"] + rows: + - [1, "1", "1", "1", "1", "1", "2020-05-22 10:43:40", "2020-05-22", "2020-05-22 10:43:40", "true", "1"] + - [2, "-1", "-1", "-1", "-1", "-1", "2020-05-22 10:43:40", "2020-05-22", "2020-05-22 10:43:40", "false", "-1"] + - [3, "-1", "-1", "-1", "-1", "-1", NULL, "2020-05-22", "2020-05-22 10:43:40", "false", ""] + - id: 20 + desc: cast as date + mode: offline-unsupport + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + date(c6) as date_c6, date(c7) as date_c7, date(c8) as date_c8, date(c10) as date_c10 + from {0}; + expect: + order: id + columns: ["id int32", "date_c6 date", "date_c7 date", "date_c8 date", "date_c10 date"] + rows: + - [1, "2020-05-22", "2020-05-22", "2020-05-22", NULL] + - [2, "2020-05-22", "2020-05-22", "2020-05-22", NULL] + - [3, NULL, "2020-05-22", "2020-05-22", NULL] + - id: 21 + desc: cast as timestamp + mode: offline-unsupport + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + timestamp(c1) as timestamp_c1, timestamp(c2) as timestamp_c2, timestamp(c3) as timestamp_c3, timestamp(c4) as timestamp_c4, timestamp(c5) as timestamp_c5, + timestamp(c6) as timestamp_c6, timestamp(c7) as timestamp_c7, timestamp(c8) as timestamp_c8, timestamp(c9) as timestamp_c9, timestamp(c10) as timestamp_c10 + from {0}; + expect: + order: id + columns: ["id int32", "timestamp_c1 timestamp", "timestamp_c2 timestamp", "timestamp_c3 timestamp", "timestamp_c4 timestamp", "timestamp_c5 timestamp", + "timestamp_c6 timestamp", "timestamp_c7 timestamp", "timestamp_c8 timestamp", "timestamp_c9 timestamp", "timestamp_c10 timestamp"] + rows: + - [1, 1, 1, 1, 1, 1, 1590115420000, 1590076800000, 1590115420000, 1, NULL] + - [2, NULL, NULL, NULL, NULL, NULL, 1590115420000, 1590076800000, 1590115420000, 0, NULL] + - [3, NULL, NULL, NULL, NULL, NULL, NULL, 1590076800000, 1590115420000, 0, NULL] + - id: 22 + desc: cast as bool + mode: offline-unsupport + tags: ["TODO", "@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["id int32", "c1 int16", "c2 int32", "c3 int64", "c4 float", "c5 double", + "c6 string", "c7 date", "c8 timestamp", "c9 bool", "c10 string"] + indexs: ["index1:c6:c8"] + rows: + - [1, 1, 1, 1, 1.0, 1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, true, "1"] + - [2, -1, -1, -1, -1.0, -1.0, "2020-05-22 10:43:40", "2020-05-22", 1590115420000, false, "-1"] + - [3, -1, -1, -1, -1.0, -1.0, NULL, "2020-05-22", 1590115420000, false, ""] + sql: | + select id, + bool(c1) as bool_c1, bool(c2) as bool_c2, bool(c3) as bool_c3, bool(c4) as bool_c4, bool(c5) as bool_c5, + bool(c6) as bool_c6, bool(c8) as bool_c8, bool(c9) as bool_c9, bool(c10) as bool_c10 + from {0}; + expect: + order: id + columns: ["id int32", "bool_c1 bool", "bool_c2 bool", "bool_c3 bool", "bool_c4 bool", "bool_c5 bool", + "bool_c6 bool", "bool_c8 bool", "bool_c9 bool", "bool_c10 bool"] + rows: + - [1, true, true, true, true, true, true, true, true, true] + - [2, true, true, true, true, true, true, true, false, true] + - [3, true, true, true, true, true, NULL, true, false, false] + - id: 23 + desc: cast string as bool + inputs: + - columns: ["id int64", "c2 int32", "c6 string"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, "t"] + - [2, 1, "true"] + - [3, 1, "f"] + - [4, 1, "false"] + - [5, 1, "1"] + - [6, 1, "0"] + - [7, 1, "y"] + - [8, 1, "n"] + - [9, 1, "yes"] + - [10, 1, "no"] + - [11, 1, ""] + - [12, 1, "abc"] + sql: | + select id, bool(c6) as bool_c6 from {0}; + expect: + order: id + columns: ["id int64", "bool_c6 bool"] + rows: + - [1, true] + - [2, true] + - [3, false] + - [4, false] + - [5, true] + - [6, false] + - [7, true] + - [8, false] + - [9, true] + - [10, false] + - [11, NULL] + - [12, NULL] + - id: 24 + desc: cast float as string + inputs: + - columns: ["id int64", "c2 int32", "c6 float"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, 1.1] + sql: | + select id, string(c6) as string_c6 from {0}; + expect: + order: id + columns: ["id int64", "string_c6 string"] + rows: + - [1, "1.1"] + - id: 25 + mode: "offline-unsupport" + tags: ["离线有时差问题"] + desc: column name prefix with _ + inputs: + - columns: ["_c1 int", "_c2 string", "_c5 bigint"] + indexs: ["index1:_c1:_c5"] + rows: + - [1, "2020-05-22 10:43:40", 1] + sql: | + select _c1, bigint(_c2) DIV 1000 as _c2_sec from (select _c1, timestamp(_c2) as _c2 from {0}); + expect: + columns: ["_c1 int", "_c2_sec bigint"] + rows: + - [1, 1590115420] + - id: 26 + desc: cast int to date raise error + inputs: + - columns: ["id int64", "c2 int32", "c6 int32"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, 1] + sql: | + select id, date(c6) as date_c6 from {0}; + expect: + success: false + - id: 27 + desc: cast bigint to date raise error + inputs: + - columns: ["id int64", "c2 int32", "c6 int64"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, 1] + sql: | + select id, date(c6) as date_c6 from {0}; + expect: + success: false + - id: 28 + desc: cast smallint to date raise error + inputs: + - columns: ["id int64", "c2 int32", "c6 int16"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, 1] + sql: | + select id, date(c6) as date_c6 from {0}; + expect: + success: false + - id: 29 + desc: cast float to date raise error + inputs: + - columns: ["id int64", "c2 int32", "c6 float"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, 1.0] + sql: | + select id, date(c6) as date_c6 from {0}; + expect: + success: false + - id: 30 + desc: cast double to date raise error + inputs: + - columns: ["id int64", "c2 int32", "c6 double"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, 1.0] + sql: | + select id, date(c6) as date_c6 from {0}; + expect: + success: false + - id: 31 + desc: cast double to date raise error + inputs: + - columns: ["id int64", "c2 int32", "c6 bool"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, true] + sql: | + select id, date(c6) as date_c6 from {0}; + expect: + success: false + - id: 32 + desc: cast date numbers + inputs: + - columns: ["id int64", "c2 int32", "c6 date"] + indexs: ["index1:c2:id"] + rows: + - [1, 1, "2020-10-12"] + sql: | + select id, int16(c6) as int16_c6, int32(c6) as int32_c6, int64(c6) as int64_c6, + float(c6) as float_c6, double(c6) as double_c6, bool(c6) as bool_c6 from {0}; + expect: + columns: [ "id int64", "int16_c6 int16", "int32_c6 int32", "int64_c6 int64", + "float_c6 float", "double_c6 double", "bool_c6 bool" ] + rows: + - [ 1, NULL, NULL, NULL, NULL, NULL, NULL] + - id: 33 + desc: SQL标准Cast语法-VARCHAR(expr) + inputs: + - columns: ["c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, 1.0, 1590115420000] + sql: | + select int(c1) as f1, timestamp(c5) as f2, + VARCHAR(c1) as f3 from {0}; + expect: + columns: ["f1 int", "f2 timestamp", "f3 string"] + rows: + - [1, 1590115420000, "1"] + - id: 34 + desc: SQL标准Cast语法-Cast(expr as VARCHAR) + inputs: + - columns: ["c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c1:c5"] + rows: + - [1, 1.0, 1590115420000] + sql: | + select CAST(c1 as int) as f1, CAST(c5 as timestamp) as f2, + CAST(c1 as VARCHAR) as f3, CAST(c1 as VARCHAR(60)) as f4 from {0}; + expect: + columns: ["f1 int", "f2 timestamp", "f3 string", "f4 string"] + rows: + - [1, 1590115420000, "1", "1"] + - id: 35 + desc: SQL标准Cast语法-Cast(NULL表达式 as VARCHAR) + inputs: + - columns: ["c0 string", "std_ts bigint", "c1 int", "c2 float", "c5 bigint"] + indexs: ["index1:c0:std_ts"] + rows: + - ["pk", 1, NULL, NULL, NULL] + sql: | + select cast(c2 as int) as f1, cast(c1 as VARCHAR) as f2, cast(c1 as VARCHAR(60)) as f3 from {0}; + expect: + columns: ["f1 int", "f2 string", "f3 string"] + rows: + - [NULL, NULL, NULL] \ No newline at end of file diff --git a/cases/integration_test/function/test_calculate.yaml b/cases/integration_test/function/test_calculate.yaml new file mode 100644 index 00000000000..7e4b5f5a3c9 --- /dev/null +++ b/cases/integration_test/function/test_calculate.yaml @@ -0,0 +1,254 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +sqlDialect: ["HybridSQL"] +version: 0.5.0 +cases: + - id: 0 + desc: abs-normal + inputs: + - columns: ["id int", "c0 smallint", "c1 int", "c2 bigint", "c3 float", "c4 double","c5 bool"] + indexs: ["index1:c0:c2"] + rows: + - [1, -1, 2, 2, -0.2, -0.5,true] + - [2, NULL, NULL, 2, NULL, NULL,false] + sql: select id as id, + abs(c0) as r0, + abs(c1) as r1, + abs(c2) as r2, + abs(c3) as r3, + abs(c4) as r4, + abs(c5) as r5 from {0}; + expect: + order: id + columns: ["id int", "r0 int", "r1 int", "r2 bigint", "r3 double", "r4 double","r5 double"] + rows: + - [1, 1, 2, 2, 0.20000000298023224, 0.5,1.0] + - [2, NULL, NULL, 2, NULL , NULL,0.0] + - id: 1 + desc: 三角函数 + tags: ["暂时不支持bool类型列"] + inputs: + - columns: ["id int", "c0 smallint", "c1 int", "c2 bigint", "c3 float", "c4 double","c5 bool"] + indexs: ["index1:c0:c2"] + rows: + - [1, 0, 1, 1, 1.0, 0.0,true] + - [2, NULL, NULL, 1, NULL, NULL,false] + sql: select id as id, + cos(c0) as r0, + cot(c1) as r1, + sin(c2) as r2, + tan(c3) as r3, + tan(c4) as r4 from {0}; + expect: + order: id + columns: ["id int", "r0 double", "r1 double", "r2 double", "r3 float","r4 double"] + rows: + - [1, 1, 0.6420926159343306, 0.8414709848078965, 1.5574077,0.0] + - [2, NULL, NULL, 0.8414709848078965, NULL,NULL] + - id: 2 + desc: 反三角函数 + inputs: + - columns: ["id int", "c0 smallint", "c1 int", "c2 bigint", "c3 float", "c4 double","c5 bool"] + indexs: ["index1:c0:c2"] + rows: + - [1, 1, 2, 2, 0.2, 0.5,true] + - [2, NULL, NULL, 2, NULL, NULL,false] + sql: select id as id, + acos(c4) as r0, + asin(c3) as r1, + atan(c1) as r2, + atan2(c1, c2) as r3, + asin(c4) as r4 + from {0}; + expect: + order: id + columns: ["id int", "r0 double", "r1 float", "r2 double", "r3 double","r4 double"] + rows: + - [1, 1.0471975511965979, 0.2013579207903308, 1.1071487177940904, 0.78539816339744828,0.5235987755982989] + - [2, NULL, NULL, NULL, NULL,NULL] + - id: 3 + desc: 反三角函数-三角函数-常量 + inputs: + - columns: ["id int", "c0 smallint", "c1 int", "c2 bigint", "c3 float", "c4 double","c5 bool"] + indexs: ["index1:c0:c2"] + rows: + - [1, 1, 2, 2, 0.2, 0.5,true] + sql: select id as id, + cos(1) as r0, + cot(2) as r1, + sin(1.1) as r2, + tan(1) as r3, + acos(0) as r4, + asin(2.0) as r5, + atan(2.2) as r6, + atan2(1, 2) as r7, + asin(2) as r8 + from {0}; + expect: + order: id + columns: ["id int", "r0 double", "r1 double", "r2 double", "r3 double","r4 double", "r5 double", "r6 double", "r7 double", "r8 double"] + rows: + - [1,0.5403023058681398,-0.45765755436028577,0.8912073600614354,1.5574077246549023,1.5707963267948966,NaN,1.1441688336680205,0.4636476090008061,NaN] + - id: 4 + desc: 对数函数 + inputs: + - columns: ["id int", "c0 smallint", "c1 int", "c2 bigint", "c3 float", "c4 double","c5 bool"] + indexs: ["index1:c0:c2"] + rows: + - [1, 1, 1, 3, 1, 1,true] + - [2, NULL, NULL, 3, NULL, NULL,false] + sql: select id as id, + log(c0) as r0, + log(c2, c1) as r1, + log2(c3) as r2, + log10(c4) as r3, + ln(c1) as r4, + log(c5) as r5 from {0}; + expect: + order: id + columns: ["id int", "r0 double", "r1 double", "r2 float", "r3 double", "r4 double","r5 double"] + rows: + - [1, 0, 0, 0, 0, 0,0.0] + - [2, NULL, NULL, NULL, NULL, NULL,-Infinity] + + - id: 5 + desc: 数值位数函数 + inputs: + - columns: ["id int", "c0 smallint", "c1 int", "c2 bigint", "c3 float", "c4 double","c5 bool"] + indexs: ["index1:c0:c2"] + rows: + - [1, 1, 2, 2, 0.5, 0.7,true] + - [2, NULL, NULL, 2, NULL, NULL,false] + sql: select id as id, + ceil(c0) as r0, + ceiling(c1) as r1, + floor(c2) as r2, + round(c3) as r3, + truncate(c4) as r4, + floor(c5) as r5 from {0}; + expect: + order: id + columns: ["id int", "r0 bigint", "r1 bigint", "r2 bigint", "r3 double", "r4 double","r5 double"] + rows: + - [1, 1, 2, 2, 1.000000, 0.000000,1.0] + - [2, NULL, NULL, 2, NULL, NULL,0.0] + + - id: 6 + desc: 数值幂函数 + inputs: + - columns: ["id int", "c0 smallint", "c1 int", "c2 bigint", "c3 float", "c4 double","c5 bool"] + indexs: ["index1:c0:c2"] + rows: + - [1, 0, 2, 10, 1, 100,true] + - [2, NULL, NULL, 10, NULL, NULL,false] + sql: select id as id, + exp(c0) as r0, + pow(c1, c2) as r1, + power(c2, c3) as r2, + sqrt(c4) as r3, + pow(c5,c1) as r4 + from {0}; + expect: + order: id + columns: ["id int", "r0 double", "r1 double", "r2 double", "r3 double","r4 double"] + rows: + - [1, 1, 1024.000000, 10.000000, 10.000000,1.0] + - [2, NULL, NULL, NULL, NULL,NULL] + - id: 7 + desc: "计算函数-单参数-fail" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",true] + sql: select d[0](d[1]) from {0}; + dataProvider: + - ["abs","cos","cot","sin","tan","acos","asin","atan","log","log2","log10","ln","ceil","ceiling","floor","round","truncate","exp","sqrt"] + - ["{0}.c1","{0}.c7","{0}.c8"] + expect: + success: false + - id: 8 + desc: "计算函数-单参数-bool-fail" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",true] + sql: select d[0](d[1]) from {0}; + dataProvider: + - ["cos","cot","sin","tan","acos","asin","atan","sqrt"] + - ["{0}.c9"] + expect: + success: false + - id: 9 + desc: "计算函数-两参数-fail" + level: 5 + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",true] + sql: select d[0](d[1],d[1]) from {0}; + dataProvider: + - ["log","pow","power","atan2"] + - ["{0}.c1","{0}.c7","{0}.c8"] + expect: + success: false + - id: 10 + desc: "mod()_整型_正确" + tags: ["TODO","暂时不支持mod()"] + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"bb",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + dataProvider: + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6"] + sql: select mod(d[0],{1}.c2) as b2,mod(d[0],{1}.c3) as b3,mod(d[0],{1}.c4) as b4,mod(d[0],{1}.c5) as b5,mod(d[0],{1}.c6) as b6,mod(d[0],{1}.c9) as b9 from {0} last join {1} ORDER BY {1}.c7 on {0}.id={1}.id; + expect: + columns: ["b2 smallint","b3 int","b4 bigint","b5 float","b6 double","b9 smallint"] + expectProvider: + 0: + rows: + - [0,10,0,7.8,5.8,0] + 1: + rows: + - [0,10,0,7.8,5.8,0] + 2: + rows: + - [0,600,900,333,363,30] + 3: + rows: + - [30,50,60,41.1,42.1,31] + 4: + rows: + - [30,10,0,18.9,17.9,29] + 5: + columns: ["b2 double","b3 double","b4 double","b5 double","b6 double","b9 double"] + rows: + - [Infinity,1.5,1.0,2.7027026098198896,2.479338842975207,30.0] diff --git a/cases/integration_test/function/test_date.yaml b/cases/integration_test/function/test_date.yaml new file mode 100644 index 00000000000..66e1ce9cbbd --- /dev/null +++ b/cases/integration_test/function/test_date.yaml @@ -0,0 +1,144 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +sqlDialect: ["HybridSQL"] +version: 0.5.0 +cases: + - id: 0 + desc: date_format-normal + mode: cli-unsupport + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",true] + - [2,2,"aa",30,-30,30,30.0,30.0,NULL,NULL,true] + sql: select id as id,date_format(c7,"%Y-%m-%d %H:%M:%S") as e1,date_format(c8,"%Y-%m-%d %H:%M:%S") as e2 from {0}; + expect: + order: id + columns: ["id bigint", "e1 string","e2 string"] + rows: + - [1, "2020-05-29 15:56:29","2020-05-01 00:00:00"] + - [2, NULL,NULL] + - id: 1 + desc: date_format-fail + level: 5 + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-01",true] + - [2,2,"aa",30,-30,30,30.0,30.0,NULL,NULL,true] + dataProvider: + - ["{0}.c1","{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c9"] + sql: select id as id,date_format(d[0],"%Y-%m-%d %H:%M:%S") as e1 from {0}; + expect: + success: false + - id: 2 + desc: 日期函数-normal + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-02",true] + - [2,2,"aa",30,-30,NULL,30.0,30.0,NULL,NULL,true] + dataProvider: + - ["{0}.c4","{0}.c7","{0}.c8"] + sql: | + select id as id, + day(d[0]) as e1, + dayofmonth(d[0]) as e2, + dayofweek(d[0]) as e3, + month(d[0]) as e4, + week(d[0]) as e5, + weekofyear(d[0]) as e6, + year(d[0]) as e7 + from {0}; + expect: + order: id + columns: ["id bigint", "e1 int","e2 int","e3 int","e4 int","e5 int","e6 int","e7 int"] + expectProvider: + 0: + rows: + - [1,1,1,5,1,1,1,1970] + - [2,null,null,null,null,null,null,null] + 1: + rows: + - [1,29,29,6,5,22,22,2020] + - [2,null,null,null,null,null,null,null] + 2: + rows: + - [1,2,2,7,5,18,18,2020] + - [2,null,null,null,null,null,null,null] + - id: 3 + desc: 一些时间函数-fail + level: 5 + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-02",true] + - [2,2,"aa",30,-30,NULL,30.0,30.0,NULL,NULL,true] + dataProvider: + - ["day","dayofmonth","dayofweek","week","weekofyear","year","month"] + - ["{0}.c1","{0}.c2","{0}.c3","{0}.c5","{0}.c6","{0}.c9"] + sql: select id as id,d[0](d[1]) as e1 from {0}; + expect: + success: false + - id: 4 + desc: hour-minute-normal + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-02",true] + - [2,2,"aa",30,-30,NULL,30.0,30.0,NULL,NULL,true] + dataProvider: + - ["{0}.c4","{0}.c7"] + sql: select id as id,hour(d[0]) as e1,minute(d[0]) as e2 from {0}; + expect: + order: id + columns: ["id bigint", "e1 int","e2 int"] + expectProvider: + 0: + rows: + - [1,8,0] + - [2,null,null] + 1: + rows: + - [1,15,56] + - [2,null,null] + - id: 5 + desc: hour-minute-fail + level: 5 + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"aa",30,-30,30,30.0,30.0,1590738989000,"2020-05-02",true] + - [2,2,"aa",30,-30,NULL,30.0,30.0,NULL,NULL,true] + dataProvider: + - ["hour","minute"] + - ["{0}.c1","{0}.c2","{0}.c3","{0}.c5","{0}.c6","{0}.c8","{0}.c9"] + sql: select id as id,d[0](d[1]) as e1 from {0}; + expect: + success: false \ No newline at end of file diff --git a/cases/integration_test/function/test_like_match.yaml b/cases/integration_test/function/test_like_match.yaml new file mode 100644 index 00000000000..5300a4f85e5 --- /dev/null +++ b/cases/integration_test/function/test_like_match.yaml @@ -0,0 +1,840 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +sqlDialect: ["HybridSQL"] +version: 0.5.0 +cases: + - id: 0 + desc: "使用_" + inputs: + - + columns : ["id bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:c7"] + rows: + - [1,"a_b",30,30,30,30.0,30.0,1590738990000,"2020-05-01",false] + - [2,"aab",30,30,30,30.0,30.0,1590738991000,"2020-05-01",false] + - [3,"a%b",30,30,30,30.0,30.0,1590738992000,"2020-05-01",false] + - [4,"b_c",30,30,30,30.0,30.0,1590738993000,"2020-05-01",false] + - [5,"abc",30,30,30,30.0,30.0,1590738994000,"2020-05-01",false] + - [6,"A0b",30,30,30,30.0,30.0,1590738995000,"2020-05-01",false] + - [7,"a#B",30,30,30,30.0,30.0,1590738996000,"2020-05-01",false] + - [8,"aaab",30,30,30,30.0,30.0,1590738991000,"2020-05-01",false] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'a_b') as v1 from {0}; + expect: + order: id + columns: ["id bigint","v1 bool"] + expectProvider: + 0: + rows: + - [1,true] + - [2,true] + - [3,true] + - [4,false] + - [5,false] + - [6,false] + - [7,false] + - [8,false] + 1: + rows: + - [1,true] + - [2,true] + - [3,true] + - [4,false] + - [5,false] + - [6,true] + - [7,true] + - [8,false] + - id: 1 + desc: "使用%" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"a%_b",1590738992000] + - [4,"b_c",1590738993000] + - [5,"abc",1590738994000] + - [6,"A0b",1590738995000] + - [7,"a#B",1590738996000] + - [8,"aaab",1590738997000] + - [9,"ab",1590738998000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'a%b') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"a_b",true] + - [2,"aabb",true] + - [3,"a%_b",true] + - [4,"b_c",false] + - [5,"abc",false] + - [6,"A0b",false] + - [7,"a#B",false] + - [8,"aaab",true] + - [9,"ab",true] + 1: + rows: + - [1,"a_b",true] + - [2,"aabb",true] + - [3,"a%_b",true] + - [4,"b_c",false] + - [5,"abc",false] + - [6,"A0b",true] + - [7,"a#B",true] + - [8,"aaab",true] + - [9,"ab",true] + - id: 2 + desc: "同时使用%和_" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"aa#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'_a%b') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"aa#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",true] + - [7,"aa#0B",true] + - id: 3 + desc: "使用默认的escape" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,"\\_a%b","\\") as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",true] + - id: 4 + desc: "指定escape为#" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'#_a%b','#') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",true] + - id: 5 + desc: "指定escape为_" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'__a%b','_') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",true] + - id: 6 + desc: "指定escape为%" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA%b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'_a%%b','%') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA%b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA%b",true] + - [7,"_a#0B",false] + - id: 7 + desc: "escape不指定" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,"\\_a%b") as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"_a#0B",true] + - id: 8 + desc: "escape为空串,使用\\" + mode: cluster-unsupport + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,'\\\%a_b',1590738990000] + - [2,'\\\aabb',1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,'\\\bA0b',1590738995000] + - [7,'\\\_a#0B',1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,"\\_a%b","") as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,'\%a_b',true] + - [2,'\aabb',true] + - [3,'_a%_b',false] + - [4,'ba_c',false] + - [5,"abb",false] + - [6,'\bA0b',false] + - [7,'\_a#0B',false] + 1: + rows: + - [1,'\%a_b',true] + - [2,'\aabb',true] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,'\bA0b',true] + - [7,'\_a#0B',true] + - id: 9 + desc: "使用两个%" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"a%_b%0",1590738992000] + - [4,"b_c",1590738993000] + - [5,"abc",1590738994000] + - [6,"A0b",1590738995000] + - [7,"a#Bb",1590738996000] + - [8,"aaabbcc",1590738991000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'a%b%') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"a_b",true] + - [2,"aabb",true] + - [3,"a%_b%0",true] + - [4,"b_c",false] + - [5,"abc",true] + - [6,"A0b",false] + - [7,"a#Bb",true] + - [8,"aaabbcc",true] + 1: + rows: + - [1,"a_b",true] + - [2,"aabb",true] + - [3,"a%_b%0",true] + - [4,"b_c",false] + - [5,"abc",true] + - [6,"A0b",true] + - [7,"a#Bb",true] + - [8,"aaabbcc",true] + - id: 10 + desc: "使用两个_" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA0b",1590738995000] + - [7,"aa#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'_a_b') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",false] + - [7,"aa#0B",false] + 1: + rows: + - [1,"%a_b",true] + - [2,"aabb",true] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA0b",true] + - [7,"aa#0B",false] + - id: 11 + desc: "使用两个%,其中一个被转义" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"a_b",1590738990000] + - [2,"aab%",1590738991000] + - [3,"a%_b%0",1590738992000] + - [4,"b_c",1590738993000] + - [5,"ab%",1590738994000] + - [6,"A0b",1590738995000] + - [7,"a#B%",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'a%b#%','#') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"a_b",false] + - [2,"aab%",true] + - [3,"a%_b%0",false] + - [4,"b_c",false] + - [5,"ab%",true] + - [6,"A0b",false] + - [7,"a#B%",false] + 1: + rows: + - [1,"a_b",false] + - [2,"aab%",true] + - [3,"a%_b%0",false] + - [4,"b_c",false] + - [5,"ab%",true] + - [6,"A0b",false] + - [7,"a#B%",true] + - id: 12 + desc: "使用两个_,其中一个被转义" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"_A0b",1590738995000] + - [7,"aa#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'#_a_b','#') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"_A0b",false] + - [7,"aa#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"_A0b",true] + - [7,"aa#0B",false] + - id: 13 + desc: "同时使用%和_,其中_被转义" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a_b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"_A0b",1590738995000] + - [7,"_a#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'#_a%b','#') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"_A0b",false] + - [7,"_a#0B",false] + 1: + rows: + - [1,"%a_b",false] + - [2,"aabb",false] + - [3,"_a%_b",true] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"_A0b",true] + - [7,"_a#0B",true] + - id: 14 + desc: "同时使用%和_,其中%被转义" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"%a%b",1590738990000] + - [2,"aabb",1590738991000] + - [3,"_a%_b",1590738992000] + - [4,"ba_c",1590738993000] + - [5,"abb",1590738994000] + - [6,"bA%b",1590738995000] + - [7,"aa#0B",1590738996000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,c1,d[0](c1,'_a#%b','#') as v1 from {0}; + expect: + order: id + columns: ["id bigint","c1 string","v1 bool"] + expectProvider: + 0: + rows: + - [1,"%a%b",true] + - [2,"aabb",false] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA%b",false] + - [7,"aa#0B",false] + 1: + rows: + - [1,"%a%b",true] + - [2,"aabb",false] + - [3,"_a%_b",false] + - [4,"ba_c",false] + - [5,"abb",false] + - [6,"bA%b",true] + - [7,"aa#0B",false] + - id: 15 + desc: "列中有null和空串" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,null,1590738991000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'a%b') as v1 from {0}; + expect: + order: id + columns: ["id bigint","v1 bool"] + rows: + - [1,false] + - [2,null] + - id: 16 + desc: "使用空串" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,"aa",1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'') as v1 from {0}; + expect: + order: id + columns: ["id bigint","v1 bool"] + rows: + - [1,true] + - [2,false] + - id: 17 + desc: "使用null" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,"aa",1590738991000] + - [3,null,1590738992000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,null) as v1 from {0}; + expect: + success: false + - id: 18 + desc: "escape使用null" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,"aa",1590738991000] + - [3,null,1590738992000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'a%',null) as v1 from {0}; + expect: + success: false + - id: 19 + desc: "int类型" + inputs: + - + columns : ["id bigint","c1 int","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12,1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'1%') as v1 from {0}; + expect: + success: false + - id: 20 + desc: "bigint类型" + inputs: + - + columns : ["id bigint","c1 bigint","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12,1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'1%') as v1 from {0}; + expect: + success: false + - id: 21 + desc: "smallint类型" + inputs: + - + columns : ["id bigint","c1 smallint","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12,1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'1%') as v1 from {0}; + expect: + success: false + - id: 22 + desc: "float类型" + inputs: + - + columns : ["id bigint","c1 float","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12.0,1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'1%') as v1 from {0}; + expect: + success: false + - id: 23 + desc: "double类型" + inputs: + - + columns : ["id bigint","c1 double","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12.0,1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'1%') as v1 from {0}; + expect: + success: false + - id: 24 + desc: "timestamp类型" + inputs: + - + columns : ["id bigint","c1 timestamp","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,12,1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'1%') as v1 from {0}; + expect: + success: false + - id: 25 + desc: "date类型" + inputs: + - + columns : ["id bigint","c1 date","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"2012-05-01",1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'1%') as v1 from {0}; + expect: + success: false + - id: 26 + desc: "bool类型" + inputs: + - + columns : ["id bigint","c1 bool","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,true,1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'1%') as v1 from {0}; + expect: + success: false + - id: 27 + desc: "列不存在" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",1590738990000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c2,'1%') as v1 from {0}; + expect: + success: false + - id: 28 + desc: "escape为多个字符" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"",1590738990000] + - [2,"aa",1590738991000] + - [3,null,1590738992000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'a%','<>') as v1 from {0}; + expect: + success: true + order: id + columns : ["id bigint","v1 bool"] + rows: + - [1,false] + - [2,false] + - [3,null] + - id: 29 + desc: "pattern以escape character结尾" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"ab#",1590738990000] + - [2,"aa",1590738991000] + dataProvider: + - ["like_match","ilike_match"] + sql: select id,d[0](c1,'a%#','#') as v1 from {0}; + expect: + success: true + columns : ["id bigint","v1 bool"] + rows: + - [1,false] + - [2,false] + diff --git a/cases/integration_test/function/test_string.yaml b/cases/integration_test/function/test_string.yaml new file mode 100644 index 00000000000..4b9220122f0 --- /dev/null +++ b/cases/integration_test/function/test_string.yaml @@ -0,0 +1,290 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: "concat_各种类型组合" + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - [2,2,null,null,null,null,null,null,null,null,null] + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + - [2,2,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + dataProvider: + - ["{0}.c1","{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c7","{0}.c8","{0}.c9"] + sql: | + select + concat(d[0],{1}.c1) as b1, + concat(d[0],{1}.c2) as b2, + concat(d[0],{1}.c3) as b3, + concat(d[0],{1}.c4) as b4, + concat(d[0],{1}.c5) as b5, + concat(d[0],{1}.c6) as b6, + concat(d[0],{1}.c7) as b7, + concat(d[0],{1}.c8) as b8, + concat(d[0],{1}.c9) as b9 + from {0} last join {1} ORDER BY {1}.ts1 on {0}.id={1}.id; + expect: + columns: ["b1 string","b2 string","b3 string","b4 string","b5 string","b6 string","b7 string","b8 string","b9 string"] + expectProvider: + 0: + rows: + - ["aa","aa0","aa20","aa30","aa11.1","aa12.1","aa2020-05-29 15:56:29","aa2020-05-02","aatrue"] + - [null,null,null,null,null,null,null,null,null] + 1: + rows: + - ["30","300","3020","3030","3011.1","3012.1","302020-05-29 15:56:29","302020-05-02","30true"] + - [null,null,null,null,null,null,null,null,null] + 2: + rows: + - ["30","300","3020","3030","3011.1","3012.1","302020-05-29 15:56:29","302020-05-02","30true"] + - [null,null,null,null,null,null,null,null,null] + 3: + rows: + - ["30","300","3020","3030","3011.1","3012.1","302020-05-29 15:56:29","302020-05-02","30true"] + - [null,null,null,null,null,null,null,null,null] + 4: + rows: + - ["30","300","3020","3030","3011.1","3012.1","302020-05-29 15:56:29","302020-05-02","30true"] + - [null,null,null,null,null,null,null,null,null] + 5: + rows: + - ["30","300","3020","3030","3011.1","3012.1","302020-05-29 15:56:29","302020-05-02","30true"] + - [null,null,null,null,null,null,null,null,null] + 6: + rows: + - ["2020-05-29 15:56:29","2020-05-29 15:56:290","2020-05-29 15:56:2920","2020-05-29 15:56:2930","2020-05-29 15:56:2911.1","2020-05-29 15:56:2912.1","2020-05-29 15:56:292020-05-29 15:56:29","2020-05-29 15:56:292020-05-02","2020-05-29 15:56:29true"] + - [null,null,null,null,null,null,null,null,null] + 7: + rows: + - ["2020-05-01","2020-05-010","2020-05-0120","2020-05-0130","2020-05-0111.1","2020-05-0112.1","2020-05-012020-05-29 15:56:29","2020-05-012020-05-02","2020-05-01true"] + - [null,null,null,null,null,null,null,null,null] + 8: + rows: + - ["false","false0","false20","false30","false11.1","false12.1","false2020-05-29 15:56:29","false2020-05-02","falsetrue"] + - [null,null,null,null,null,null,null,null,null] + - id: 1 + desc: concat三个字符串 + sqlDialect: ["HybridSQL","MYSQL"] + inputs: + - columns: ["id int", "c1 string","c2 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa","bbb",1590738989000] + sql: select id, c1, c2, concat(c1, c2,"cc") as c12 from {0}; + expect: + columns: ["id int", "c1 string","c2 string", "c12 string"] + rows: + - [1, "aa", "bbb", "aabbbcc"] + + - id: 2 + desc: concat_ws一个字符串和三个字符串 + sqlDialect: ["HybridSQL","MYSQL"] + inputs: + - columns: ["id int", "c1 string","c2 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa","bbb",1590738989000] + sql: select id, c1, concat_ws("-",c2) as c2, concat_ws("-", c1, c2,"cc") as c1_2 from {0}; + expect: + columns: ["id int", "c1 string","c2 string","c1_2 string"] + rows: + - [1, "aa", "bbb", "aa-bbb-cc"] + - id: 3 + mode: cli-unsupport + desc: "concat_ws-所有类型" + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - [2,2,"aa",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"",0,20,30,11.1,12.1,1590738989001,"2020-05-02",true] + - [2,2,null,null,null,null,null,null,null,null,null] + dataProvider: + - ["{0}.c1","{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c7","{0}.c8","{0}.c9"] + sql: | + select + concat_ws(d[0],{0}.c1,{1}.c1) as b1, + concat_ws(d[0],{0}.c1,{1}.c2) as b2, + concat_ws(d[0],{0}.c1,{1}.c3) as b3, + concat_ws(d[0],{0}.c1,{1}.c4) as b4, + concat_ws(d[0],{0}.c1,{1}.c5) as b5, + concat_ws(d[0],{0}.c1,{1}.c6) as b6, + concat_ws(d[0],{0}.c1,{1}.c7) as b7, + concat_ws(d[0],{0}.c1,{1}.c8) as b8, + concat_ws(d[0],{0}.c1,{1}.c9) as b9 + from {0} last join {1} ORDER BY {1}.ts1 on {0}.id={1}.id; + expect: + columns: ["b1 string","b2 string","b3 string","b4 string","b5 string","b6 string","b7 string","b8 string","b9 string"] + expectProvider: + 0: + rows: + - ["aaaa","aaaa0","aaaa20","aaaa30","aaaa11.1","aaaa12.1","aaaa2020-05-29 15:56:29","aaaa2020-05-02","aaaatrue"] + - [null,null,null,null,null,null,null,null,null] + 1: + rows: + - ["aa30","aa300","aa3020","aa3030","aa3011.1","aa3012.1","aa302020-05-29 15:56:29","aa302020-05-02","aa30true"] + - [null,null,null,null,null,null,null,null,null] + 2: + rows: + - ["aa30","aa300","aa3020","aa3030","aa3011.1","aa3012.1","aa302020-05-29 15:56:29","aa302020-05-02","aa30true"] + - [null,null,null,null,null,null,null,null,null] + 3: + rows: + - ["aa30","aa300","aa3020","aa3030","aa3011.1","aa3012.1","aa302020-05-29 15:56:29","aa302020-05-02","aa30true"] + - [null,null,null,null,null,null,null,null,null] + 4: + rows: + - ["aa30","aa300","aa3020","aa3030","aa3011.1","aa3012.1","aa302020-05-29 15:56:29","aa302020-05-02","aa30true"] + - [null,null,null,null,null,null,null,null,null] + 5: + rows: + - ["aa30","aa300","aa3020","aa3030","aa3011.1","aa3012.1","aa302020-05-29 15:56:29","aa302020-05-02","aa30true"] + - [null,null,null,null,null,null,null,null,null] + 6: + rows: + - ["aa2020-05-29 15:56:29","aa2020-05-29 15:56:290","aa2020-05-29 15:56:2920","aa2020-05-29 15:56:2930","aa2020-05-29 15:56:2911.1","aa2020-05-29 15:56:2912.1","aa2020-05-29 15:56:292020-05-29 15:56:29","aa2020-05-29 15:56:292020-05-02","aa2020-05-29 15:56:29true"] + - [null,null,null,null,null,null,null,null,null] + 7: + rows: + - ["aa2020-05-01","aa2020-05-010","aa2020-05-0120","aa2020-05-0130","aa2020-05-0111.1","aa2020-05-0112.1","aa2020-05-012020-05-29 15:56:29","aa2020-05-012020-05-02","aa2020-05-01true"] + - [null,null,null,null,null,null,null,null,null] + 8: + rows: + - ["aafalse","aafalse0","aafalse20","aafalse30","aafalse11.1","aafalse12.1","aafalse2020-05-29 15:56:29","aafalse2020-05-02","aafalsetrue"] + - [null,null,null,null,null,null,null,null,null] + - id: 4 + desc: strcmp 两个字符串 + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["id int", "c1 string","c2 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1, "text","text2",1590738989000] + - [2, "text","text",1590738989000] + - [3, "text2","text",1590738989000] + - [4, null,"text",1590738989000] + - [5, "text",null,1590738989000] + - [6, null,null,1590738989000] + sql: select id, c1, c2, strcmp(c1, c2) as cmp_c1c2 from {0}; + expect: + columns: ["id int", "c1 string","c2 string","cmp_c1c2 int"] + order: id + rows: + - [1, "text", "text2", -1] + - [2, "text", "text", 0] + - [3, "text2", "text", 1] + - [4, null,"text",null] + - [5, "text",null,null] + - [6, null,null,null] + - id: 5 + desc: "strcmp-fail" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"123456789",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + dataProvider: + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c7","{0}.c8","{0}.c9"] + - ["{0}.c1","{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c7","{0}.c8","{0}.c9"] + sql: select strcmp(d[0],d[1]) from {0}; + expect: + success: false + - id: 6 + desc: "strcmp-string-fail" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"123456789",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + dataProvider: + - ["{0}.c1"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c7","{0}.c8","{0}.c9"] + sql: select strcmp(d[0],d[1]) from {0}; + expect: + success: false + - id: 7 + desc: "substr-normal" + mode: cli-unsupport + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"123456789",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - [2,2,null,null,null,null,null,null,null,null,null] + dataProvider: + - ["substr","substring"] + sql: | + select + d[0](c1,3) as b1, + d[0](c1,3,2) as b2, + d[0](c1,3,20) as b3, + d[0](c1,30,2) as b4, + d[0](c1,30) as b5 + from {0}; + expect: + columns: ["b1 string","b2 string","b3 string","b4 string","b5 string"] + expectProvider: + 0: + rows: + - ["3456789","34","3456789","",""] + - [null,null,null,null,null] + 1: + rows: + - ["3456789","34","3456789","",""] + - [null,null,null,null,null] + + - id: 8 + desc: "substr-fail" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id bigint","ts1 bigint","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:id:ts1"] + rows: + - [1,1,"123456789",30,30,30,30.0,30.0,1590738989000,"2020-05-01",false] + - [2,2,null,null,null,null,null,null,null,null,null] + dataProvider: + - ["substr","substring"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6","{0}.c7","{0}.c8","{0}.c9"] + sql: select d[0](d[1],1) from {0}; + expect: + success: false diff --git a/cases/integration_test/function/test_udaf_function.yaml b/cases/integration_test/function/test_udaf_function.yaml new file mode 100644 index 00000000000..0642ed737fa --- /dev/null +++ b/cases/integration_test/function/test_udaf_function.yaml @@ -0,0 +1,2563 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: max + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, max(c2) OVER w1 as m2,max(c3) OVER w1 as m3,max(c4) OVER w1 as m4,max(c5) OVER w1 as m5,max(c6) OVER w1 as m6,max(c7) OVER w1 as m7,max(c8) OVER w1 as m8,max(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 smallint","m3 int","m4 bigint","m5 float","m6 double","m7 timestamp","m8 date","m9 string"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c"] + - [3,"aa",4,4,33,1.4,2.4,1590738992000,"2020-05-03","c"] + - [4,"aa",4,4,33,1.4,2.4,1590738993000,"2020-05-03","c"] + - + id: 1 + desc: min + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, min(c2) OVER w1 as m2,min(c3) OVER w1 as m3,min(c4) OVER w1 as m4,min(c5) OVER w1 as m5,min(c6) OVER w1 as m6,min(c7) OVER w1 as m7,min(c8) OVER w1 as m8,min(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 smallint","m3 int","m4 bigint","m5 float","m6 double","m7 timestamp","m8 date","m9 string"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [2,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [3,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [4,"aa",3,3,32,1.3,2.3,1590738991000,"2020-05-02","b"] + - + id: 2 + desc: count + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, count(c2) OVER w1 as m2,count(c3) OVER w1 as m3,count(c4) OVER w1 as m4,count(c5) OVER w1 as m5,count(c6) OVER w1 as m6,count(c7) OVER w1 as m7,count(c8) OVER w1 as m8,count(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 bigint","m3 bigint","m4 bigint","m5 bigint","m6 bigint","m7 bigint","m8 bigint","m9 bigint"] + rows: + - [1,"aa",1,1,1,1,1,1,1,1] + - [2,"aa",2,2,2,2,2,2,2,2] + - [3,"aa",3,3,3,3,3,3,3,3] + - [4,"aa",2,2,2,2,2,3,2,2] + - + id: 3 + desc: sum + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, sum(c2) OVER w1 as m2,sum(c3) OVER w1 as m3,sum(c4) OVER w1 as m4,sum(c5) OVER w1 as m5,sum(c6) OVER w1 as m6 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 smallint","m3 int","m4 bigint","m5 float","m6 double"] + rows: + - [1,"aa",1,1,30,1.1,2.1] + - [2,"aa",5,5,63,2.5,4.5] + - [3,"aa",8,8,95,3.7999997,6.799999999999999] + - [4,"aa",7,7,65,2.7,4.7] + - + id: 4 + desc: avg + version: 0.6.0 + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1, NULL,30, 1.1, 2.1, 1590738990000,"2020-05-01","a",true] + - [2,"aa",4, 4, 33, 1.4, 2.4, 1590738991000,"2020-05-03","c",false] + - [3,"aa",1, 1, 33, 1.1, 2.1, 1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, + avg(c2) OVER w1 as m2, + avg(c3) OVER w1 as m3, + avg(c4) OVER w1 as m4, + avg(c5) OVER w1 as m5, + avg(c6) OVER w1 as m6, + avg(c3 + 1) over w1 as m7 + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 double","m3 double","m4 double","m5 double","m6 double", "m7 double"] + rows: + - [1, aa, 1, NULL, 30, 1.100000023841858,2.1, NULL] + - [2, aa, 2.5, 4.0, 31.5, 1.25, 2.25, 5.0] + - [3, aa, 2, 2.5, 32, 1.200000007947286,2.1999999999999997,3.5] + - [4, aa, 2.5, 2.5, 33, 1.25, 2.25, 3.5] + - + id: 5 + desc: distinct_count + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool","ts timestamp"] + indexs: ["index1:c1:ts"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true,1590738990000] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-02","c",false,1590738991000] + - [3,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-02","c",true,1590738992000] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL,1590738993000] + sql: | + SELECT {0}.id, c1, distinct_count(c2) OVER w1 as m2,distinct_count(c3) OVER w1 as m3,distinct_count(c4) OVER w1 as m4,distinct_count(c5) OVER w1 as m5,distinct_count(c6) OVER w1 as m6,distinct_count(c7) OVER w1 as m7,distinct_count(c8) OVER w1 as m8,distinct_count(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.ts ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 bigint","m3 bigint","m4 bigint","m5 bigint","m6 bigint","m7 bigint","m8 bigint","m9 bigint"] + rows: + - [1,"aa",1,1,1,1,1,1,1,1] + - [2,"aa",2,2,2,2,2,2,2,2] + - [3,"aa",2,2,2,2,2,2,2,2] + - [4,"aa",2,2,2,2,2,2,2,2] + - + id: 6 + desc: count/distinct_count-bool + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",1,1,33,1.1,2.1,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, count(c10) OVER w1 as count_bool, distinct_count(c10) OVER w1 as distinct_count_bool + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int", "count_bool bigint", "distinct_count_bool bigint"] + rows: + - [1,1,1] + - [2,2,2] + - [3,3,2] + - [4,2,2] + - + id: 7 + desc: sum-timestamp + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id bigint","c1 string", "c2 timestamp", "c3 timestamp"] + indexs: ["index1:c1:c2"] + rows: + - [1,"aa",1590738990000,1590738990000] + - [2,"aa",1590738991000,1590738991000] + - [3,"aa",1590738992000,1590738992000] + - [4,"aa",1590738993000,NULL] + sql: | + SELECT {0}.id, sum(c3) OVER w1 as m2 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c2 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint", "m2 timestamp"] + rows: + - [1, 1590738990000] + - [2, 3181477981000] + - [3, 4772216973000] + - [4, 3181477983000] + - + id: 8 + desc: avg-timestamp + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [2,"aa",4,33,1.4,2.4,1590738991000,"2020-05-03","c"] + - [3,"aa",3,32,1.3,2.3,1590738992000,"2020-05-02","b"] + sql: | + SELECT {0}.id, c1,avg(c7) OVER w1 as m7 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 9 + desc: sum-date + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [2,"aa",4,33,1.4,2.4,1590738991000,"2020-05-03","c"] + - [3,"aa",3,32,1.3,2.3,1590738992000,"2020-05-02","b"] + sql: | + SELECT {0}.id, c1,sum(c8) OVER w1 as m8 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 10 + desc: sum-string + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [2,"aa",4,33,1.4,2.4,1590738991000,"2020-05-03","c"] + - [3,"aa",3,32,1.3,2.3,1590738992000,"2020-05-02","b"] + sql: | + SELECT {0}.id, c1,sum(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 11 + desc: avg-date + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [2,"aa",4,33,1.4,2.4,1590738991000,"2020-05-03","c"] + - [3,"aa",3,32,1.3,2.3,1590738992000,"2020-05-02","b"] + sql: | + SELECT {0}.id, c1,avg(c8) OVER w1 as m8 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 12 + desc: avg-string + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [2,"aa",4,33,1.4,2.4,1590738991000,"2020-05-03","c"] + - [3,"aa",3,32,1.3,2.3,1590738992000,"2020-05-02","b"] + sql: | + SELECT {0}.id, c1,avg(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 13 + desc: MAX_WHERE-normal + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [0, "00", 5, 3, 10, 1.0, 4.4, 1590738990000, "2020-05-01", "a", false] + - [1, "aa", 1, 1, 30, 1.1, 2.1, 1590738990000, "2020-05-01", "a", true] + - [2, "aa", 4, 4, 33, 1.4, 2.4, 1590738991000, "2020-05-03", "c", false] + - [3, "aa", 3, 3, 32, 1.3, 2.3, 1590738992000, "2020-05-02", "b", true] + - [4, "aa", NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, max_where(c2,c2<4) OVER w1 as m2,max_where(c3,c3<4) OVER w1 as m3,max_where(c4,c10) OVER w1 as m4,max_where(c5,c5<=1.3) OVER w1 as m5,max_where(c6,c6<=2.3) OVER w1 as m6 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 smallint","m3 int","m4 bigint","m5 float","m6 double"] + rows: + - [0,"00",NULL,3,NULL,1.0,NULL] + - [1,"aa",1,1,30,1.1,2.1] + - [2,"aa",1,1,30,1.1,2.1] + - [3,"aa",3,3,32,1.3,2.3] + - [4,"aa",3,3,32,1.3,2.3] + - + id: 14 + desc: MIN_WHERE-normal + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, min_where(c2,c2>2) OVER w1 as m2,min_where(c3,c3>=3) OVER w1 as m3,min_where(c4,c4<33) OVER w1 as m4,min_where(c5,c5<=2) OVER w1 as m5,min_where(c6,c10) OVER w1 as m6 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 smallint","m3 int","m4 bigint","m5 float","m6 double"] + rows: + - [1,"aa",NULL,NULL,30,1.1,2.1] + - [2,"aa",4,4,30,1.1,2.1] + - [3,"aa",3,3,30,1.1,2.1] + - [4,"aa",3,3,32,1.3,2.3] + - + id: 15 + desc: SUM_WHERE-normal + sqlDialect: ["HybridSQL"] + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1, 1, 30, NULL,2.1, 1590738990000, "2020-05-01","a",true] + - [2,"aa",4, 4, NULL,1.4, 2.4, 1590738991000, "2020-05-03","c",false] + - [3,"aa",3, NULL,33, 1.3, 2.3, 1590738992000, "2020-05-02","b",true] + - [4,"aa",NULL,3, 32, 1.1, NULL,1590738993000, NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, + sum_where(c2,c2<4) OVER w1 as m2, + sum_where(c3,c3<4) OVER w1 as m3, + sum_where(c4,c4<33) OVER w1 as m4, + sum_where(c5,c5<=1.3) OVER w1 as m5, + sum_where(c6,c10) OVER w1 as m6, + sum_where(c2, c2 = null) over w1 as m7 + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 smallint","m3 int","m4 bigint","m5 float","m6 double", "m7 smallint"] + rows: + - [1, "aa", 1, 1, 30, NULL, 2.1, NULL] + - [2, "aa", 1, 1, 30, NULL, 2.1, NULL] + - [3, "aa", 4, 1, 30, 1.3, 4.4, NULL] + - [4, "aa", 3, 3, 32, 2.4, 2.3, NULL] + - + id: 16 + desc: AVG_WHERE-normal + sqlDialect: ["HybridSQL"] + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1, "aa", 1, 1, 30, NULL,2.1, 1590738990000, "2020-05-01", "a", true] + - [2, "aa", 4, 4, NULL,1.4, 2.4, 1590738991000, "2020-05-03", "c", false] + - [3, "aa", 3, NULL,32, 1.3, 2.3, 1590738992000, "2020-05-02", "b", true] + - [4, "aa", NULL,3, 33, 1.1, NULL,1590738993000, NULL, NULL,NULL] + sql: | + SELECT {0}.id, c1, + avg_where(c2, c2<4) OVER w1 as m2, + avg_where(c3, c3<4) OVER w1 as m3, + avg_where(c4, c4<33) OVER w1 as m4, + avg_where(c5, c5<=1.3) OVER w1 as m5, + avg_where(c6, c10) OVER w1 as m6, + avg_where(c3, c3 = null) over w1 as m7 + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 double","m3 double","m4 double","m5 double","m6 double", "m7 double"] + rows: + - [1, aa, 1, 1, 30, NULL, 2.1, NULL] + - [2, aa, 1, 1, 30, NULL, 2.1, NULL] + - [3, aa, 2, 1, 31, 1.2999999523162842, 2.2, NULL] + - [4, aa, 3, 3, 32, 1.199999988079071, 2.3, NULL] + - + id: 17 + desc: COUNT_WHERE-normal + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, count_where(c2,c2<4) OVER w1 as m2,count_where(c3,c3<4) OVER w1 as m3,count_where(c4,c4<33) OVER w1 as m4,count_where(c5,c5<=1.3) OVER w1 as m5,count_where(c6,c10) OVER w1 as m6, + count_where(c7,c10) OVER w1 as m7,count_where(c8,c10) OVER w1 as m8,count_where(c9,c10) OVER w1 as m9, count_where(*,c3<4) over w1 as m10 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 bigint","m3 bigint","m4 bigint","m5 bigint","m6 bigint","m7 bigint","m8 bigint","m9 bigint","m10 bigint"] + rows: + - [1,"aa",1,1,1,1,1,1,1,1,1] + - [2,"aa",1,1,1,1,1,1,1,1,1] + - [3,"aa",2,2,2,2,2,2,2,2,2] + - [4,"aa",1,1,1,1,1,1,1,1,1] + - + id: 18 + desc: AVG_WHERE/MAX_WHERE/MIN_WHERE/SUM_WHERE-fail + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + dataProvider: + - ["avg_where","sum_where","max_where","min_where"] + - ["c7","c8","c9","c10"] + sql: | + SELECT {0}.id, c1, d[0](d[1],c10) OVER w1 as m2 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 19 + desc: COUNT_WHERE-fail + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + dataProvider: + - ["count_where"] + - ["c10"] + sql: | + SELECT {0}.id, c1, d[0](d[1],c10) OVER w1 as m2 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 20 + desc: max_cate-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + max_cate({0}.c2,d[0]) OVER w1 as m2, + max_cate({0}.c3,d[0]) OVER w1 as m3, + max_cate({0}.c4,d[0]) OVER w1 as m4, + max_cate({0}.c5,d[0]) OVER w1 as m5, + max_cate({0}.c6,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:4","1:4","1:33","1:1.400000","1:2.400000"] + - [3,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + - [4,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:4","1:4","1:33","1:1.400000","1:2.400000"] + - [3,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + - [4,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:4","1:4","1:33","1:1.400000","1:2.400000"] + - [3,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + - [4,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:4","30:4","30:33","30:1.400000","30:2.400000"] + - [3,"aa","30:4,32:3","30:4,32:3","30:33,32:32","30:1.400000,32:1.300000","30:2.400000,32:2.300000"] + - [4,"aa","30:4,32:3","30:4,32:3","30:33,32:32","30:1.400000,32:1.300000","30:2.400000,32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:4","2020-05-29 15:56:30:4","2020-05-29 15:56:30:33","2020-05-29 15:56:30:1.400000","2020-05-29 15:56:30:2.400000"] + - [3,"aa","2020-05-29 15:56:30:4,2020-05-29 15:56:32:3","2020-05-29 15:56:30:4,2020-05-29 15:56:32:3","2020-05-29 15:56:30:33,2020-05-29 15:56:32:32","2020-05-29 15:56:30:1.400000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.400000,2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:30:4,2020-05-29 15:56:32:3","2020-05-29 15:56:30:4,2020-05-29 15:56:32:3","2020-05-29 15:56:30:33,2020-05-29 15:56:32:32","2020-05-29 15:56:30:1.400000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.400000,2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:4","2020-05-01:4","2020-05-01:33","2020-05-01:1.400000","2020-05-01:2.400000"] + - [3,"aa","2020-05-01:4,2020-05-02:3","2020-05-01:4,2020-05-02:3","2020-05-01:33,2020-05-02:32","2020-05-01:1.400000,2020-05-02:1.300000","2020-05-01:2.400000,2020-05-02:2.300000"] + - [4,"aa","2020-05-01:4,2020-05-02:3","2020-05-01:4,2020-05-02:3","2020-05-01:33,2020-05-02:32","2020-05-01:1.400000,2020-05-02:1.300000","2020-05-01:2.400000,2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:4","a:4","a:33","a:1.400000","a:2.400000"] + - [3,"aa","a:4,b:3","a:4,b:3","a:33,b:32","a:1.400000,b:1.300000","a:2.400000,b:2.300000"] + - [4,"aa","a:4,b:3","a:4,b:3","a:33,b:32","a:1.400000,b:1.300000","a:2.400000,b:2.300000"] + - + id: 21 + desc: min_cate-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + min_cate({0}.c2,d[0]) OVER w1 as m2, + min_cate({0}.c3,d[0]) OVER w1 as m3, + min_cate({0}.c4,d[0]) OVER w1 as m4, + min_cate({0}.c5,d[0]) OVER w1 as m5, + min_cate({0}.c6,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","1:1,2:3","1:1,2:3","1:30,2:32","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","1:1,2:3","1:1,2:3","1:30,2:32","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [3,"aa","30:1,32:3","30:1,32:3","30:30,32:32","30:1.100000,32:1.300000","30:2.100000,32:2.300000"] + - [4,"aa","30:4,32:3","30:4,32:3","30:33,32:32","30:1.400000,32:1.300000","30:2.400000,32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:30:1,2020-05-29 15:56:32:3","2020-05-29 15:56:30:1,2020-05-29 15:56:32:3","2020-05-29 15:56:30:30,2020-05-29 15:56:32:32","2020-05-29 15:56:30:1.100000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.100000,2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:30:4,2020-05-29 15:56:32:3","2020-05-29 15:56:30:4,2020-05-29 15:56:32:3","2020-05-29 15:56:30:33,2020-05-29 15:56:32:32","2020-05-29 15:56:30:1.400000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.400000,2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-01:1,2020-05-02:3","2020-05-01:1,2020-05-02:3","2020-05-01:30,2020-05-02:32","2020-05-01:1.100000,2020-05-02:1.300000","2020-05-01:2.100000,2020-05-02:2.300000"] + - [4,"aa","2020-05-01:4,2020-05-02:3","2020-05-01:4,2020-05-02:3","2020-05-01:33,2020-05-02:32","2020-05-01:1.400000,2020-05-02:1.300000","2020-05-01:2.400000,2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [3,"aa","a:1,b:3","a:1,b:3","a:30,b:32","a:1.100000,b:1.300000","a:2.100000,b:2.300000"] + - [4,"aa","a:4,b:3","a:4,b:3","a:33,b:32","a:1.400000,b:1.300000","a:2.400000,b:2.300000"] + - + id: 22 + desc: count_cate-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + count_cate({0}.c2,d[0]) OVER w1 as m2, + count_cate({0}.c3,d[0]) OVER w1 as m3, + count_cate({0}.c4,d[0]) OVER w1 as m4, + count_cate({0}.c5,d[0]) OVER w1 as m5, + count_cate({0}.c6,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:1","1:1","1:1"] + - [2,"aa","1:2","1:2","1:2","1:2","1:2"] + - [3,"aa","1:2,2:1","1:2,2:1","1:2,2:1","1:2,2:1","1:2,2:1"] + - [4,"aa","1:1,2:1","1:1,2:1","1:1,2:1","1:1,2:1","1:1,2:1"] + 1: + rows: + - [1,"aa","1:1","1:1","1:1","1:1","1:1"] + - [2,"aa","1:2","1:2","1:2","1:2","1:2"] + - [3,"aa","1:2,2:1","1:2,2:1","1:2,2:1","1:2,2:1","1:2,2:1"] + - [4,"aa","1:1,2:1","1:1,2:1","1:1,2:1","1:1,2:1","1:1,2:1"] + 2: + rows: + - [1,"aa","30:1","30:1","30:1","30:1","30:1"] + - [2,"aa","30:2","30:2","30:2","30:2","30:2"] + - [3,"aa","30:2,32:1","30:2,32:1","30:2,32:1","30:2,32:1","30:2,32:1"] + - [4,"aa","30:1,32:1","30:1,32:1","30:1,32:1","30:1,32:1","30:1,32:1"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1"] + - [2,"aa","2020-05-29 15:56:30:2","2020-05-29 15:56:30:2","2020-05-29 15:56:30:2","2020-05-29 15:56:30:2","2020-05-29 15:56:30:2"] + - [3,"aa","2020-05-29 15:56:30:2,2020-05-29 15:56:32:1","2020-05-29 15:56:30:2,2020-05-29 15:56:32:1","2020-05-29 15:56:30:2,2020-05-29 15:56:32:1","2020-05-29 15:56:30:2,2020-05-29 15:56:32:1","2020-05-29 15:56:30:2,2020-05-29 15:56:32:1"] + - [4,"aa","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1"] + - [2,"aa","2020-05-01:2","2020-05-01:2","2020-05-01:2","2020-05-01:2","2020-05-01:2"] + - [3,"aa","2020-05-01:2,2020-05-02:1","2020-05-01:2,2020-05-02:1","2020-05-01:2,2020-05-02:1","2020-05-01:2,2020-05-02:1","2020-05-01:2,2020-05-02:1"] + - [4,"aa","2020-05-01:1,2020-05-02:1","2020-05-01:1,2020-05-02:1","2020-05-01:1,2020-05-02:1","2020-05-01:1,2020-05-02:1","2020-05-01:1,2020-05-02:1"] + 5: + rows: + - [1,"aa","a:1","a:1","a:1","a:1","a:1"] + - [2,"aa","a:2","a:2","a:2","a:2","a:2"] + - [3,"aa","a:2,b:1","a:2,b:1","a:2,b:1","a:2,b:1","a:2,b:1"] + - [4,"aa","a:1,b:1","a:1,b:1","a:1,b:1","a:1,b:1","a:1,b:1"] + - + id: 23 + desc: sum_cate-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + sum_cate({0}.c2,d[0]) OVER w1 as m2, + sum_cate({0}.c3,d[0]) OVER w1 as m3, + sum_cate({0}.c4,d[0]) OVER w1 as m4, + sum_cate({0}.c5,d[0]) OVER w1 as m5, + sum_cate({0}.c6,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:5","1:5","1:63","1:2.500000","1:4.500000"] + - [3,"aa","1:5,2:3","1:5,2:3","1:63,2:32","1:2.500000,2:1.300000","1:4.500000,2:2.300000"] + - [4,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:5","1:5","1:63","1:2.500000","1:4.500000"] + - [3,"aa","1:5,2:3","1:5,2:3","1:63,2:32","1:2.500000,2:1.300000","1:4.500000,2:2.300000"] + - [4,"aa","1:4,2:3","1:4,2:3","1:33,2:32","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:5","30:5","30:63","30:2.500000","30:4.500000"] + - [3,"aa","30:5,32:3","30:5,32:3","30:63,32:32","30:2.500000,32:1.300000","30:4.500000,32:2.300000"] + - [4,"aa","30:4,32:3","30:4,32:3","30:33,32:32","30:1.400000,32:1.300000","30:2.400000,32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:5","2020-05-29 15:56:30:5","2020-05-29 15:56:30:63","2020-05-29 15:56:30:2.500000","2020-05-29 15:56:30:4.500000"] + - [3,"aa","2020-05-29 15:56:30:5,2020-05-29 15:56:32:3","2020-05-29 15:56:30:5,2020-05-29 15:56:32:3","2020-05-29 15:56:30:63,2020-05-29 15:56:32:32","2020-05-29 15:56:30:2.500000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:4.500000,2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:30:4,2020-05-29 15:56:32:3","2020-05-29 15:56:30:4,2020-05-29 15:56:32:3","2020-05-29 15:56:30:33,2020-05-29 15:56:32:32","2020-05-29 15:56:30:1.400000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.400000,2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:5","2020-05-01:5","2020-05-01:63","2020-05-01:2.500000","2020-05-01:4.500000"] + - [3,"aa","2020-05-01:5,2020-05-02:3","2020-05-01:5,2020-05-02:3","2020-05-01:63,2020-05-02:32","2020-05-01:2.500000,2020-05-02:1.300000","2020-05-01:4.500000,2020-05-02:2.300000"] + - [4,"aa","2020-05-01:4,2020-05-02:3","2020-05-01:4,2020-05-02:3","2020-05-01:33,2020-05-02:32","2020-05-01:1.400000,2020-05-02:1.300000","2020-05-01:2.400000,2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:5","a:5","a:63","a:2.500000","a:4.500000"] + - [3,"aa","a:5,b:3","a:5,b:3","a:63,b:32","a:2.500000,b:1.300000","a:4.500000,b:2.300000"] + - [4,"aa","a:4,b:3","a:4,b:3","a:33,b:32","a:1.400000,b:1.300000","a:2.400000,b:2.300000"] + - + id: 24 + desc: avg_cate-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + avg_cate({0}.c2,d[0]) OVER w1 as m2, + avg_cate({0}.c3,d[0]) OVER w1 as m3, + avg_cate({0}.c4,d[0]) OVER w1 as m4, + avg_cate({0}.c5,d[0]) OVER w1 as m5, + avg_cate({0}.c6,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [2,"aa","1:2.500000","1:2.500000","1:31.500000","1:1.250000","1:2.250000"] + - [3,"aa","1:2.500000,2:3.000000","1:2.500000,2:3.000000","1:31.500000,2:32.000000","1:1.250000,2:1.300000","1:2.250000,2:2.300000"] + - [4,"aa","1:4.000000,2:3.000000","1:4.000000,2:3.000000","1:33.000000,2:32.000000","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + 1: + rows: + - [1,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [2,"aa","1:2.500000","1:2.500000","1:31.500000","1:1.250000","1:2.250000"] + - [3,"aa","1:2.500000,2:3.000000","1:2.500000,2:3.000000","1:31.500000,2:32.000000","1:1.250000,2:1.300000","1:2.250000,2:2.300000"] + - [4,"aa","1:4.000000,2:3.000000","1:4.000000,2:3.000000","1:33.000000,2:32.000000","1:1.400000,2:1.300000","1:2.400000,2:2.300000"] + 2: + rows: + - [1,"aa","30:1.000000","30:1.000000","30:30.000000","30:1.100000","30:2.100000"] + - [2,"aa","30:2.500000","30:2.500000","30:31.500000","30:1.250000","30:2.250000"] + - [3,"aa","30:2.500000,32:3.000000","30:2.500000,32:3.000000","30:31.500000,32:32.000000","30:1.250000,32:1.300000","30:2.250000,32:2.300000"] + - [4,"aa","30:4.000000,32:3.000000","30:4.000000,32:3.000000","30:33.000000,32:32.000000","30:1.400000,32:1.300000","30:2.400000,32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:30.000000","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:2.500000","2020-05-29 15:56:30:2.500000","2020-05-29 15:56:30:31.500000","2020-05-29 15:56:30:1.250000","2020-05-29 15:56:30:2.250000"] + - [3,"aa","2020-05-29 15:56:30:2.500000,2020-05-29 15:56:32:3.000000","2020-05-29 15:56:30:2.500000,2020-05-29 15:56:32:3.000000","2020-05-29 15:56:30:31.500000,2020-05-29 15:56:32:32.000000","2020-05-29 15:56:30:1.250000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.250000,2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:30:4.000000,2020-05-29 15:56:32:3.000000","2020-05-29 15:56:30:4.000000,2020-05-29 15:56:32:3.000000","2020-05-29 15:56:30:33.000000,2020-05-29 15:56:32:32.000000","2020-05-29 15:56:30:1.400000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.400000,2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1.000000","2020-05-01:1.000000","2020-05-01:30.000000","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:2.500000","2020-05-01:2.500000","2020-05-01:31.500000","2020-05-01:1.250000","2020-05-01:2.250000"] + - [3,"aa","2020-05-01:2.500000,2020-05-02:3.000000","2020-05-01:2.500000,2020-05-02:3.000000","2020-05-01:31.500000,2020-05-02:32.000000","2020-05-01:1.250000,2020-05-02:1.300000","2020-05-01:2.250000,2020-05-02:2.300000"] + - [4,"aa","2020-05-01:4.000000,2020-05-02:3.000000","2020-05-01:4.000000,2020-05-02:3.000000","2020-05-01:33.000000,2020-05-02:32.000000","2020-05-01:1.400000,2020-05-02:1.300000","2020-05-01:2.400000,2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1.000000","a:1.000000","a:30.000000","a:1.100000","a:2.100000"] + - [2,"aa","a:2.500000","a:2.500000","a:31.500000","a:1.250000","a:2.250000"] + - [3,"aa","a:2.500000,b:3.000000","a:2.500000,b:3.000000","a:31.500000,b:32.000000","a:1.250000,b:1.300000","a:2.250000,b:2.300000"] + - [4,"aa","a:4.000000,b:3.000000","a:4.000000,b:3.000000","a:33.000000,b:32.000000","a:1.400000,b:1.300000","a:2.400000,b:2.300000"] + - + id: 25 + desc: "*_cate-fail1" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["avg_cate","sum_cate","max_cate","min_cate","count_cate"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6"] + - ["{1}.c5","{1}.c6","{1}.c10"] + sql: | + SELECT {0}.id, {0}.c1, + d[0](d[1],d[2]) OVER w1 as m2 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 26 + desc: "*_cate-fail2" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["avg_cate","sum_cate","max_cate","min_cate","count_cate"] + - ["{0}.c7","{0}.c8","{0}.c9","{0}.c10"] + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c5","{1}.c6","{1}.c7","{1}.c8","{1}.c9","{1}.c10"] + sql: | + SELECT {0}.id, {0}.c1, + d[0](d[1],d[2]) OVER w1 as m2 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 27 + desc: max_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + max_cate_where({0}.c2,{0}.c10,d[0]) OVER w1 as m2, + max_cate_where({0}.c3,{0}.c10,d[0]) OVER w1 as m3, + max_cate_where({0}.c4,{0}.c10,d[0]) OVER w1 as m4, + max_cate_where({0}.c5,{0}.c10,d[0]) OVER w1 as m5, + max_cate_where({0}.c6,{0}.c10,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","1:1,2:3","1:1,2:3","1:30,2:32","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","1:1,2:3","1:1,2:3","1:30,2:32","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [3,"aa","30:1,32:3","30:1,32:3","30:30,32:32","30:1.100000,32:1.300000","30:2.100000,32:2.300000"] + - [4,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:30:1,2020-05-29 15:56:32:3","2020-05-29 15:56:30:1,2020-05-29 15:56:32:3","2020-05-29 15:56:30:30,2020-05-29 15:56:32:32","2020-05-29 15:56:30:1.100000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.100000,2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-01:1,2020-05-02:3","2020-05-01:1,2020-05-02:3","2020-05-01:30,2020-05-02:32","2020-05-01:1.100000,2020-05-02:1.300000","2020-05-01:2.100000,2020-05-02:2.300000"] + - [4,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [3,"aa","a:1,b:3","a:1,b:3","a:30,b:32","a:1.100000,b:1.300000","a:2.100000,b:2.300000"] + - [4,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - + id: 28 + desc: min_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + min_cate_where({0}.c2,{0}.c10,d[0]) OVER w1 as m2, + min_cate_where({0}.c3,{0}.c10,d[0]) OVER w1 as m3, + min_cate_where({0}.c4,{0}.c10,d[0]) OVER w1 as m4, + min_cate_where({0}.c5,{0}.c10,d[0]) OVER w1 as m5, + min_cate_where({0}.c6,{0}.c10,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","1:1,2:3","1:1,2:3","1:30,2:32","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","1:1,2:3","1:1,2:3","1:30,2:32","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [3,"aa","30:1,32:3","30:1,32:3","30:30,32:32","30:1.100000,32:1.300000","30:2.100000,32:2.300000"] + - [4,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:30:1,2020-05-29 15:56:32:3","2020-05-29 15:56:30:1,2020-05-29 15:56:32:3","2020-05-29 15:56:30:30,2020-05-29 15:56:32:32","2020-05-29 15:56:30:1.100000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.100000,2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-01:1,2020-05-02:3","2020-05-01:1,2020-05-02:3","2020-05-01:30,2020-05-02:32","2020-05-01:1.100000,2020-05-02:1.300000","2020-05-01:2.100000,2020-05-02:2.300000"] + - [4,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [3,"aa","a:1,b:3","a:1,b:3","a:30,b:32","a:1.100000,b:1.300000","a:2.100000,b:2.300000"] + - [4,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - + id: 29 + desc: count_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + count_cate_where({0}.c2,{0}.c10,d[0]) OVER w1 as m2, + count_cate_where({0}.c3,{0}.c10,d[0]) OVER w1 as m3, + count_cate_where({0}.c4,{0}.c10,d[0]) OVER w1 as m4, + count_cate_where({0}.c5,{0}.c10,d[0]) OVER w1 as m5, + count_cate_where({0}.c6,{0}.c10,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:1","1:1","1:1"] + - [2,"aa","1:1","1:1","1:1","1:1","1:1"] + - [3,"aa","1:1,2:1","1:1,2:1","1:1,2:1","1:1,2:1","1:1,2:1"] + - [4,"aa","2:1","2:1","2:1","2:1","2:1"] + 1: + rows: + - [1,"aa","1:1","1:1","1:1","1:1","1:1"] + - [2,"aa","1:1","1:1","1:1","1:1","1:1"] + - [3,"aa","1:1,2:1","1:1,2:1","1:1,2:1","1:1,2:1","1:1,2:1"] + - [4,"aa","2:1","2:1","2:1","2:1","2:1"] + 2: + rows: + - [1,"aa","30:1","30:1","30:1","30:1","30:1"] + - [2,"aa","30:1","30:1","30:1","30:1","30:1"] + - [3,"aa","30:1,32:1","30:1,32:1","30:1,32:1","30:1,32:1","30:1,32:1"] + - [4,"aa","32:1","32:1","32:1","32:1","32:1"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1"] + - [3,"aa","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1","2020-05-29 15:56:30:1,2020-05-29 15:56:32:1"] + - [4,"aa","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1"] + - [3,"aa","2020-05-01:1,2020-05-02:1","2020-05-01:1,2020-05-02:1","2020-05-01:1,2020-05-02:1","2020-05-01:1,2020-05-02:1","2020-05-01:1,2020-05-02:1"] + - [4,"aa","2020-05-02:1","2020-05-02:1","2020-05-02:1","2020-05-02:1","2020-05-02:1"] + 5: + rows: + - [1,"aa","a:1","a:1","a:1","a:1","a:1"] + - [2,"aa","a:1","a:1","a:1","a:1","a:1"] + - [3,"aa","a:1,b:1","a:1,b:1","a:1,b:1","a:1,b:1","a:1,b:1"] + - [4,"aa","b:1","b:1","b:1","b:1","b:1"] + - + id: 30 + desc: sum_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + sum_cate_where({0}.c2,{0}.c10,d[0]) OVER w1 as m2, + sum_cate_where({0}.c3,{0}.c10,d[0]) OVER w1 as m3, + sum_cate_where({0}.c4,{0}.c10,d[0]) OVER w1 as m4, + sum_cate_where({0}.c5,{0}.c10,d[0]) OVER w1 as m5, + sum_cate_where({0}.c6,{0}.c10,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","1:1,2:3","1:1,2:3","1:30,2:32","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","1:1,2:3","1:1,2:3","1:30,2:32","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [3,"aa","30:1,32:3","30:1,32:3","30:30,32:32","30:1.100000,32:1.300000","30:2.100000,32:2.300000"] + - [4,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:30:1,2020-05-29 15:56:32:3","2020-05-29 15:56:30:1,2020-05-29 15:56:32:3","2020-05-29 15:56:30:30,2020-05-29 15:56:32:32","2020-05-29 15:56:30:1.100000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.100000,2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-01:1,2020-05-02:3","2020-05-01:1,2020-05-02:3","2020-05-01:30,2020-05-02:32","2020-05-01:1.100000,2020-05-02:1.300000","2020-05-01:2.100000,2020-05-02:2.300000"] + - [4,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [3,"aa","a:1,b:3","a:1,b:3","a:30,b:32","a:1.100000,b:1.300000","a:2.100000,b:2.300000"] + - [4,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - + id: 31 + desc: avg_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + avg_cate_where({0}.c2,{0}.c10,d[0]) OVER w1 as m2, + avg_cate_where({0}.c3,{0}.c10,d[0]) OVER w1 as m3, + avg_cate_where({0}.c4,{0}.c10,d[0]) OVER w1 as m4, + avg_cate_where({0}.c5,{0}.c10,d[0]) OVER w1 as m5, + avg_cate_where({0}.c6,{0}.c10,d[0]) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [2,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [3,"aa","1:1.000000,2:3.000000","1:1.000000,2:3.000000","1:30.000000,2:32.000000","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","2:3.000000","2:3.000000","2:32.000000","2:1.300000","2:2.300000"] + 1: + rows: + - [1,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [2,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [3,"aa","1:1.000000,2:3.000000","1:1.000000,2:3.000000","1:30.000000,2:32.000000","1:1.100000,2:1.300000","1:2.100000,2:2.300000"] + - [4,"aa","2:3.000000","2:3.000000","2:32.000000","2:1.300000","2:2.300000"] + 2: + rows: + - [1,"aa","30:1.000000","30:1.000000","30:30.000000","30:1.100000","30:2.100000"] + - [2,"aa","30:1.000000","30:1.000000","30:30.000000","30:1.100000","30:2.100000"] + - [3,"aa","30:1.000000,32:3.000000","30:1.000000,32:3.000000","30:30.000000,32:32.000000","30:1.100000,32:1.300000","30:2.100000,32:2.300000"] + - [4,"aa","32:3.000000","32:3.000000","32:32.000000","32:1.300000","32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:30.000000","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:30.000000","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:30:1.000000,2020-05-29 15:56:32:3.000000","2020-05-29 15:56:30:1.000000,2020-05-29 15:56:32:3.000000","2020-05-29 15:56:30:30.000000,2020-05-29 15:56:32:32.000000","2020-05-29 15:56:30:1.100000,2020-05-29 15:56:32:1.300000","2020-05-29 15:56:30:2.100000,2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:32:3.000000","2020-05-29 15:56:32:3.000000","2020-05-29 15:56:32:32.000000","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1.000000","2020-05-01:1.000000","2020-05-01:30.000000","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1.000000","2020-05-01:1.000000","2020-05-01:30.000000","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-01:1.000000,2020-05-02:3.000000","2020-05-01:1.000000,2020-05-02:3.000000","2020-05-01:30.000000,2020-05-02:32.000000","2020-05-01:1.100000,2020-05-02:1.300000","2020-05-01:2.100000,2020-05-02:2.300000"] + - [4,"aa","2020-05-02:3.000000","2020-05-02:3.000000","2020-05-02:32.000000","2020-05-02:1.300000","2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1.000000","a:1.000000","a:30.000000","a:1.100000","a:2.100000"] + - [2,"aa","a:1.000000","a:1.000000","a:30.000000","a:1.100000","a:2.100000"] + - [3,"aa","a:1.000000,b:3.000000","a:1.000000,b:3.000000","a:30.000000,b:32.000000","a:1.100000,b:1.300000","a:2.100000,b:2.300000"] + - [4,"aa","b:3.000000","b:3.000000","b:32.000000","b:1.300000","b:2.300000"] + - + id: 32 + desc: "*_cate_where-fail1" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["avg_cate_where","sum_cate_where","max_cate_where","min_cate_where","count_cate_where"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6"] + - ["{1}.c5","{1}.c6","{1}.c10"] + sql: | + SELECT {0}.id, {0}.c1, + d[0](d[1],{0}.c10,d[2]) OVER w1 as m2 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 33 + desc: "*_cate_where-fail2" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["avg_cate_where","sum_cate_where","max_cate_where","min_cate_where","count_cate_where"] + - ["{0}.c7","{0}.c8","{0}.c9","{0}.c10"] + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c5","{1}.c6","{1}.c7","{1}.c8","{1}.c9","{1}.c10"] + sql: | + SELECT {0}.id, {0}.c1, + d[0](d[1],{0}.c10,d[2]) OVER w1 as m2 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 34 + desc: top_n_key_max_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + top_n_key_max_cate_where({0}.c2,{0}.c10,d[0],1) OVER w1 as m2, + top_n_key_max_cate_where({0}.c3,{0}.c10,d[0],1) OVER w1 as m3, + top_n_key_max_cate_where({0}.c4,{0}.c10,d[0],1) OVER w1 as m4, + top_n_key_max_cate_where({0}.c5,{0}.c10,d[0],1) OVER w1 as m5, + top_n_key_max_cate_where({0}.c6,{0}.c10,d[0],1) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [3,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + - [4,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + - [4,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [3,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - [4,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - + id: 35 + desc: top_n_key_min_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + top_n_key_min_cate_where({0}.c2,{0}.c10,d[0],1) OVER w1 as m2, + top_n_key_min_cate_where({0}.c3,{0}.c10,d[0],1) OVER w1 as m3, + top_n_key_min_cate_where({0}.c4,{0}.c10,d[0],1) OVER w1 as m4, + top_n_key_min_cate_where({0}.c5,{0}.c10,d[0],1) OVER w1 as m5, + top_n_key_min_cate_where({0}.c6,{0}.c10,d[0],1) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [3,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + - [4,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + - [4,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [3,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - [4,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - + id: 36 + desc: top_n_key_sum_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + top_n_key_sum_cate_where({0}.c2,{0}.c10,d[0],1) OVER w1 as m2, + top_n_key_sum_cate_where({0}.c3,{0}.c10,d[0],1) OVER w1 as m3, + top_n_key_sum_cate_where({0}.c4,{0}.c10,d[0],1) OVER w1 as m4, + top_n_key_sum_cate_where({0}.c5,{0}.c10,d[0],1) OVER w1 as m5, + top_n_key_sum_cate_where({0}.c6,{0}.c10,d[0],1) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 1: + rows: + - [1,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [2,"aa","1:1","1:1","1:30","1:1.100000","1:2.100000"] + - [3,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + - [4,"aa","2:3","2:3","2:32","2:1.300000","2:2.300000"] + 2: + rows: + - [1,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [2,"aa","30:1","30:1","30:30","30:1.100000","30:2.100000"] + - [3,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + - [4,"aa","32:3","32:3","32:32","32:1.300000","32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:30","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:32:3","2020-05-29 15:56:32:3","2020-05-29 15:56:32:32","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:30","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + - [4,"aa","2020-05-02:3","2020-05-02:3","2020-05-02:32","2020-05-02:1.300000","2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [2,"aa","a:1","a:1","a:30","a:1.100000","a:2.100000"] + - [3,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - [4,"aa","b:3","b:3","b:32","b:1.300000","b:2.300000"] + - + id: 37 + desc: top_n_key_avg_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + top_n_key_avg_cate_where({0}.c2,{0}.c10,d[0],1) OVER w1 as m2, + top_n_key_avg_cate_where({0}.c3,{0}.c10,d[0],1) OVER w1 as m3, + top_n_key_avg_cate_where({0}.c4,{0}.c10,d[0],1) OVER w1 as m4, + top_n_key_avg_cate_where({0}.c5,{0}.c10,d[0],1) OVER w1 as m5, + top_n_key_avg_cate_where({0}.c6,{0}.c10,d[0],1) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [2,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [3,"aa","2:3.000000","2:3.000000","2:32.000000","2:1.300000","2:2.300000"] + - [4,"aa","2:3.000000","2:3.000000","2:32.000000","2:1.300000","2:2.300000"] + 1: + rows: + - [1,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [2,"aa","1:1.000000","1:1.000000","1:30.000000","1:1.100000","1:2.100000"] + - [3,"aa","2:3.000000","2:3.000000","2:32.000000","2:1.300000","2:2.300000"] + - [4,"aa","2:3.000000","2:3.000000","2:32.000000","2:1.300000","2:2.300000"] + 2: + rows: + - [1,"aa","30:1.000000","30:1.000000","30:30.000000","30:1.100000","30:2.100000"] + - [2,"aa","30:1.000000","30:1.000000","30:30.000000","30:1.100000","30:2.100000"] + - [3,"aa","32:3.000000","32:3.000000","32:32.000000","32:1.300000","32:2.300000"] + - [4,"aa","32:3.000000","32:3.000000","32:32.000000","32:1.300000","32:2.300000"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:30.000000","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [2,"aa","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:1.000000","2020-05-29 15:56:30:30.000000","2020-05-29 15:56:30:1.100000","2020-05-29 15:56:30:2.100000"] + - [3,"aa","2020-05-29 15:56:32:3.000000","2020-05-29 15:56:32:3.000000","2020-05-29 15:56:32:32.000000","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + - [4,"aa","2020-05-29 15:56:32:3.000000","2020-05-29 15:56:32:3.000000","2020-05-29 15:56:32:32.000000","2020-05-29 15:56:32:1.300000","2020-05-29 15:56:32:2.300000"] + 4: + rows: + - [1,"aa","2020-05-01:1.000000","2020-05-01:1.000000","2020-05-01:30.000000","2020-05-01:1.100000","2020-05-01:2.100000"] + - [2,"aa","2020-05-01:1.000000","2020-05-01:1.000000","2020-05-01:30.000000","2020-05-01:1.100000","2020-05-01:2.100000"] + - [3,"aa","2020-05-02:3.000000","2020-05-02:3.000000","2020-05-02:32.000000","2020-05-02:1.300000","2020-05-02:2.300000"] + - [4,"aa","2020-05-02:3.000000","2020-05-02:3.000000","2020-05-02:32.000000","2020-05-02:1.300000","2020-05-02:2.300000"] + 5: + rows: + - [1,"aa","a:1.000000","a:1.000000","a:30.000000","a:1.100000","a:2.100000"] + - [2,"aa","a:1.000000","a:1.000000","a:30.000000","a:1.100000","a:2.100000"] + - [3,"aa","b:3.000000","b:3.000000","b:32.000000","b:1.300000","b:2.300000"] + - [4,"aa","b:3.000000","b:3.000000","b:32.000000","b:1.300000","b:2.300000"] + - + id: 38 + desc: top_n_key_count_cate_where-normal + mode: cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c7","{1}.c8","{1}.c9"] + sql: | + SELECT {0}.id, {0}.c1, + top_n_key_count_cate_where({0}.c2,{0}.c10,d[0],1) OVER w1 as m2, + top_n_key_count_cate_where({0}.c3,{0}.c10,d[0],1) OVER w1 as m3, + top_n_key_count_cate_where({0}.c4,{0}.c10,d[0],1) OVER w1 as m4, + top_n_key_count_cate_where({0}.c5,{0}.c10,d[0],1) OVER w1 as m5, + top_n_key_count_cate_where({0}.c6,{0}.c10,d[0],1) OVER w1 as m6 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 string","m3 string","m4 string","m5 string","m6 string"] + expectProvider: + 0: + rows: + - [1,"aa","1:1","1:1","1:1","1:1","1:1"] + - [2,"aa","1:1","1:1","1:1","1:1","1:1"] + - [3,"aa","2:1","2:1","2:1","2:1","2:1"] + - [4,"aa","2:1","2:1","2:1","2:1","2:1"] + 1: + rows: + - [1,"aa","1:1","1:1","1:1","1:1","1:1"] + - [2,"aa","1:1","1:1","1:1","1:1","1:1"] + - [3,"aa","2:1","2:1","2:1","2:1","2:1"] + - [4,"aa","2:1","2:1","2:1","2:1","2:1"] + 2: + rows: + - [1,"aa","30:1","30:1","30:1","30:1","30:1"] + - [2,"aa","30:1","30:1","30:1","30:1","30:1"] + - [3,"aa","32:1","32:1","32:1","32:1","32:1"] + - [4,"aa","32:1","32:1","32:1","32:1","32:1"] + 3: + rows: + - [1,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1"] + - [2,"aa","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1","2020-05-29 15:56:30:1"] + - [3,"aa","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1"] + - [4,"aa","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1","2020-05-29 15:56:32:1"] + 4: + rows: + - [1,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1"] + - [2,"aa","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1","2020-05-01:1"] + - [3,"aa","2020-05-02:1","2020-05-02:1","2020-05-02:1","2020-05-02:1","2020-05-02:1"] + - [4,"aa","2020-05-02:1","2020-05-02:1","2020-05-02:1","2020-05-02:1","2020-05-02:1"] + 5: + rows: + - [1,"aa","a:1","a:1","a:1","a:1","a:1"] + - [2,"aa","a:1","a:1","a:1","a:1","a:1"] + - [3,"aa","b:1","b:1","b:1","b:1","b:1"] + - [4,"aa","b:1","b:1","b:1","b:1","b:1"] + - + id: 39 + desc: "top_n_key_*_cate_where-fail1" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["top_n_key_count_cate_where","top_n_key_sum_cate_where","top_n_key_avg_cate_where","top_n_key_max_cate_where","top_n_key_min_cate_where"] + - ["{0}.c2","{0}.c3","{0}.c4","{0}.c5","{0}.c6"] + - ["{1}.c5","{1}.c6","{1}.c10"] + sql: | + SELECT {0}.id, {0}.c1, + d[0](d[1],{0}.c10,d[2],1) OVER w1 as m2 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 40 + desc: "top_n_key_*_cate_where-fail2" + sqlDialect: ["HybridSQL"] + level: 5 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:c7","index2:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + - + columns : ["id int","timecol bigint","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:id:timecol"] + rows: + - [1,1,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,2,1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [3,3,2,2,32,1.3,2.3,1590738992000,"2020-05-02","b",false] + - [4,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + dataProvider: + - ["top_n_key_count_cate_where","top_n_key_sum_cate_where","top_n_key_avg_cate_where","top_n_key_max_cate_where","top_n_key_min_cate_where"] + - ["{0}.c7","{0}.c8","{0}.c9","{0}.c10"] + - ["{1}.c2","{1}.c3","{1}.c4","{1}.c5","{1}.c6","{1}.c7","{1}.c8","{1}.c9","{1}.c10"] + sql: | + SELECT {0}.id, {0}.c1, + d[0](d[1],{0}.c10,d[2],1) OVER w1 as m2 + FROM {0} last join {1} ORDER BY {1}.timecol on {0}.id={1}.id + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 41 + desc: arithmetic_and_udf_before_udaf + inputs: + - columns: ["id bigint", "c1 double", "c2 float", "c3 int"] + indexs: ["index1:c3:id"] + rows: + - [1, 10.0, 1.0, 5] + - [2, 9.0, 2.0, 5] + - [3, 8.0, 3.0, 5] + - [4, 7.0, 4.0, 2] + - [5, 6.0, 5.0, 2] + sql: | + SELECT {0}.id, + sum((c1 - c2) / c3) OVER w1 AS r1, + sum(log(c1 + c2) + c3) OVER w1 as r2 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint","r1 double", "r2 double"] + rows: + - [1, 1.8, 7.3978952727983707] + - [2, 3.2, 14.795790545596741] + - [3, 4.2, 22.19368581839511] + - [4, 1.5, 4.3978952727983707] + - [5, 2.0, 8.7957905455967413] + + - id: 42 + desc: arithmetic_and_udf_after_udaf + sqlDialect: ["HybridSQL"] + tags: ["目前只能f(udaf()) over w,否则无法进入window agg节点"] + inputs: + - columns: ["id bigint", "c1 double", "c2 float", "c3 int"] + indexs: ["index1:c3:id"] + rows: + - [1, 10.0, 1.0, 5] + - [2, 9.0, 2.0, 5] + - [3, 8.0, 3.0, 5] + - [4, 7.0, 4.0, 2] + - [5, 6.0, 5.0, 2] + sql: | + SELECT {0}.id, + abs(sum(c3)) OVER w1 as r1, + log((sum(c1) + sum(c2)) / c3) OVER w1 AS r2 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint","r1 int", "r2 double"] + rows: + - [1, 5, 0.78845736036427028] + - [2, 10, 1.4816045409242156] + - [3, 15, 1.8870696490323797] + - [4, 2, 1.7047480922384253] + - [5, 4, 2.3978952727983707] + + - id: 43 + desc: nested udaf + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["id bigint", "c1 double", "c2 float", "c3 int"] + indexs: ["index1:c3:id"] + rows: + - [1, 10.0, 1.0, 5] + - [2, 9.0, 2.0, 5] + - [3, 8.0, 3.0, 5] + - [4, 7.0, 4.0, 2] + - [5, 6.0, 5.0, 2] + sql: | + SELECT {0}.id, + sum(c1 - count(c1)) OVER w1 AS r1, + abs(sum(log(c1) - log(count(c1)))) OVER w1 AS r2, + sum(c1 + sum(c2 * count(c3))) OVER w1 AS r3 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint","r1 double", "r2 double", "r3 double"] + rows: + - [1, 9.0, 2.3025850929940459, 11.0] + - [2, 15.0, 3.1135153092103747, 31.0] + - [3, 18.0, 3.2834143460057721, 81.0] + - [4, 6.0, 1.9459101490553132, 11.0] + - [5, 9.0, 2.3513752571634776, 49.0] + + - id: 44 + desc: cast after udaf + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["id bigint", "c1 double", "c2 float", "c3 int"] + indexs: ["index1:c3:id"] + rows: + - [1, 10.0, 1.0, 5] + - [2, 9.0, 2.0, 5] + - [3, 8.0, 3.0, 5] + - [4, 7.0, 4.0, 2] + - [5, 6.0, 5.0, 2] + sql: | + SELECT {0}.id, c3, + CAST(sum(c1) OVER w1 AS string) AS r1, + string(sum(c1) OVER w1) AS r2, + `string`(sum(c1) OVER w1) AS r3 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint", "c3 int", "r1 string", "r2 string", "r3 string"] + rows: + - [1, 5, "10", "10", "10"] + - [2, 5, "19", "19", "19"] + - [3, 5, "27", "27", "27"] + - [4, 2, "7", "7", "7"] + - [5, 2, "13", "13", "13"] + + - id: 45 + desc: aggregate where + sqlDialect: ["HybridSQL"] + mode: request-unsupport + inputs: + - columns: ["id bigint", "c1 double", "c2 float", "c3 bigint"] + indexs: ["index1:c3:id"] + rows: + - [1, 1.0, 1.1, 0] + - [2, 2.0, 7.7, 0] + - [3, NULL, 0.1, 0] + - [4, 3.0, NULL, 0] + - [5, 4.0, 5.5, 0] + - [6, 5.0, 3.3, 1] + - [7, NULL, 2.2, 1] + - [8, 7.0, NULL, 1] + - [9, 8.0, 4.4, 1] + sql: | + SELECT {0}.id, + count_where(c1, c1 < c2) OVER w1 AS count_where_1, + avg_where(c1, c1 < c2) OVER w1 AS avg_where_1, + count_where(c2, c2 > 4) OVER w1 AS count_where_2, + avg_where(c2, c2 > 4) OVER w1 AS avg_where_2 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint", "count_where_1 bigint", "avg_where_1 double", "count_where_2 bigint", "avg_where_2 double"] + rows: + - [1, 1, 1.0, 0, NULL] + - [2, 2, 1.5, 1, 7.6999998092651367] + - [3, 2, 1.5, 1, 7.6999998092651367] + - [4, 2, 1.5, 1, 7.6999998092651367] + - [5, 3, 2.3333333333333335, 2, 6.5999999046325684] + - [6, 0, NULL, 0, NULL] + - [7, 0, NULL, 0, NULL] + - [8, 0, NULL, 0, NULL] + - [9, 0, NULL, 1, 4.4000000953674316] + + - id: 46 + desc: window lag functions + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","pk bigint","c1 string","c2 int","c3 bigint","c4 float", + "c5 double","c6 timestamp","c7 date","c8 bool"] + indexs: ["index1:pk:c6"] + rows: + - [1, 1, "a", 1, 30, 1.1, 2.1, 1590738990000, "2020-05-01", true] + - [2, 1, "c", 4, 33, 1.4, 2.4, 1590738991000, "2020-05-03", false] + - [3, 1, "b", 3, 32, 1.3, 2.3, 1590738992000, "2020-05-02", true,] + - [4, 1, NULL, NULL, NULL, NULL, NULL, 1590738993000, NULL, NULL] + - [5, 1, "d", 5, 35, 1.5, 2.5, 1590738994000, "2020-05-04", false] + sql: | + SELECT {0}.id, + lag(c1, 0) OVER w1 as m1, + lag(c1, 2) OVER w1 as m2, + lag(c2, 0) OVER w1 as m3, + lag(c2, 2) OVER w1 as m4, + lag(c3, 0) OVER w1 as m5, + lag(c3, 2) OVER w1 as m6, + lag(c4, 0) OVER w1 as m7, + lag(c4, 2) OVER w1 as m8, + lag(c5, 0) OVER w1 as m9, + lag(c5, 2) OVER w1 as m10, + lag(c6, 0) OVER w1 as m11, + lag(c6, 2) OVER w1 as m12, + lag(c7, 0) OVER w1 as m13, + lag(c7, 2) OVER w1 as m14, + lag(c8, 0) OVER w1 as m15, + lag(c8, 2) OVER w1 as m16 + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.pk ORDER BY {0}.c6 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","m1 string", "m2 string", "m3 int", "m4 int", "m5 bigint", "m6 bigint", + "m7 float", "m8 float", "m9 double", "m10 double", + "m11 timestamp", "m12 timestamp", "m13 date", "m14 date", "m15 bool", "m16 bool"] + rows: + - [1, "a", NULL, 1, NULL, 30, NULL, 1.1, NULL, 2.1, NULL, + 1590738990000, NULL, "2020-05-01", NULL, true, NULL] + - [2, "c", NULL, 4, NULL, 33, NULL, 1.4, NULL, 2.4, NULL, + 1590738991000, NULL, "2020-05-03", NULL, false, NULL] + - [3, "b", "a", 3, 1, 32, 30, 1.3, 1.1, 2.3, 2.1, + 1590738992000, 1590738990000, "2020-05-02", "2020-05-01", true, true] + - [4, NULL, "c", NULL, 4, NULL, 33, NULL, 1.4, NULL, 2.4, + 1590738993000, 1590738991000, NULL, "2020-05-03", NULL, false] + - [5, "d", "b", 5, 3, 35, 32, 1.5, 1.3, 2.5, 2.3, + 1590738994000, 1590738992000, "2020-05-04", "2020-05-02", false, true] + + - id: 47 + desc: count where value equals first value + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["id bigint", "pk bigint", "c1 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 0, "a"] + - [2, 0, "b"] + - [3, 0, "c"] + - [4, 0, NULL] + - [5, 0, "b"] + - [6, 0, NULL] + - [7, 0, "c"] + - [8, 0, "a"] + - [9, 0, NULL] + - [10, 0, "c"] + - [11, 0, "a"] + - [12, 0, "b"] + sql: | + SELECT {0}.id, + count_where(id, ifnull(c1, "a") = ifnull(first_value(c1), "a")) OVER w1 AS count_where + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint", "count_where bigint"] + rows: + - [1, 1] + - [2, 1] + - [3, 1] + - [4, 2] + - [5, 2] + - [6, 3] + - [7, 2] + - [8, 4] + - [9, 5] + - [10, 3] + - [11, 6] + - [12, 3] + - id: 48 + desc: count where value equals lag + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["id bigint", "pk bigint", "c1 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 0, "a"] + - [2, 0, "b"] + - [3, 0, "c"] + - [4, 0, NULL] + - [5, 0, "b"] + - [6, 0, NULL] + - [7, 0, "c"] + - [8, 0, "a"] + - [9, 0, NULL] + - [10, 0, "c"] + - [11, 0, "a"] + - [12, 0, "b"] + - [13, 0, "a"] + - [14, 0, "a"] + sql: | + SELECT {0}.id, + count_where(id, ifnull(c1, "a") = ifnull(lag(c1, 0), "a")) OVER w1 AS count_where_w1, + count_where(id, ifnull(c1, "a") = ifnull(lag(c1, 0), "a")) OVER w2 AS count_where_w2 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS_RANGE BETWEEN 100s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint", "count_where_w1 bigint", "count_where_w2 bigint"] + rows: + - [1, 1, 1] + - [2, 1, 1] + - [3, 1, 1] + - [4, 2, 2] + - [5, 2, 2] + - [6, 3, 3] + - [7, 2, 2] + - [8, 4, 4] + - [9, 5, 5] + - [10, 3, 3] + - [11, 6, 6] + - [12, 3, 3] + - [13, 6, 7] + - [14, 7, 8] + - id: 49 + desc: count where value equals case when lag + sqlDialect: ["HybridSQL"] + inputs: + - columns: ["id bigint", "pk bigint", "c1 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 0, "a"] + - [2, 0, "b"] + - [3, 0, "c"] + - [4, 0, NULL] + - [5, 0, "b"] + - [6, 0, NULL] + - [7, 0, "c"] + - [8, 0, "a"] + - [9, 0, NULL] + - [10, 0, "c"] + - [11, 0, "a"] + - [12, 0, "b"] + - [13, 0, "a"] + - [14, 0, "a"] + sql: | + SELECT {0}.id, + case when !isnull(lag(c1,0)) OVER w1 then count_where(id, c1 = lag(c1, 0)) OVER w1 else null end AS count_where_w1, + case when !isnull(lag(c1,0)) OVER w2 then count_where(id, c1 = lag(c1, 0)) OVER w2 else null end AS count_where_w2 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS_RANGE BETWEEN 100s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint", "count_where_w1 bigint", "count_where_w2 bigint"] + rows: + - [1, 1, 1] + - [2, 1, 1] + - [3, 1, 1] + - [4, NULL, NULL] + - [5, 2, 2] + - [6, NULL, NULL] + - [7, 2, 2] + - [8, 2, 2] + - [9, NULL, NULL] + - [10, 3, 3] + - [11, 3, 3] + - [12, 3, 3] + - [13, 3, 4] + - [14, 4, 5] + - + id: 50 + desc: 重复的聚合表达式 + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w1 as w1_c4_sum2 + FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint", "w1_c4_sum2 bigint"] + rows: + - ["aa",20,30, 30] + - ["aa",21,61, 61] + - ["aa",22,93, 93] + - ["aa",23,96, 96] + - ["bb",24,34, 34] + + - + id: 51 + desc: 重复的聚合表达式 + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w1 as w1_c4_sum2 + FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint", "w1_c4_sum2 bigint"] + rows: + - ["aa",20,30, 30] + - ["aa",21,61, 61] + - ["aa",22,93, 93] + - ["aa",23,96, 96] + - ["bb",24,34, 34] + + - id: 52 + desc: 多个可合并窗口上的多个聚合函数计算 + sqlDialect: ["HybridSQL"] + version: 0.6.0 + sql: | + SELECT {0}.id, pk, col1, std_ts, + distinct_count(col1) OVER w1 as a1, + distinct_count(col1) OVER w2 as a2, + distinct_count(col1) OVER w3 as a3, + sum(col1 * 1.0) OVER w1 as b1, + sum(col1 * 1.0) OVER w2 as b2, + sum(col1 * 1.0) OVER w3 as b3 + FROM {0} WINDOW + w1 AS (PARTITION BY pk ORDER BY std_ts ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY pk ORDER BY std_ts ROWS BETWEEN 4 PRECEDING AND 3 PRECEDING), + w3 AS (PARTITION BY pk ORDER BY std_ts ROWS BETWEEN 6 PRECEDING AND 5 PRECEDING); + inputs: + - + columns: ["id int", "pk string", "col1 int32", "std_ts timestamp"] + indexs: ["index1:pk:std_ts"] + rows: + - [1, A, 1, 1590115420000] + - [2, A, 1, 1590115430000] + - [3, A, 2, 1590115440000] + - [4, A, 2, 1590115450000] + - [5, A, 2, 1590115460000] + - [6, A, 3, 1590115470000] + - [7, A, 3, 1590115480000] + - [8, A, 3, 1590115490000] + - [9, A, 3, 1590115500000] + - [10, B, 1, 1590115420000] + - [11, B, 2, 1590115430000] + - [12, B, 3, 1590115440000] + - [13, B, 4, 1590115450000] + - [14, B, 5, 1590115460000] + expect: + columns: ["id int32", "pk string", "col1 int32", "std_ts timestamp", + "a1 bigint", "a2 bigint", "a3 bigint", + "b1 double" ,"b2 double", "b3 double"] + order: id + rows: + - [1, A, 1, 1590115420000, 1, 0, 0, 1.0, NULL, NULL] + - [2, A, 1, 1590115430000, 1, 0, 0, 2.0, NULL, NULL] + - [3, A, 2, 1590115440000, 2, 0, 0, 4.0, NULL, NULL] + - [4, A, 2, 1590115450000, 2, 1, 0, 5.0, 1.0, NULL] + - [5, A, 2, 1590115460000, 1, 1, 0, 6.0, 2.0, NULL] + - [6, A, 3, 1590115470000, 2, 2, 1, 7.0, 3.0, 1.0] + - [7, A, 3, 1590115480000, 2, 1, 1, 8.0, 4.0, 2.0] + - [8, A, 3, 1590115490000, 1, 1, 2, 9.0, 4.0, 3.0] + - [9, A, 3, 1590115500000, 1, 2, 1, 9.0, 5.0, 4.0] + - [10, B, 1, 1590115420000, 1, 0, 0, 1.0, NULL, NULL] + - [11, B, 2, 1590115430000, 2, 0, 0, 3.0, NULL, NULL] + - [12, B, 3, 1590115440000, 3, 0, 0, 6.0, NULL, NULL] + - [13, B, 4, 1590115450000, 3, 1, 0, 9.0, 1.0, NULL] + - [14, B, 5, 1590115460000, 3, 2, 0, 12.0, 3.0, NULL] + + - id: 53 + desc: 同窗口下多类聚合函数 + sqlDialect: ["HybridSQL"] + version: 0.6.0 + sql: | + SELECT {0}.id, pk, col1, std_ts, + sum(col1 + count(col1)) OVER w as a1, + distinct_count(col1) OVER w as a2, + sum_where(col1, std_ts > timestamp(1590115440000)) OVER w as a3, + count_where(col1, std_ts > timestamp(1590115440000)) OVER w as a4, + avg_where(col1, std_ts > timestamp(1590115440000)) OVER w as a5, + sum(col1) OVER w as a6, + count(col1) OVER w as a7, + fz_topn_frequency(id, 3) OVER w as a8 + FROM {0} WINDOW + w AS (PARTITION BY pk ORDER BY std_ts ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + inputs: + - + columns: ["id int", "pk string", "col1 int32", "std_ts timestamp"] + indexs: ["index1:pk:std_ts"] + rows: + - [1, A, 1, 1590115420000] + - [2, A, 2, 1590115430000] + - [3, A, 3, 1590115440000] + - [4, A, 4, 1590115450000] + - [5, A, 5, 1590115460000] + expect: + columns: ["id int32", "pk string", "col1 int32", "std_ts timestamp", + "a1 bigint", "a2 bigint", "a3 int32", "a4 bigint", + "a5 double" ,"a6 int32", "a7 bigint", "a8 string"] + order: id + rows: + - [1, A, 1, 1590115420000, 2, 1, null, 0, null, 1, 1, "1,NULL,NULL"] + - [2, A, 2, 1590115430000, 7, 2, null, 0, null, 3, 2, "1,2,NULL"] + - [3, A, 3, 1590115440000, 15, 3, null, 0, null, 6, 3, "1,2,3"] + - [4, A, 4, 1590115450000, 18, 3, 4, 1, 4.0, 9, 3, "2,3,4"] + - [5, A, 5, 1590115460000, 21, 3, 9, 2, 4.5, 12, 3, "3,4,5"] + + - id: 54 + desc: max空窗口 + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float", + "c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, max(c2) OVER w1 as m2, max(c3) OVER w1 as m3, max(c4) OVER w1 as m4, + max(c5) OVER w1 as m5,max(c6) OVER w1 as m6,max(c7) OVER w1 as m7, + max(c8) OVER w1 as m8,max(c9) OVER w1 as m9 + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","m2 smallint","m3 int","m4 bigint","m5 float", + "m6 double","m7 timestamp","m8 date","m9 string"] + rows: + - [1,"aa",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + - [2,"aa",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + - [3,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [4,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c"] + + - id: 55 + desc: min空窗口 + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, min(c2) OVER w1 as m2,min(c3) OVER w1 as m3,min(c4) OVER w1 as m4,min(c5) OVER w1 as m5,min(c6) OVER w1 as m6,min(c7) OVER w1 as m7,min(c8) OVER w1 as m8,min(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 4 PRECEDING AND 2 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","m2 smallint","m3 int","m4 bigint","m5 float","m6 double","m7 timestamp","m8 date","m9 string"] + rows: + - [1,"aa",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + - [2,"aa",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL] + - [3,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - [4,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a"] + - id: 56 + desc: window at functions, at is synonym to lag + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int","pk bigint","c1 string","c2 int","c3 bigint","c4 float", + "c5 double","c6 timestamp","c7 date","c8 bool"] + indexs: ["index1:pk:c6"] + rows: + - [1, 1, "a", 1, 30, 1.1, 2.1, 1590738990000, "2020-05-01", true] + - [2, 1, "c", 4, 33, 1.4, 2.4, 1590738991000, "2020-05-03", false] + - [3, 1, "b", 3, 32, 1.3, 2.3, 1590738992000, "2020-05-02", true,] + - [4, 1, NULL, NULL, NULL, NULL, NULL, 1590738993000, NULL, NULL] + - [5, 1, "d", 5, 35, 1.5, 2.5, 1590738994000, "2020-05-04", false] + sql: | + SELECT {0}.id, + at(c1, 0) OVER w1 as m1, + at(c1, 2) OVER w1 as m2, + at(c2, 0) OVER w1 as m3, + at(c2, 2) OVER w1 as m4, + at(c3, 0) OVER w1 as m5, + at(c3, 2) OVER w1 as m6, + at(c4, 0) OVER w1 as m7, + at(c4, 2) OVER w1 as m8, + at(c5, 0) OVER w1 as m9, + at(c5, 2) OVER w1 as m10, + at(c6, 0) OVER w1 as m11, + at(c6, 2) OVER w1 as m12, + at(c7, 0) OVER w1 as m13, + at(c7, 2) OVER w1 as m14, + at(c8, 0) OVER w1 as m15, + at(c8, 2) OVER w1 as m16 + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.pk ORDER BY {0}.c6 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","m1 string", "m2 string", "m3 int", "m4 int", "m5 bigint", "m6 bigint", + "m7 float", "m8 float", "m9 double", "m10 double", + "m11 timestamp", "m12 timestamp", "m13 date", "m14 date", "m15 bool", "m16 bool"] + rows: + - [1, "a", NULL, 1, NULL, 30, NULL, 1.1, NULL, 2.1, NULL, + 1590738990000, NULL, "2020-05-01", NULL, true, NULL] + - [2, "c", NULL, 4, NULL, 33, NULL, 1.4, NULL, 2.4, NULL, + 1590738991000, NULL, "2020-05-03", NULL, false, NULL] + - [3, "b", "a", 3, 1, 32, 30, 1.3, 1.1, 2.3, 2.1, + 1590738992000, 1590738990000, "2020-05-02", "2020-05-01", true, true] + - [4, NULL, "c", NULL, 4, NULL, 33, NULL, 1.4, NULL, 2.4, + 1590738993000, 1590738991000, NULL, "2020-05-03", NULL, false] + - [5, "d", "b", 5, 3, 35, 32, 1.5, 1.3, 2.5, 2.3, + 1590738994000, 1590738992000, "2020-05-04", "2020-05-02", false, true] + + - id: 57 + desc: | + correctness for at/lag when offset out-of-range rows_range window frame bound. + keynote, lag returns value evaluated at the row that is offset rows before the current row within the partition. + refer https://github.com/4paradigm/OpenMLDB/issues/1554 + inputs: + - columns: [ "id int","ts timestamp","group1 string","val1 int" ] + indexs: [ "index1:group1:ts" ] + name: t1 + data: | + 1, 1612130400000, g1, 1 + 2, 1612130401000, g1, 2 + 3, 1612130402000, g1, 3 + 4, 1612130403000, g1, 4 + 5, 1612130404000, g1, 5 + 6, 1612130404000, g2, 4 + 7, 1612130405000, g2, 3 + 8, 1612130406000, g2, 2 + sql: | + select + `id`, + `val1`, + lag(val1, 0) over w1 as agg1, + lag(val1, 1) over w1 as agg2, + lag(val1, 3) over w1 as agg3 + from `t1` WINDOW + w1 as (partition by `group1` order by `ts` rows_range between 2s preceding and 1s preceding MAXSIZE 10); + expect: + columns: ["id int", "val1 int", "agg1 int", "agg2 int", "agg3 int"] + order: id + rows: + - [1, 1, 1, NULL, NULL] + - [2, 2, 2, 1, NULL] + - [3, 3, 3, 2, NULL] + - [4, 4, 4, 3, 1] + - [5, 5, 5, 4, 2] + - [6, 4, 4, NULL, NULL] + - [7, 3, 3, 4, NULL] + - [8, 2, 2, 3, NULL] + + - id: 58 + desc: | + correctness for at/lag when offset out-of-range rows_range window frame bound, together with other window function. + refer https://github.com/4paradigm/OpenMLDB/issues/1554 + inputs: + - columns: [ "id int","ts timestamp","group1 string","val1 int" ] + indexs: [ "index1:group1:ts" ] + name: t1 + data: | + 1, 1612130400000, g1, 1 + 2, 1612130401000, g1, 2 + 3, 1612130402000, g1, 3 + 4, 1612130403000, g1, 4 + 5, 1612130404000, g1, 5 + 6, 1612130405000, g2, 4 + 7, 1612130406000, g2, 3 + 8, 1612130407000, g2, 2 + sql: | + select + `id`, + `val1`, + lag(val1, 0) over w1 as agg1, + lag(val1, 3) over w1 as agg2, + first_value(val1) over w1 as agg3 + from `t1` WINDOW + w1 as (partition by `group1` order by `ts` rows_range between 2s preceding and 1s preceding MAXSIZE 10); + expect: + columns: ["id int", "val1 int", "agg1 int", "agg2 int", "agg3 int"] + order: id + rows: + - [1, 1, 1, NULL, NULL] + - [2, 2, 2, NULL, 1] + - [3, 3, 3, NULL, 2] + - [4, 4, 4, 1, 3] + - [5, 5, 5, 2, 4] + - [6, 4, 4, NULL, NULL] + - [7, 3, 3, NULL, 4] + - [8, 2, 2, NULL, 3] + + - id: 59 + desc: | + correctness for at/lag when offset out-of-range window frame bound. + keynote, lag returns value evaluated at the row that is offset rows before the current row within the partition. + refer https://github.com/4paradigm/OpenMLDB/issues/1554 + inputs: + - columns: [ "id int","ts timestamp","group1 string","val1 int" ] + indexs: [ "index1:group1:ts" ] + name: t1 + data: | + 1, 1612130400000, g1, 1 + 2, 1612130401000, g1, 2 + 3, 1612130402000, g1, 3 + 4, 1612130403000, g1, 4 + 5, 1612130404000, g1, 5 + 6, 1612130405000, g2, 4 + 7, 1612130406000, g2, 3 + 8, 1612130407000, g2, 2 + sql: | + select + `id`, + `val1`, + lag(val1, 0) over w1 as agg1, + lag(val1, 1) over w1 as agg2, + lag(val1, 3) over w1 as agg3 + from `t1` WINDOW + w1 as (partition by `group1` order by `ts` rows between 2 preceding and 1 preceding); + expect: + columns: ["id int", "val1 int", "agg1 int", "agg2 int", "agg3 int"] + order: id + rows: + - [1, 1, 1, NULL, NULL] + - [2, 2, 2, 1, NULL] + - [3, 3, 3, 2, NULL] + - [4, 4, 4, 3, 1] + - [5, 5, 5, 4, 2] + - [6, 4, 4, NULL, NULL] + - [7, 3, 3, 4, NULL] + - [8, 2, 2, 3, NULL] + + - id: 60 + desc: | + correctness for at/lag when offset out-of-range rows window frame bound + refer https://github.com/4paradigm/OpenMLDB/issues/1554 + inputs: + - columns: [ "id int","ts timestamp","group1 string","val1 int" ] + indexs: [ "index1:group1:ts" ] + name: t1 + data: | + 1, 1612130400000, g1, 1 + 2, 1612130401000, g1, 2 + 3, 1612130402000, g1, 3 + 4, 1612130403000, g1, 4 + 5, 1612130404000, g1, 5 + 6, 1612130405000, g2, 4 + 7, 1612130406000, g2, 3 + 8, 1612130407000, g2, 2 + sql: | + select + `id`, + `val1`, + lag(val1, 0) over w1 as agg1, + lag(val1, 3) over w1 as agg2, + first_value(val1) over w1 as agg3 + from `t1` WINDOW + w1 as (partition by `group1` order by `ts` rows between 2 preceding and 1 preceding); + expect: + columns: ["id int", "val1 int", "agg1 int", "agg2 int", "agg3 int"] + order: id + rows: + - [1, 1, 1, NULL, NULL] + - [2, 2, 2, NULL, 1] + - [3, 3, 3, NULL, 2] + - [4, 4, 4, 1, 3] + - [5, 5, 5, 2, 4] + - [6, 4, 4, NULL, NULL] + - [7, 3, 3, NULL, 4] + - [8, 2, 2, NULL, 3] + + - id: 61 + desc: median + sqlDialect: ["HybridSQL"] + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string","c10 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01","a",true] + - [2,"aa",4,4,33,1.4,2.4,1590738991000,"2020-05-03","c",false] + - [3,"aa",1,1,33,1.1,2.1,1590738992000,"2020-05-02","b",true] + - [4,"aa",NULL,NULL,NULL,NULL,NULL,1590738993000,NULL,NULL,NULL] + sql: | + SELECT {0}.id, c1, median(c2) OVER w1 as m2,median(c3) OVER w1 as m3,median(c4) OVER w1 as m4,median(c5) OVER w1 as m5,median(c6) OVER w1 as m6 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m2 double","m3 double","m4 double","m5 double","m6 double"] + rows: + - [1,"aa",1,1,30,1.1000000238418579,2.1] + - [2,"aa",2.5,2.5,31.5,1.25,2.25] + - [3,"aa",1,1,33,1.1000000238418579,2.1] + - [4,"aa",2.5,2.5,33,1.25,2.25] diff --git a/cases/integration_test/function/test_udf_function.yaml b/cases/integration_test/function/test_udf_function.yaml new file mode 100644 index 00000000000..7165f09182a --- /dev/null +++ b/cases/integration_test/function/test_udf_function.yaml @@ -0,0 +1,89 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +sqlDialect: ["HybridSQL"] +version: 0.5.0 +cases: + - id: 0 + desc: 默认udf null处理逻辑:返回null + inputs: + - columns: ["id int64", "c1 string", "c2 int", "c3 double", + "c4 date", "c5 timestamp", "std_ts timestamp"] + indexs: ["index1:id:std_ts"] + rows: + - [1, NULL, 42, 3.14, "2020-05-20", 1590738989000, 1590738989000] + - [2, "hello world", NULL, NULL, NULL, NULL, 1590738989000] + sql: select id, + substring(c1, 1, 5) as r1, + substring(c1, 1, c2) as r2, + pow(c2, 2) as r3, + floor(c3) as r4, + dayofweek(c4) as r5, + dayofweek(c5) as r6 + from {0}; + expect: + order: id + columns: ["id int64", "r1 string", "r2 string", "r3 double", "r4 double", + "r5 int", "r6 int"] + rows: + - [1, NULL, NULL, 1764, 3.00, 4, 6] + - [2, "hello", NULL, NULL, NULL, NULL, NULL] + + - id: 1 + desc: udf使用中间结果null值 + inputs: + - columns: ["id int64", "c1 string", "c2 int", "c3 double", + "c4 date", "c5 timestamp", "std_ts timestamp"] + indexs: ["index1:id:std_ts"] + rows: + - [1, NULL, 42, 3.14, "2020-05-20", 1590738989000, 1590738989000] + - [2, "hello world", NULL, NULL, NULL, NULL, 1590738989000] + sql: select id, + substring(substring(c1, 1, 5), 1, 1) as r1, + substring(substring(c1, 1, c2), c2, 1) as r2, + abs(pow(c2, 2)) as r3, + abs(floor(c3)) as r4, + abs(dayofweek(c4)) as r5, + abs(dayofweek(c5)) as r6 + from {0}; + expect: + order: id + columns: ["id int64", "r1 string", "r2 string", "r3 double", "r4 double", + "r5 int", "r6 int"] + rows: + - [1, NULL, NULL, 1764, 3.00, 4, 6] + - [2, "h", NULL, NULL, NULL, NULL, NULL] + + - id: 2 + desc: 函数名大小写不敏感 + inputs: + - columns: ["id int64", "c1 double", "c2 timestamp"] + indexs: ["index1:id:c2"] + rows: + - [1, 1.0, 1590738989000] + sql: select id, + SUM(c1) over w as r1, sUm(c1) over w as r2, sum(c1) over w as r3, log(c1) as r4 + from {0} window w as (PARTITION BY id ORDER BY c2 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int64", "r1 double", "r2 double", "r3 double", "r4 double"] + rows: + - [1, 1, 1, 1, 0] + + + + + diff --git a/cases/integration_test/fz_ddl/test_bank.yaml b/cases/integration_test/fz_ddl/test_bank.yaml new file mode 100644 index 00000000000..4b725afd22c --- /dev/null +++ b/cases/integration_test/fz_ddl/test_bank.yaml @@ -0,0 +1,151 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: bank +version: 0.5.0 +cases: + - desc: bank test + id: 0 + inputs: + - columns: [ reqId string, eventTime timestamp, main_id string, new_user_id string, + loan_ts bigint, split_id int, time1 string ] + indexs: [ "index1:new_user_id:eventTime" ] + name: flattenRequest + - columns: [reqId string, eventTime timestamp, ingestionTime timestamp, actionValue + int] + indexs: ["index1:reqId:eventTime"] + name: action + - columns: [ingestionTime timestamp, new_user_id string, trx_ts bigint, trx_typ + string, trx_amt double, is_slry string] + indexs: ["index1:new_user_id:ingestionTime"] + name: bo_detail + - columns: [ingestionTime timestamp, new_user_id string, bill_ts bigint, bank_id string, + lst_bill_amt double, lst_repay_amt double, card_limit double, cur_blc double, cur_bill_min_repay double, + buy_cnt double, cur_bill_amt double, adj_amt double, rev_credit double, avl_amt double, advc_limit double, repay_status string] + indexs: ["index1:new_user_id:ingestionTime"] + name: bo_bill_detail + - columns: [ingestionTime timestamp, new_user_id string, sex string, prof string, + edu string, marriage string, hukou_typ string] + indexs: ["index1:new_user_id:ingestionTime"] + name: bo_user + - columns: [ingestionTime timestamp, new_user_id string, bws_ts bigint, action string, + subaction string] + indexs: ["index1:new_user_id:ingestionTime"] + name: bo_browse_history + batch_request: + columns: [reqId string, eventTime timestamp, main_id string, new_user_id string, + loan_ts bigint, split_id int, time1 string] + indexs: ["index1:new_user_id:eventTime"] + common_column_indices: [1, 2, 3, 4, 5] + rows: + - [reqId1, 1609894067190, "main_id1", "new_user_id1", 1609894067190, 1, "time1_1"] + expect: + success: true + sql: "select * from \n(\nselect\n reqId as reqId_1,\n `reqId` as flattenRequest_reqId_original_0,\n\ + \ `eventTime` as flattenRequest_eventTime_original_1,\n `main_id` as flattenRequest_main_id_original_2,\n\ + \ `new_user_id` as flattenRequest_new_user_id_original_3\nfrom\n `flattenRequest`\n\ + \ )\nas out0\nlast join\n(\nselect\n flattenRequest.reqId as reqId_5,\n\ + \ `action_reqId`.`actionValue` as action_actionValue_multi_direct_4,\n `bo_user_new_user_id`.`edu`\ + \ as bo_user_edu_multi_direct_5,\n `bo_user_new_user_id`.`hukou_typ` as bo_user_hukou_typ_multi_direct_6,\n\ + \ `bo_user_new_user_id`.`ingestionTime` as bo_user_ingestionTime_multi_direct_7,\n\ + \ `bo_user_new_user_id`.`marriage` as bo_user_marriage_multi_direct_8,\n \ + \ `bo_user_new_user_id`.`prof` as bo_user_prof_multi_direct_9,\n `bo_user_new_user_id`.`sex`\ + \ as bo_user_sex_multi_direct_10\nfrom\n `flattenRequest`\n last join `action`\ + \ as `action_reqId` on `flattenRequest`.`reqId` = `action_reqId`.`reqId`\n \ + \ last join `bo_user` as `bo_user_new_user_id` on `flattenRequest`.`new_user_id`\ + \ = `bo_user_new_user_id`.`new_user_id`)\nas out1\non out0.reqId_1 = out1.reqId_5\n\ + last join\n(\nselect\n reqId as reqId_12,\n max(`adj_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_adj_amt_multi_max_11,\n min(`adj_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_adj_amt_multi_min_12,\n max(`advc_limit`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_advc_limit_multi_max_13,\n avg(`advc_limit`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_advc_limit_multi_avg_14,\n min(`avl_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_avl_amt_multi_min_15,\n avg(`avl_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_avl_amt_multi_avg_16,\n min(`buy_cnt`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_buy_cnt_multi_min_17,\n min(`buy_cnt`) over bo_bill_detail_new_user_id_ingestionTime_0s_5529601s\ + \ as bo_bill_detail_buy_cnt_multi_min_18,\n max(`card_limit`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_card_limit_multi_max_19,\n min(`card_limit`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_card_limit_multi_min_20,\n max(`cur_bill_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_cur_bill_amt_multi_max_21,\n max(`cur_bill_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_5529601s\ + \ as bo_bill_detail_cur_bill_amt_multi_max_22,\n min(`cur_bill_min_repay`)\ + \ over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s as bo_bill_detail_cur_bill_min_repay_multi_min_23,\n\ + \ max(`cur_bill_min_repay`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_cur_bill_min_repay_multi_max_24,\n max(`cur_blc`) over\ + \ bo_bill_detail_new_user_id_ingestionTime_0s_2764801s as bo_bill_detail_cur_blc_multi_max_25,\n\ + \ max(`cur_blc`) over bo_bill_detail_new_user_id_ingestionTime_0s_5529601s\ + \ as bo_bill_detail_cur_blc_multi_max_26,\n max(`lst_bill_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_lst_bill_amt_multi_max_27,\n avg(`lst_bill_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_5529601s\ + \ as bo_bill_detail_lst_bill_amt_multi_avg_28,\n avg(`lst_repay_amt`) over\ + \ bo_bill_detail_new_user_id_ingestionTime_0s_2764801s as bo_bill_detail_lst_repay_amt_multi_avg_29,\n\ + \ max(`lst_repay_amt`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_lst_repay_amt_multi_max_30,\n min(`rev_credit`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_rev_credit_multi_min_31,\n avg(`rev_credit`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_rev_credit_multi_avg_32,\n fz_topn_frequency(`bank_id`,\ + \ 3) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s as bo_bill_detail_bank_id_multi_top3frequency_33,\n\ + \ distinct_count(`bank_id`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_bank_id_multi_unique_count_34,\n fz_topn_frequency(`repay_status`,\ + \ 3) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s as bo_bill_detail_repay_status_multi_top3frequency_35,\n\ + \ distinct_count(`repay_status`) over bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as bo_bill_detail_repay_status_multi_unique_count_36\nfrom\n (select `eventTime`\ + \ as `ingestionTime`, `new_user_id` as `new_user_id`, bigint(0) as `bill_ts`,\ + \ '' as `bank_id`, double(0) as `lst_bill_amt`, double(0) as `lst_repay_amt`,\ + \ double(0) as `card_limit`, double(0) as `cur_blc`, double(0) as `cur_bill_min_repay`,\ + \ double(0) as `buy_cnt`, double(0) as `cur_bill_amt`, double(0) as `adj_amt`,\ + \ double(0) as `rev_credit`, double(0) as `avl_amt`, double(0) as `advc_limit`,\ + \ '' as `repay_status`, reqId from `flattenRequest`)\n window bo_bill_detail_new_user_id_ingestionTime_0s_2764801s\ + \ as (\nUNION (select `ingestionTime`, `new_user_id`, `bill_ts`, `bank_id`, `lst_bill_amt`,\ + \ `lst_repay_amt`, `card_limit`, `cur_blc`, `cur_bill_min_repay`, `buy_cnt`, `cur_bill_amt`,\ + \ `adj_amt`, `rev_credit`, `avl_amt`, `advc_limit`, `repay_status`, '' as reqId\ + \ from `bo_bill_detail`) partition by `new_user_id` order by `ingestionTime` rows_range\ + \ between 2764801s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW),\n bo_bill_detail_new_user_id_ingestionTime_0s_5529601s\ + \ as (\nUNION (select `ingestionTime`, `new_user_id`, `bill_ts`, `bank_id`, `lst_bill_amt`,\ + \ `lst_repay_amt`, `card_limit`, `cur_blc`, `cur_bill_min_repay`, `buy_cnt`, `cur_bill_amt`,\ + \ `adj_amt`, `rev_credit`, `avl_amt`, `advc_limit`, `repay_status`, '' as reqId\ + \ from `bo_bill_detail`) partition by `new_user_id` order by `ingestionTime` rows_range\ + \ between 5529601s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW))\nas out2\n\ + on out0.reqId_1 = out2.reqId_12\nlast join\n(\nselect\n reqId as reqId_38,\n\ + \ distinct_count(`action`) over bo_browse_history_new_user_id_ingestionTime_0s_5529601s\ + \ as bo_browse_history_action_multi_unique_count_37,\n distinct_count(`action`)\ + \ over bo_browse_history_new_user_id_ingestionTime_0_10 as bo_browse_history_action_multi_unique_count_38,\n\ + \ distinct_count(`subaction`) over bo_browse_history_new_user_id_ingestionTime_0s_5529601s\ + \ as bo_browse_history_subaction_multi_unique_count_39,\n distinct_count(`subaction`)\ + \ over bo_browse_history_new_user_id_ingestionTime_0_10 as bo_browse_history_subaction_multi_unique_count_40\n\ + from\n (select `eventTime` as `ingestionTime`, `new_user_id` as `new_user_id`,\ + \ bigint(0) as `bws_ts`, '' as `action`, '' as `subaction`, reqId from `flattenRequest`)\n\ + \ window bo_browse_history_new_user_id_ingestionTime_0s_5529601s as (\nUNION\ + \ (select `ingestionTime`, `new_user_id`, `bws_ts`, `action`, `subaction`, ''\ + \ as reqId from `bo_browse_history`) partition by `new_user_id` order by `ingestionTime`\ + \ rows_range between 5529601s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW),\n\ + \ bo_browse_history_new_user_id_ingestionTime_0_10 as (\nUNION (select `ingestionTime`,\ + \ `new_user_id`, `bws_ts`, `action`, `subaction`, '' as reqId from `bo_browse_history`)\ + \ partition by `new_user_id` order by `ingestionTime` rows_range between 10 preceding\ + \ and 0 preceding INSTANCE_NOT_IN_WINDOW))\nas out3\non out0.reqId_1 = out3.reqId_38\n\ + last join\n(\nselect\n reqId as reqId_42,\n max(`trx_amt`) over bo_detail_new_user_id_ingestionTime_0s_5529601s\ + \ as bo_detail_trx_amt_multi_max_41,\n avg(`trx_amt`) over bo_detail_new_user_id_ingestionTime_0s_5529601s\ + \ as bo_detail_trx_amt_multi_avg_42,\n distinct_count(`is_slry`) over bo_detail_new_user_id_ingestionTime_0_10\ + \ as bo_detail_is_slry_multi_unique_count_43,\n distinct_count(`is_slry`) over\ + \ bo_detail_new_user_id_ingestionTime_0s_5529601s as bo_detail_is_slry_multi_unique_count_44,\n\ + \ distinct_count(`trx_typ`) over bo_detail_new_user_id_ingestionTime_0_10 as\ + \ bo_detail_trx_typ_multi_unique_count_45,\n distinct_count(`trx_typ`) over\ + \ bo_detail_new_user_id_ingestionTime_0s_5529601s as bo_detail_trx_typ_multi_unique_count_46\n\ + from\n (select `eventTime` as `ingestionTime`, `new_user_id` as `new_user_id`,\ + \ bigint(0) as `trx_ts`, '' as `trx_typ`, double(0) as `trx_amt`, '' as `is_slry`,\ + \ reqId from `flattenRequest`)\n window bo_detail_new_user_id_ingestionTime_0s_5529601s\ + \ as (\nUNION (select `ingestionTime`, `new_user_id`, `trx_ts`, `trx_typ`, `trx_amt`,\ + \ `is_slry`, '' as reqId from `bo_detail`) partition by `new_user_id` order by\ + \ `ingestionTime` rows_range between 5529601s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW),\n\ + \ bo_detail_new_user_id_ingestionTime_0_10 as (\nUNION (select `ingestionTime`,\ + \ `new_user_id`, `trx_ts`, `trx_typ`, `trx_amt`, `is_slry`, '' as reqId from `bo_detail`)\ + \ partition by `new_user_id` order by `ingestionTime` rows_range between 10 preceding\ + \ and 0 preceding INSTANCE_NOT_IN_WINDOW))\nas out4\non out0.reqId_1 = out4.reqId_42\n\ + ;" diff --git a/cases/integration_test/fz_ddl/test_luoji.yaml b/cases/integration_test/fz_ddl/test_luoji.yaml new file mode 100644 index 00000000000..65b8056909f --- /dev/null +++ b/cases/integration_test/fz_ddl/test_luoji.yaml @@ -0,0 +1,293 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: luoji +version: 0.5.0 +cases: +- id: 0 + desc: luoji test + mode: rtidb-batch-unsupport + inputs: + - columns: [ + reqId string, + eventTime timestamp, + f_requestId string, + f_cId string, + f_uId string, + f_cSrc string, + f_cLength double] + indexs: [ + index1:f_requestId:eventTime, + index2:f_uId:eventTime] + repeat: 100 + name: flattenRequest + rows: + - [reqId1, 1609894067190, f_requestId1, f_cId1-1, f_uId1, f_cSrc1-1, 1.0] + - [reqId1, 1609894067190, f_requestId1, f_cId1-1, f_uId1, f_cSrc1-1, 1.0] + - [reqId1, 1609894067190, f_requestId1, f_cId1-2, f_uId1, f_cSrc1-2, 1.0] + - [reqId2, 1609894067190, f_requestId2, f_cId2-1, f_uId2, f_cSrc2-1, 2.0] + - [reqId2, 1609894067190, f_requestId2, f_cId2-2, f_uId2, f_cSrc2-2, 2.0] + - [NULL, 1609894067190, f_requestIdNull, f_cIdNull, f_uIdNull, f_cSrcNul, 3.0] + - columns: [ + reqId string, + eventTime timestamp, + ingestionTime timestamp, + actionValue int, + ] + indexs: [index1:reqId:null:1:latest] + name: action + rows: + - [reqId1, 1609894067191, 1609894067191, 1] + - [NULL, 1609894067191, 1609894067191, 3] + sql: | + select * from + ( + select + reqId as reqId_1, + `reqId` as flattenRequest_reqId_original_0, + `eventTime` as flattenRequest_eventTime_original_1, + `f_requestId` as flattenRequest_f_requestId_original_2, + `f_cId` as flattenRequest_f_cId_original_3, + `f_cSrc` as flattenRequest_f_cSrc_original_8, + `f_uId` as flattenRequest_f_uId_original_17, + `f_cLength` as flattenRequest_f_cLength_original_10, + sum(`f_cLength`) over flattenRequest_f_requestId_eventTime_0s_604801s as flattenRequest_f_cLength_window_sum_32, + distinct_count(`f_cId`) over flattenRequest_f_uId_eventTime_0_10 as flattenRequest_f_cId_window_unique_count_38, + fz_top1_ratio(`f_cId`) over flattenRequest_f_requestId_eventTime_0_10 as flattenRequest_f_cId_window_top1_ratio_39, + fz_top1_ratio(`f_cId`) over flattenRequest_f_requestId_eventTime_0s_604801s as flattenRequest_f_cId_window_top1_ratio_40, + sum(`f_cLength`) over flattenRequest_f_requestId_eventTime_0s_432001s as flattenRequest_f_cLength_window_sum_41, + case when !isnull(lag(`f_cSrc`, 0)) over flattenRequest_f_requestId_eventTime_0s_604801s then count(`f_cSrc`) over flattenRequest_f_requestId_eventTime_0s_604801s else null end as flattenRequest_f_cSrc_window_count_42, + case when !isnull(lag(`f_cSrc`, 0)) over flattenRequest_f_uId_eventTime_0s_604801s then count(`f_cSrc`) over flattenRequest_f_uId_eventTime_0s_604801s else null end as flattenRequest_f_cSrc_window_count_43, + fz_top1_ratio(`f_cId`) over flattenRequest_f_uId_eventTime_0_10 as flattenRequest_f_cId_window_top1_ratio_44, + fz_top1_ratio(`f_cId`) over flattenRequest_f_uId_eventTime_0s_604801s as flattenRequest_f_cId_window_top1_ratio_45, + fz_top1_ratio(`f_cId`) over flattenRequest_f_uId_eventTime_0s_432001s as flattenRequest_f_cId_window_top1_ratio_46, + case when !isnull(lag(`f_cId`, 0)) over flattenRequest_f_requestId_eventTime_0s_604801s then count(`f_cId`) over flattenRequest_f_requestId_eventTime_0s_604801s else null end as flattenRequest_f_cId_window_count_47, + case when !isnull(lag(`f_cId`, 0)) over flattenRequest_f_uId_eventTime_0s_432001s then count(`f_cId`) over flattenRequest_f_uId_eventTime_0s_432001s else null end as flattenRequest_f_cId_window_count_48, + case when !isnull(lag(`f_cId`, 0)) over flattenRequest_f_uId_eventTime_0s_604801s then count(`f_cId`) over flattenRequest_f_uId_eventTime_0s_604801s else null end as flattenRequest_f_cId_window_count_49 + from + `flattenRequest` + window flattenRequest_f_requestId_eventTime_0s_604801s as (partition by `f_requestId` order by `eventTime` rows_range between 604801s preceding and 0s preceding), + flattenRequest_f_uId_eventTime_0_10 as (partition by `f_uId` order by `eventTime` rows_range between 10 preceding and 0 preceding), + flattenRequest_f_requestId_eventTime_0_10 as (partition by `f_requestId` order by `eventTime` rows_range between 10 preceding and 0 preceding), + flattenRequest_f_requestId_eventTime_0s_432001s as (partition by `f_requestId` order by `eventTime` rows_range between 432001s preceding and 0s preceding), + flattenRequest_f_uId_eventTime_0s_604801s as (partition by `f_uId` order by `eventTime` rows_range between 604801s preceding and 0s preceding), + flattenRequest_f_uId_eventTime_0s_432001s as (partition by `f_uId` order by `eventTime` rows_range between 432001s preceding and 0s preceding)) + as out0 + last join + ( + select + flattenRequest.reqId as reqId_32, + `action_reqId`.`actionValue` as action_actionValue_multi_direct_31 + from + `flattenRequest` + last join `action` as `action_reqId` on `flattenRequest`.`reqId` = `action_reqId`.`reqId`) + as out1 + on out0.reqId_1 = out1.reqId_32; + batch_request: + columns: [ + reqId string, + eventTime timestamp, + f_requestId string, + f_cId string, + f_uId string, + f_cSrc string, + f_cLength double ] + rows: + - [reqId1, 1609894067190, f_requestId1, f_cId1, f_uId1, f_cSrc1, 1.0] + - [reqId1, 1609894067190, f_requestId1, f_cId1, f_uId1, NULL, 1.0] + - [reqId1, 1609894067190, f_requestId1, NULL, f_uId1, f_cSrc1, 1.0] + - [reqId2, 1609894067190, f_requestId2, f_cId2, f_uId2, f_cSrc2, 2.0] + - [NULL, 1609894067190, f_requestIdNull, f_cIdNull, f_uIdNull, f_cSrcNul, 3.0] + expect: + success: true + schema: reqId_1:string, flattenRequest_reqId_original_0:string, flattenRequest_eventTime_original_1:timestamp, flattenRequest_f_requestId_original_2:string, flattenRequest_f_cId_original_3:string, flattenRequest_f_cSrc_original_8:string, flattenRequest_f_uId_original_17:string, flattenRequest_f_cLength_original_10:double, flattenRequest_f_cLength_window_sum_32:double, flattenRequest_f_cId_window_unique_count_38:bigint, flattenRequest_f_cId_window_top1_ratio_39:double, flattenRequest_f_cId_window_top1_ratio_40:double, flattenRequest_f_cLength_window_sum_41:double, flattenRequest_f_cSrc_window_count_42:bigint, flattenRequest_f_cSrc_window_count_43:bigint, flattenRequest_f_cId_window_top1_ratio_44:double, flattenRequest_f_cId_window_top1_ratio_45:double, flattenRequest_f_cId_window_top1_ratio_46:double, flattenRequest_f_cId_window_count_47:bigint, flattenRequest_f_cId_window_count_48:bigint, flattenRequest_f_cId_window_count_49:bigint, reqId_32:string, action_actionValue_multi_direct_31:int + rows: + - [ reqId1, reqId1, 1609894067190, f_requestId1, f_cId1, f_cSrc1, f_uId1, 1.000000, + 301.000000, # flattenRequest_f_cLength_window_sum_32 + 3, # distinct_count f_cId1, f_cId1-1 f_cId1-2 + 0.66445182724252494, # fz_top1_ratio f_cId1-1:200, f_cId1-2:100 f_cId1:1 -> 200/301 + 0.66445182724252494, + 301.000000, + 301, + 301, + 0.66445182724252494, + 0.66445182724252494, + 0.66445182724252494, + 301, 301, 301, reqId1, 1 ] + - [ reqId1, reqId1, 1609894067190, f_requestId1, f_cId1, NULL, f_uId1, 1.000000, + 301.000000, + 3, + 0.66445182724252494, + 0.66445182724252494, + 301.000000, + NULL, # case when !isnull(lag(`f_cSrc`, 0)) ... else NULL end + NULL, # case when !isnull(lag(`f_cSrc`, 0)) ... else NULL end + 0.66445182724252494, + 0.66445182724252494, + 0.66445182724252494, + 301, 301, 301, reqId1, 1 ] + - [ reqId1, reqId1, 1609894067190, f_requestId1, NULL, f_cSrc1, f_uId1, 1.000000, + 301.000000, # flattenRequest_f_cLength_window_sum_32 + 3, # distinct_count f_cId1, f_cId1-1 f_cId1-2 + 0.66666666666666663, + 0.66666666666666663, + 301.000000, + 301, + 301, + 0.66666666666666663, + 0.66666666666666663, + 0.66666666666666663, + NULL, NULL, NULL, # case when !isnull(lag(`f_cId`, 0)) then ... else NULL + reqId1, 1 ] + - [reqId2, reqId2, 1609894067190, f_requestId2, f_cId2, f_cSrc2, f_uId2, 2.000000, + 402.000000, + 3, + 0.49751243781094528, 0.49751243781094528, + 402.000000, + 201, 201, + 0.49751243781094528, 0.49751243781094528, 0.49751243781094528, + 201, 201, 201, + reqId2, NULL] + - [ NULL, NULL, 1609894067190, f_requestIdNull, f_cIdNull, f_cSrcNul, f_uIdNull, 3.000000, + 303.000000, + 1, + 1.000000, 1.000000, + 303.000000, + 101, 101, + 1.000000, 1.000000, 1.000000, + 101, 101, 101, + NULL, 3 ] + +- id: 1 + desc: luoji test window flattenRequest_f_requestId_eventTime_0s_604801s without ttl + mode: rtidb-batch-unsupport + inputs: + - columns: [ + reqId string, + eventTime timestamp, + f_requestId string, + f_cId string, + f_uId string, + f_cSrc string, + f_cLength double] + indexs: [ + index1:f_requestId:eventTime, + index2:f_uId:eventTime] + repeat: 100 + name: flattenRequest + rows: + - [reqId1, 1609894067190, f_requestId1, f_cId1-1, f_uId1, f_cSrc1-1, 1.0] + - [reqId1, 1609894067190, f_requestId1, f_cId1-1, f_uId1, f_cSrc1-1, 1.0] + - [reqId1, 1609894067190, f_requestId1, f_cId1-2, f_uId1, f_cSrc1-2, 1.0] + - [reqId2, 1609894067190, f_requestId2, f_cId2-1, f_uId2, f_cSrc2-1, 2.0] + - [reqId2, 1609894067190, f_requestId2, f_cId2-2, f_uId2, f_cSrc2-2, 2.0] + - [NULL, 1609894067190, f_requestIdNull, f_cIdNull, f_uIdNull, f_cSrcNul, 3.0] + - columns: [ + reqId string, + eventTime timestamp, + ingestionTime timestamp, + actionValue int, + ] + indexs: [index1:reqId:null:1:latest] + name: action + rows: + - [reqId1, 1609894067191, 1609894067191, 1] + - [NULL, 1609894067191, 1609894067191, 3] + sql: | + select * from + ( + select + reqId as reqId_1, + `reqId` as flattenRequest_reqId_original_0, + `eventTime` as flattenRequest_eventTime_original_1, + `f_requestId` as flattenRequest_f_requestId_original_2, + `f_cId` as flattenRequest_f_cId_original_3, + `f_cSrc` as flattenRequest_f_cSrc_original_8, + `f_uId` as flattenRequest_f_uId_original_17, + `f_cLength` as flattenRequest_f_cLength_original_10, + sum(`f_cLength`) over flattenRequest_f_requestId_eventTime_0s_604801s as flattenRequest_f_cLength_window_sum_32, + fz_top1_ratio(`f_cId`) over flattenRequest_f_requestId_eventTime_0s_604801s as flattenRequest_f_cId_window_top1_ratio_40, + case when !isnull(lag(`f_cSrc`, 0)) over flattenRequest_f_requestId_eventTime_0s_604801s then count(`f_cSrc`) over flattenRequest_f_requestId_eventTime_0s_604801s else null end as flattenRequest_f_cSrc_window_count_42, + case when !isnull(lag(`f_cId`, 0)) over flattenRequest_f_requestId_eventTime_0s_604801s then count(`f_cId`) over flattenRequest_f_requestId_eventTime_0s_604801s else null end as flattenRequest_f_cId_window_count_47 + from + `flattenRequest` + window flattenRequest_f_requestId_eventTime_0s_604801s as (partition by `f_requestId` order by `eventTime` rows_range between 604801s preceding and 0s preceding)) + as out0 + last join + ( + select + flattenRequest.reqId as reqId_32, + `action_reqId`.`actionValue` as action_actionValue_multi_direct_31 + from + `flattenRequest` + last join `action` as `action_reqId` on `flattenRequest`.`reqId` = `action_reqId`.`reqId`) + as out1 + on out0.reqId_1 = out1.reqId_32; + batch_request: + columns: [ + reqId string, + eventTime timestamp, + f_requestId string, + f_cId string, + f_uId string, + f_cSrc string, + f_cLength double ] + rows: + - [reqId1, 1609894067190, f_requestId1, f_cId1, f_uId1, f_cSrc1, 1.0] + - [reqId1, 1609894067190, f_requestId1, f_cId1, f_uId1, NULL, 1.0] + - [reqId1, 1609894067190, f_requestId1, NULL, f_uId1, f_cSrc1, 1.0] + - [reqId2, 1609894067190, f_requestId2, f_cId2, f_uId2, f_cSrc2, 2.0] + - [NULL, 1609894067190, f_requestIdNull, f_cIdNull, f_uIdNull, f_cSrcNul, 3.0] + expect: + success: true + schema: reqId_1:string, flattenRequest_reqId_original_0:string, flattenRequest_eventTime_original_1:timestamp, flattenRequest_f_requestId_original_2:string, flattenRequest_f_cId_original_3:string, flattenRequest_f_cSrc_original_8:string, flattenRequest_f_uId_original_17:string, flattenRequest_f_cLength_original_10:double, flattenRequest_f_cLength_window_sum_32:double, flattenRequest_f_cId_window_top1_ratio_40:double, flattenRequest_f_cSrc_window_count_42:bigint, flattenRequest_f_cId_window_count_47:bigint, reqId_32:string, action_actionValue_multi_direct_31:int + rows: + - [ reqId1, reqId1, 1609894067190, f_requestId1, f_cId1, f_cSrc1, f_uId1, 1.000000, 301.000000, 0.66445182724252494, 301, 301, reqId1, 1 ] + - [ reqId1, reqId1, 1609894067190, f_requestId1, f_cId1, NULL, f_uId1, 1.000000, 301.000000, 0.66445182724252494, NULL, 301, reqId1, 1 ] + - [ reqId1, reqId1, 1609894067190, f_requestId1, NULL, f_cSrc1, f_uId1, 1.000000, 301.000000, 0.66666666666666663, 301, NULL, reqId1, 1 ] + - [ reqId2, reqId2, 1609894067190, f_requestId2, f_cId2, f_cSrc2, f_uId2, 2.000000, 402.000000, 0.49751243781094528, 201, 201, reqId2, NULL ] + - [ NULL, NULL, 1609894067190, f_requestIdNull, f_cIdNull, f_cSrcNul, f_uIdNull, 3.000000, 303.000000, 1.000000, 101, 101, NULL, 3 ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cases/integration_test/fz_ddl/test_myhug.yaml b/cases/integration_test/fz_ddl/test_myhug.yaml new file mode 100644 index 00000000000..02d0f971040 --- /dev/null +++ b/cases/integration_test/fz_ddl/test_myhug.yaml @@ -0,0 +1,314 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: mybug +version: 0.5.0 +cases: +- id: 0 + desc: mybug test + mode: rtidb-batch-unsupport + inputs: + - + columns: ["reqId string","eventTime timestamp","uUserId string","zUserId string", + "uSex string","zSex string","zChannel string","uPlayGame string", + "uHasJoinedGroup string","uWatchMorning double","uWatchEvening double", + "uWatchAvgLength double","zSWihsperNum double" ] + indexs: [ + "index1:uUserId:eventTime", + "index2:zChannel:eventTime", + "index3:uSex:eventTime", + "index4:zUserId:eventTime", + "index5:uPlayGame:eventTime", + "index6:uHasJoinedGroup:eventTime", + "index7:zUserId|uUserId:eventTime" ] + repeat: 100 + name: flattenRequest + rows: + - [reqId1, 1609894067190, uUserId1, zUserId1, uSex1, zSex1, zChannel1, uPlayGame1, uHasJoinedGroup1, 1.0, 2.0, 3.0, 4.0] + - [reqId2, 1609894067190, uUserId2, zUserId2, uSex2, zSex2, zChannel2, uPlayGame2, uHasJoinedGroup2, 1.0, 2.0, 3.0, 4.0] + - [NULL, 1609894067190, uUserIdNull, zUserIdNull, uSexNull, zSexNull, zChannelNull, uPlayGameNull, uHasJoinedGroupNull, 1.0, 2.0, 3.0, 4.0] + - columns: [ + "reqId string", + "eventTime timestamp", + "ingestionTime timestamp", + "actionValue double"] + indexs: ["index1:reqId:eventTime"] + name: action + rows: + - [reqId1, 1609894067191, 1609894067191, 1.1] + - [NULL, 1609894067191, 1609894067191, 3.3] + - columns: [ "ingestionTime timestamp", + "zUserId string", + "uUserId string", + "nRequestTime timestamp", + "fWatchedTimeLen double" ] + indexs: [ "index1:zUserId|uUserId:ingestionTime" ] + name: bo_hislabel + rows: + - [ 1609894067191, zUserId1, uUserId1, 1609894067191, 1.0 ] + - [ 1609894067191, zUserId2, uUserId2, 1609894067191, 1.0 ] + - [ 1609894067191, zUserIdNull, uUserIdNull, 1609894067191, 1.0 ] + sql: | + select * from + ( + select + `reqId` as reqId_1, + `reqId` as flattenRequest_reqId_original_0, + `eventTime` as flattenRequest_eventTime_original_1, + `uUserId` as flattenRequest_uUserId_original_2, + `zUserId` as flattenRequest_zUserId_original_3, + `uSex` as flattenRequest_uSex_combine_77, + `zSex` as flattenRequest_zSex_original_8, + `zChannel` as flattenRequest_zChannel_original_14, + `uPlayGame` as flattenRequest_uPlayGame_original_67, + `uHasJoinedGroup` as flattenRequest_uHasJoinedGroup_original_46, + + `uWatchMorning` as flattenRequest_uWatchMorning_original_60, + `uWatchEvening` as flattenRequest_uWatchEvening_original_62, + `uWatchAvgLength` as flattenRequest_uWatchAvgLength_original_63, + `zSWihsperNum` as flattenRequest_zSWihsperNum_original_23, + + sum(`uWatchAvgLength`) over flattenRequest_uUserId_eventTime_0_10 as flattenRequest_uWatchAvgLength_window_sum_76, + avg(`uWatchMorning`) over flattenRequest_uUserId_eventTime_0_10 as flattenRequest_uWatchMorning_window_avg_78, + avg(`uWatchEvening`) over flattenRequest_uUserId_eventTime_0_10 as flattenRequest_uWatchEvening_window_avg_79, + sum(`zSWihsperNum`) over flattenRequest_zChannel_eventTime_0s_172801s as flattenRequest_zSWihsperNum_window_sum_80, + avg(`uWatchAvgLength`) over flattenRequest_uUserId_eventTime_0_10 as flattenRequest_uWatchAvgLength_window_avg_81, + + case when !isnull(lag(`zUserId`, 0)) over flattenRequest_uUserId_eventTime_0s_36001s then count(`zUserId`) over flattenRequest_uUserId_eventTime_0s_36001s else null end as flattenRequest_zUserId_window_count_82, + case when !isnull(lag(`zUserId`, 0)) over flattenRequest_uUserId_eventTime_0s_172801s then count(`zUserId`) over flattenRequest_uUserId_eventTime_0s_172801s else null end as flattenRequest_zUserId_window_count_83, + case when !isnull(lag(`zUserId`, 0)) over flattenRequest_uSex_eventTime_0_10 then count(`zUserId`) over flattenRequest_uSex_eventTime_0_10 else null end as flattenRequest_zUserId_window_count_84, + case when !isnull(lag(`zUserId`, 0)) over flattenRequest_uUserId_eventTime_0_10 then count(`zUserId`) over flattenRequest_uUserId_eventTime_0_10 else null end as flattenRequest_zUserId_window_count_85, + case when !isnull(lag(`uUserId`, 0)) over flattenRequest_zUserId_eventTime_0s_36001s then count(`uUserId`) over flattenRequest_zUserId_eventTime_0s_36001s else null end as flattenRequest_uUserId_window_count_86, + case when !isnull(lag(`uUserId`, 0)) over flattenRequest_zUserId_eventTime_0s_172801s then count(`uUserId`) over flattenRequest_zUserId_eventTime_0s_172801s else null end as flattenRequest_uUserId_window_count_87, + case when !isnull(lag(`uUserId`, 0)) over flattenRequest_uPlayGame_eventTime_0s_36001s then count(`uUserId`) over flattenRequest_uPlayGame_eventTime_0s_36001s else null end as flattenRequest_uUserId_window_count_88, + case when !isnull(lag(`uUserId`, 0)) over flattenRequest_uHasJoinedGroup_eventTime_0s_36001s then count(`uUserId`) over flattenRequest_uHasJoinedGroup_eventTime_0s_36001s else null end as flattenRequest_uUserId_window_count_89, + case when !isnull(lag(`uUserId`, 0)) over flattenRequest_uHasJoinedGroup_eventTime_0s_172801s then count(`uUserId`) over flattenRequest_uHasJoinedGroup_eventTime_0s_172801s else null end as flattenRequest_uUserId_window_count_90, + case when !isnull(lag(`uUserId`, 0)) over flattenRequest_uSex_eventTime_0s_172801s then count(`uUserId`) over flattenRequest_uSex_eventTime_0s_172801s else null end as flattenRequest_uUserId_window_count_91, + case when !isnull(lag(`uUserId`, 0)) over flattenRequest_uSex_eventTime_0s_36001s then count(`uUserId`) over flattenRequest_uSex_eventTime_0s_36001s else null end as flattenRequest_uUserId_window_count_92 + from + `flattenRequest` + window flattenRequest_uUserId_eventTime_0_10 as (partition by `uUserId` order by `eventTime` rows between 10 preceding and 0 preceding), + flattenRequest_zChannel_eventTime_0s_172801s as (partition by `zChannel` order by `eventTime` rows_range between 172801s preceding and 0s preceding), + flattenRequest_uUserId_eventTime_0s_36001s as (partition by `uUserId` order by `eventTime` rows_range between 36001s preceding and 0s preceding), + flattenRequest_uUserId_eventTime_0s_172801s as (partition by `uUserId` order by `eventTime` rows_range between 172801s preceding and 0s preceding), + flattenRequest_uSex_eventTime_0_10 as (partition by `uSex` order by `eventTime` rows between 10 preceding and 0 preceding), + flattenRequest_zUserId_eventTime_0s_36001s as (partition by `zUserId` order by `eventTime` rows_range between 36001s preceding and 0s preceding), + flattenRequest_zUserId_eventTime_0s_172801s as (partition by `zUserId` order by `eventTime` rows_range between 172801s preceding and 0s preceding), + flattenRequest_uPlayGame_eventTime_0s_36001s as (partition by `uPlayGame` order by `eventTime` rows_range between 36001s preceding and 0s preceding), + flattenRequest_uHasJoinedGroup_eventTime_0s_36001s as (partition by `uHasJoinedGroup` order by `eventTime` rows_range between 36001s preceding and 0s preceding), + flattenRequest_uHasJoinedGroup_eventTime_0s_172801s as (partition by `uHasJoinedGroup` order by `eventTime` rows_range between 172801s preceding and 0s preceding), + flattenRequest_uSex_eventTime_0s_172801s as (partition by `uSex` order by `eventTime` rows_range between 172801s preceding and 0s preceding), + flattenRequest_uSex_eventTime_0s_36001s as (partition by `uSex` order by `eventTime` rows_range between 36001s preceding and 0s preceding)) + as out0 + last join + ( + select + flattenRequest.reqId as reqId_74, + `action_reqId`.`actionValue` as action_actionValue_multi_direct_73 + from + `flattenRequest` + last join `action` as `action_reqId` on `flattenRequest`.`reqId` = `action_reqId`.`reqId`) + as out1 + on out0.reqId_1 = out1.reqId_74 + last join + ( + select + reqId as reqId_75, + max(`fWatchedTimeLen`) over bo_hislabel_zUserId_uUserId_ingestionTime_1s_172801s as bo_hislabel_fWatchedTimeLen_multi_max_74, + avg(`fWatchedTimeLen`) over bo_hislabel_zUserId_uUserId_ingestionTime_1s_172801s as bo_hislabel_fWatchedTimeLen_multi_avg_75 + from + (select `eventTime` as `ingestionTime`, `zUserId` as `zUserId`, `uUserId` as `uUserId`, timestamp('2019-07-18 09:20:20') as `nRequestTime`, double(0) as `fWatchedTimeLen`, reqId from `flattenRequest`) + window bo_hislabel_zUserId_uUserId_ingestionTime_1s_172801s as ( + UNION (select `ingestionTime`, `zUserId`, `uUserId`, `nRequestTime`, `fWatchedTimeLen`, '' as reqId from `bo_hislabel`) partition by `zUserId`,`uUserId` order by `ingestionTime` rows_range between 172801s preceding and 1s preceding INSTANCE_NOT_IN_WINDOW)) + as out2 + on out0.reqId_1 = out2.reqId_75 + ; + batch_request: + columns: [ + "reqId string", + "eventTime timestamp", + "uUserId string", + "zUserId string", + "uSex string", + "zSex string", + "zChannel string", + "uPlayGame string", + "uHasJoinedGroup string", + "uWatchMorning double", + "uWatchEvening double", + "uWatchAvgLength double", + "zSWihsperNum double"] + rows: + - [reqId1, 1609894067191, uUserId1, zUserId1, uSex1, zSex1, zChannel1, uPlayGame1, uHasJoinedGroup1, 1.0, 2.0, 3.0, 4.0] + - [reqId2, 1609894068191, uUserId2, zUserId2, uSex2, zSex2, zChannel2, uPlayGame2, uHasJoinedGroup2, 1.0, 2.0, 3.0, 4.0] + - [reqId2, 1609894068191, uUserId2, NULL, uSex2, zSex2, zChannel2, uPlayGame2, uHasJoinedGroup2, 1.0, 2.0, 3.0, 4.0] + - [NULL, 1609894068191, uUserIdNull, zUserIdNull, uSexNull, zSexNull, zChannelNull, uPlayGameNull, uHasJoinedGroupNull, 1.0, 2.0, 3.0, 4.0] + expect: + schema: > + reqId_1:string, flattenRequest_reqId_original_0:string, flattenRequest_eventTime_original_1:timestamp, flattenRequest_uUserId_original_2:string, + flattenRequest_zUserId_original_3:string, flattenRequest_uSex_combine_77:string, flattenRequest_zSex_original_8:string, + flattenRequest_zChannel_original_14:string, flattenRequest_uPlayGame_original_67:string, flattenRequest_uHasJoinedGroup_original_46:string, + flattenRequest_uWatchMorning_original_60:double, flattenRequest_uWatchEvening_original_62:double, flattenRequest_uWatchAvgLength_original_63:double, + flattenRequest_zSWihsperNum_original_23:double, flattenRequest_uWatchAvgLength_window_sum_76:double, flattenRequest_uWatchMorning_window_avg_78:double, + flattenRequest_uWatchEvening_window_avg_79:double, flattenRequest_zSWihsperNum_window_sum_80:double, flattenRequest_uWatchAvgLength_window_avg_81:double, + flattenRequest_zUserId_window_count_82:bigint, flattenRequest_zUserId_window_count_83:bigint, flattenRequest_zUserId_window_count_84:bigint, + flattenRequest_zUserId_window_count_85:bigint, flattenRequest_uUserId_window_count_86:bigint, flattenRequest_uUserId_window_count_87:bigint, + flattenRequest_uUserId_window_count_88:bigint, flattenRequest_uUserId_window_count_89:bigint, flattenRequest_uUserId_window_count_90:bigint, + flattenRequest_uUserId_window_count_91:bigint, flattenRequest_uUserId_window_count_92:bigint, reqId_74:string, action_actionValue_multi_direct_73:double, + reqId_75:string, bo_hislabel_fWatchedTimeLen_multi_max_74:double, bo_hislabel_fWatchedTimeLen_multi_avg_75:double + rows: + - [ reqId1, reqId1, 1609894067191, uUserId1, zUserId1, uSex1, zSex1, zChannel1, uPlayGame1, uHasJoinedGroup1, + 1.000000, 2.000000, 3.000000, 4.000000, + 33.000000, 1.000000, 2.000000, 404.000000, 3.000000, + 101, 101, 11, 11, 101, 101, 101, 101, 101, 101, 101, + reqId1, 1.1, reqId1, NULL, NULL ] + - [ reqId2, reqId2, 1609894068191, uUserId2, zUserId2, uSex2, zSex2, zChannel2, uPlayGame2, uHasJoinedGroup2, + 1.000000, 2.000000, 3.000000, 4.000000, + 33.000000, 1.000000, 2.000000, 404.000000, 3.000000, + 101, 101, 11, 11, 101, 101, 101, 101, 101, 101, 101, + reqId2, NULL, reqId2, 1.000000, 1.000000 ] + - [ reqId2, reqId2, 1609894068191, uUserId2, NULL, uSex2, zSex2, zChannel2, uPlayGame2, uHasJoinedGroup2, + 1.000000, 2.000000, 3.000000, 4.000000, + 33.000000, 1.000000, 2.000000, 404.000000, 3.000000, + NULL, NULL, NULL, NULL, 1, 1, 101, 101, 101, 101, 101, + reqId2, NULL, reqId2, NULL, NULL ] + - [ NULL, NULL, 1609894068191, uUserIdNull, zUserIdNull, uSexNull, zSexNull, zChannelNull, uPlayGameNull, uHasJoinedGroupNull, + 1.000000, 2.000000, 3.000000, 4.000000, + 33.000000, 1.000000, 2.000000, 404.000000, 3.000000, + 101, 101, 11, 11, 101, 101, 101, 101, 101, 101, 101, + NULL, 3.3, NULL, 1.000000, 1.000000 ] +- id: 1 + desc: mybug bo_hislabel_fWatchedTimeLen_multi_max_74 + mode: rtidb-batch-unsupport + inputs: + - columns: [ "reqId string", + "eventTime timestamp", + "uUserId string", + "zUserId string", + "uSex string", + "zSex string", + "zChannel string", + "uPlayGame string", + "uHasJoinedGroup string", + "uWatchMorning double", + "uWatchEvening double", + "uWatchAvgLength double", + "zSWihsperNum double" ] + indexs: [ + "index1:uUserId:eventTime", + "index2:zChannel:eventTime", + "index3:uSex:eventTime", + "index4:zUserId:eventTime", + "index5:uPlayGame:eventTime", + "index6:uHasJoinedGroup:eventTime", + "index7:zUserId|uUserId:eventTime" ] + name: flattenRequest + rows: + - [reqId1, 1609894067191, uUserId1, zUserId1, uSex1, zSex1, zChannel1, uPlayGame1, uHasJoinedGroup1, 1.0, 2.0, 3.0, 4.0] + - columns: [ + "reqId string", + "eventTime timestamp", + "ingestionTime timestamp", + "actionValue double"] + indexs: ["index1:reqId:eventTime"] + name: action + rows: + - [reqId1, 1609894067191, 1609894067191, 1.1] + - [NULL, 1609894067191, 1609894067191, 3.3] + - columns: [ "ingestionTime timestamp", + "zUserId string", + "uUserId string", + "nRequestTime timestamp", + "fWatchedTimeLen double"] + indexs: ["index1:zUserId|uUserId:ingestionTime"] + name: bo_hislabel + repeat: 100 + rows: + - [ 1609894067191, zUserId1, uUserId1, 1609894067191, 1.0 ] + - [ 1609894067191, zUserId2, uUserId2, 1609894067191, 1.0 ] + - [ 1609894067191, NULL, NULL, 1609894067191, 1.0 ] + sql: |- + select * from + ( + select + `reqId` as reqId_1 + from `flattenRequest`) as out0 + last join + ( + select + flattenRequest.reqId as reqId_74, + `action_reqId`.`actionValue` as action_actionValue_multi_direct_73 + from + `flattenRequest` + last join `action` as `action_reqId` on `flattenRequest`.`reqId` = `action_reqId`.`reqId`) + as out1 + on out0.reqId_1 = out1.reqId_74 + last join + ( + select + reqId as reqId_75, + sum(`fWatchedTimeLen`) over bo_hislabel_zUserId_uUserId_ingestionTime_1s_172801s as bo_hislabel_fWatchedTimeLen_multi_sum_73, + max(`fWatchedTimeLen`) over bo_hislabel_zUserId_uUserId_ingestionTime_1s_172801s as bo_hislabel_fWatchedTimeLen_multi_max_74, + avg(`fWatchedTimeLen`) over bo_hislabel_zUserId_uUserId_ingestionTime_1s_172801s as bo_hislabel_fWatchedTimeLen_multi_avg_75 + from + (select `eventTime` as `ingestionTime`, `zUserId` as `zUserId`, `uUserId` as `uUserId`, timestamp('2019-07-18 09:20:20') as `nRequestTime`, double(0) as `fWatchedTimeLen`, reqId from `flattenRequest`) + window bo_hislabel_zUserId_uUserId_ingestionTime_1s_172801s as ( + UNION (select `ingestionTime`, `zUserId`, `uUserId`, `nRequestTime`, `fWatchedTimeLen`, '' as reqId from `bo_hislabel`) partition by `zUserId`,`uUserId` order by `ingestionTime` rows_range between 172801s preceding and 1s preceding INSTANCE_NOT_IN_WINDOW)) + as out2 + on out0.reqId_1 = out2.reqId_75 + ; + tags: ["@baoxinqi, avg 空表处理需要对齐feql/mysql"] + batch_request: + columns: [ + "reqId string", + "eventTime timestamp", + "uUserId string", + "zUserId string", + "uSex string", + "zSex string", + "zChannel string", + "uPlayGame string", + "uHasJoinedGroup string", + "uWatchMorning double", + "uWatchEvening double", + "uWatchAvgLength double", + "zSWihsperNum double" ] + indexs: [ + "index1:uUserId:eventTime", + "index2:zChannel:eventTime", + "index3:uSex:eventTime", + "index4:zUserId:eventTime", + "index5:uPlayGame:eventTime", + "index6:uHasJoinedGroup:eventTime", + "index7:zUserId|uUserId:eventTime", + "index8:uUserId:eventTime", + "index9:uUserId:eventTime" ] + name: flattenRequest + rows: + # pure history window is empty: rows out of time range + - [reqId1, 1609894067191, uUserId1, zUserId1, uSex1, zSex1, zChannel1, uPlayGame1, uHasJoinedGroup1, 1.0, 2.0, 3.0, 4.0] + # pure history window isn't empty + - [reqId2, 1609894068191, uUserId2, zUserId2, uSex2, zSex2, zChannel2, uPlayGame2, uHasJoinedGroup2, 1.0, 2.0, 3.0, 4.0] + # last join key is NULL + - [NULL, 1609894068191, uUserIdNull, zUserIdNull, uSexNull, zSexNull, zChannelNull, uPlayGameNull, uHasJoinedGroupNull, 1.0, 2.0, 3.0, 4.0] + - [reqId2, 1609894068191, uUserId2, NULL, uSex2, zSex2, zChannel2, uPlayGame2, uHasJoinedGroup2, 1.0, 2.0, 3.0, 4.0] + - [reqId2, 1609894068191, NULL, NULL, uSex2, zSex2, zChannel2, uPlayGame2, uHasJoinedGroup2, 1.0, 2.0, 3.0, 4.0] + expect: + schema: reqId_1:string, reqId_74:string, action_actionValue_multi_direct_73:double, reqId_75:string, bo_hislabel_fWatchedTimeLen_multi_sum_73:double, bo_hislabel_fWatchedTimeLen_multi_max_74:double, bo_hislabel_fWatchedTimeLen_multi_avg_75:double + rows: + - [ reqId1, reqId1, 1.1, reqId1, NULL, NULL, NULL ] + - [ reqId2, reqId2, NULL, reqId2, 100.0, 1.0, 1.0 ] + - [ NULL, NULL, 3.3, NULL, NULL, NULL, NULL] + - [ reqId2, reqId2, NULL, reqId2, NULL, NULL, NULL ] + - [ reqId2, reqId2, NULL, reqId2, 100.0, 1.0, 1.0 ] diff --git a/cases/integration_test/join/test_lastjoin_complex.yaml b/cases/integration_test/join/test_lastjoin_complex.yaml new file mode 100644 index 00000000000..07b65aec95c --- /dev/null +++ b/cases/integration_test/join/test_lastjoin_complex.yaml @@ -0,0 +1,1197 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: lastjoin+窗口 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c4, + sum({1}.c4) OVER w1 as w1_c4_sum + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,32,32] + - [2,"aa",21,32,64] + - [3,"aa",22,32,64] + - [4,"bb",23,34,34] + - [5,"bb",24,34,68] + - id: 1 + desc: lastjoin+窗口-没有匹配的列 + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"cc",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"cc",21,34,1.2,2.2,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c4, + sum({1}.c4) OVER w1 as w1_c4_sum, + count({1}.c4) OVER w1 as w1_c4_count + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint","w1_c4_sum bigint","w1_c4_count bigint"] + rows: + - [1,"aa",20,32,32,1] + - [2,"aa",21,32,64,2] + - [3,"aa",22,32,64,2] + - [4,"bb",23,NULL,NULL,0] + - [5,"bb",24,NULL,NULL,0] + - id: 2 + desc: lastjoin+窗口+union + tags: ["TODO","暂时不支持 lastjoin window + union共存"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["d1 string","d4 bigint","d7 timestamp"] + indexs: ["index1:d1:d7"] + rows: + - ["aa",30,1590738990000] + - ["aa",32,1590738990002] + - ["bb",34,1590738990004] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","d1 string","d4 bigint","d7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02","aa",31,1590738990001] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04","bb",32,1590738990003] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select id,{0}.c1,{0}.c3,{1}.d4, + sum({1}.d4) OVER w1 as w1_c4_sum + from {0} + last join {1} ORDER BY {1}.d7 on {0}.c1={1}.d1 + WINDOW + w1 AS (UNION {2} PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","d4 bigint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,32,32] + - [3,"aa",22,32,63] + - [5,"bb",24,34,67] + - id: 3 + desc: lastjoin+窗口+union子查询 + tags: ["TODO","暂时不支持 lastjoin window + union共存"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["d1 string","d4 bigint","d7 timestamp"] + indexs: ["index1:d1:d7"] + rows: + - ["aa",30,1590738990000] + - ["aa",32,1590738990002] + - ["bb",34,1590738990004] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","d4 bigint"] + indexs: ["index1:c1:c7"] + rows: + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02",31] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04",32] + - + columns: ["d1 string","d7 timestamp"] + indexs: ["index1:d1:d7"] + rows: + - ["aa",1590738990001] + - ["bb",1590738990003] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select id,{0}.c1,{0}.c3,{1}.d4, + sum({1}.d4) OVER w1 as w1_c4_sum + from {0} + last join {1} ORDER BY {1}.d7 on {0}.c1={1}.d1 + WINDOW + w1 AS (UNION + (select id,c1,c3,c4,c5,c6,c7,c8,d1,d4,d7 from {2} last join {3} ORDER BY {3}.d7 on {2}.c1={3}.d1) + PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","d4 bigint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,32,32] + - [3,"aa",22,32,63] + - [5,"bb",24,34,67] + - id: 4 + desc: lastjoin-一个子查询 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select id,{0}.c1,{0}.c3,t1.c4, + sum(t1.c4) OVER w1 as w1_c4_sum + from {0} + last join (select c1,c4,c7 from {1}) as t1 ORDER BY t1.c7 on {0}.c1=t1.c1 + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,32,32] + - [2,"aa",21,32,64] + - [3,"aa",22,32,64] + - [4,"bb",23,34,34] + - [5,"bb",24,34,68] + - id: 5 + desc: 基于子查询作窗口-功能边界外 + tags: ["TODO","client core"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select t1.id,t2.c1,t2.c3,t1.c4, + sum(t1.c4) OVER w1 as w1_c4_sum + from (select id,c1,c3,c4,c7 from {0}) as t2 + last join (select c1,c4,c7 from {1}) as t1 ORDER BY t1.c7 on t2.c1=t1.c1 + WINDOW + w1 AS (PARTITION BY t2.c1 ORDER BY t2.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + success: false + - id: 6-1 + desc: 两个子查询lastjoin-子查询带窗口特征-rtidb不支持 + mode: offline-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"aa",22,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",23,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",24,34,1.2,2.2,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select id,t2.c1,t2.c3,t1.c4, + sum(t1.c4) OVER w1 as w1_c4_sum, + sum(t2.w2_c3_sum) OVER w1 as w2_c3_sum, + sum(t1.w3_c4_sum) OVER w1 as w3_c4_sum + from (select id,c1,c3,c4,c7,sum({0}.c3) OVER w2 as w2_c3_sum from {0} WINDOW w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)) as t2 + last join (select c1,c4,c7,sum({1}.c4) OVER w3 as w3_c4_sum from {1} WINDOW w3 AS (PARTITION BY {1}.c1 ORDER BY {1}.c7 ROWS_RANGE BETWEEN 1 PRECEDING AND CURRENT ROW)) as t1 + ORDER BY t1.c7 on t2.c1=t1.c1 + WINDOW + w1 AS (PARTITION BY t2.c1 ORDER BY t2.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + success: false + - id: 6-2 + desc: 两个子查询lastjoin-子查询带窗口特征-离线场景 + tags: ["TODO", "@chenjing", "0.3.0", ""] + mode: rtidb-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"aa",22,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",23,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",24,34,1.2,2.2,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select id,t2.c1,t2.c3,t1.c4, + sum(t1.c4) OVER w1 as w1_c4_sum, + sum(t2.w2_c3_sum) OVER w1 as w2_c3_sum, + sum(t1.w3_c4_sum) OVER w1 as w3_c4_sum + from (select id,c1,c3,c4,c7,sum({0}.c3) OVER w2 as w2_c3_sum from {0} WINDOW w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)) as t2 + last join (select c1,c4,c7,sum({1}.c4) OVER w3 as w3_c4_sum from {1} WINDOW w3 AS (PARTITION BY {1}.c1 ORDER BY {1}.c7 ROWS_RANGE BETWEEN 1 PRECEDING AND CURRENT ROW)) as t1 + ORDER BY t1.c7 on t2.c1=t1.c1 + WINDOW + w1 AS (PARTITION BY t2.c1 ORDER BY t2.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + success: true + - id: 7 + desc: lastjoin-ts-null + tags: ["TODO", "@chendihao", "zhaowei", "lastjoin对null的处理现在跟在线无法一致"] + mode: offline-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,null,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c4 + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint"] + rows: + - [1,"aa",20,31] + - [2,"aa",21,31] + - [3,"aa",22,31] + - [4,"bb",23,34] + - [5,"bb",24,34] + - id: 8 + desc: lastjoin三张表 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",20,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",20,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.2,1606766400000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"ee",20,30,1.1,2.1,1606752000000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.2,1606838400000,"2020-05-01"] + - [3,"ee",20,32,1.1,2.3,1606924800000,"2020-05-01"] + - [4,"ee",20,33,1.1,2.4,1607011200000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.5,1606752000000,"2020-05-02"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c4,{2}.c5,{3}.c6 + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + last join {2} ORDER BY {2}.c7 on {0}.c1={2}.c1 + last join {3} ORDER BY {3}.c7 on {0}.c1={3}.c1 + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double"] + rows: + - [1,"aa",20,31,1.1,null] + - [2,"bb",21,null,1.4,2.2] + - [3,"cc",22,32,null,null] + - [4,"dd",23,33,null,null] + - [5,"ee",24,34,1.5,2.4] + - id: 9-1 + desc: lastjoin三张表-5个window, rtidb模式不支持 + mode: offline-unsupport + tags: ["TODO","边界外", "@zhaowei", "后面需要支持多张表lastjoin后作window"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",20,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",20,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"bb",21,34,1.5,2.2,1606766400000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"bb",20,30,1.1,2.1,1606752000000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.2,1606838400000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.3,1606924800000,"2020-05-01"] + - [4,"ee",20,33,1.1,2.4,1607011200000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.5,1606752000000,"2020-05-02"] + sql: | + select id,{0}.c1,{0}.c3,{1}.c4,{2}.c5,{3}.c6, + sum({0}.c4) OVER w1 as w1_c4_sum, + sum({1}.c4) OVER w2 as w2_c4_sum, + sum({2}.c4) OVER w3 as w3_c4_sum, + sum({3}.c4) OVER w4 as w4_c4_sum, + count({3}.c4) OVER w5 as w5_c4_count + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + last join {2} ORDER BY {2}.c7 on {0}.c1={2}.c1 + last join {3} ORDER BY {3}.c7 on {0}.c1={3}.c1 + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 1s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {1}.c7 ROWS_RANGE BETWEEN 1m PRECEDING AND CURRENT ROW), + w3 AS (PARTITION BY {0}.c1 ORDER BY {2}.c7 ROWS_RANGE BETWEEN 1h PRECEDING AND CURRENT ROW), + w4 AS (PARTITION BY {0}.c1 ORDER BY {3}.c7 ROWS_RANGE BETWEEN 1d PRECEDING AND CURRENT ROW), + w5 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 9-2 + desc: lastjoin三张表-5个window-离线场景支持 + mode: rtidb-unsupport + tags: ["TODO", "@chendihao", "last join 多张表后做window离线支持有问题"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",20,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",20,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"bb",21,34,1.5,2.2,1606766400000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"bb",20,30,1.1,2.1,1606752000000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.2,1606838400000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.3,1606924800000,"2020-05-01"] + - [4,"ee",20,33,1.1,2.4,1607011200000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.5,1606752000000,"2020-05-02"] + sql: | + select id,{0}.c1,{0}.c3,{1}.c4,{2}.c5,{3}.c6, + sum({0}.c4) OVER w1 as w1_c4_sum, + sum({1}.c4) OVER w2 as w2_c4_sum, + sum({2}.c4) OVER w3 as w3_c4_sum, + sum({3}.c4) OVER w4 as w4_c4_sum, + count({3}.c4) OVER w5 as w5_c4_count + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + last join {2} ORDER BY {2}.c7 on {0}.c1={2}.c1 + last join {3} ORDER BY {3}.c7 on {0}.c1={3}.c1 + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 1s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {1}.c7 ROWS_RANGE BETWEEN 1m PRECEDING AND CURRENT ROW), + w3 AS (PARTITION BY {0}.c1 ORDER BY {2}.c7 ROWS_RANGE BETWEEN 1h PRECEDING AND CURRENT ROW), + w4 AS (PARTITION BY {0}.c1 ORDER BY {3}.c7 ROWS_RANGE BETWEEN 1d PRECEDING AND CURRENT ROW), + w5 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: true +# order: id +# columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","w1_c4_sum bigint","w2_c4_sum bigint","w3_c4_sum bigint","w4_c4_sum bigint","w5_c4_count bigint"] +# rows: +# - [1,"aa",20,31,1.1,null,30,32,31,null,0] +# - [2,"aa",21,null,1.4,2.2,61,64,62,null,0] +# - [3,"aa",22,32,null,null,63,64,62,null,0] +# - [4,"bb",23,33,null,null,33,34,34,31,1] +# - [5,"bb",24,34,1.5,2.4,67,68,68,62,2] + - id: 10 + desc: t1 join t2 join t3,t2的key产出为null + mode: offline-unsupport + tags: ["@chendihao", "这个场景离线的预期不正确,需要迪豪看看"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",21,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"cc",21,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"dd",21,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"ee",24,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",null,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",21,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.2,1606766401000,"2020-05-02"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c3,{2}.c4 + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + last join {2} ORDER BY {2}.c7 on {1}.c3={2}.c3 + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c3 int","c4 bigint"] + rows: + - [1,"aa",20,21,34] + - [2,"bb",21,null,32] + - [3,"cc",22,21,34] + - [4,"dd",23,21,34] + - [5,"ee",24,24,null] + - id: 11 + desc: (t1 join t2) join t3 + mode: offline-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",21,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"cc",21,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"dd",21,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"ee",24,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",null,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",21,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.2,1606766401000,"2020-05-02"] + sql: | + select + t1.id,t1.c1,t1.c3,{2}.c4 + from ( + select {0}.id,{0}.c1,{1}.c3 + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + ) as t1 last join {2} ORDER BY {2}.c7 on t1.c3={2}.c3 + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint"] + rows: + - [1,"aa",21,34] + - [2,"bb",null,32] + - [3,"cc",21,34] + - [4,"dd",21,34] + - [5,"ee",24,null] + - id: 11-2 + desc: (t1 join t2) join t3 error column resolved + tags: ["TODO", "@baoxinqi 重复列没有报错,理论上要计划编译失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",21,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"cc",21,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"dd",21,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"ee",24,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",null,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",21,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.2,1606766401000,"2020-05-02"] + sql: | + select + id,t1.c1,t1.c3,{2}.c4 + from ( + select id,{0}.c1,{1}.c3 + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + ) as t1 last join {2} ORDER BY {2}.c7 on t1.c3={2}.c3 + ; + expect: + success: false + - id: 12 + desc: t1 join (t2 join t3) + mode: rtidb-unsupport + tags: ["@zhaowei RITDB边界外的能力join的时候主表只有一张","http://jira.4paradigm.com/browse/FEX-1014"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",21,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"cc",21,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"dd",21,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"ee",24,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",null,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",21,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.2,1606766401000,"2020-05-02"] + sql: | + select + {0}.id,{0}.c1,t1.c3,t1.c4 + from + {0} last join + (select {1}.c1,{1}.c3,{1}.c7,{2}.c4 from {1} last join {2} order by {2}.c7 on {1}.c3={2}.c3) as t1 + order by t1.c7 on {0}.c1=t1.c1; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint"] + rows: + - [1,"aa",21,34] + - [2,"bb",null,null] + - [3,"cc",21,34] + - [4,"dd",21,34] + - [5,"ee",24,null] + - id: 13-1 + desc: t1 join (t2 join t3)-rtidb功能边界外的查询, join包含两张主表 + mode: request-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",21,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"cc",21,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"dd",21,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"ee",24,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",null,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",21,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.2,1606766401000,"2020-05-02"] + sql: | + select + {0}.id,{0}.c1,t1.c3,t1.c4 + from + {0} last join + (select {1}.c1,{1}.c3,{2}.c7,{2}.c4 from {1} last join {2} order by {2}.c7 on {1}.c3={2}.c3) as t1 + order by t1.c7 on {0}.c1=t1.c1; + expect: + success: true + order: id + columns: [ "id int", "c1 string", "c3 int", "c4 bigint"] + rows: + - [ 1, aa, 21, 34 ] + - [ 2, bb, NULL, NULL ] + - [ 3, cc, 21, 34 ] + - [ 4, dd, 21, 34 ] + - [ 5, ee, 24, NULL ] + + - id: 13-2 + desc: t1 join (t2 join t3)-key和ts不是来自同一个主表 + tags: ["TODO", "@zhaowei", "case构造不合理,需要构造(t1 join t2) join t3 - key 和 ts不来自同一个主表"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"aa",21,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"cc",21,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"dd",21,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"ee",24,34,1.2,2.2,1606755660000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.1,1606759200000,"2020-05-01"] + - [3,"bb",null,32,1.3,2.1,1606762800000,"2020-05-01"] + - [4,"bb",21,33,1.4,2.1,1606766400000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.2,1606766401000,"2020-05-02"] + sql: | + select + {0}.id,{0}.c1,t1.c3,t1.c4 + from + {0} last join + (select {1}.c1,{1}.c3,{2}.c7,{2}.c4 from {1} last join {2} order by {2}.c7 on {1}.c3={2}.c3) as t1 + order by t1.c7 on {0}.c1=t1.c1; + expect: + success: false + - id: 14 + desc: lastjoin-重名 + tags: ["TODO", "@baoxinqi select c3 预期column resolved error"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,null,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + sql: | + select {0}.id,{0}.c1,c3,c3,{1}.c4 + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + ; + expect: + success: false + - id: 15 + desc: lastjoin-重名,指定不同的表名-在线场景 + tags: ["TODO", "@zhaowei", "离线场景预期不一样,后面和可能需要针对离线在线配置不同预期"] + mode: offline-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,null,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c3,{1}.c4 + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c3 int","c4 bigint"] + rows: + - [1,"aa",20,20,31] + - [2,"aa",21,20,31] + - [3,"aa",22,20,31] + - [4,"bb",23,21,34] + - [5,"bb",24,21,34] + + - id: 16 + desc: 两个子查询lastjoin,拼接条件不是主表的索引 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + select t1.id,t2.c8,t2.c3,t1.c4 + from + (select id,c1,c3,c4,c7,c8 from {0}) as t2 + last join + (select c1,c4,c7,c8 from {1}) as t1 + ORDER BY t1.c7 on t2.c8=t1.c8 + ; + expect: + success: false + - id: 17-1 + desc: 两个子查询lastjoin,order不是主表的ts-rtidb不支持 + mode: request-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + select id,t2.c8,t2.c3,t1.c4 + from + (select id,c1,c3,c4,c7,c8 from {0}) as t2 + last join + (select c1,c4,c7,c8 from {1}) as t1 + ORDER BY t1.c4 on t2.c1=t1.c1 + ; + expect: + success: true + columns: [ "id int", "c8 date", "c3 int", "c4 bigint" ] + rows: + - [ 1, '2020-05-01', 20, 30 ] + + - id: 17-2 + desc: 两个子查询lastjoin,order不是主表的ts-离线支持 + mode: rtidb-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + select id,t2.c8,t2.c3,t1.c4 + from + (select id,c1,c3,c4,c7,c8 from {0}) as t2 + last join + (select c1,c4,c7,c8 from {1}) as t1 + ORDER BY t1.c4 on t2.c1=t1.c1 + ; + expect: + success: true + - id: 18-1 + desc: 两个子查询lastjoin,拼接条件不是主表的索引-不带orderby-rtidb边界外 + mode: request-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + select id,t2.c8,t2.c3,t1.c4 + from + (select id,c1,c3,c4,c7,c8 from {0}) as t2 + last join + (select c1,c4,c7,c8 from {1}) as t1 + on t2.c8=t1.c8 + ; + expect: + success: true + columns: [ "id int", "c8 date", "c3 int", "c4 bigint" ] + rows: + - [ 1, '2020-05-01', 20, 30 ] + + - id: 18-2 + desc: 两个子查询lastjoin,拼接条件不是主表的索引-不带orderby-离线支持 + mode: request-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + select id,t2.c8,t2.c3,t1.c4 + from + (select id,c1,c3,c4,c7,c8 from {0}) as t2 + last join + (select c1,c4,c7,c8 from {1}) as t1 + on t2.c8=t1.c8 + ; + expect: + success: true + columns: [ "id int", "c8 date", "c3 int", "c4 bigint" ] + rows: + - [ 1, '2020-05-01', 20, 30 ] + + - id: 19-1 + desc: 两个子查询lastjoin-子查询带窗口特征-没有使用索引-不带orderby + mode: request-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-02"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-02"] + sql: | + select id,t2.c1,t2.c3,t1.c4, t2.w2_c3_sum, t1.w3_c4_sum + from (select id,c1,c3,c4,c7,c8,sum({0}.c3) OVER w2 as w2_c3_sum from {0} WINDOW w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)) as t2 + last join (select c1,c4,c7,c8,sum({0}.c4) OVER w3 as w3_c4_sum from {0} WINDOW w3 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 1 PRECEDING AND CURRENT ROW)) as t1 + on t2.c7=t1.c7 + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint", "w2_c3_sum int", "w3_c4_sum bigint"] + rows: + - [1,"aa",20,30, 20, 30] + - [2,"aa",21,31, 41, 61] + - [3,"aa",22,32, 63, 63] + - [4,"bb",23,33, 23, 33] + - [5,"bb",24,34, 47, 67] + - id: 20 + desc: 两个子查询lastjoin-子查询带窗口特征-没有使用索引-带orderby + mode: request-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + select id,t2.c1,t2.c3,t1.c4 + from (select id,c1,c3,c4,c7,c8,sum({0}.c3) OVER w2 as w2_c3_sum from {0} WINDOW w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)) as t2 + last join (select c1,c4,c7,c8,sum({1}.c4) OVER w3 as w3_c4_sum from {1} WINDOW w3 AS (PARTITION BY {1}.c1 ORDER BY {1}.c7 ROWS_RANGE BETWEEN 1 PRECEDING AND CURRENT ROW)) as t1 + ORDER BY t1.c7 on t2.c8=t1.c8 + ; + expect: + success: true + columns: [ "id int", "c1 string", "c3 int", "c4 bigint" ] + rows: + - [ 1, aa, 20, 30 ] + + - id: 21 + desc: lastjoin列名重复-窗口没有指定表名 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"bb",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c4, + sum({1}.c4) OVER w1 as w1_c4_sum + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW) + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,31,31] + - [2,"aa",21,31,62] + - [3,"aa",22,31,62] + - [4,"bb",23,34,34] + - [5,"bb",24,34,68] + - id: 22 + desc: lastjoin后group by + mode: request-unsupport, cluster-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select {0}.c1,sum({1}.c3) as v1 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1 group by {0}.c1; + expect: + order: c1 + columns: [ "c1 string","v1 bigint" ] + rows: + - [ "aa",26 ] + - [ "cc",151 ] + - id: 23 + desc: lastjoin后group by, left key is match with left table index + mode: request-unsupport, cluster-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select {0}.c1,sum({1}.c3) as v1 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1 group by {0}.c1; + expect: + order: c1 + columns: [ "c1 string","v1 bigint" ] + rows: + - [ "aa",26 ] + - [ "cc",151 ] + - id: 24 + desc: lastjoin后group by with left key and index key + mode: request-unsupport, cluster-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: | + select {0}.c1,sum({1}.c3) as v1 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1 and {0}.c2 = + {1}.c2 group by {0}.c1; + expect: + order: c1 + columns: [ "c1 string","v1 bigint" ] + rows: + - [ "aa",13 ] + - [ "cc",151 ] diff --git a/cases/integration_test/join/test_lastjoin_simple.yaml b/cases/integration_test/join/test_lastjoin_simple.yaml new file mode 100644 index 00000000000..05a27164047 --- /dev/null +++ b/cases/integration_test/join/test_lastjoin_simple.yaml @@ -0,0 +1,1068 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 1 + desc: 正常拼接 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1; + expect: + order: c1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + - id: 2 + desc: 右表没有匹配 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "dd",41,151,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,null,null ] + - id: 3 + desc: 右表匹配了多条-bigint + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "bb",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - id: 4-1 + desc: Last Join 无order by, 拼表条件命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "dd", 41, NULL, NULL ] + - id: 4-2 + desc: Last Join 无order by, 拼表条件没有命中索引-performance-sensitive环境下编译失败 + mode: non-performance-sensitive-unsupport, offline-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1; + expect: + success: false + - id: 4-2 + desc: Last Join 无order by, 部分拼表条件命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",3,14,1590738990000 ] + - [ "aa",4,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1 and {0}.c4={1}.c4; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c2 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",20,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "dd", 41, NULL, NULL ] + - id: 4-3 + desc: Last Join 无order by, 拼表条件命中部分的组合索引(前缀索引), performance-sensitive下失败 + mode: non-performance-sensitive-unsupport, offline-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1|c2:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",3,14,1590738990000 ] + - [ "aa",4,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1 and {0}.c4={1}.c4; + expect: + success: false + - id: 4-4 + desc: Last Join 无order by, 拼表条件命中部分的组合索引(后缀索引) + mode: non-performance-sensitive-unsupport, offline-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2|c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",3,14,1590738990000 ] + - [ "aa",4,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1 and {0}.c4={1}.c4; + expect: + success: false + - id: 4-5 + desc: Last Join 无order by, 拼表条件命中索引, 副表多条命中 + tags: [ "注意offline随机拼接最后一条,改变结果顺序可能导致Spark结果不符合预期" ] + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "bb",51,130,1590738992000 ] + - [ "bb",31,132,1590738989000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,132,1590738989000 ] + - [ "dd", 41, NULL, NULL ] + - id: 4-6 + desc: Last Join 无order by, 拼表条件没有命中索引-离线支持 + mode: rtidb-unsupport,cli-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "aa", 2, 13, 1590738989000 ] + - [ "bb", 21, 131, 1590738990000 ] + - id: 4-7 + desc: Last Join 无order by, 部分拼表条件命中索引(常量条件=右边索引key) + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",3,14,1590738990000 ] + - [ "aa",4,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2, {1}.c1 as t2_c1, {1}.c3,{1}.c4 from {0} last join {1} on {1}.c1="aa" and {0}.c4={1}.c4; + expect: + columns: [ "c1 string","c2 int", "t2_c1 string", "c3 bigint","c4 timestamp" ] + order: c2 + rows: + - [ "aa",2, "aa", 13,1590738989000 ] + - [ "aa",20,"aa", 15,1590738991000 ] + - [ "bb",21, "aa", 14,1590738990000 ] + - [ "dd", 41, "aa", 14, 1590738990000 ] + - id: 5 + desc: orderby-timestamp + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "bb",41,121,1590738992000 ] + - [ "bb",41,141,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,121,1590738992000 ] + - id: 6 + desc: orderby-int without index optimized, request-unsupport + mode: request-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "bb",41,121,1590738991000 ] + - [ "bb",31,141,1590738992000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c2 on {0}.c1={1}.c1; + expect: + success: true + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ aa, 2, 13, 1590738989000 ] + - [ bb, 21, 121, 1590738991000 ] + + - id: 6 + desc: orderby-int-离线支持 + mode: rtidb-unsupport,cli-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "bb",41,121,1590738991000 ] + - [ "bb",31,141,1590738992000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c2 on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,121,1590738991000 ] + - id: 7 + desc: orderby-float + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.3,1590738990000,"2020-05-03","ab" ] + - [ "bb",2.5,3.6,1590738991000,"2020-05-04","bc" ] + - [ "bb",2.4,3.1,1590738992000,"2020-05-02","bb" ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c2 on {0}.c1={1}.c1; + expect: + success: false + - id: 8 + desc: orderby-double + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.3,1590738990000,"2020-05-03","ab" ] + - [ "bb",2.5,3.6,1590738991000,"2020-05-04","bc" ] + - [ "bb",2.4,3.1,1590738992000,"2020-05-02","bb" ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1; + expect: + success: false + - id: 9 + desc: orderby-date + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.3,1590738990000,"2020-05-03","ab" ] + - [ "bb",2.5,3.6,1590738991000,"2020-05-04","bc" ] + - [ "bb",2.4,3.1,1590738992000,"2020-05-02","bb" ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c5 on {0}.c1={1}.c1; + expect: + success: false + - id: 10 + desc: orderby-string + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.3,1590738990000,"2020-05-03","ab" ] + - [ "bb",2.5,3.6,1590738991000,"2020-05-04","bc" ] + - [ "bb",2.4,3.1,1590738992000,"2020-05-02","bb" ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c6 on {0}.c1={1}.c1; + expect: + success: false + - id: 11 + desc: 拼接条件-bigint + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",41,31,1590738992000 ] + - [ "bb",41,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c3={1}.c3; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738992000 ] + - id: 12 + desc: 拼接条件-int + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",21,31,1590738992000 ] + - [ "bb",21,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c2={1}.c2; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738992000 ] + - id: 13 + desc: 拼接条件-float-未命中索引 + mode: rtidb-unsupport, performance-sensitive-unsupport + tags: ["TODO", "v0.3.0", "@chenjing, fix join on double/float equal condition"] + inputs: + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.2,1590738990000,"2020-05-02","aa" ] + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.2,1590738990000,"2020-05-03","ab" ] + - [ "bb",2.2,3.2,1590738992000,"2020-05-04","bc" ] + - [ "bb",2.2,3.2,1590738991000,"2020-05-02","bb" ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c2={1}.c2; + expect: + columns: [ "c1 string","c2 float","c3 double","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2.1,3.1,1590738989000 ] + - [ "bb",2.2,3.2,1590738992000 ] + - id: 13-2 + desc: 拼接条件-double + mode: rtidb-unsupport, performance-sensitive-unsupport + tags: ["TODO", "v0.3.0", "@chenjing, fix join on double/float equal condition"] + inputs: + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.2,1590738990000,"2020-05-02","aa" ] + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.2,1590738990000,"2020-05-03","ab" ] + - [ "bb",2.2,3.2,1590738992000,"2020-05-04","bc" ] + - [ "bb",2.2,3.2,1590738991000,"2020-05-02","bb" ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c3={1}.c3; + expect: + columns: [ "c1 string","c2 float","c3 double","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2.1,3.1,1590738989000 ] + - [ "bb",2.2,3.2,1590738992000 ] + - id: 14 + desc: 拼接条件-date + inputs: + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c5:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.2,1590738990000,"2020-05-02","aa" ] + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 string" ] + indexs: [ "index1:c5:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01","aa" ] + - [ "bb",2.2,3.2,1590738990000,"2020-05-02","ab" ] + - [ "bb",2.2,3.2,1590738992000,"2020-05-02","bc" ] + - [ "bb",2.2,3.2,1590738991000,"2020-05-02","bb" ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c5={1}.c5; + expect: + columns: [ "c1 string","c2 float","c3 double","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2.1,3.1,1590738989000 ] + - [ "bb",2.2,3.2,1590738992000 ] + - id: 14 + desc: 拼接条件-timestamp + inputs: + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 timestamp" ] + indexs: [ "index1:c6:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01",1590738989000 ] + - [ "bb",2.2,3.2,1590738990000,"2020-05-02",1590738990000 ] + - columns: [ "c1 string","c2 float","c3 double","c4 timestamp","c5 date","c6 timestamp" ] + indexs: [ "index1:c6:c4" ] + rows: + - [ "aa",2.1,3.1,1590738989000,"2020-05-01",1590738989000 ] + - [ "bb",2.2,3.2,1590738990000,"2020-05-02",1590738990000 ] + - [ "bb",2.2,3.2,1590738992000,"2020-05-02",1590738990000 ] + - [ "bb",2.2,3.2,1590738991000,"2020-05-02",1590738990000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c6={1}.c6; + expect: + columns: [ "c1 string","c2 float","c3 double","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2.1,3.1,1590738989000 ] + - [ "bb",2.2,3.2,1590738992000 ] + - id: 15 + desc: 不同类型的列作为拼接条件 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ "aa",2,2,1590738989000 ] + - [ "bb",21,21,1590738990000 ] + - [ "bb",21,21,1590738992000 ] + - [ "bb",21,21,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c2={1}.c3; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,2,1590738989000 ] + - [ "bb",21,21,1590738992000 ] + - id: 16 + desc: 多个拼接条件 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",21,32,1590738993000 ] + - [ "bb",21,31,1590738992000 ] + - [ "bb",21,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c2={1}.c2 and {0}.c3={1}.c3; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738992000 ] + - id: 17 + desc: 不等值拼接 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",21,32,1590738993000 ] + - [ "bb",21,31,1590738992000 ] + - [ "bb",21,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c2 = {1}.c2 and {0}.c3 <= {1}.c3; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,32,1590738993000 ] + - id: 17-1 + desc: 不等值拼接-未命中索引 + mode: rtidb-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",21,32,1590738993000 ] + - [ "bb",21,31,1590738992000 ] + - [ "bb",21,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c3<{1}.c3; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,32,1590738993000 ] + - [ "bb",21,32,1590738993000 ] + - id: 17-2 + desc: order by 限定列的范围-常量 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",21,32,1590738993000 ] + - [ "bb",21,31,1590738992000 ] + - [ "bb",21,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c3={1}.c3 and {1}.c3>10; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,null,null ] + - [ "bb",21,31,1590738992000 ] + - id: 18 + desc: order by 限定列的范围-变量 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",22,31,1590738990000 ] + - [ "bb",21,32,1590738993000 ] + - [ "bb",22,31,1590738992000 ] + - [ "bb",22,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c3={1}.c3 and {0}.c2<{1}.c2; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,null,null ] + - [ "bb",21,31,1590738992000 ] + - id: 19 + desc: 拼接条件中有空串 + mode: cli-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "",2,3,1590738989000 ] + - [ "bb",22,31,1590738990000 ] + - [ "ab",21,32,1590738993000 ] + - [ "bb",22,31,1590738992000 ] + - [ "bb",22,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "",2,3,1590738989000 ] + - [ "bb",21,31,1590738992000 ] + - id: 19 + desc: 拼接条件中有null + tags: [ "TODO", "@chenjing, @baoxinqi" ] + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ NULL,2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ NULL,2,3,1590738989000 ] + - [ "bb",22,31,1590738990000 ] + - [ "ab",21,32,1590738993000 ] + - [ "bb",22,31,1590738992000 ] + - [ "bb",22,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ null,2,3,1590738989000 ] + - [ "bb",21,31,1590738992000 ] + - id: 20 + desc: 结合limit + tags: [ "TODO", "remove @zhaowei" ] + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",41,31,1590738992000 ] + - [ "bb",41,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c3={1}.c3 limit 1; + expect: + rows: + - [ "aa",2,3,1590738989000 ] + - id: 21 + desc: 三表拼表 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "bb",41,121,1590738992000 ] + - [ "bb",41,121,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",21,131,1590738992000 ] + - [ "aa",41,121,1590738991000 ] + - [ "bb",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c4,{2}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c1={1}.c1 last join {2} order by {2}.c4 on {0}.c1={2}.c1; + expect: + columns: [ "c1 string","c2 int","c4 timestamp","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,1590738989000,1590738992000 ] + - [ "bb",21,1590738992000,1590738991000 ] + - id: 22 + desc: 拼接条件不是索引列 + mode: rtidb-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",21,31,1590738992000 ] + - [ "bb",21,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c2={1}.c2; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738992000 ] + - id: 23 + desc: 使用表别名 + inputs: + - columns: [ "c1 string","c2 bigint","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 bigint","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c2" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "bb",41,121,1590738991000 ] + - [ "bb",31,141,1590738992000 ] + sql: select t1.c1,t1.c2,t2.c3,t2.c4 from {0} as t1 last join {1} as t2 ORDER BY t2.c2 on t1.c1=t2.c1; + expect: + columns: [ "c1 string","c2 bigint","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,121,1590738991000 ] + - id: 25 + desc: LAST JOIN with rename table + mode: python-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4", "index2:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",21,32,1590738993000 ] + - [ "cc",21,31,1590738992000 ] + - [ "dd",21,31,1590738991000 ] + sql: | + select + {0}.c1, {0}.c2, {0}.c3, + t2.c1 as t2_c1, t2.c2 as t2_c2, t2.c3 as t2_c3,t2.c4 as t2_c4, + t3.c1 as t3_c1, t3.c4 as t3_c4 from {0} + last join {1} as t2 ORDER BY t2.c4 on {0}.c2 = t2.c2 and {0}.c3 <= t2.c3 + last join {1} as t3 ORDER BY t3.c4 on {0}.c1 = t3.c1 and {0}.c3 <= t3.c3; + expect: + columns: [ "c1 string","c2 int", "c3 bigint", "t2_c1 string", "t2_c2 int", "t2_c3 bigint","t2_c4 timestamp", "t3_c1 string", "t3_c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,3, "aa", 2, 3,1590738989000, "aa", 1590738989000 ] + - [ "bb",21, 31, "cc", 21, 32,1590738993000, "bb", 1590738990000 ] + - id: 26 + desc: LAST JOIN subquery with rename table + mode: python-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "col1 string","col2 int","col3 bigint","col4 timestamp" ] + indexs: [ "index1:col2:col4", "index2:col1:col4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",21,32,1590738993000 ] + - [ "cc",21,31,1590738992000 ] + - [ "dd",21,31,1590738991000 ] + sql: | + select + {0}.c1, {0}.c2, {0}.c3, + t2.c1 as t2_c1, t2.c2 as t2_c2, t2.c3 as t2_c3,t2.c4 as t2_c4, + t3.c1 as t3_c1, t3.c4 as t3_c4 from {0} + last join (select col1 as c1, col2 as c2, col3 as c3, col4 as c4 from {1}) as t2 ORDER BY t2.c4 on {0}.c2 = t2.c2 and {0}.c3 <= t2.c3 + last join (select col1 as c1, col3 as c3, col4 as c4 from {1}) as t3 ORDER BY t3.c4 on {0}.c1 = t3.c1 and {0}.c3 <= t3.c3; + expect: + columns: [ "c1 string","c2 int", "c3 bigint", "t2_c1 string", "t2_c2 int", "t2_c3 bigint","t2_c4 timestamp", "t3_c1 string", "t3_c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,3, "aa", 2, 3,1590738989000, "aa", 1590738989000 ] + - [ "bb",21, 31, "cc", 21, 32,1590738993000, "bb", 1590738990000 ] + - id: 27 + desc: LAST JOIN subquery with rename table 2 + mode: python-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "col1 string","col2 int","col3 bigint","col4 timestamp" ] + indexs: [ "index1:col2:col4", "index2:col1:col4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",21,32,1590738993000 ] + - [ "cc",21,31,1590738992000 ] + - [ "dd",21,31,1590738991000 ] + sql: | + select + {0}.c1, {0}.c2, {0}.c3, + t2.c1 as t2_c1, t2.c2 as t2_c2, t2.c3 as t2_c3,t2.c4 as t2_c4, + t3.c1 as t3_c1, t3.c4 as t3_c4 from {0} + last join (select col1 as c1, col2 as c2, col3 as c3, col4 as c4 from {1}) as t2 ORDER BY t2.c4 on {0}.c2 = t2.c2 and {0}.c3 <= t2.c3 + last join (select col1 as c1, col2 as c2, col3 as c3, col4 as c4 from {1}) as t3 ORDER BY t3.c4 on {0}.c1 = t3.c1 and {0}.c3 <= t3.c3; + expect: + columns: [ "c1 string","c2 int", "c3 bigint", "t2_c1 string", "t2_c2 int", "t2_c3 bigint","t2_c4 timestamp", "t3_c1 string", "t3_c4 timestamp" ] + order: c1 + rows: + - ["aa",2,3, "aa", 2, 3,1590738989000, "aa", 1590738989000] + - ["bb",21, 31, "cc", 21, 32,1590738993000, "bb", 1590738990000] + + - id: 28 + desc: orderby-smallint + tags: ["offline-unsupport", "TODO"] + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - columns: ["c1 string","c2 smallint","c3 double","c4 timestamp","c5 date","c6 string"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",1,3.1,1590738989000,"2020-05-01","aa"] + - ["bb",2,3.3,1590738990000,"2020-05-03","ab"] + - ["bb",5,3.6,1590738991000,"2020-05-04","bc"] + - ["bb",4,3.1,1590738992000,"2020-05-02","bb"] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c2 on {0}.c1={1}.c1; + expect: + success: false + + - id: 29 + desc: orderby-bool + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - columns: ["c1 string","c2 bool","c3 double","c4 timestamp","c5 date","c6 string"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",true,3.1,1590738989000,"2020-05-01","aa"] + - ["bb",true,3.3,1590738990000,"2020-05-03","ab"] + - ["bb",false,3.6,1590738991000,"2020-05-04","bc"] + - ["bb",true,3.1,1590738992000,"2020-05-02","bb"] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c2 on {0}.c1={1}.c1; + expect: + success: false + - id: 30 + desc: 拼接条件-smallint + inputs: + - columns: ["c1 string","c2 smallint","c3 bigint","c4 timestamp"] + indexs: ["index1:c2:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - columns: ["c1 string","c2 smallint","c3 bigint","c4 timestamp"] + indexs: ["index1:c2:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["bb",21,31,1590738992000] + - ["bb",21,31,1590738991000] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c2={1}.c2; + expect: + columns: ["c1 string","c2 smallint","c3 bigint","c4 timestamp"] + order: c1 + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738992000] + - id: 31 + desc: 拼接条件-bool + tags: ["TODO", "bug"] + inputs: + - columns: ["c1 string","c2 bool","c3 bigint","c4 timestamp"] + indexs: ["index1:c2:c4"] + rows: + - ["aa",true,3,1590738989000] + - ["bb",false,31,1590738990000] + - columns: ["c1 string","c2 bool","c3 bigint","c4 timestamp"] + indexs: ["index1:c2:c4"] + rows: + - ["aa",true,3,1590738989000] + - ["bb",false,31,1590738990000] + - ["bb",false,31,1590738992000] + - ["bb",false,31,1590738991000] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c2={1}.c2; + expect: + columns: ["c1 string","c2 bool","c3 bigint","c4 timestamp"] + order: c1 + rows: + - ["aa",true,3,1590738989000] + - ["bb",false,31,1590738992000] + - id: 4-6 + desc: lastjoin-拼表条件没有命中索引 + mode: performance-sensitive-unsupport,cli-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} order by {1}.c4 on {0}.c1={1}.c1; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + order: c1 + rows: + - [ "aa", 2, 13, 1590738989000 ] + - [ "bb", 21, 131, 1590738990000 ] + - + id: 12 + desc: 不指定索引,进行lastjoin + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "dd", 41, NULL, NULL ] + - + id: 13 + desc: 不指定索引,进行lastjoin,匹配多行 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,131,1590738990000 ] + - [ "bb",21,NULL,NULL ] + - [ "dd", 41, NULL, NULL ] \ No newline at end of file diff --git a/cases/integration_test/long_window/test_count_where.yaml b/cases/integration_test/long_window/test_count_where.yaml new file mode 100644 index 00000000000..e2ac7304c72 --- /dev/null +++ b/cases/integration_test/long_window/test_count_where.yaml @@ -0,0 +1,811 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.6.0 +cases: + - + id: 0 + desc: 长窗口count_where,date类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",1,2,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",1,3,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,4,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,5,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_where_c8_c2 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,1] + - + id: 1 + desc: 长窗口count_where,smallint类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c2,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 2 + desc: 长窗口count_where,int类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c3,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 3 + desc: 长窗口count_where,bigint类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c4,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 4 + desc: 长窗口count_where,string类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c1,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 5 + desc: 长窗口count_where,timestamp类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c7,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 6 + desc: 长窗口count_where,row类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(*,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 7 + desc: 长窗口count_where,bool类型 + tags: ["TODO","bug,下个版本修复后测试,@qiliguo"] + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c9,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 8 + desc: 长窗口count_where,float类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c5,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 9 + desc: 长窗口count_where,double类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c6,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 10 + desc: 长窗口count_where,第二个参数使用bool列 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c9) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 11 + desc: 长窗口count_where,第二个参数使用= + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2=4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",0] + - [2,"aa",0] + - [3,"aa",0] + - [4,"aa",1] + - [5,"aa",1] + - + id: 12 + desc: 长窗口count_where,第二个参数使用!= + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2!=4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",2] + - + id: 13 + desc: 长窗口count_where,第二个参数使用>= + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2>=2) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",0] + - [2,"aa",1] + - [3,"aa",2] + - [4,"aa",3] + - [5,"aa",3] + - + id: 14 + desc: 长窗口count_where,第二个参数使用<= + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2<=3) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 15 + desc: 长窗口count_where,第二个参数使用> + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2>1) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",0] + - [2,"aa",1] + - [3,"aa",2] + - [4,"aa",3] + - [5,"aa",3] + - + id: 17 + desc: 长窗口count_where,第二个参数使用and + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2<4 and c2>1) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 18 + desc: 长窗口count_where,第二个参数使用两个列 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c3>c2) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 19 + desc: 长窗口count_where,第二个参数使用嵌套 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,if_null(c2,0)>4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 20 + desc: 长窗口count_where,第二个参数常量在前 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,4>c2) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 21 + desc: 长窗口count_where,rows + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 22 + desc: 长窗口count_where,第二个参数类型是int + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c3<23) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 23 + desc: 长窗口count_where,第二个参数类型是bigint + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c4<33) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 24 + desc: 长窗口count_where,第二个参数类型是float + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c5<1.35) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 25 + desc: 长窗口count_where,第二个参数类型是double + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c6<2.4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 26 + desc: 长窗口count_where,第二个参数类型是timestamp + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c7<1590738993000) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 27 + desc: 长窗口count_where,第二个参数类型是date + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c8<"2020-05-04") OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 28 + desc: 长窗口count_where,第二个参数类型是bool + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",false] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c9=true) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 29 + desc: 长窗口count_where,w1:2 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 30 + desc: 长窗口count_where,磁盘表 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: SSD + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c3,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 31 + desc: 长窗口count_where,第二个参数类型是string + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01","true"] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02","true"] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03","true"] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04","false"] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05","false"] + sql: | + SELECT id, c1, count_where(c8,c9="true") OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + - + id: 32 + desc: 长窗口count_where,验证预聚合表 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,2,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,4,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,5,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, count_where(c8,c2<4) OVER w1 as w1_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_count bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",2] + - [5,"aa",1] + + + diff --git a/cases/integration_test/long_window/test_long_window.yaml b/cases/integration_test/long_window/test_long_window.yaml new file mode 100644 index 00000000000..75f6f6193a5 --- /dev/null +++ b/cases/integration_test/long_window/test_long_window.yaml @@ -0,0 +1,397 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: options(long_window='w1:2y') + longWindow: w1:2y + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7:0:latest"] + rows: + - [1,"aa",20,30,1.1,2.1,1262278860000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1293814860000,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1325350860000,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1356973260000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1356973260000,"2020-05-05"] + sql: | + SELECT id, c1, count(c4) OVER w1 as w1_long FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: create aggregator failed + - + id: 1 + desc: options(long_window='w1:2d') + longWindow: w1:2d + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1577811660000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1577898060000,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1577984460000,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1578070860000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1578157260000,"2020-05-05"] + sql: | + SELECT id, c1, count(c4) OVER w1 as w1_long FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2d PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_long bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c4 + type: bigint + rows: + - ["aa",1577664000000,1577836799999,1,1,null] + - ["aa",1577836800000,1578009599999,2,2,null] + - + id: 2 + desc: options(long_window='w1:2h') + longWindow: w1:2h + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1577811661000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1577815261000,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1577818861000,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1577822461000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1577826061000,"2020-05-05"] + sql: | + SELECT id, c1, count(c4) OVER w1 as w1_long FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2h PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_long bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c4 + type: bigint + rows: + - ["aa",1577808000000,1577815199999,1,1,null] + - ["aa",1577815200000,1577822399999,2,2,null] + - + id: 3 + desc: options(long_window='w1:2m') + longWindow: w1:2m + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1577812141000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1577812201000,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1577812261000,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1577812321000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1577812381000,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_long FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2m PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_long bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + type: bigint + rows: + - ["aa",1577812080000,1577812199999,1,30,null] + - ["aa",1577812200000,1577812319999,2,63,null] + - + id: 4 + desc: options(long_window='w1:2s') + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738991000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738992000,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738993000,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738995000,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_long FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_long bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,1,30,null] + - ["aa",1590738992000,1590738993999,2,63,null] + - + id: 5 + desc: 相同的PARTITION BY和ORDER BY,长窗口和短窗口可合并 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_long, count(c4) OVER w2 as w2_long from {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_long bigint","w2_long bigint"] + rows: + - [1,"aa",30,1] + - [2,"aa",61,2] + - [3,"aa",93,3] + - [4,"aa",96,4] + - [5,"aa",99,4] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738990001,2,61,null] + - ["aa",1590738990002,1590738990003,2,65,null] + - + id: 6 + desc: 相同的PARTITION BY和ORDER BY,长窗口之间可合并 + longWindow: w1:2,w2:2 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7:0:latest"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_long, min(c3) OVER w2 as w2_long from {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_long bigint","w2_long int"] + rows: + - [1,"aa",30,20] + - [2,"aa",61,20] + - [3,"aa",93,20] + - [4,"aa",96,20] + - [5,"aa",99,21] + preAggList: + - + name: pre_{db_name}_{sp_name}_w1_sum_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738990001,2,61,null] + - ["aa",1590738990002,1590738990003,2,65,null] + - + name: pre_{db_name}_{sp_name}_w2_min_c3 + type: bigint + rows: + - ["aa",1590738990000,1590738990001,2,20,null] + - ["aa",1590738990002,1590738990003,2,22,null] + - + id: 7 + desc: 相同的PARTITION BY和ORDER BY,-短窗口之间可合并(三个窗口 一个长窗口,俩个短窗口) + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7:0:latest"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_long, avg(c3) OVER w2 as w2_c3_avg, count(c3) OVER w3 as w3_c3_count from {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 1 PRECEDING AND CURRENT ROW), + w3 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_long bigint","w2_c3_avg double","w3_c3_count bigint"] + rows: + - [1,"aa",30,20,1] + - [2,"aa",61,20.5,2] + - [3,"aa",93,21.5,3] + - [4,"aa",96,22.5,4] + - [5,"aa",99,23.5,4] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738990001,2,61,null] + - ["aa",1590738990002,1590738990003,2,65,null] + - + id: 8 + desc: 不同的PARTITION BY和ORDER BY,长窗口和短窗口混合-不可合并窗口 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7:0:latest"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",20,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1,c3, sum(c4) OVER w1 as w1_long,count(c5) OVER w2 as w2_c5_count from {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_long bigint","w2_c5_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"aa",20,61,2] + - [3,"aa",20,93,3] + - [4,"aa",20,96,3] + - [5,"aa",24,99,1] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738990001,2,61,null] + - ["aa",1590738990002,1590738990003,2,65,null] + - + id: 9 + desc: 窗口名不存在 + longWindow: w2:2 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7:0:latest"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + msg: long_windows option doesn't match window in sql + - + id: 10 + version: 0.6.1 + desc: delete pk + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738991000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738992000,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738993000,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738995000,"2020-05-05"] + steps: + - sql: SELECT id, c1, sum(c4) OVER w1 as w1_long FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_long bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,1,30,null] + - ["aa",1590738992000,1590738993999,2,63,null] + - sql: delete from {0} where c1='aa'; + expect: + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + count: 0 + - + id: 11 + version: 0.6.1 + desc: delete 组合索引 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1|c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738991000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738992000,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738993000,"2020-05-03"] + - [4,"aa",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"aa",20,34,1.5,2.5,1590738995000,"2020-05-05"] + steps: + - sql: SELECT id, c1,c3, sum(c4) OVER w1 as w1_long FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_long bigint"] + rows: + - [1,"aa",20,30] + - [2,"aa",20,61] + - [3,"aa",20,93] + - [4,"aa",20,96] + - [5,"aa",20,99] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + type: bigint + rows: + - ["aa|20",1590738990000,1590738991999,1,30,null] + - ["aa|20",1590738992000,1590738993999,2,63,null] + - sql: delete from {0} where c1='aa' and c3=20; + expect: + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4 + count: 0 + + + diff --git a/cases/integration_test/long_window/test_long_window_batch.yaml b/cases/integration_test/long_window/test_long_window_batch.yaml new file mode 100644 index 00000000000..60c938490d4 --- /dev/null +++ b/cases/integration_test/long_window/test_long_window_batch.yaml @@ -0,0 +1,35 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: options格式错误 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + deploy {0} options(long_windows='w1:100') SELECT id, c1, avg(c5) OVER w1 as w1_c4_avg FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: true diff --git a/cases/integration_test/long_window/test_udaf.yaml b/cases/integration_test/long_window/test_udaf.yaml new file mode 100644 index 00000000000..1eb2778c6e5 --- /dev/null +++ b/cases/integration_test/long_window/test_udaf.yaml @@ -0,0 +1,788 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 长窗口count/avg/sum/max/min,date类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,2,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,4,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,5,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c8) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min","max","sum","avg","count"] + expectProvider: + 0: + order: id + columns: [ "id int","c1 string","w1_udaf date" ] + rows: + - [1,"aa","2020-05-01"] + - [2,"aa","2020-05-01"] + - [3,"aa","2020-05-01"] + - [4,"aa","2020-05-02"] + - [5,"aa","2020-05-03"] + preAgg: + name: pre_{db_name}_{sp_name}_w1_min_c8 + type: date + rows: + - ["aa",1590738990000,1590738991000,2,"2020-05-01",null] + - ["aa",1590738992000,1590738993000,2,"2020-05-03",null] + 1: + order: id + columns: [ "id int","c1 string","w1_udaf date" ] + rows: + - [1,"aa","2020-05-01"] + - [2,"aa","2020-05-02"] + - [3,"aa","2020-05-03"] + - [4,"aa","2020-05-04"] + - [5,"aa","2020-05-05"] + preAgg: + name: pre_{db_name}_{sp_name}_w1_max_c8 + type: date + rows: + - ["aa",1590738990000,1590738991000,2,"2020-05-02",null] + - ["aa",1590738992000,1590738993000,2,"2020-05-04",null] + 2: + success: false + msg: fail + 3: + success: false + msg: fail + 4: + order: id + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c8 + type: bigint + rows: + - ["aa",1590738990000,1590738991000,2,2,null] + - ["aa",1590738992000,1590738993000,2,2,null] + - + id: 1 + desc: 长窗口count/avg/sum/max/min,smallint类型 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min","max","sum","avg","count"] + sql: | + SELECT id, c1, d[0](c2) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_udaf smallint"] + expectProvider: + 0: + rows: + - [1,"aa",1] + - [2,"aa",1] + - [3,"aa",1] + - [4,"aa",2] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_min_c2 + type: smallint + rows: + - ["aa",1590738990000,1590738991000,2,1,null] + - ["aa",1590738992000,1590738993000,2,3,null] + 1: + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",4] + - [5,"aa",5] + preAgg: + name: pre_{db_name}_{sp_name}_w1_max_c2 + type: smallint + rows: + - ["aa",1590738990000,1590738991000,2,2,null] + - ["aa",1590738992000,1590738993000,2,4,null] + 2: + rows: + - [1,"aa",1] + - [2,"aa",3] + - [3,"aa",6] + - [4,"aa",9] + - [5,"aa",12] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c2 + type: smallint + rows: + - ["aa",1590738990000,1590738991000,2,3,null] + - ["aa",1590738992000,1590738993000,2,7,null] + 3: + columns: ["id int","c1 string","w1_udaf double"] + rows: + - [1,"aa",1] + - [2,"aa",1.5] + - [3,"aa",2] + - [4,"aa",3] + - [5,"aa",4] + 4: + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c2 + type: bigint + rows: + - ["aa",1590738990000,1590738991000,2,2,null] + - ["aa",1590738992000,1590738993000,2,2,null] + - + id: 2 + desc: 长窗口count/avg/sum/max/min,int类型 # pre_{db_name}_{table_name}_{window_name}_{function_name}_{column_name}; + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min","max","sum","avg","count"] + sql: | + SELECT id, c1, d[0](c3) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_udaf int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + preAgg: + name: pre_{db_name}_{sp_name}_w1_min_c3 + type: int + rows: + - ["aa",1590738990000,1590738991999,2,20,null] + - ["aa",1590738992000,1590738993999,2,22,null] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",23] + - [5,"aa",24] + preAgg: + name: pre_{db_name}_{sp_name}_w1_max_c3 + type: int + rows: + - ["aa",1590738990000,1590738991999,2,21,null] + - ["aa",1590738992000,1590738993999,2,23,null] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",66] + - [5,"aa",69] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c3 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,41,null] + - ["aa",1590738992000,1590738993999,2,45,null] + 3: + columns: ["id int","c1 string","w1_udaf double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",22] + - [5,"aa",23] +# preAgg: +# name: pre_{db_name}_{sp_name}_w1_avg_c3; +# rows: +# - ["aa",1590738990000,1590738991999,2,20.5,null] +# - ["aa",1590738992000,1590738993999,2,22.5,null] + 4: + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c3 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + - + id: 3 + desc: 长窗口count/avg/sum/max/min,bigint类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min","max","sum","avg","count"] + sql: | + SELECT id, c1, d[0](c4) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_udaf bigint"] + expectProvider: + 0: + rows: + - [1,"aa",30] + - [2,"aa",30] + - [3,"aa",30] + - [4,"aa",31] + - [5,"aa",32] + preAgg: + name: pre_{db_name}_{sp_name}_w1_min_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,30,null] + - ["aa",1590738992000,1590738993999,2,32,null] + 1: + rows: + - [1,"aa",30] + - [2,"aa",31] + - [3,"aa",32] + - [4,"aa",33] + - [5,"aa",34] + preAgg: + name: pre_{db_name}_{sp_name}_w1_max_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,31,null] + - ["aa",1590738992000,1590738993999,2,33,null] + 2: + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_c4; + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,61,null] + - ["aa",1590738992000,1590738993999,2,65,null] + 3: + columns: ["id int","c1 string","w1_udaf double"] + rows: + - [1,"aa",30] + - [2,"aa",30.5] + - [3,"aa",31] + - [4,"aa",32] + - [5,"aa",33] + 4: + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c4 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + - + id: 4 + desc: 长窗口count/avg/sum/max/min,string类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 string","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min","max","sum","avg","count"] + sql: | + SELECT id, c1, d[0](c8) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expectProvider: + 0: + order: id + columns: [ "id int","c1 string","w1_udaf string" ] + rows: + - [1,"aa","2020-05-01"] + - [2,"aa","2020-05-01"] + - [3,"aa","2020-05-01"] + - [4,"aa","2020-05-02"] + - [5,"aa","2020-05-03"] + preAgg: + name: pre_{db_name}_{sp_name}_w1_min_c8 + type: string + rows: + - ["aa",1590738990000,1590738991999,2,"2020-05-01",null] + - ["aa",1590738992000,1590738993999,2,"2020-05-03",null] + 1: + order: id + columns: [ "id int","c1 string","w1_udaf string" ] + rows: + - [1,"aa","2020-05-01"] + - [2,"aa","2020-05-02"] + - [3,"aa","2020-05-03"] + - [4,"aa","2020-05-04"] + - [5,"aa","2020-05-05"] + preAgg: + name: pre_{db_name}_{sp_name}_w1_max_c8 + type: string + rows: + - ["aa",1590738990000,1590738991999,2,"2020-05-02",null] + - ["aa",1590738992000,1590738993999,2,"2020-05-04",null] + 2: + success: false + msg: fail + 3: + success: false + msg: fail + 4: + order: id + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c8 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + - + id: 5 + desc: 长窗口count/avg/sum/max/min,timestamp类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min","max","sum","avg","count"] + sql: | + SELECT id, c1, d[0](c7) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expectProvider: + 0: + order: id + columns: [ "id int","c1 string","w1_udaf timestamp" ] + rows: + - [1,"aa",1590738990000] + - [2,"aa",1590738990000] + - [3,"aa",1590738990000] + - [4,"aa",1590738991000] + - [5,"aa",1590738992000] +# preAgg: +# name: pre_{db_name}_{sp_name}_w1_min_c7 +# type: timestamp +# rows: +# - ["aa",1590738990000,1590738991999,2,1590738990000,null] # 101110010 01011111 01101110 10110011 10110000 +# - ["aa",1590738992000,1590738993999,2,1590738992000,null] + 1: + order: id + columns: [ "id int","c1 string","w1_udaf timestamp" ] + rows: + - [1,"aa",1590738990000] + - [2,"aa",1590738991000] + - [3,"aa",1590738992000] + - [4,"aa",1590738993000] + - [5,"aa",1590738994000] +# preAgg: +# name: pre_{db_name}_{sp_name}_w1_max_c7 +# type: timestamp +# rows: +# - ["aa",1590738990000,1590738991999,2,1590738993000,null] +# - ["aa",1590738992000,1590738993999,2,1590738994000,null] + 2: + order: id + columns: [ "id int","c1 string","w1_udaf timestamp" ] + rows: + - [1,"aa",1590738990000] + - [2,"aa",3181477981000] + - [3,"aa",4772216973000] + - [4,"aa",4772216976000] + - [5,"aa",4772216979000] +# preAgg: +# name: pre_{db_name}_{sp_name}_w1_sum_c7 +# type: bigtimestampint +# rows: +# - ["aa",1590738990000,1590738991999,2,3181477981000,null] +# - ["aa",1590738992000,1590738993999,2,3181477985000,null] + 3: + success: false + msg: fail + 4: + order: id + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c7 + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + - + id: 6 + desc: 长窗口count/avg/sum/max/min,row类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min","max","sum","avg","count"] + sql: | + SELECT id, c1, d[0](*) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expectProvider: + 0: + success: false + msg: fail + 1: + success: false + msg: fail + 2: + success: false + msg: fail + 3: + success: false + msg: fail + 4: + order: id + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_ + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + - + id: 7 + desc: 长窗口count/avg/sum/max/min,bool类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c9) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min","max","sum","avg","count"] + expectProvider: + 0: + success: false + msg: fail + 1: + success: false + msg: fail + 2: + success: false + msg: fail + 3: + success: false + msg: fail + 4: + order: id + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c9; + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + - + id: 8 + desc: 长窗口count/avg/sum/max/min,float类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c5) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min","max","sum","avg","count"] + expect: + order: id + columns: ["id int","c1 string","w1_udaf float"] + expectProvider: + 0: + rows: + - [1,"aa",1.1] + - [2,"aa",1.1] + - [3,"aa",1.1] + - [4,"aa",1.2] + - [5,"aa",1.3] +# preAgg: +# name: pre_{db_name}_{sp_name}_w1_min_c5; +# type: float +# rows: +# - ["aa",1590738990000,1590738991999,2,1.1,null] +# - ["aa",1590738992000,1590738993999,2,1.3,null] + 1: + rows: + - [1,"aa",1.1] + - [2,"aa",1.2] + - [3,"aa",1.3] + - [4,"aa",1.4] + - [5,"aa",1.5] + 2: + rows: + - [1,"aa",1.1] + - [2,"aa",2.3] + - [3,"aa",3.6] + - [4,"aa",3.9] + - [5,"aa",4.2] + 3: + columns: ["id int","c1 string","w1_udaf double"] + rows: + - [1,"aa",1.1] + - [2,"aa",1.15] + - [3,"aa",1.2] + - [4,"aa",1.3] + - [5,"aa",1.4] + 4: + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c5; + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + - + id: 9 + desc: 长窗口count/avg/sum/max/min,double类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c6) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min","max","sum","avg","count"] + expect: + order: id + columns: ["id int","c1 string","w1_udaf double"] + expectProvider: + 0: + rows: + - [1,"aa",2.1] + - [2,"aa",2.1] + - [3,"aa",2.1] + - [4,"aa",2.2] + - [5,"aa",2.3] + 1: + rows: + - [1,"aa",2.1] + - [2,"aa",2.2] + - [3,"aa",2.3] + - [4,"aa",2.4] + - [5,"aa",2.5] + 2: + rows: + - [1,"aa",2.1] + - [2,"aa",4.3] + - [3,"aa",6.6] + - [4,"aa",6.9] + - [5,"aa",7.2] + 3: + columns: ["id int","c1 string","w1_udaf double"] + rows: + - [1,"aa",2.1] + - [2,"aa",2.15] + - [3,"aa",2.2] + - [4,"aa",2.3] + - [5,"aa",2.4] + 4: + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c6; + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + - + id: 10 + desc: 长窗口count/avg/sum/max/min,rows + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3) OVER w1 as w1_udaf FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min","max","sum","avg","count"] + expect: + order: id + columns: ["id int","c1 string","w1_udaf int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",23] + - [5,"aa",24] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",66] + - [5,"aa",69] + 3: + columns: ["id int","c1 string","w1_udaf double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",22] + - [5,"aa",23] + 4: + columns: ["id int","c1 string","w1_udaf bigint"] + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + preAgg: + name: pre_{db_name}_{sp_name}_w1_count_c3; + type: bigint + rows: + - ["aa",1590738990000,1590738991999,2,2,null] + - ["aa",1590738992000,1590738993999,2,2,null] + diff --git a/cases/integration_test/long_window/test_xxx_where.yaml b/cases/integration_test/long_window/test_xxx_where.yaml new file mode 100644 index 00000000000..7915ceb3e2b --- /dev/null +++ b/cases/integration_test/long_window/test_xxx_where.yaml @@ -0,0 +1,1210 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.6.0 +cases: + - + id: 0 + desc: 长窗口xxx_where,date类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,1,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,2,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,3,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,4,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,5,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c8,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + success: false + msg: fail + - + id: 1 + desc: 长窗口xxx_where,smallint类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + sql: | + SELECT id, c1, d[0](c2,c2>2) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_where smallint"] + expectProvider: + 0: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + 1: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",3] + - [4,"aa",4] + - [5,"aa",5] + 2: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",3] + - [4,"aa",7] + - [5,"aa",12] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",3] + - [4,"aa",3.5] + - [5,"aa",4] + - + id: 2 + desc: 长窗口xxx_where,int类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",1,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",1,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + sql: | + SELECT id, c1, d[0](c3,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + preAgg: + name: pre_{db_name}_{sp_name}_w1_min_where_c3_c2 + type: int + rows: + - ["aa",1590738990000,1590738991999,2,20,1] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + preAgg: + name: pre_{db_name}_{sp_name}_w1_max_where_c3_c2 + type: int + rows: + - ["aa",1590738990000,1590738991999,2,21,1] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + preAgg: + name: pre_{db_name}_{sp_name}_w1_sum_where_c3_c2 + type: int + rows: + - ["aa",1590738990000,1590738991999,2,41,1] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] +# preAgg: +# name: pre_{db_name}_{sp_name}_w1_avg_where_c3_c2 +# type: int +# rows: +# - ["aa",1590738990000,1590738991999,2,20,1] + - + id: 3 + desc: 长窗口xxx_where,bigint类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + sql: | + SELECT id, c1, d[0](c4,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_where bigint"] + expectProvider: + 0: + rows: + - [1,"aa",30] + - [2,"aa",30] + - [3,"aa",30] + - [4,"aa",31] + - [5,"aa",32] + 1: + rows: + - [1,"aa",30] + - [2,"aa",31] + - [3,"aa",32] + - [4,"aa",32] + - [5,"aa",32] + 2: + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",63] + - [5,"aa",32] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",30] + - [2,"aa",30.5] + - [3,"aa",31] + - [4,"aa",31.5] + - [5,"aa",32] + - + id: 4 + desc: 长窗口xxx_where,string类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + sql: | + SELECT id, c1, d[0](c1,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 5 + desc: 长窗口xxx_where,timestamp类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + sql: | + SELECT id, c1, d[0](c7,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 6 + desc: 长窗口xxx_where,row类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + sql: | + SELECT id, c1, d[0](*,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 7 + desc: 长窗口xxx_where,bool类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c9,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + success: false + msg: fail + - + id: 8 + desc: 长窗口xxx_where,float类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c5,c2>2) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where float"] + expectProvider: + 0: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",1.3] + - [4,"aa",1.3] + - [5,"aa",1.3] + 1: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",1.3] + - [4,"aa",1.4] + - [5,"aa",1.5] + 2: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",1.3] + - [4,"aa",2.7] + - [5,"aa",4.2] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",1.3] + - [4,"aa",1.35] + - [5,"aa",1.4] + - + id: 9 + desc: 长窗口xxx_where,double类型 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c6,c2>2) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where double"] + expectProvider: + 0: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",2.3] + - [4,"aa",2.3] + - [5,"aa",2.3] + 1: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",2.3] + - [4,"aa",2.4] + - [5,"aa",2.5] + 2: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",2.3] + - [4,"aa",4.7] + - [5,"aa",7.2] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",2.3] + - [4,"aa",2.35] + - [5,"aa",2.4] + - + id: 10 + desc: 长窗口xxx_where,第二个参数使用bool列 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c9) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + success: false + msg: fail + - + id: 11 + desc: 长窗口xxx_where,第二个参数使用= + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c2,c2=4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where smallint"] + expectProvider: + 0: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",null] + - [4,"aa",4] + - [5,"aa",4] + 1: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",null] + - [4,"aa",4] + - [5,"aa",4] + 2: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",null] + - [4,"aa",4] + - [5,"aa",4] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",null] + - [4,"aa",4] + - [5,"aa",4] + - + id: 12 + desc: 长窗口xxx_where,第二个参数使用!= + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c2,c2!=4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where smallint"] + expectProvider: + 0: + rows: + - [1,"aa",1] + - [2,"aa",1] + - [3,"aa",1] + - [4,"aa",2] + - [5,"aa",3] + 1: + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",5] + 2: + rows: + - [1,"aa",1] + - [2,"aa",3] + - [3,"aa",6] + - [4,"aa",5] + - [5,"aa",8] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",1] + - [2,"aa",1.5] + - [3,"aa",2] + - [4,"aa",2.5] + - [5,"aa",4] + - + id: 13 + desc: 长窗口xxx_where,第二个参数使用>= + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c2,c2>=3) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where smallint"] + expectProvider: + 0: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + 1: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",3] + - [4,"aa",4] + - [5,"aa",5] + 2: + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",3] + - [4,"aa",7] + - [5,"aa",12] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",3] + - [4,"aa",3.5] + - [5,"aa",4] + - + id: 14 + desc: 长窗口xxx_where,第二个参数使用<= + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c2<=3) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + - + id: 17 + desc: 长窗口xxx_where,第二个参数使用and + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + sql: | + SELECT id, c1, d[0](c3,c2<4 and c2>1) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 18 + desc: 长窗口xxx_where,第二个参数使用两个列 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + sql: | + SELECT id, c1, d[0](c3,c3>c2) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + msg: fail + - + id: 19 + desc: 长窗口xxx_where,第二个参数使用嵌套 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,if_null(c2,0)>4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + success: false + msg: fail + - + id: 20 + desc: 长窗口xxx_where,第二个参数常量在前 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,4>c2) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + - + id: 21 + desc: 长窗口xxx_where,rows + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + - + id: 22 + desc: 长窗口xxx_where,第二个参数类型是int + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c3<23) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + - + id: 23 + desc: 长窗口xxx_where,第二个参数类型是bigint + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c4<33) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + - + id: 24 + desc: 长窗口xxx_where,第二个参数类型是float + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c5<1.35) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + - + id: 25 + desc: 长窗口xxx_where,第二个参数类型是double + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c6<2.4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + - + id: 26 + desc: 长窗口xxx_where,第二个参数类型是timestamp + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c7<1590738993000) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + success: false + msg: fail + - + id: 27 + desc: 长窗口xxx_where,第二个参数类型是date + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c8<"2020-05-04") OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + success: false + msg: fail + - + id: 28 + desc: 长窗口xxx_where,第二个参数类型是bool + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",false] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c9=true) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + - + id: 29 + desc: 长窗口xxx_where,w1:2 + longWindow: w1:2 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + success: false + msg: fail + - + id: 30 + desc: 长窗口xxx_where,磁盘表 + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + index: ["index1:c1:c7"] + storage: SSD + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01",true] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02",true] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03",true] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04",true] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05",false] + sql: | + SELECT id, c1, d[0](c3,c2<4) OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + success: false + msg: fail + - + id: 31 + desc: 长窗口count_where,第二个参数类型是string + longWindow: w1:2s + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + index: ["index1:c1:c7:0:latest"] + storage: memory + rows: + - [1,"aa",1,20,30,1.1,2.1,1590738990000,"2020-05-01","true"] + - [2,"aa",2,21,31,1.2,2.2,1590738991000,"2020-05-02","true"] + - [3,"aa",3,22,32,1.3,2.3,1590738992000,"2020-05-03","true"] + - [4,"aa",4,23,33,1.4,2.4,1590738993000,"2020-05-04","false"] + - [5,"aa",5,24,34,1.5,2.5,1590738994000,"2020-05-05","false"] + sql: | + SELECT id, c1, d[0](c3,c9="true") OVER w1 as w1_where FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + dataProvider: + - ["min_where","max_where","sum_where","avg_where"] + expect: + order: id + columns: ["id int","c1 string","w1_where int"] + expectProvider: + 0: + rows: + - [1,"aa",20] + - [2,"aa",20] + - [3,"aa",20] + - [4,"aa",21] + - [5,"aa",22] + 1: + rows: + - [1,"aa",20] + - [2,"aa",21] + - [3,"aa",22] + - [4,"aa",22] + - [5,"aa",22] + 2: + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",43] + - [5,"aa",22] + 3: + columns: ["id int","c1 string","w1_where double"] + rows: + - [1,"aa",20] + - [2,"aa",20.5] + - [3,"aa",21] + - [4,"aa",21.5] + - [5,"aa",22] + + diff --git a/cases/integration_test/multiple_databases/test_multiple_databases.yaml b/cases/integration_test/multiple_databases/test_multiple_databases.yaml new file mode 100644 index 00000000000..208270b4ae5 --- /dev/null +++ b/cases/integration_test/multiple_databases/test_multiple_databases.yaml @@ -0,0 +1,383 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: Last Join tables from two databases 1 - default db is db1 + db: db1 + inputs: + - db: db1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - db: db2 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select db1.{0}.c1,db1.{0}.c2,db2.{1}.c3,db2.{1}.c4 from db1.{0} last join db2.{1} ORDER BY db2.{1}.c3 on db1.{0}.c1=db2.{1}.c1; + expect: + order: c1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + - id: 1 + desc: Last Join tables from two databases 2 - default db is db, explicit db1 and db2 + db: db + inputs: + - db: db1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - db: db2 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select db1.{0}.c1, db1.{0}.c2,db2.{1}.c3,db2.{1}.c4 from db1.{0} last join db2.{1} ORDER BY db2.{1}.c3 on db1.{0}.c1=db2.{1}.c1; + expect: + order: c1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + - id: 2 + desc: Last join tables from 2 databases fail 1 - db2 is not exist + db: db1 + inputs: + - db: db1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - db: db3 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select db1.{0}.c1, db1.{0}.c2,db2.{1}.c3,db2.{1}.c4 from {0} last join db2.{1} ORDER BY db2.{1}.c3 on db1.{0}.c1=db2.{1}.c1; + expect: + success: false + - id: 3 + desc: Last join tables from 2 databases fail 2 - fail to resolve column {1}.c3 default db + db: db1 + inputs: + - db: db1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - db: db2 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select db1.{0}.c1, db1.{0}.c2, {1}.c3, {1}.c4 from {0} last join db2.{1} ORDER BY db2.{1}.c3 on db1.{0}.c1=db2.{1}.c1; + expect: + success: false + - id: 4 + desc: 全部使用默认库 + db: test_zw + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1; + expect: + order: c1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + - id: 5 + desc: 指定当前库查询 + db: test_zw + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1; + expect: + order: c1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + - id: 6 + desc: 查询使用其他库 + db: test_zw + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + db: db1 + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select * from (select c1, c2+1 as v1,c3+1 as v2 from db1.{0}) as t1; + expect: + columns: ["c1 string", "v1 int", "v2 bigint"] + order: c1 + rows: + - ["aa", 3,4] + - ["bb", 22,32] + - ["cc", 42,52] + - id: 7 + desc: 子查询后的表使用默认库 + db: db + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + db: db1 + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select db.t1.c1 from (select c1, c2+1,c3+1 from db1.{0}) as t1; + expect: + columns: ["c1 string"] + order: c1 + rows: + - ["aa"] + - ["bb"] + - ["cc"] + - id: 8 + desc: 子查询后的表使用其他库 + db: db + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + db: db1 + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select db1.t1.c1 from (select c1, c2+1,c3+1 from db1.{0}) as t1; + expect: + success: false + - id: 9 + desc: 使用子查询查不同库的数据然后lastjoin + tags: ["request 模式有问题,@chenjing"] + db: db + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + db: db1 + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + db: db2 + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select db.t1.c1,db.t1.c2,db.t2.c3,db.t2.c4 from (select * from db1.{0}) as t1 last join (select * from db2.{1}) as t2 ORDER BY db.t2.c3 on db.t1.c1=db.t2.c1; + expect: + order: c1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + - id: 10 + desc: 三表三个库拼表 + db: db + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + db: db1 + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + db: db2 + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "bb",41,121,1590738992000 ] + - [ "bb",41,121,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + db: db3 + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",21,131,1590738992000 ] + - [ "aa",41,121,1590738991000 ] + - [ "bb",41,121,1590738991000 ] + sql: select db1.{0}.c1,db1.{0}.c2,db2.{1}.c4,db3.{2}.c4 from db1.{0} last join db2.{1} ORDER BY db2.{1}.c4 on db1.{0}.c1=db2.{1}.c1 last join db3.{2} order by db3.{2}.c4 on db1.{0}.c1=db3.{2}.c1; + expect: + columns: [ "c1 string","c2 int","c4 timestamp","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,1590738989000,1590738992000 ] + - [ "bb",21,1590738992000,1590738991000 ] + - id: 11 + desc: 不等值拼接 + db: db + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + db: db1 + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + db: db2 + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",21,32,1590738993000 ] + - [ "bb",21,31,1590738992000 ] + - [ "bb",21,31,1590738991000 ] + sql: select db1.{0}.c1,db1.{0}.c2,db2.{1}.c3,db2.{1}.c4 from db1.{0} last join db2.{1} ORDER BY db2.{1}.c4 on db1.{0}.c2 = db2.{1}.c2 and db1.{0}.c3 <= db2.{1}.c3; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,32,1590738993000 ] + - id: 12 + desc: 不同库相同表lastjoin + db: db + inputs: + - db: db1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + name: t1 + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - db: db2 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + name: t1 + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select db1.t1.c1,db1.t1.c2,db2.t1.c3,db2.t1.c4 from db1.t1 last join db2.t1 ORDER BY db2.t1.c3 on db1.t1.c1=db2.t1.c1; + expect: + order: c1 + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + - + id: 13 + desc: window rows使用其他库 + db: db + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + db: db1 + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM db1.{0} WINDOW w1 AS (PARTITION BY db1.{0}.c1 ORDER BY db1.{0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,30] + - ["aa",21,61] + - ["aa",22,93] + - ["aa",23,96] + - ["bb",24,34] + - id: 14 + desc: window ROWS_RANGE 使用其他库 + db: db + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + db: db1 + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM db1.{0} WINDOW w1 AS (PARTITION BY db1.{0}.c1 ORDER BY db1.{0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,30 ] + - [ "aa",21,61 ] + - [ "aa",22,93 ] + - [ "aa",23,96 ] + - [ "bb",24,34 ] + + diff --git a/cases/integration_test/out_in/test_out_in.yaml b/cases/integration_test/out_in/test_out_in.yaml new file mode 100644 index 00000000000..e7ac9134dfd --- /dev/null +++ b/cases/integration_test/out_in/test_out_in.yaml @@ -0,0 +1,894 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: ['数据里有null、空串、特殊字符'] +cases: + - + id: 0 + desc: 数据里有null、空串、特殊字符 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [4,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [5,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - [6,"~!@#$%^&*()_+<",3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + count: 6 + - + id: 1 + desc: 全部数据类型测试 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 2 + desc: 复杂sql结果导出 + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, 1590738990000, 2.2] + - [3, "bb",10, 1590738990000, 3.3] + - + columns : ["crd_lst_isu_dte timestamp", "crd_nbr string"] + indexs: ["index2:crd_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, "aaaaaaaaaa"] + - [1590738990000, "aaaaaaaaaa"] + - [1590738989000, "cc"] + - [1590738992000, "cc"] + - + columns: ["id int", "card_no string", "trx_time timestamp", "card_no_prefix string","sum_trx_amt float", "count_merchant_id int64", "crd_lst_isu_dte timestamp","crd_nbr string"] + sqls: + - select * from + (select + id, + card_no, + trx_time, + substr(card_no, 1, 6) as card_no_prefix, + sum(trx_amt) over w30d as sum_trx_amt, + count(merchant_id) over w10d as count_merchant_id + from {0} + window w30d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 30d PRECEDING AND CURRENT ROW), + w10d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW)) as trx_fe + last join {1} order by {1}.crd_lst_isu_dte on trx_fe.card_no = {1}.crd_nbr and trx_fe.trx_time >= {1}.crd_lst_isu_dte + into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {2}; + - select * from {2}; + expect: + columns: ["id int", "card_no string", "trx_time timestamp", "card_no_prefix string","sum_trx_amt float", "count_merchant_id int64", "crd_lst_isu_dte timestamp","crd_nbr string"] + order: id + rows: + - [1, "aaaaaaaaaa", 1590738989000, "aaaaaa", 1.1, 1, 1590738988000, "aaaaaaaaaa"] + - [2, "aaaaaaaaaa", 1590738990000, "aaaaaa", 3.3, 2, 1590738990000, "aaaaaaaaaa"] + - [3, "bb", 1590738990000, "bb", 3.3, 1, null, null] + - + id: 3 + desc: 全部数据类型测试 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 4 + desc: 执行其他库查询 + inputs: + - + db: db1 + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from db1.{0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 5 + desc: 导出insert结果 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + sqls: + - insert into {0} values (1,"aa",1590738989000) outfile '{0}.csv'; + expect: + success: false + - + id: 6 + desc: sql执行错误 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from db1.{0} into outfile '{0}.csv'; + expect: + success: false + - + id: 7 + desc: mode默认值,文件已经存在 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {0} into outfile '{0}.csv'; + expect: + success: false + - + id: 8 + desc: mode=overwrite,先到处大数据量,再到处小数据量 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {1} into outfile '{0}.csv' options(mode='overwrite'); + - load data infile '{0}.csv' into table {2}; + - select * from {2}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 9 + desc: mode=append,相同的表到处两次 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {0} into outfile '{0}.csv' options(mode='append',header=false); + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 10 + desc: mode=append,不同的表导出,第二次header=false + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {1} into outfile '{0}.csv' options(mode='append',header=false); + - load data infile '{0}.csv' into table {2}; + - select * from {2}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 11 + desc: mode=append,不同的表导出,第二次header=true + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {1} into outfile '{0}.csv' options(mode='append',header=true); + expect: + cat: + path: "{0}.csv" + lines: + - id,c1,c2,c3,c4,c5,c6,c7,c8,c9 + - 1,aa,1,2,3,1.100000,2.100000,1590738989000,2020-05-01,true + - 2,bb,2,21,31,1.200000,2.200000,1590738990000,2020-05-02,false + - id,c1,c2,c3,c4,c5,c6,c7,c8,c9 + - 3,cc,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - + id: 12 + desc: option key错误 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv' options(head=true); + expect: + success: false + - + id: 13 + desc: option header 值错误 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv' options(header='true'); + expect: + success: false + - + id: 14 + desc: format 其他格式 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv' options(format='txt'); + expect: + success: false + - + id: 15 + desc: delimiter为一些特殊字符 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(delimiter='@'); + - load data infile '{0}.csv' into table {1} options(delimiter='@'); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 16 + desc: null_value为特殊字符 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value='~!@#$%^&*()_+'); + - load data infile '{0}.csv' into table {1} options(null_value='~!@#$%^&*()_+'); + - select * from {1}; + expect: + count: 3 + - + id: 17 + desc: String 有null 空串 ”null“ null_value为”“ + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [4,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [5,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - [6,"~!@#$%^&*()_+<",3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value=''); + expect: + cat: + path: "{0}.csv" + lines: + - id,c1,c2,c3,c4,c5,c6,c7,c8,c9 + - 3,,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - 5,,3,22,32,1.300000,2.300000,1590738991000,2020-05-03, + - 4,,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - 1,aa,1,2,3,1.100000,2.100000,1590738989000,2020-05-01,true + - 6,~!@#$%^&*()_+<,3,22,32,1.300000,2.300000,1590738991000,2020-05-03, + - 2,null,2,21,31,1.200000,2.200000,1590738990000,2020-05-02,false + - + id: 18 + desc: String 有null 空串 ”null“ null_value为”null“ + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [4,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [5,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - [6,"~!@#$%^&*()_+<",3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value='null'); + expect: + cat: + path: "{0}.csv" + lines: + - id,c1,c2,c3,c4,c5,c6,c7,c8,c9 + - 3,,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - 5,null,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,null + - 4,null,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - 1,aa,1,2,3,1.100000,2.100000,1590738989000,2020-05-01,true + - 6,~!@#$%^&*()_+<,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,null + - 2,null,2,21,31,1.200000,2.200000,1590738990000,2020-05-02,false + - + id: 19 + desc: header=false导出数据 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=false); + - load data infile '{0}.csv' into table {1} options(header=false); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 20 + desc: format=csv,导出数据 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(format='csv'); + - load data infile '{0}.csv' into table {1} options(format='csv'); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 21 + desc: 路径文件夹不存在 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '/{0}/{0}.csv'; + expect: + success: false + - + id: 22 + desc: 数据类型不匹配 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 int","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + expect: + success: false + - + id: 23 + desc: header=true导出数据 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=true); + - load data infile '{0}.csv' into table {1} options(header=true); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 24 + desc: header=true,csv没有header + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=false); + - load data infile '{0}.csv' into table {1} options(header=true); + expect: + success: false + - + id: 25 + desc: header=false,csv有header + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=true); + - load data infile '{0}.csv' into table {1} options(header=false); + expect: + success: false + - + id: 26 + desc: 表不存在 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=true); + - load data infile '{0}.csv' into table {1}11 options(header=true); + expect: + success: false + - + id: 27 + desc: format=csv,csv格式的文件,文件名不是csv结尾 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.txt' ; + - load data infile '{0}.txt' into table {1} options(format='csv'); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 28 + desc: format=其他值 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1} options(format='txt'); + expect: + success: false + - + id: 29 + desc: 路径错误 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}1.csv' into table {1}; + expect: + success: false + - + id: 30 + desc: 导入其他库的表 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + db: db1 + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table db1.{1}; + - select * from db1.{1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 31 + desc: 导出后导入 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {0}; + - select * from {0}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 32 + desc: 创建表的列和csv对不上 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","cc smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}1.csv' into table {1}; + expect: + success: false + - + id: 33 + desc: 表中已经有数据,然后导入 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 34 + desc: delimiter为,数据中有, + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"b,b",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1} options(delimiter=','); + expect: + success: false + - + id: 35 + desc: 导入-null_value=null + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value='null'); + - load data infile '{0}.csv' into table {1} options(null_value='null'); + - select * from {1}; + expect: + count: 3 + - + id: 36 + desc: 导入-null_value=空串 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value=''); + - load data infile '{0}.csv' into table {1} options(null_value=''); + - select * from {1}; + expect: + count: 3 + - + id: 37 + desc: 表删除后再次导入 +# tags: ["TODO","下个版本修复,@huangwei"] + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + - [2,"bb",1590738990000] + - [3,"cc",1590738991000] + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - drop table {1}; + - create table {1}( + id int, + c1 string, + c7 timestamp, + index(key=(c1),ts=c7))options(partitionnum=1,replicanum=1); + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c7 timestamp"] + order: id + rows: + - [1,"aa",1590738989000] + - [2,"bb",1590738990000] + - [3,"cc",1590738991000] + - + id: 38 + desc: mode 值错误 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv' options(mode='true'); + expect: + success: false + + + diff --git a/cases/integration_test/select/test_select_sample.yaml b/cases/integration_test/select/test_select_sample.yaml new file mode 100644 index 00000000000..97c47194cac --- /dev/null +++ b/cases/integration_test/select/test_select_sample.yaml @@ -0,0 +1,307 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: 查询所有列 + inputs: + - columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select c1,c3,c4,c5,c6,c7,c8 from {0}; + expect: + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + - id: 1 + desc: 查询部分列 + inputs: + - columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select c1,c3,c4 from {0}; + expect: + columns: ["c1 string","c3 int","c4 bigint"] + rows: + - ["aa",2,3] + - id: 2 + desc: 查询* + inputs: + - columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + sql: select * from {0}; + expect: + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + rows: + - ["aa",2,3,1.1,2.1,1590738989000,"2020-05-01"] + - id: 3 + desc: 查询列中部分重命名 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + sql: select c1 as name,c2,c3,c4 from {0}; + expect: + columns: ["name string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa",2,3,1590738989000] + - id: 4 + desc: 查询列中全部重命名 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + sql: select c1 as name,c2 as v2,c3 as v3 ,c4 as v4 from {0}; + expect: + columns: ["name string","v2 int","v3 bigint","v4 timestamp"] + rows: + - ["aa",2,3,1590738989000] + - id: 5 + desc: 查询的列部分带表名 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + sql: select c1 as name,{0}.c2,c3,c4 from {0}; + expect: + columns: ["name string","c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa",2,3,1590738989000] + - id: 6 + desc: 查询的表不存在 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + sql: select c1,c2,c3,c4 from {0}1; + expect: + success: false + - id: 7 + desc: 查询的列不存在 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + sql: select c1,c2,c3,c5 from {0}; + expect: + success: false + - id: 8 + desc: 查询的数据中有空串 + mode: cli-unsupport + inputs: + - columns: ["c1 string","c2 int","c3 string","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["",2,"",1590738989000] + sql: select c1,c2,c3,c4 from {0}; + expect: + columns: ["c1 string","c2 int","c3 string","c4 timestamp"] + rows: + - ["",2,"",1590738989000] + - id: 9 + desc: 查询的数据中有null + inputs: + - columns: ["c1 string","c2 int","c3 string","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [NULL,2,NULL,1590738989000] + sql: select c1,c2,c3,c4 from {0}; + expect: + columns: ["c1 string","c2 int","c3 string","c4 timestamp"] + rows: + - [NULL,2,NULL,1590738989000] + - id: 10 + desc: 结合limit + tags: ["TODO", "@zhaowei"] + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select c1,c2,c3,c4 from {0} limit 2; + expect: + rows: + - ["aa",2,3,1590738989000] + - ["cc",41,51,1590738991000] + - id: 11 + desc: limit 1 + tags: ["TODO", "@zhaowei"] + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select c1,c2,c3,c4 from {0} limit 1; + expect: + rows: + - ["aa",2,3,1590738989000] + - id: 12 + desc: limit 0 + tags: ["TODO", "@zhaowei"] + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select c1,c2,c3,c4 from {0} limit 0; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + order: c1 + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + - id: 13 + desc: limit条数大于表的条数 + tags: ["TODO","@zhaoweiLIMIT单独测,现在先别测"] + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select c1,c2,c3,c4 from {0} limit 4; + expect: + columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + order: c1 + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + - id: 14 + desc: 查询常量 + sqlDialect: ["HybridSQL","SQLITE3"] + tags: ["常量fesql和mysql类型不配"] + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + sql: select c1 as name,c2,c3,c4,1 from {0}; + expect: + columns: ["name string","c2 int","c3 bigint","c4 timestamp","1 int"] + rows: + - ["aa",2,3,1590738989000,1] + - id: 15 + desc: 查询的列带表名和别名 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + sql: select {0}.c1 as name,{0}.c2 as t_c2,{0}.c3 as t_c3,{0}.c4 as t_c4 from {0}; + expect: + columns: ["name string","t_c2 int","t_c3 bigint","t_c4 timestamp"] + rows: + - ["aa",2,3,1590738989000] + - id: 16 + desc: 查询表达式使用表名 + sqlDialect: ["HybridSQL","SQLITE3"] + tags: ["表达式计算结果fesql和mysql类型不配"] + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + sql: select c1 as name,{0}.c2+1 as t_c2,c3,c4 from {0}; + expect: + columns: ["name string","t_c2 int","c3 bigint","c4 timestamp"] + rows: + - ["aa",3,3,1590738989000] + - id: 17 + desc: 查询函数表达式使用表名 + sqlDialect: ["HybridSQL","SQLITE3"] + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["123456789",2,3,1590738989000] + sql: select substr({0}.c1, 3, 6) as name,{0}.c2+1 as t_c2,c3,c4 from {0}; + expect: + columns: ["name string","t_c2 int","c3 bigint","c4 timestamp"] + rows: + - ["345678",3,3,1590738989000] + - id: 18 + desc: column name prefix with _ + mode: offline-unsupport + sqlDialect: ["HybridSQL"] + tags: ["@chendihao, @baoxinqi, support simple project node with column cast"] + inputs: + - columns: ["_c1 int", "_c2 string", "_c5 bigint"] + indexs: ["index1:_c1:_c5"] + rows: + - [1, "2020-05-22 10:43:40", 1] + sql: | + select _c1, bigint(_c2) DIV 1000 as _c2_sec from (select _c1, timestamp(_c2) as _c2 from {0}); + expect: + columns: ["_c1 int", "_c2_sec bigint"] + rows: + - [1, 1590115420] + - id: 19 + desc: 全表聚合 + mode: rtidb-unsupport,offline-unsupport,cli-unsupport + db: db1 + sqlDialect: ["HybridSQL", "MYSQL"] + sql: | + SELECT SUM(col1) as sum_col1, COUNT(col1) as cnt_col1, MAX(col1) as max_col1, + MIN(col1) as min_col1, AVG(col1) as avg_col1 FROM {0}; + inputs: + - columns: ["col0 string", "col1 int32", "col2 int16", "col3 float", "col4 double", "col5 int64", "col6 string"] + indexs: ["index1:col2:col5"] + rows: + - [0, 1, 5, 1.1, 11.1, 1, 1] + - [0, 2, 5, 2.2, 22.2, 2, 22] + - [1, 3, 55, 3.3, 33.3, 1, 333] + - [1, 4, 55, 4.4, 44.4, 2, 4444] + - [2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] + batch_plan: | + PROJECT(type=Aggregation) + DATA_PROVIDER(table=auto_t0) + expect: + columns: ["sum_col1 int32", "cnt_col1 int64", "max_col1 int32", "min_col1 int32", "avg_col1 double"] + order: sum_col1 + rows: + - [15, 5, 5, 1, 3] + - + id: 14 + desc: 不指定索引,插入数据,可查询 + inputs: + - columns: [ "id int not null","c1 int not null","c2 smallint not null","c3 float not null","c4 double not null","c5 bigint not null","c6 string not null","c7 timestamp not null","c8 date not null","c9 bool not null" ] + rows: + - [ 1, 1, 2, 3.3, 4.4, 5, "aa", 12345678, "2020-05-21", true ] + sql: select * from {0}; + expect: + columns : ["id int","c1 int","c2 smallint","c3 float","c4 double","c5 bigint","c6 string","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,1,2,3.3,4.4,5,"aa",12345678,"2020-05-21",true] \ No newline at end of file diff --git a/cases/integration_test/select/test_sub_select.yaml b/cases/integration_test/select/test_sub_select.yaml new file mode 100644 index 00000000000..292b6d35d2a --- /dev/null +++ b/cases/integration_test/select/test_sub_select.yaml @@ -0,0 +1,359 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 正常使用子查询 + sqlDialect: ["HybridSQL","SQLITE3"] + mode: cli-unsupport + tags: ["mysql要求派生表必须有别名"] + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select * from (select c1, c2+1,c3+1 from {0}); + expect: + columns: ["c1 string", "c2 + 1 int", "c3 + 1 bigint"] + order: c1 + rows: + - ["aa", 3,4] + - ["bb", 22,32] + - ["cc", 42,52] + - + id: 1 + desc: 子查询使列别名 + sqlDialect: ["HybridSQL","SQLITE3"] + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select v2,v3 from (select c2+1 as v2,c3+1 as v3 from {0}) as t; + expect: + columns: ["v2 int","v3 bigint"] + order: v2 + rows: + - [3,4] + - [22,32] + - [42,52] + - + id: 2 + desc: 子查询使用常量 + sqlDialect: ["HybridSQL","SQLITE3"] + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select * from (select c2+1 as v2,c3+1 as v3,1 as v4 from {0}) as t; + expect: + columns: ["v2 int","v3 bigint","v4 int"] + order: v2 + rows: + - [3,4,1] + - [22,32,1] + - [42,52,1] + - + id: 3 + desc: 子查询中有空串 + mode: cli-unsupport + sqlDialect: ["HybridSQL","SQLITE3"] + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select * from (select c1,c2+1 as v2,c3+1 as v3,1 as v4 from {0}) as t; + expect: + columns: ["c1 string","v2 int","v3 bigint","v4 int"] + order: c1 + rows: + - ["",22,32,1] + - ["aa",3,4,1] + - ["cc",42,52,1] + - + id: 4 + desc: 子查询中有null + inputs: + - + columns : ["id int","c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa",2,3,1590738989000] + - [2,NULL,21,31,1590738990000] + - [3,"cc",41,51,1590738991000] + sql: select * from (select id,c1,c3+1 as v3 from {0}) as t; + expect: + columns: ["id int","c1 string","v3 bigint"] + order: id + rows: + - [1,"aa",4] + - [2,null,32] + - [3,"cc",52] + - + id: 5 + desc: 查询时列不在子查询中 + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + - ["cc",41,51,1590738991000] + sql: select v5 from (select c1,c2+1 as v2,c3+1 as v3,1 as v4 from {0}); + expect: + success: false + - + id: 6 + desc: last join 子查询和副表, 子查询包含window + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, 1590738990000, 2.2] + - [3, "bb",10, 1590738990000, 3.3] + - + columns : ["crd_lst_isu_dte timestamp", "crd_nbr string"] + indexs: ["index2:crd_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, "aaaaaaaaaa"] + - [1590738990000, "aaaaaaaaaa"] + - [1590738989000, "cc"] + - [1590738992000, "cc"] + sql: select * from + (select + id, + card_no, + trx_time, + substr(card_no, 1, 6) as card_no_prefix, + sum(trx_amt) over w30d as sum_trx_amt, + count(merchant_id) over w10d as count_merchant_id + from {0} + window w30d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 30d PRECEDING AND CURRENT ROW), + w10d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW)) as trx_fe + last join {1} order by {1}.crd_lst_isu_dte on trx_fe.card_no = {1}.crd_nbr and trx_fe.trx_time >= {1}.crd_lst_isu_dte; + expect: + columns: ["id int", "card_no string", "trx_time timestamp", "card_no_prefix string", + "sum_trx_amt float", "count_merchant_id int64", "crd_lst_isu_dte timestamp", + "crd_nbr string"] + order: id + rows: + - [1, "aaaaaaaaaa", 1590738989000, "aaaaaa", 1.1, 1, 1590738988000, "aaaaaaaaaa"] + - [2, "aaaaaaaaaa", 1590738990000, "aaaaaa", 3.3, 2, 1590738990000, "aaaaaaaaaa"] + - [3, "bb", 1590738990000, "bb", 3.3, 1, null, null] + - + id: 7 + desc: window样本表和副表都作子查询 + sqlDialect: ["HybridSQL"] + mode: python-unsupport, cluster-unsupport,cli-unsupport + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, 1590738991000, 2.2] + - [3, "bb",10, 1590738990000, 3.3] + - + columns : ["crd_lst_isu_dte timestamp", "crd_nbr string"] + indexs: ["index2:crd_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, "aaaaaaaaaa"] + - [1590738990000, "aaaaaaaaaa"] + - [1590738989000, "cc"] + - [1590738992000, "cc"] + sql: | + select + id, + card_no, + trx_time, + substr(card_no, 1, 6) as card_no_prefix, + sum(trx_amt) over w30d as w30d_amt_sum, + count(id) over w10d as w10d_id_cnt + from (select id, card_no, trx_time, trx_amt from {0}) as t_instance + window w30d as (PARTITION BY card_no ORDER BY trx_time ROWS_RANGE BETWEEN 30d PRECEDING AND CURRENT ROW), + w10d as (UNION (select 0 as id, crd_nbr as card_no, crd_lst_isu_dte as trx_time, 0.0f as trx_amt from {1}) PARTITION BY card_no ORDER BY trx_time ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW); + expect: + columns: ["id int", "card_no string", "trx_time timestamp", "card_no_prefix string", + "w30d_amt_sum float", "w10d_id_cnt int64"] + order: id + rows: + - [1, "aaaaaaaaaa", 1590738989000, "aaaaaa", 1.1, 2] + - [2, "aaaaaaaaaa", 1590738991000, "aaaaaa", 3.3, 4] + - [3, "bb", 1590738990000, "bb", 3.3, 1] + - + id: 8 + desc: window样本表和副表都作子查询,INSTANCE_NOT_IN_WINDOW + sqlDialect: ["HybridSQL"] + mode: python-unsupport + inputs: + - + columns : ["id int", "user_id string", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + + indexs: ["index1:user_id:trx_time"] + rows: + - [1, "aaaaaaaaaa", "xxx", 1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa", "xxx", 1, 1590738991000, 2.2] + - [3, "bb", "000", 10, 1590738990000, 3.3] + - [4, "cc", "zzz", 20, 1590738993000, 4.4] + - + columns : ["crd_lst_isu_dte timestamp", "crd_nbr string", "account_amt double"] + indexs: ["index2:crd_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, "xxx", 100.0] + - [1590738990000, "xxx", 200.0] + - [1590738990000, "yyy", 300.0] + - [1590738989000, "zzz", 400.0] + - [1590738992000, "zzz", 500.0] + sql: | + select id as out2_id, + crd_nbr, + count(id) over w10d as w10d_id_cnt, + sum(account_amt) over w10d as w10d_total_account_amt + from (select id as id, trx_time as crd_lst_isu_dte, card_no as crd_nbr, 0.0 as account_amt from {0}) as t_instance + window w10d as (UNION (select 0 as id, crd_lst_isu_dte, crd_nbr, account_amt from {1}) + PARTITION BY crd_nbr ORDER BY crd_lst_isu_dte ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW); + + expect: + columns: ["out2_id int", "crd_nbr string", "w10d_id_cnt int64", "w10d_total_account_amt double"] + order: out2_id + rows: + - [1, "xxx", 2, 100.0] + - [2, "xxx", 3, 300.0] + - [3, "000", 1, 0.0] + - [4, "zzz", 3, 900.0] + - + id: 9 + desc: 特征拼接 + mode: offline-unsupport, python-unsupport,cli-unsupport + sqlDialect: ["HybridSQL"] + inputs: + - + columns : ["id int", "user_id string", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + + indexs: ["index1:user_id:trx_time"] + rows: + - [1, "aaaaaaaaaa", "xxx", 1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa","xxx", 1, 1590738991000, 2.2] + - [3, "bb", "000", 10, 1590738990000, 3.3] + - [4, "cc", "zzz", 20, 1590738993000, 4.4] + - + columns : ["crd_lst_isu_dte timestamp", "crd_nbr string", "account_amt double"] + indexs: ["index2:crd_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, "xxx", 100.0] + - [1590738990000, "xxx", 200.0] + - [1590738990000, "yyy", 300.0] + - [1590738989000, "zzz", 400.0] + - [1590738992000, "zzz", 500.0] + sql: | + select * from + ( select + id as out1_id, + user_id, + trx_time, + sum(trx_amt) over w30d as w30d_amt_sum + from (select id, user_id, trx_time, trx_amt from {0}) as t_instance + window w30d as (PARTITION BY user_id ORDER BY trx_time ROWS_RANGE BETWEEN 30d PRECEDING AND CURRENT ROW) + ) as out1 last join + ( select id as out2_id, + crd_nbr, + count(id) over w10d as w10d_id_cnt, + sum(account_amt) over w10d as w10d_total_account_amt + from (select id as id, trx_time as crd_lst_isu_dte, card_no as crd_nbr, 0.0 as account_amt from {0}) as t_instance + window w10d as (UNION (select 0 as id, crd_lst_isu_dte, crd_nbr, account_amt from {1}) + PARTITION BY crd_nbr ORDER BY crd_lst_isu_dte ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW)) as out2 + on out1.out1_id=out2.out2_id; + + expect: + columns: ["out1_id int", "user_id string", "trx_time timestamp", + "w30d_amt_sum float", "out2_id int", "crd_nbr string", "w10d_id_cnt int64", "w10d_total_account_amt double"] + order: out1_id + rows: + - [1, "aaaaaaaaaa", 1590738989000, 1.1, 1, "xxx", 2, 100.0] + - [2, "aaaaaaaaaa", 1590738991000, 3.3, 2, "xxx", 3, 300.0] + - [3, "bb", 1590738990000, 3.3, 3, "000", 1, 0.0] + - [4, "cc", 1590738993000, 4.4, 4, "zzz", 3, 900.0] + - + id: 10 + desc: 子查询使列别名重名 + sqlDialect: ["HybridSQL"] + tags: ["mysql报错"] + inputs: + - + columns : ["id int","c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa",2,3,1590738989000] + - [2,"bb",21,31,1590738990000] + - [3,"cc",41,51,1590738991000] + sql: select * from (select id,c2+1 as v2,c3+1 as v2 from {0}) as t; + expect: + columns: ["id int","v2 int","v2 bigint"] + order: id + rows: + - [1,3,4] + - [2,22,32] + - [3,42,52] + - + id: 11 + desc: 子查询使列别名重名,并同时select + tags: ["TODO", "@baoxinqi", "bug-期望子查询别名不可以一致FEX-1009"] + inputs: + - + columns : ["id int","c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa",2,3,1590738989000] + - [2,"bb",21,31,1590738990000] + - [3,"cc",41,51,1590738991000] + sql: select id,v2,v2 from (select id,c2+1 as v2,c3+1 as v2 from {0}); + expect: + success: false + - + id: 15 + desc: 不指定索引,进行子查询操作 + inputs: + - columns: [ "id int not null","c1 int not null","c2 smallint not null","c3 float not null","c4 double not null","c5 bigint not null","c6 string not null","c7 timestamp not null","c8 date not null","c9 bool not null" ] + rows: + - [ 1, 1, 2, 3.3, 4.4, 5, "aa", 12345678, "2020-05-21", true ] + sql: select c1,c2 from (select id as c1,c1 as c2,c7 as c3 from {0}); + expect: + columns : ["c1 int","c2 int"] + order: id + rows: + - [1,1] diff --git a/cases/integration_test/select/test_where.yaml b/cases/integration_test/select/test_where.yaml new file mode 100644 index 00000000000..8a2f8d26387 --- /dev/null +++ b/cases/integration_test/select/test_where.yaml @@ -0,0 +1,252 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +sqlDialect: ["HybridSQL"] +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: Where条件命中索引 + mode: request-unsupport + db: db1 + sql: | + SELECT col0, col1, col2, col3, col4, col5, col6 FROM {0} where col2=5; + inputs: + - columns: ["col0 string", "col1 int32", "col2 int16", "col3 float", "col4 double", "col5 int64", "col6 string"] + indexs: ["index1:col2:col5"] + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + 1, 3, 55, 3.3, 33.3, 1, 333 + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + batch_plan: | + SIMPLE_PROJECT(sources=(col0, col1, col2, col3, col4, col5, col6)) + FILTER_BY(condition=, left_keys=(), right_keys=(), index_keys=(5)) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + order: col1 + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + - id: 1-1 + desc: Where部分条件命中索引, col1>3条件未命中 + mode: request-unsupport, offline-unsupport + db: db1 + sql: | + SELECT col0, col1, col2, col3, col4, col5, col6 FROM {0} where col2=55 and col1 > 3; + inputs: + - schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + index: index1:col2:col5 + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + 1, 3, 55, 3.3, 33.3, 1, 333 + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + batch_plan: | + SIMPLE_PROJECT(sources=(col0, col1, col2, col3, col4, col5, col6)) + FILTER_BY(condition=col1 > 3, left_keys=(), right_keys=(), index_keys=(55)) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + order: col1 + data: | + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + - id: 1-1 + desc: Where部分条件命中索引, col1=3条件未命中 + mode: request-unsupport, offline-unsupport + db: db1 + sql: | + SELECT col0, col1, col2, col3, col4, col5, col6 FROM {0} where col2=55 and col1 = 3; + inputs: + - schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + index: index1:col2:col5 + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + 1, 3, 55, 3.3, 33.3, 1, 333 + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + batch_plan: | + SIMPLE_PROJECT(sources=(col0, col1, col2, col3, col4, col5, col6)) + FILTER_BY(condition=3 = col1, left_keys=(), right_keys=(), index_keys=(55)) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + order: col1 + data: | + 1, 3, 55, 3.3, 33.3, 1, 333 + - id: 2-1 + desc: Where条件未命中索引 + mode: request-unsupport + tags: ["OnlineServing不支持,Training可以支持"] + db: db1 + sql: | + SELECT col0, col1, col2, col3, col4, col5, col6 FROM {0} where col2=55 and col1 > 1; + inputs: + - schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + index: index1:col6:col5 + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + 1, 3, 55, 3.3, 33.3, 1, 333 + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + expect: + success: true + columns: [ "col0 string", "col1 int", "col2 smallint", "col3 float", "col4 double", "col5 bigint", "col6 string" ] + order: col1 + rows: + - [ 1, 3, 55, 3.300000, 33.300000, 1, 333 ] + - [ 1, 4, 55, 4.400000, 44.400000, 2, 4444 ] + - [ 2, 5, 55, 5.500000, 55.500000, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ] + + - id: 2-2 + desc: Where条件未命中索引-离线支持 + mode: rtidb-unsupport,cli-unsupport + db: db1 + sql: | + SELECT col0, col1, col2, col3, col4, col5, col6 FROM {0} where col2=5 and col1 < 2; + inputs: + - schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + index: index1:col6:col5 + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + 1, 3, 55, 3.3, 33.3, 1, 333 + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + expect: + schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + order: col1 + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + - id: 3-1 + desc: Where条件未命中索引示例2 + mode: request-unsupport + db: db1 + sql: | + SELECT col0, col1, col2, col3, col4, col5, col6 FROM {0} where col2=col3 and col1 < 2; + inputs: + - columns: ["col0 string", "col1 int32", "col2 int16", "col3 float", "col4 double", "col5 int64", "col6 string"] + indexs: ["index1:col2:col5"] + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + 1, 3, 55, 3.3, 33.3, 1, 333 + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + expect: + success: true + columns: [ "col0 string", "col1 int", "col2 smallint", "col3 float", "col4 double", "col5 bigint", "col6 string" ] + rows: + + - id: 3-2 + desc: Where条件未命中索引示例2 + mode: rtidb-unsupport,cli-unsupport + db: db1 + sql: | + SELECT col0, col1, col2, col3, col4, col5, col6 FROM {0} where col1=col5 and col1 > 1; + inputs: + - schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + index: index1:col2:col5 + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + 1, 3, 55, 3.3, 33.3, 1, 333 + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + expect: + schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + order: col1 + data: | + 0, 2, 5, 2.2, 22.2, 2, 22 + - id: 4 + desc: Where条件命中索引,索引穿透简单子查询 + mode: request-unsupport + db: db1 + sql: | + SELECT c0, c1, c2, c3, c4, c5, c6, c1+c4 as c14 FROM + (select col0 as c0, col1 as c1, col2 as c2, 0.0f as c3, col4 as c4, col5 as c5, "empty_str" as c6 from {0}) as t1 where t1.c2=5; + inputs: + - schema: col0:string, col1:int32, col2:int16, col3:float, col4:double, col5:int64, col6:string + index: index1:col2:col5 + data: | + 0, 1, 5, 1.1, 11.1, 1, 1 + 0, 2, 5, 2.2, 22.2, 2, 22 + 1, 3, 55, 3.3, 33.3, 1, 333 + 1, 4, 55, 4.4, 44.4, 2, 4444 + 2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + batch_plan: | + PROJECT(type=TableProject) + FILTER_BY(condition=, left_keys=(), right_keys=(), index_keys=(5)) + RENAME(name=t1) + SIMPLE_PROJECT(sources=(col0 -> c0, col1 -> c1, col2 -> c2, 0.000000 -> c3, col4 -> c4, col5 -> c5, empty_str -> c6)) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + schema: c0:string, c1:int32, c2:int16, c3:float, c4:double, c5:int64, c6:string, c14:double + order: c1 + data: | + 0, 1, 5, 0.0, 11.1, 1, empty_str, 12.1 + 0, 2, 5, 0.0, 22.2, 2, empty_str, 24.2 + - id: 5 + desc: lastjoin+Where,包含重复列名 + mode: request-unsupport, rtidb-unsupport + tags: ["TODO", "@chenjing", "0.3.0", "fail to compute where condition bug"] + db: db1 + inputs: + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp", "c5 int"] + indexs: ["index1:c5:c4"] + rows: + - ["aa",2,3,1590738989000, 100] + - ["bb",21,31,1590738990000, 200] + - columns: ["c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: ["index1:c3:c4"] + rows: + - ["aa",2,3,1590738989000] + - ["bb",21,31,1590738990000] + sql: select {0}.c1,{1}.c1,{0}.c2,{1}.c3,{1}.c4,{0}.c5 from {0} last join {1} on {0}.c3={1}.c3 where c5 = 100; + expect: + columns: ["c1 string","c1 string", "c2 int","c3 bigint", "c4 timestamp", "c5 int"] + rows: + - ["aa","aa",2,3,1590738989000, 100] + - id: 6-1 + desc: Where条件后全表聚合 + tags: ["TODO","batch exec failed"] + mode: request-unsupport + db: db1 + sql: | + SELECT SUM(col1) as sum_col1, COUNT(col1) as cnt_col1, MAX(col1) as max_col1, + MIN(col1) as min_col1, AVG(col1) as avg_col1 FROM {0} where col2=5; + inputs: + - columns: ["col0 string", "col1 int32", "col2 int16", "col3 float", "col4 double", "col5 int64", "col6 string"] + indexs: ["index1:col2:col5"] + rows: + - [0, 1, 5, 1.1, 11.1, 1, 1] + - [0, 2, 5, 2.2, 22.2, 2, 22] + - [1, 3, 55, 3.3, 33.3, 1, 333] + - [1, 4, 55, 4.4, 44.4, 2, 4444] + - [2, 5, 55, 5.5, 55.5, 3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] + batch_plan: | + PROJECT(type=Aggregation) + FILTER_BY(condition=, left_keys=(), right_keys=(), index_keys=(5)) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + + expect: + columns: ["sum_col1 int32", "cnt_col1 int64", "max_col1 int32", "min_col1 int32", "avg_col1 double"] + order: sum_col1 + rows: + - [3, 2, 2, 1, 1.5] diff --git a/cases/integration_test/spark/generate_yaml_case.py b/cases/integration_test/spark/generate_yaml_case.py new file mode 100755 index 00000000000..de8551cc70c --- /dev/null +++ b/cases/integration_test/spark/generate_yaml_case.py @@ -0,0 +1,191 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# -*- coding: utf-8 -*- + +# pip3 install -U ruamel.yaml pyspark first +import argparse +from datetime import date +import random +import string +import time +import sys + +import pyspark +import pyspark.sql +from pyspark.sql.types import * +import ruamel.yaml as yaml +from ruamel.yaml import RoundTripDumper, RoundTripLoader + +from ruamel.yaml.scalarstring import LiteralScalarString, DoubleQuotedScalarString + +YAML_TEST_TEMPLATE = """ +db: test_db +cases: + - id: 1 + desc: yaml 测试用例模版 + inputs: [] + sql: | + select * from t1 + expect: + success: true +""" + +INPUT_TEMPLATE = """ + columns: [] + indexs: [] + rows: [] +""" + + +def random_string(prefix, n): + return "{}_{}".format(prefix, ''.join(random.choices(string.ascii_letters + string.digits, k=n))) + +# random date in current year +def random_date(): + start_dt = date.today().replace(day=1, month=1).toordinal() + end_dt = date.today().toordinal() + random_day = date.fromordinal(random.randint(start_dt, end_dt)) + return random_day + +def to_column_str(field): + tp = '{unknown_type}' + if isinstance(field.dataType, BooleanType): + tp = 'bool' + elif isinstance(field.dataType, ShortType): + tp = 'int16' + elif isinstance(field.dataType, IntegerType): + tp = 'int32' + elif isinstance(field.dataType, LongType): + tp = 'int64' + elif isinstance(field.dataType, StringType): + tp = 'string' + elif isinstance(field.dataType, TimestampType): + tp = 'timestamp' + elif isinstance(field.dataType, DateType): + tp = 'date' + elif isinstance(field.dataType, DoubleType): + tp = 'double' + elif isinstance(field.dataType, FloatType): + tp = 'float' + + return "%s %s" % (field.name, tp) + +def random_row(schema): + row = [] + for field_schema in schema.fields: + field_type = field_schema.dataType + if isinstance(field_type, BooleanType): + row.append(random.choice([True, False])) + elif isinstance(field_type, ShortType): + row.append(random.randint(- (1 << 15), 1 << 15 - 1)) + elif isinstance(field_type, IntegerType): + row.append(random.randint(- (1 << 31), 1 << 31 - 1)) + elif isinstance(field_type, LongType): + row.append(random.randint(-(1 << 63), 1 << 63 - 1)) + elif isinstance(field_type, StringType): + row.append(random_string(field_schema.name, 10)) + elif isinstance(field_type, TimestampType): + # in milliseconds + row.append(int(time.time()) * 1000) + elif isinstance(field_type, DateType): + row.append(random_date()) + elif isinstance(field_type, DoubleType): + row.append(random.uniform(-128.0, 128.0)) + elif isinstance(field_type, FloatType): + row.append(random.uniform(-128.0, 128.0)) + else: + row.append('{unknown}') + + return row + + +def to_string(value): + if isinstance(value, date): + return DoubleQuotedScalarString(value.strftime("%Y-%m-%d")) + if isinstance(value, float): + return float("%.2f" % value) + if isinstance(value, str): + return DoubleQuotedScalarString(value) + return value + + +sess = None +def gen_inputs_column_and_rows(parquet_file, table_name=''): + global sess + if sess is None: + sess = pyspark.sql.SparkSession(pyspark.SparkContext()) + dataframe = sess.read.parquet(parquet_file) + hdfs_schema = dataframe.schema + schema = [DoubleQuotedScalarString(to_column_str(f)) for f in hdfs_schema.fields] + + table = yaml.load(INPUT_TEMPLATE, Loader=RoundTripLoader) + + if table_name: + table['name'] = table_name + + table['columns'] = schema + + data_set = [] + row_cnt = random.randint(1, 10) + for _ in range(row_cnt): + data_set.append(random_row(hdfs_schema)) + + table['rows'] = [list(map(to_string, row)) for row in data_set] + return table + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument("--sql", required=True, help="sql text path") + group = parser.add_mutually_exclusive_group() + group.add_argument("--schema-file", help="path to hdfs content(in parquet format), used to detect table schema") + group.add_argument("--schema-list-file", help="list file conataining a list of hdfs files, \"table_name: file path\" per line") + parser.add_argument("--output", required=True, help="path to output yaml file") + args = parser.parse_args() + + sql = args.sql + schema_file = args.schema_file + schema_list_file = args.schema_list_file + output = args.output + + yaml_test = yaml.load(YAML_TEST_TEMPLATE, Loader=RoundTripLoader, preserve_quotes=True) + + if schema_file: + tb = gen_inputs_column_and_rows(schema_file) + yaml_test['cases'][0]['inputs'].append(tb) + elif schema_list_file: + with open(schema_list_file, 'r') as l: + for schema_file in l: + sf = schema_file.strip() + if not sf: + continue + table_name, parquet_file, *_ = sf.split(':') + + parquet_file = parquet_file.strip() + if parquet_file: + tb = gen_inputs_column_and_rows(parquet_file, table_name) + yaml_test['cases'][0]['inputs'].append(tb) + else: + print("error") + sys.exit(1) + + + with open(sql, 'r') as f: + yaml_test['cases'][0]['sql'] = LiteralScalarString(f.read().strip()) + + with open(output, 'w') as f: + f.write(yaml.dump(yaml_test, Dumper=RoundTripDumper, allow_unicode=True)) + diff --git a/cases/integration_test/spark/requirements.txt b/cases/integration_test/spark/requirements.txt new file mode 100644 index 00000000000..257735c8ec6 --- /dev/null +++ b/cases/integration_test/spark/requirements.txt @@ -0,0 +1,3 @@ +py4j==0.10.9 +pyspark==3.1.3 +ruamel.yaml==0.16.12 diff --git a/cases/integration_test/spark/test_ads.yaml b/cases/integration_test/spark/test_ads.yaml new file mode 100644 index 00000000000..43d889969ff --- /dev/null +++ b/cases/integration_test/spark/test_ads.yaml @@ -0,0 +1,176 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: template_name +cases: +- id: 1 + desc: 单表-广告场景 + inputs: + - columns: + - "id string" + - "time timestamp" + - "C1 string" + - "banner_pos int32" + - "site_id string" + - "site_domain string" + - "site_category string" + - "app_id string" + - "app_domain string" + - "app_category string" + - "device_id string" + - "device_ip string" + - "device_model string" + - "device_type string" + - "device_conn_type string" + - "C14 string" + - "C15 string" + - "C16 string" + - "C17 string" + - "C18 string" + - "C19 string" + - "C20 string" + - "C21 string" + - "click int32" + indexs: ["index1:device_ip:time"] + rows: + - - "id_XfRHH4kXfh" + - 1609398202000 + - "C1_AXkRcXx3Kw" + - -2136663223 + - "site_id_eDHW3HhKq1" + - "site_domain_BiGZfMhPi4" + - "site_category_fRuxhKkzG7" + - "app_id_qU7KTLhbfd" + - "app_domain_89LBfwJOX6" + - "app_category_6ZYuZwBFU8" + - "device_id_wblCHgZ5XS" + - "device_ip_QghSozyTkL" + - "device_model_npId0EBZlF" + - "device_type_FC6ZCotmB0" + - "device_conn_type_ZDYT1Ax9Ms" + - "C14_fp4R2g2zVQ" + - "C15_uMIOpZgomo" + - "C16_mdReYZ82da" + - "C17_BHAroEq4Oa" + - "C18_tg1duoMypp" + - "C19_Bk6GldZeSl" + - "C20_LHuXYsBnVj" + - "C21_JasNjK98O3" + - 13560844 + - - "id_CcZoKjZdWh" + - 1609398202000 + - "C1_xu9l18vaoM" + - -2064473435 + - "site_id_JTwfcebGpx" + - "site_domain_DrGpN7fHxB" + - "site_category_VnKBVLPjCN" + - "app_id_fFOUOMIZb2" + - "app_domain_WEH14cif3z" + - "app_category_5SDJL3MMbz" + - "device_id_BYRnezWSFI" + - "device_ip_UzE2rMHw3i" + - "device_model_eEvfxxZu2H" + - "device_type_WSyKKMDHzw" + - "device_conn_type_ImtQtq1M0h" + - "C14_N6KNpoRxB7" + - "C15_NoqO6r3LI0" + - "C16_5SkwZizokc" + - "C17_Ubxmmk7l7D" + - "C18_mhmpWVGnvx" + - "C19_MEZPm43rbw" + - "C20_20PAS4g6pi" + - "C21_jBaglxDzWN" + - -1234570441 + sql: |- + select + id as id_1, + id as t1_id_original_0, + `time` as t1_time_original_1, + C1 as t1_C1_original_2, + banner_pos as t1_banner_pos_original_3, + site_id as t1_site_id_original_4, + site_domain as t1_site_domain_original_5, + site_category as t1_site_category_original_6, + app_id as t1_app_id_original_7, + app_domain as t1_app_domain_original_8, + app_category as t1_app_category_original_9, + device_id as t1_device_id_original_10, + device_ip as t1_device_ip_original_11, + device_model as t1_device_model_original_12, + device_type as t1_device_type_original_13, + device_conn_type as t1_device_conn_type_original_14, + C14 as t1_C14_original_15, + C15 as t1_C15_original_16, + C16 as t1_C16_original_17, + C17 as t1_C17_original_18, + C18 as t1_C18_original_19, + C19 as t1_C19_original_20, + C20 as t1_C20_original_21, + C21 as t1_C21_original_22, + click as t1_click_original_23, + device_ip as t1_device_ip_combine_24, + device_model as t1_device_model_combine_24, + C17 as t1_C17_combine_24, + device_ip as t1_device_ip_combine_25, + device_model as t1_device_model_combine_25, + C19 as t1_C19_combine_25, + device_ip as t1_device_ip_combine_26, + device_model as t1_device_model_combine_26, + C21 as t1_C21_combine_26, + banner_pos as t1_banner_pos_combine_27, + device_ip as t1_device_ip_combine_27, + device_model as t1_device_model_combine_27, + C1 as t1_C1_combine_28, + banner_pos as t1_banner_pos_combine_28, + site_domain as t1_site_domain_combine_29, + device_ip as t1_device_ip_combine_29, + device_model as t1_device_model_combine_29, + site_id as t1_site_id_combine_30, + device_ip as t1_device_ip_combine_30, + device_model as t1_device_model_combine_30, + app_domain as t1_app_domain_combine_31, + device_ip as t1_device_ip_combine_31, + device_model as t1_device_model_combine_31, + site_category as t1_site_category_combine_32, + device_ip as t1_device_ip_combine_32, + device_model as t1_device_model_combine_32, + device_ip as t1_device_ip_combine_33, + device_model as t1_device_model_combine_33, + C18 as t1_C18_combine_33, + fz_top1_ratio(id) over t1_device_ip_time_0s_7200s as t1_id_window_top1_ratio_34, + fz_top1_ratio(id) over t1_device_ip_time_0s_36000s as t1_id_window_top1_ratio_35, + case when !isnull(lag(app_domain, 0)) over t1_device_ip_time_0s_7200s then count(app_domain) over t1_device_ip_time_0s_7200s else null end as t1_app_domain_window_count_36, + case when !isnull(lag(app_category, 0)) over t1_device_ip_time_0s_7200s then count(app_category) over t1_device_ip_time_0s_7200s else null end as t1_app_category_window_count_37, + case when !isnull(lag(device_model, 0)) over t1_device_ip_time_0s_36000s then count(device_model) over t1_device_ip_time_0s_36000s else null end as t1_device_model_window_count_38, + case when !isnull(lag(app_id, 0)) over t1_device_ip_time_0s_7200s then count(app_id) over t1_device_ip_time_0s_7200s else null end as t1_app_id_window_count_39, + case when !isnull(lag(C17, 0)) over t1_device_ip_time_0s_7200s then count(C17) over t1_device_ip_time_0s_7200s else null end as t1_C17_window_count_40, + case when !isnull(lag(C19, 0)) over t1_device_ip_time_0s_7200s then count(C19) over t1_device_ip_time_0s_7200s else null end as t1_C19_window_count_41, + case when !isnull(lag(banner_pos, 0)) over t1_device_ip_time_0s_7200s then count(banner_pos) over t1_device_ip_time_0s_7200s else null end as t1_banner_pos_window_count_42, + fz_top1_ratio(C14) over t1_device_ip_time_0s_7200s as t1_C14_window_top1_ratio_43, + case when !isnull(lag(app_id, 0)) over t1_device_ip_time_0s_36000s then count(app_id) over t1_device_ip_time_0s_36000s else null end as t1_app_id_window_count_44, + case when !isnull(lag(site_id, 0)) over t1_device_ip_time_0s_36000s then count(site_id) over t1_device_ip_time_0s_36000s else null end as t1_site_id_window_count_45, + case when !isnull(lag(site_domain, 0)) over t1_device_ip_time_0s_36000s then count(site_domain) over t1_device_ip_time_0s_36000s else null end as t1_site_domain_window_count_46, + case when !isnull(lag(site_category, 0)) over t1_device_ip_time_0s_36000s then count(site_category) over t1_device_ip_time_0s_36000s else null end as t1_site_category_window_count_47, + case when !isnull(lag(app_domain, 0)) over t1_device_ip_time_0s_36000s then count(app_domain) over t1_device_ip_time_0s_36000s else null end as t1_app_domain_window_count_48, + case when !isnull(lag(app_category, 0)) over t1_device_ip_time_0s_36000s then count(app_category) over t1_device_ip_time_0s_36000s else null end as t1_app_category_window_count_49, + case when !isnull(lag(device_id, 0)) over t1_device_ip_time_0s_36000s then count(device_id) over t1_device_ip_time_0s_36000s else null end as t1_device_id_window_count_50, + case when !isnull(lag(C18, 0)) over t1_device_ip_time_0s_36000s then count(C18) over t1_device_ip_time_0s_36000s else null end as t1_C18_window_count_51, + case when !isnull(lag(device_conn_type, 0)) over t1_device_ip_time_0s_36000s then count(device_conn_type) over t1_device_ip_time_0s_36000s else null end as t1_device_conn_type_window_count_52, + case when !isnull(lag(C19, 0)) over t1_device_ip_time_0s_36000s then count(C19) over t1_device_ip_time_0s_36000s else null end as t1_C19_window_count_53 + from + {0} + window t1_device_ip_time_0s_7200s as ( partition by device_ip order by `time` rows_range between 7200s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_device_ip_time_0s_36000s as ( partition by device_ip order by `time` rows_range between 36000s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW); + expect: + success: true diff --git a/cases/integration_test/spark/test_credit.yaml b/cases/integration_test/spark/test_credit.yaml new file mode 100644 index 00000000000..4e466ad44d0 --- /dev/null +++ b/cases/integration_test/spark/test_credit.yaml @@ -0,0 +1,1012 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_db +cases: +- id: 1 + desc: 多表-信用卡用户转借记卡预测场景 + inputs: + - columns: + - "id int32" + - "cust_id_an int32" + - "ins_date timestamp" + - "Label int32" + indexs: ["index1:id:ins_date"] + rows: + - - -1985437192 + - -1317908971 + - 1611144215000 + - -506221216 + - - -906012118 + - 122153399 + - 1611144215000 + - -2073586764 + - - 192540564 + - -1868891884 + - 1611144215000 + - -1291765609 + - - -12339370 + - -1068593442 + - 1611144215000 + - -1218544053 + - - -1346508105 + - 389329057 + - 1611144215000 + - 72100927 + - - -1563970013 + - 64743832 + - 1611144215000 + - -1456087176 + - - -420456303 + - 83758185 + - 1611144215000 + - 593328038 + name: t1 + - columns: + - "cust_id_an int32" + - "agmt_id_an int32" + - "atta_acct_ind string" + - "stmt_dt date" + - "open_acct_dt timestamp" + - "clos_acct_dt timestamp" + indexs: ["indext8:cust_id_an:open_acct_dt"] + rows: + - - -103578926 + - -2129345374 + - "atta_acct_ind_QSKoYcBykS" + - "2021-01-19" + - 1611144215000 + - 1611144215000 + - - -1738231442 + - -1827648982 + - "atta_acct_ind_YCzSZpWh36" + - "2021-01-01" + - 1611144215000 + - 1611144215000 + - - -313899349 + - -620524833 + - "atta_acct_ind_b06NdQiRiE" + - "2021-01-14" + - 1611144215000 + - 1611144215000 + - - -412596205 + - -1082468256 + - "atta_acct_ind_4rFa5IVSF4" + - "2021-01-02" + - 1611144215000 + - 1611144215000 + - - -48236232 + - -170343294 + - "atta_acct_ind_NU8FhCMOiL" + - "2021-01-11" + - 1611144215000 + - 1611144215000 + - - -1455816949 + - 403926185 + - "atta_acct_ind_yIDKZcJSaj" + - "2021-01-04" + - 1611144215000 + - 1611144215000 + - - 225487286 + - 834608659 + - "atta_acct_ind_xOG219V8NP" + - "2021-01-01" + - 1611144215000 + - 1611144215000 + name: t8 + - columns: + - "cust_id_an int32" + - "agmt_id_an int32" + - "curr_ovrd_stat_cd string" + - "curr_yr_ovrd_cnt int32" + - "curr_yr_crdt_card_point double" + - "crdt_card_point double" + - "acct_stat_cd string" + - "consm_od_bal double" + - "cash_od_bal double" + - "amtbl_od_bal double" + - "spl_pay_bal double" + - "ovrd_bal double" + - "last_mth_stmt_amt double" + - "last_mth_consm_cnt int32" + - "m_consm_amt_accm double" + - "m_cash_amt_accm double" + - "m_amtbl_amt_accm double" + - "m_spl_pay_amt_accm double" + - "m_ovrd_bal_accm double" + - "data_date timestamp" + indexs: ["indext9:cust_id_an:data_date"] + rows: + - - -1965865733 + - 181943904 + - "curr_ovrd_stat_cd_pSWF7Z7UVZ" + - 288301759 + - 10.03 + - 57.38 + - "acct_stat_cd_cTTBtj3JnQ" + - 30.94 + - -53.93 + - -81.51 + - -111.3 + - -101.78 + - 68.7 + - -1929310650 + - 121.96 + - -35.3 + - -1.68 + - 109.97 + - 89.78 + - 1611144215000 + - - 305578483 + - 594627092 + - "curr_ovrd_stat_cd_KH7JIGfFuM" + - -583313456 + - -109.77 + - 22.53 + - "acct_stat_cd_nrBFWkaCSO" + - -14.29 + - 126.7 + - 40.33 + - 120.44 + - -73.54 + - 17.18 + - -337679856 + - -81.93 + - -19.57 + - -11.83 + - 80.59 + - 75.35 + - 1611144215000 + - - -501231072 + - 22230390 + - "curr_ovrd_stat_cd_Mwu1mCxGqn" + - 1039709568 + - -113.24 + - -108.36 + - "acct_stat_cd_co20Q23EM8" + - -58.61 + - -73.54 + - -98.85 + - -43.24 + - 33.71 + - -11.95 + - -1818947456 + - -59.67 + - -62.73 + - -51.21 + - 50.64 + - 90.51 + - 1611144215000 + - - -1832175587 + - -991415524 + - "curr_ovrd_stat_cd_H1NkAqnwqe" + - -1908516905 + - -27.17 + - 102.83 + - "acct_stat_cd_pq3jTUtjF0" + - 91.15 + - -83.81 + - -69.61 + - 127.86 + - -86.14 + - 56.68 + - -1995257141 + - 6.71 + - 83.5 + - -32.51 + - -94.43 + - 8.3 + - 1611144215000 + - - 611330902 + - 679194351 + - "curr_ovrd_stat_cd_HIlzlZymnH" + - -254111972 + - 3.04 + - 9.18 + - "acct_stat_cd_PhHHTvGLTL" + - -75.39 + - 15.09 + - -18.1 + - -104.29 + - -49.22 + - -100.48 + - 730288655 + - 58.18 + - 8.3 + - 11.78 + - -91.13 + - 6.87 + - 1611144215000 + - - 826069039 + - 470439749 + - "curr_ovrd_stat_cd_8JQvcEi7yJ" + - 811087014 + - 85.17 + - -97.16 + - "acct_stat_cd_AFju4WMCgx" + - -108.14 + - 117.13 + - -93.99 + - 70.68 + - 107.57 + - 98.27 + - -891433275 + - 35.0 + - -33.36 + - 127.18 + - 25.36 + - -64.98 + - 1611144215000 + - - -784663900 + - -1192305947 + - "curr_ovrd_stat_cd_U4Ophb2kIQ" + - 515010670 + - 105.76 + - 3.51 + - "acct_stat_cd_Z1Kyb1mz7y" + - 9.64 + - -28.33 + - 60.18 + - 117.39 + - -24.18 + - -0.82 + - -1458522076 + - 105.11 + - -68.3 + - -16.45 + - -29.62 + - 47.34 + - 1611144215000 + - - 808471893 + - -2029597450 + - "curr_ovrd_stat_cd_NMy2UGhIrf" + - -551211114 + - -29.29 + - -92.54 + - "acct_stat_cd_HMcl6pIDg4" + - 6.99 + - -111.57 + - -124.1 + - 85.09 + - 113.05 + - -25.19 + - -928477688 + - 110.96 + - 14.01 + - 95.6 + - 4.15 + - -56.27 + - 1611144215000 + - - -414811981 + - -106781549 + - "curr_ovrd_stat_cd_z5gVcFFs0m" + - -1846401879 + - 11.12 + - -56.57 + - "acct_stat_cd_pbubmnmn1M" + - -63.85 + - -47.45 + - 124.76 + - -120.79 + - -70.46 + - -42.95 + - -1432475728 + - -123.98 + - 25.41 + - -95.39 + - -76.1 + - 50.44 + - 1611144215000 + - - 352609173 + - 748553820 + - "curr_ovrd_stat_cd_qgOUkDJ1rQ" + - -932519461 + - -80.07 + - 75.8 + - "acct_stat_cd_9AdRp2Spps" + - -102.28 + - 88.3 + - -15.75 + - 108.03 + - -127.15 + - 94.95 + - -1288349027 + - 100.95 + - 2.77 + - 81.25 + - -26.63 + - 70.67 + - 1611144215000 + name: t9 + - columns: + - "cust_id_an int32" + - "card_agmt_id_an int32" + - "pri_acct_id_an int32" + - "atta_card_ind string" + - "camp_org_id string" + - "prod_id string" + - "snp_gage_cd string" + - "crdt_card_lvl_cd string" + - "pin_card_dt date" + - "card_matr_yr_mth string" + - "sell_chnl_cd string" + - "card_org_cd string" + - "actv_chnl_cd string" + - "free_annl_fee_ind string" + - "annl_fee double" + - "bus_card_ind string" + - "matr_contn_card_ind string" + - "issu_card_dt timestamp" + - "actv_dt timestamp" + indexs: ["indext6:cust_id_an:actv_dt"] + rows: + - - 756930160 + - -1362270267 + - 820739577 + - "atta_card_ind_4oS8b63mVd" + - "camp_org_id_BFbsLHpdSR" + - "prod_id_3m2TZ0si7Z" + - "snp_gage_cd_onOB021pP1" + - "crdt_card_lvl_cd_vQuD1gTTwe" + - "2021-01-12" + - "card_matr_yr_mth_tDIUWOk5ia" + - "sell_chnl_cd_FLfurUmdfR" + - "card_org_cd_piAFoPGMLH" + - "actv_chnl_cd_mTHr98b5Es" + - "free_annl_fee_ind_Lq3eblqZFw" + - 68.08 + - "bus_card_ind_5KK6nTjOxr" + - "matr_contn_card_ind_S4hHwHdJNH" + - 1611144215000 + - 1611144215000 + - - 394465803 + - -1469812793 + - 46768555 + - "atta_card_ind_MEbCAC4sCs" + - "camp_org_id_gV8Zs3vkri" + - "prod_id_Pk1B3xv6JA" + - "snp_gage_cd_ZgHDu3hZbx" + - "crdt_card_lvl_cd_Etc9TpL5u7" + - "2021-01-02" + - "card_matr_yr_mth_AMweyZaygN" + - "sell_chnl_cd_dV661JROf4" + - "card_org_cd_8nvfaf471b" + - "actv_chnl_cd_nmjPCpzA37" + - "free_annl_fee_ind_0yvInU4aXe" + - -4.02 + - "bus_card_ind_gDjvmuKOo9" + - "matr_contn_card_ind_MgCwGwHYy4" + - 1611144215000 + - 1611144215000 + - - -1915196249 + - 715245555 + - -1037414536 + - "atta_card_ind_NBFRDWsXul" + - "camp_org_id_LUgZQkavDC" + - "prod_id_5HHVvMevjR" + - "snp_gage_cd_TLVPPbmIqP" + - "crdt_card_lvl_cd_f1khBG0oFM" + - "2021-01-08" + - "card_matr_yr_mth_0AoPAu7blU" + - "sell_chnl_cd_gmGs4O8BsG" + - "card_org_cd_fCbMNmDc7W" + - "actv_chnl_cd_SkuX9MfN7Z" + - "free_annl_fee_ind_oEUcJ2azyx" + - 108.44 + - "bus_card_ind_NWfBj4nd18" + - "matr_contn_card_ind_6ieA1VpR6O" + - 1611144215000 + - 1611144215000 + - - -1937671087 + - -1386163364 + - 936709843 + - "atta_card_ind_SchOBM3ADn" + - "camp_org_id_iIcs5gi51w" + - "prod_id_pNeYvSsCK9" + - "snp_gage_cd_qs3ZQWlyfm" + - "crdt_card_lvl_cd_Nzbp7Cy4v2" + - "2021-01-02" + - "card_matr_yr_mth_24GI4NhCum" + - "sell_chnl_cd_e6sZGx0UIr" + - "card_org_cd_mEaWKOr2eK" + - "actv_chnl_cd_5jHnIHbODx" + - "free_annl_fee_ind_mNxB0OUuqB" + - -94.58 + - "bus_card_ind_9twM1Sm8N6" + - "matr_contn_card_ind_Ze6N7bLuqc" + - 1611144215000 + - 1611144215000 + - - -1897243199 + - -1931817796 + - 390672335 + - "atta_card_ind_mN5Mw55PCb" + - "camp_org_id_Zn4STXeUD6" + - "prod_id_4uoNNgMc0p" + - "snp_gage_cd_fNOXthNs7J" + - "crdt_card_lvl_cd_ynL4AtIJa3" + - "2021-01-11" + - "card_matr_yr_mth_XROF2DVFVq" + - "sell_chnl_cd_0QLdMs0ENq" + - "card_org_cd_odnosB8A0R" + - "actv_chnl_cd_AjThMogiEt" + - "free_annl_fee_ind_Eem4dzghME" + - -72.53 + - "bus_card_ind_7AD96Q3i6Z" + - "matr_contn_card_ind_35MrxB5cXA" + - 1611144215000 + - 1611144215000 + - - -1853796531 + - -1258445777 + - -1547814111 + - "atta_card_ind_oeDA6We5EC" + - "camp_org_id_S7pZ2RJ4HP" + - "prod_id_DHeuN53pSv" + - "snp_gage_cd_aW92GS2DMu" + - "crdt_card_lvl_cd_tzSehkdxa8" + - "2021-01-17" + - "card_matr_yr_mth_bIlFSqWgT9" + - "sell_chnl_cd_SQE3eVhOwn" + - "card_org_cd_GiXhH8Ilw1" + - "actv_chnl_cd_BBCwH068cK" + - "free_annl_fee_ind_t5sz5QGjAq" + - 59.91 + - "bus_card_ind_2HCWPtpDe5" + - "matr_contn_card_ind_vAViU3mnTF" + - 1611144215000 + - 1611144215000 + - - 599351765 + - -2026344167 + - 406435567 + - "atta_card_ind_0Dc8HKmpeg" + - "camp_org_id_jY2qjsi2yM" + - "prod_id_nn1lrj5ZFX" + - "snp_gage_cd_SDeBM6a51B" + - "crdt_card_lvl_cd_LfX4N7yXil" + - "2021-01-12" + - "card_matr_yr_mth_ORvNy6K6TO" + - "sell_chnl_cd_sUJHlnXZS4" + - "card_org_cd_SzZoSXxmYR" + - "actv_chnl_cd_FuTmvFJMGv" + - "free_annl_fee_ind_00i8JxFXcx" + - 68.1 + - "bus_card_ind_pWrx4XVAKK" + - "matr_contn_card_ind_MgjGK92EfE" + - 1611144215000 + - 1611144215000 + - - 129929182 + - -812735353 + - -776403184 + - "atta_card_ind_caXhPAUCSn" + - "camp_org_id_wvDdQBr0bh" + - "prod_id_6OrANg0pDT" + - "snp_gage_cd_qZhYdtg1EX" + - "crdt_card_lvl_cd_WLmc0oczDJ" + - "2021-01-13" + - "card_matr_yr_mth_fJ7zh8PWuu" + - "sell_chnl_cd_vA3H163pUi" + - "card_org_cd_se7PxoQEWW" + - "actv_chnl_cd_IuJot5ylAH" + - "free_annl_fee_ind_PlRcZHiwDg" + - 40.89 + - "bus_card_ind_Q6vTzxFs7N" + - "matr_contn_card_ind_M8fvOjy5B0" + - 1611144215000 + - 1611144215000 + - - -1696305996 + - -178589482 + - 788546600 + - "atta_card_ind_MkfeU6kAPv" + - "camp_org_id_4Bn9Zgg4eM" + - "prod_id_1ah3kydsh7" + - "snp_gage_cd_ySl8kkcGst" + - "crdt_card_lvl_cd_L8aZAMygq2" + - "2021-01-07" + - "card_matr_yr_mth_ZXmdyVXukr" + - "sell_chnl_cd_UXPdm0d9B6" + - "card_org_cd_3QYp5QfEG6" + - "actv_chnl_cd_uRXCNeSnzt" + - "free_annl_fee_ind_WyScZ3hmyM" + - 5.45 + - "bus_card_ind_taVaX634Mh" + - "matr_contn_card_ind_ppVD5sqBfA" + - 1611144215000 + - 1611144215000 + name: t6 + - columns: + - "cust_id_an int32" + - "card_agmt_id_an int32" + - "fst_use_card_dt date" + - "ltst_use_card_dt date" + - "card_stat_cd string" + - "data_date timestamp" + indexs: ["indext7:cust_id_an:data_date"] + rows: + - - -1416323258 + - 1062068004 + - "2021-01-15" + - "2021-01-10" + - "card_stat_cd_I5RUbf7xEL" + - 1611144216000 + - - 433240030 + - 729717634 + - "2021-01-19" + - "2021-01-17" + - "card_stat_cd_wFB0gUWKQI" + - 1611144216000 + - - -1880955883 + - -1807838612 + - "2021-01-03" + - "2021-01-19" + - "card_stat_cd_rG5nhnzcV5" + - 1611144216000 + name: t7 + - columns: + - "cust_id_an int32" + - "crdt_card_net_incom_amt double" + - "int_incom_amt double" + - "annl_fee_incom_amt double" + - "cash_incom_amt double" + - "commsn_incom_amt double" + - "late_chrg_incom_amt double" + - "extras_fee_incom_amt double" + - "oth_incom_amt double" + - "amtbl_comm_fee double" + - "cap_cost_amt double" + - "provs_cost_amt double" + - "data_date timestamp" + indexs: ["indext5:cust_id_an:data_date"] + rows: + - - -586341746 + - -91.38 + - -103.8 + - -91.79 + - 77.09 + - -39.25 + - -104.55 + - -25.37 + - -42.69 + - 20.24 + - 121.05 + - 40.71 + - 1611144216000 + - - -903799431 + - 82.69 + - 56.49 + - -105.1 + - -126.73 + - 91.97 + - -113.83 + - -119.99 + - 126.4 + - 107.63 + - -1.88 + - 54.72 + - 1611144216000 + - - -2006396570 + - 101.8 + - -63.94 + - 7.75 + - 41.46 + - -42.03 + - 52.33 + - 39.98 + - 10.07 + - -29.53 + - 126.03 + - -63.56 + - 1611144216000 + - - -2035678095 + - -99.5 + - 83.92 + - -63.44 + - -45.01 + - -16.37 + - 105.96 + - -82.37 + - -76.09 + - -120.12 + - -116.56 + - 22.47 + - 1611144216000 + - - 634869109 + - -38.91 + - -0.08 + - 25.59 + - -80.43 + - -23.8 + - 127.24 + - 72.18 + - -84.52 + - -91.3 + - -64.03 + - -117.28 + - 1611144216000 + name: t5 + - columns: + - "cust_id_an int32" + - "crdt_lmt_cust double" + - "aval_lmt_cust double" + - "crdt_lmt_cash double" + - "aval_lmt_cash double" + - "data_date timestamp" + indexs: ["indext3:cust_id_an:data_date"] + rows: + - - -2001222170 + - -4.23 + - -101.67 + - 76.28 + - -83.94 + - 1611144216000 + - - -1514280701 + - -32.77 + - -73.6 + - -17.73 + - 118.89 + - 1611144216000 + - - 5866653 + - 25.81 + - 109.68 + - 62.1 + - -121.53 + - 1611144216000 + - - 10968234 + - 94.03 + - -27.92 + - 37.07 + - -42.7 + - 1611144216000 + - - -537371887 + - -120.6 + - 3.15 + - -22.5 + - -115.86 + - 1611144216000 + - - -904433195 + - 116.03 + - -44.09 + - 65.5 + - 100.47 + - 1611144216000 + - - -358019130 + - -74.14 + - 127.09 + - 30.8 + - 100.9 + - 1611144216000 + name: t3 + - columns: + - "cust_id_an int32" + - "cert_typ_cd string" + - "cert_area_cd string" + - "birth_dt date" + - "gender_typ_cd string" + - "nation_cd string" + - "marrrg_situ_cd string" + - "rsdnt_ind string" + - "citic_grp_emp_typ_cd string" + - "cust_stat_cd string" + - "open_cust_dt date" + - "open_cust_org_id string" + - "open_cust_chnl_typ_cd string" + - "cust_belg_bank_cd string" + indexs: ["indext2:cust_id_an"] + rows: + - - -164930359 + - "cert_typ_cd_cGpwz0DGMQ" + - "cert_area_cd_HecqmfKfQ7" + - "2021-01-09" + - "gender_typ_cd_HlbTDsKxLx" + - "nation_cd_IcAmK6iCHk" + - "marrrg_situ_cd_JzdSTSvnI2" + - "rsdnt_ind_qV6EO9H2E4" + - "citic_grp_emp_typ_cd_mZjOs6AvEm" + - "cust_stat_cd_pL86avtzOm" + - "2021-01-12" + - "open_cust_org_id_TgCKG40Joz" + - "open_cust_chnl_typ_cd_cBUBu2Wm6D" + - "cust_belg_bank_cd_UBZAxmSLUW" + - - -43274786 + - "cert_typ_cd_QetmS9wxcU" + - "cert_area_cd_rrltclnYQU" + - "2021-01-05" + - "gender_typ_cd_DzQCyg6Ui2" + - "nation_cd_tasmOg7NAe" + - "marrrg_situ_cd_t43rdVAhR5" + - "rsdnt_ind_qZOBkBtacn" + - "citic_grp_emp_typ_cd_Xp6gvlxr7o" + - "cust_stat_cd_R9lp6oM2x8" + - "2021-01-03" + - "open_cust_org_id_7rnyNbu4Yu" + - "open_cust_chnl_typ_cd_mu1leQa1Gx" + - "cust_belg_bank_cd_XLIXJnEtRf" + name: t2 + - columns: + - "cust_id_an int32" + - "tx_time timestamp" + - "crdt_card_tx_cd string" + - "tx_amt_to_rmb double" + - "mercht_typ_cd string" + - "cross_bord_ind string" + - "tx_desc_an int32" + indexs: ["indext4:cust_id_an:tx_time"] + rows: + - - 951632459 + - 1611144216000 + - "crdt_card_tx_cd_6j6bjhDy9o" + - 110.73 + - "mercht_typ_cd_feZu3kqy1P" + - "cross_bord_ind_j5RBoKax1g" + - -1752891717 + - - 1033871191 + - 1611144216000 + - "crdt_card_tx_cd_bDs5fzy7vx" + - -20.85 + - "mercht_typ_cd_Ponis59I95" + - "cross_bord_ind_3ErQHlOtLq" + - 24112845 + - - 19144738 + - 1611144216000 + - "crdt_card_tx_cd_G2CZyldEgg" + - -94.15 + - "mercht_typ_cd_xM8BN1jxf5" + - "cross_bord_ind_MuFWwfgxqi" + - -1625982017 + - - -709159498 + - 1611144216000 + - "crdt_card_tx_cd_SWmMk5bGbe" + - -104.9 + - "mercht_typ_cd_F8SmujshlU" + - "cross_bord_ind_Cja6dv7mJt" + - 734595537 + - - 407401011 + - 1611144216000 + - "crdt_card_tx_cd_Q2bYofa0LV" + - 118.56 + - "mercht_typ_cd_raO5rr5AZW" + - "cross_bord_ind_FtZc0Pd2e8" + - -347783598 + - - -274181216 + - 1611144216000 + - "crdt_card_tx_cd_SrvekEh3VO" + - -36.7 + - "mercht_typ_cd_wkQggxQwfB" + - "cross_bord_ind_lIkIIKdrmU" + - -1929744820 + - - -1693120077 + - 1611144216000 + - "crdt_card_tx_cd_crzOFQUvEV" + - -63.78 + - "mercht_typ_cd_gyHnXWDCcr" + - "cross_bord_ind_lSjZJSUzjz" + - -1367456280 + - - -1441604939 + - 1611144216000 + - "crdt_card_tx_cd_gLqQvmRyub" + - 58.01 + - "mercht_typ_cd_ltgNcE28wj" + - "cross_bord_ind_ruileQrE9G" + - -26181260 + name: t4 + sql: |- + select * from + ( + select + id as id_1, + `id` as t1_id_original_0, + `cust_id_an` as t1_cust_id_an_original_1, + `ins_date` as t1_ins_date_original_2, + `Label` as t1_Label_original_3, + dayofweek(timestamp(`ins_date`)) as t1_ins_date_dayofweek_138 + from + `t1` + ) + as out0 + last join + ( + select + t1.id as id_5, + `t2_cust_id_an`.`birth_dt` as t2_birth_dt_multi_direct_4, + `t2_cust_id_an`.`cert_area_cd` as t2_cert_area_cd_multi_direct_5, + `t2_cust_id_an`.`cert_typ_cd` as t2_cert_typ_cd_multi_direct_6, + `t2_cust_id_an`.`citic_grp_emp_typ_cd` as t2_citic_grp_emp_typ_cd_multi_direct_7, + `t2_cust_id_an`.`cust_belg_bank_cd` as t2_cust_belg_bank_cd_multi_direct_8, + `t2_cust_id_an`.`cust_stat_cd` as t2_cust_stat_cd_multi_direct_9, + `t2_cust_id_an`.`gender_typ_cd` as t2_gender_typ_cd_multi_direct_10, + `t2_cust_id_an`.`marrrg_situ_cd` as t2_marrrg_situ_cd_multi_direct_11, + `t2_cust_id_an`.`nation_cd` as t2_nation_cd_multi_direct_12, + `t2_cust_id_an`.`open_cust_chnl_typ_cd` as t2_open_cust_chnl_typ_cd_multi_direct_13, + `t2_cust_id_an`.`open_cust_dt` as t2_open_cust_dt_multi_direct_14, + `t2_cust_id_an`.`open_cust_org_id` as t2_open_cust_org_id_multi_direct_15, + `t2_cust_id_an`.`rsdnt_ind` as t2_rsdnt_ind_multi_direct_16, + `t3_cust_id_an__ins_date_0_10`.`aval_lmt_cash` as t3_aval_lmt_cash_multi_last_value_17, + `t3_cust_id_an__ins_date_0_10`.`aval_lmt_cust` as t3_aval_lmt_cust_multi_last_value_18, + `t3_cust_id_an__ins_date_0_10`.`crdt_lmt_cash` as t3_crdt_lmt_cash_multi_last_value_19, + `t3_cust_id_an__ins_date_0_10`.`crdt_lmt_cust` as t3_crdt_lmt_cust_multi_last_value_20, + `t3_cust_id_an__ins_date_0_10`.`data_date` as t3_data_date_multi_last_value_21, + `t5_cust_id_an__ins_date_0_10`.`amtbl_comm_fee` as t5_amtbl_comm_fee_multi_last_value_22, + `t5_cust_id_an__ins_date_0_10`.`annl_fee_incom_amt` as t5_annl_fee_incom_amt_multi_last_value_23, + `t5_cust_id_an__ins_date_0_10`.`cap_cost_amt` as t5_cap_cost_amt_multi_last_value_24, + `t5_cust_id_an__ins_date_0_10`.`cash_incom_amt` as t5_cash_incom_amt_multi_last_value_25, + `t5_cust_id_an__ins_date_0_10`.`commsn_incom_amt` as t5_commsn_incom_amt_multi_last_value_26, + `t5_cust_id_an__ins_date_0_10`.`crdt_card_net_incom_amt` as t5_crdt_card_net_incom_amt_multi_last_value_27, + `t5_cust_id_an__ins_date_0_10`.`data_date` as t5_data_date_multi_last_value_28, + `t5_cust_id_an__ins_date_0_10`.`extras_fee_incom_amt` as t5_extras_fee_incom_amt_multi_last_value_29, + `t5_cust_id_an__ins_date_0_10`.`int_incom_amt` as t5_int_incom_amt_multi_last_value_30, + `t5_cust_id_an__ins_date_0_10`.`late_chrg_incom_amt` as t5_late_chrg_incom_amt_multi_last_value_31, + `t5_cust_id_an__ins_date_0_10`.`oth_incom_amt` as t5_oth_incom_amt_multi_last_value_32, + `t5_cust_id_an__ins_date_0_10`.`provs_cost_amt` as t5_provs_cost_amt_multi_last_value_33 + from + `t1` + last join `t2` as `t2_cust_id_an` on `t1`.`cust_id_an` = `t2_cust_id_an`.`cust_id_an` + last join `t3` as `t3_cust_id_an__ins_date_0_10` order by t3_cust_id_an__ins_date_0_10.`data_date` on `t1`.`cust_id_an` = `t3_cust_id_an__ins_date_0_10`.`cust_id_an` + last join `t5` as `t5_cust_id_an__ins_date_0_10` order by t5_cust_id_an__ins_date_0_10.`data_date` on `t1`.`cust_id_an` = `t5_cust_id_an__ins_date_0_10`.`cust_id_an`) + as out1 + on out0.id_1 = out1.id_5 + last join + ( + select + id as id_35, + min(`tx_amt_to_rmb`) over t4_cust_id_an_tx_time_0s_1d as t4_tx_amt_to_rmb_multi_min_34, + avg(`tx_amt_to_rmb`) over t4_cust_id_an_tx_time_0s_1d as t4_tx_amt_to_rmb_multi_avg_35, + fz_topn_frequency(`crdt_card_tx_cd`, 3) over t4_cust_id_an_tx_time_0_100 as t4_crdt_card_tx_cd_multi_top3frequency_36, + distinct_count(`crdt_card_tx_cd`) over t4_cust_id_an_tx_time_0_100 as t4_crdt_card_tx_cd_multi_unique_count_37, + distinct_count(`cross_bord_ind`) over t4_cust_id_an_tx_time_0_100 as t4_cross_bord_ind_multi_unique_count_38, + fz_topn_frequency(`cross_bord_ind`, 3) over t4_cust_id_an_tx_time_0_100 as t4_cross_bord_ind_multi_top3frequency_39, + distinct_count(`mercht_typ_cd`) over t4_cust_id_an_tx_time_0_10 as t4_mercht_typ_cd_multi_unique_count_40, + distinct_count(`mercht_typ_cd`) over t4_cust_id_an_tx_time_0_100 as t4_mercht_typ_cd_multi_unique_count_41, + distinct_count(`tx_desc_an`) over t4_cust_id_an_tx_time_0_10 as t4_tx_desc_an_multi_unique_count_42, + distinct_count(`tx_desc_an`) over t4_cust_id_an_tx_time_0_100 as t4_tx_desc_an_multi_unique_count_43 + from + (select `cust_id_an` as `cust_id_an`, `ins_date` as `tx_time`, '' as `crdt_card_tx_cd`, double(0) as `tx_amt_to_rmb`, '' as `mercht_typ_cd`, '' as `cross_bord_ind`, int(0) as `tx_desc_an`, id from `t1`) + window t4_cust_id_an_tx_time_0s_1d as ( + UNION (select `cust_id_an`, `tx_time`, `crdt_card_tx_cd`, `tx_amt_to_rmb`, `mercht_typ_cd`, `cross_bord_ind`, `tx_desc_an`, int(0) as id from `t4`) partition by `cust_id_an` order by `tx_time` rows_range between 1d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t4_cust_id_an_tx_time_0_100 as ( + UNION (select `cust_id_an`, `tx_time`, `crdt_card_tx_cd`, `tx_amt_to_rmb`, `mercht_typ_cd`, `cross_bord_ind`, `tx_desc_an`, int(0) as id from `t4`) partition by `cust_id_an` order by `tx_time` rows between 100 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW), + t4_cust_id_an_tx_time_0_10 as ( + UNION (select `cust_id_an`, `tx_time`, `crdt_card_tx_cd`, `tx_amt_to_rmb`, `mercht_typ_cd`, `cross_bord_ind`, `tx_desc_an`, int(0) as id from `t4`) partition by `cust_id_an` order by `tx_time` rows between 10 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW)) + as out2 + on out0.id_1 = out2.id_35 + last join + ( + select + id as id_45, + min(`annl_fee`) over t6_cust_id_an_actv_dt_0_100 as t6_annl_fee_multi_min_44, + min(`annl_fee`) over t6_cust_id_an_actv_dt_0_10 as t6_annl_fee_multi_min_45, + min(`card_agmt_id_an`) over t6_cust_id_an_actv_dt_0_10 as t6_card_agmt_id_an_multi_min_46, + avg(`card_agmt_id_an`) over t6_cust_id_an_actv_dt_0_10 as t6_card_agmt_id_an_multi_avg_47, + min(`pri_acct_id_an`) over t6_cust_id_an_actv_dt_0_100 as t6_pri_acct_id_an_multi_min_48, + min(`pri_acct_id_an`) over t6_cust_id_an_actv_dt_0_10 as t6_pri_acct_id_an_multi_min_49, + fz_topn_frequency(`actv_chnl_cd`, 3) over t6_cust_id_an_actv_dt_0_100 as t6_actv_chnl_cd_multi_top3frequency_50, + fz_topn_frequency(`actv_chnl_cd`, 3) over t6_cust_id_an_actv_dt_0_10 as t6_actv_chnl_cd_multi_top3frequency_51, + distinct_count(`atta_card_ind`) over t6_cust_id_an_actv_dt_0s_32d as t6_atta_card_ind_multi_unique_count_52, + fz_topn_frequency(`atta_card_ind`, 3) over t6_cust_id_an_actv_dt_0s_32d as t6_atta_card_ind_multi_top3frequency_53, + fz_topn_frequency(`bus_card_ind`, 3) over t6_cust_id_an_actv_dt_0s_32d as t6_bus_card_ind_multi_top3frequency_54, + distinct_count(`bus_card_ind`) over t6_cust_id_an_actv_dt_0s_32d as t6_bus_card_ind_multi_unique_count_55, + distinct_count(`camp_org_id`) over t6_cust_id_an_actv_dt_0_100 as t6_camp_org_id_multi_unique_count_56, + distinct_count(`camp_org_id`) over t6_cust_id_an_actv_dt_0_10 as t6_camp_org_id_multi_unique_count_57, + fz_topn_frequency(`card_matr_yr_mth`, 3) over t6_cust_id_an_actv_dt_0_100 as t6_card_matr_yr_mth_multi_top3frequency_58, + fz_topn_frequency(`card_matr_yr_mth`, 3) over t6_cust_id_an_actv_dt_0_10 as t6_card_matr_yr_mth_multi_top3frequency_59, + fz_topn_frequency(`card_org_cd`, 3) over t6_cust_id_an_actv_dt_0s_32d as t6_card_org_cd_multi_top3frequency_60, + distinct_count(`card_org_cd`) over t6_cust_id_an_actv_dt_0s_32d as t6_card_org_cd_multi_unique_count_61, + distinct_count(`crdt_card_lvl_cd`) over t6_cust_id_an_actv_dt_0_100 as t6_crdt_card_lvl_cd_multi_unique_count_62, + distinct_count(`crdt_card_lvl_cd`) over t6_cust_id_an_actv_dt_0_10 as t6_crdt_card_lvl_cd_multi_unique_count_63, + fz_topn_frequency(`free_annl_fee_ind`, 3) over t6_cust_id_an_actv_dt_0s_32d as t6_free_annl_fee_ind_multi_top3frequency_64, + distinct_count(`free_annl_fee_ind`) over t6_cust_id_an_actv_dt_0s_32d as t6_free_annl_fee_ind_multi_unique_count_65, + fz_topn_frequency(`matr_contn_card_ind`, 3) over t6_cust_id_an_actv_dt_0s_32d as t6_matr_contn_card_ind_multi_top3frequency_66, + distinct_count(`matr_contn_card_ind`) over t6_cust_id_an_actv_dt_0s_32d as t6_matr_contn_card_ind_multi_unique_count_67, + distinct_count(`prod_id`) over t6_cust_id_an_actv_dt_0_100 as t6_prod_id_multi_unique_count_68, + fz_topn_frequency(`prod_id`, 3) over t6_cust_id_an_actv_dt_0_10 as t6_prod_id_multi_top3frequency_69, + fz_topn_frequency(`sell_chnl_cd`, 3) over t6_cust_id_an_actv_dt_0_10 as t6_sell_chnl_cd_multi_top3frequency_70, + fz_topn_frequency(`sell_chnl_cd`, 3) over t6_cust_id_an_actv_dt_0_100 as t6_sell_chnl_cd_multi_top3frequency_71, + fz_topn_frequency(`snp_gage_cd`, 3) over t6_cust_id_an_actv_dt_0_10 as t6_snp_gage_cd_multi_top3frequency_72, + fz_topn_frequency(`snp_gage_cd`, 3) over t6_cust_id_an_actv_dt_0_100 as t6_snp_gage_cd_multi_top3frequency_73 + from + (select `cust_id_an` as `cust_id_an`, int(0) as `card_agmt_id_an`, int(0) as `pri_acct_id_an`, '' as `atta_card_ind`, '' as `camp_org_id`, '' as `prod_id`, '' as `snp_gage_cd`, '' as `crdt_card_lvl_cd`, date('2019-07-18') as `pin_card_dt`, '' as `card_matr_yr_mth`, '' as `sell_chnl_cd`, '' as `card_org_cd`, '' as `actv_chnl_cd`, '' as `free_annl_fee_ind`, double(0) as `annl_fee`, '' as `bus_card_ind`, '' as `matr_contn_card_ind`, timestamp('2019-07-18 09:20:20') as `issu_card_dt`, `ins_date` as `actv_dt`, id from `t1`) + window t6_cust_id_an_actv_dt_0_100 as ( + UNION (select `cust_id_an`, `card_agmt_id_an`, `pri_acct_id_an`, `atta_card_ind`, `camp_org_id`, `prod_id`, `snp_gage_cd`, `crdt_card_lvl_cd`, `pin_card_dt`, `card_matr_yr_mth`, `sell_chnl_cd`, `card_org_cd`, `actv_chnl_cd`, `free_annl_fee_ind`, `annl_fee`, `bus_card_ind`, `matr_contn_card_ind`, `issu_card_dt`, `actv_dt`, int(0) as id from `t6`) partition by `cust_id_an` order by `actv_dt` rows between 100 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW), + t6_cust_id_an_actv_dt_0_10 as ( + UNION (select `cust_id_an`, `card_agmt_id_an`, `pri_acct_id_an`, `atta_card_ind`, `camp_org_id`, `prod_id`, `snp_gage_cd`, `crdt_card_lvl_cd`, `pin_card_dt`, `card_matr_yr_mth`, `sell_chnl_cd`, `card_org_cd`, `actv_chnl_cd`, `free_annl_fee_ind`, `annl_fee`, `bus_card_ind`, `matr_contn_card_ind`, `issu_card_dt`, `actv_dt`, int(0) as id from `t6`) partition by `cust_id_an` order by `actv_dt` rows between 10 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW), + t6_cust_id_an_actv_dt_0s_32d as ( + UNION (select `cust_id_an`, `card_agmt_id_an`, `pri_acct_id_an`, `atta_card_ind`, `camp_org_id`, `prod_id`, `snp_gage_cd`, `crdt_card_lvl_cd`, `pin_card_dt`, `card_matr_yr_mth`, `sell_chnl_cd`, `card_org_cd`, `actv_chnl_cd`, `free_annl_fee_ind`, `annl_fee`, `bus_card_ind`, `matr_contn_card_ind`, `issu_card_dt`, `actv_dt`, int(0) as id from `t6`) partition by `cust_id_an` order by `actv_dt` rows_range between 32d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW)) + as out3 + on out0.id_1 = out3.id_45 + last join + ( + select + id as id_75, + fz_topn_frequency(`card_agmt_id_an`, 3) over t7_cust_id_an_data_date_0s_1d as t7_card_agmt_id_an_multi_top3frequency_74, + fz_topn_frequency(`card_agmt_id_an`, 3) over t7_cust_id_an_data_date_0s_32d as t7_card_agmt_id_an_multi_top3frequency_75, + fz_topn_frequency(`card_stat_cd`, 3) over t7_cust_id_an_data_date_0_100 as t7_card_stat_cd_multi_top3frequency_76, + distinct_count(`card_stat_cd`) over t7_cust_id_an_data_date_0_100 as t7_card_stat_cd_multi_unique_count_77 + from + (select `cust_id_an` as `cust_id_an`, int(0) as `card_agmt_id_an`, date('2019-07-18') as `fst_use_card_dt`, date('2019-07-18') as `ltst_use_card_dt`, '' as `card_stat_cd`, `ins_date` as `data_date`, id from `t1`) + window t7_cust_id_an_data_date_0s_1d as ( + UNION (select `cust_id_an`, `card_agmt_id_an`, `fst_use_card_dt`, `ltst_use_card_dt`, `card_stat_cd`, `data_date`, int(0) as id from `t7`) partition by `cust_id_an` order by `data_date` rows_range between 1d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t7_cust_id_an_data_date_0s_32d as ( + UNION (select `cust_id_an`, `card_agmt_id_an`, `fst_use_card_dt`, `ltst_use_card_dt`, `card_stat_cd`, `data_date`, int(0) as id from `t7`) partition by `cust_id_an` order by `data_date` rows_range between 32d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t7_cust_id_an_data_date_0_100 as ( + UNION (select `cust_id_an`, `card_agmt_id_an`, `fst_use_card_dt`, `ltst_use_card_dt`, `card_stat_cd`, `data_date`, int(0) as id from `t7`) partition by `cust_id_an` order by `data_date` rows between 100 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW)) + as out4 + on out0.id_1 = out4.id_75 + last join + ( + select + id as id_79, + min(`agmt_id_an`) over t8_cust_id_an_open_acct_dt_0_10 as t8_agmt_id_an_multi_min_78, + max(`agmt_id_an`) over t8_cust_id_an_open_acct_dt_0_10 as t8_agmt_id_an_multi_max_79, + fz_topn_frequency(`atta_acct_ind`, 3) over t8_cust_id_an_open_acct_dt_0s_32d as t8_atta_acct_ind_multi_top3frequency_80, + distinct_count(`atta_acct_ind`) over t8_cust_id_an_open_acct_dt_0s_32d as t8_atta_acct_ind_multi_unique_count_81 + from + (select `cust_id_an` as `cust_id_an`, int(0) as `agmt_id_an`, '' as `atta_acct_ind`, date('2019-07-18') as `stmt_dt`, `ins_date` as `open_acct_dt`, timestamp('2019-07-18 09:20:20') as `clos_acct_dt`, id from `t1`) + window t8_cust_id_an_open_acct_dt_0_10 as ( + UNION (select `cust_id_an`, `agmt_id_an`, `atta_acct_ind`, `stmt_dt`, `open_acct_dt`, `clos_acct_dt`, int(0) as id from `t8`) partition by `cust_id_an` order by `open_acct_dt` rows between 10 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW), + t8_cust_id_an_open_acct_dt_0s_32d as ( + UNION (select `cust_id_an`, `agmt_id_an`, `atta_acct_ind`, `stmt_dt`, `open_acct_dt`, `clos_acct_dt`, int(0) as id from `t8`) partition by `cust_id_an` order by `open_acct_dt` rows_range between 32d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW)) + as out5 + on out0.id_1 = out5.id_79 + last join + ( + select + id as id_83, + min(`amtbl_od_bal`) over t9_cust_id_an_data_date_0s_32d as t9_amtbl_od_bal_multi_min_82, + avg(`amtbl_od_bal`) over t9_cust_id_an_data_date_0_10 as t9_amtbl_od_bal_multi_avg_83, + min(`cash_od_bal`) over t9_cust_id_an_data_date_0_100 as t9_cash_od_bal_multi_min_84, + min(`cash_od_bal`) over t9_cust_id_an_data_date_0_10 as t9_cash_od_bal_multi_min_85, + min(`consm_od_bal`) over t9_cust_id_an_data_date_0_100 as t9_consm_od_bal_multi_min_86, + min(`consm_od_bal`) over t9_cust_id_an_data_date_0_10 as t9_consm_od_bal_multi_min_87, + max(`crdt_card_point`) over t9_cust_id_an_data_date_0_100 as t9_crdt_card_point_multi_max_88, + max(`crdt_card_point`) over t9_cust_id_an_data_date_0_10 as t9_crdt_card_point_multi_max_89, + min(`curr_yr_crdt_card_point`) over t9_cust_id_an_data_date_0_100 as t9_curr_yr_crdt_card_point_multi_min_90, + min(`curr_yr_crdt_card_point`) over t9_cust_id_an_data_date_0_10 as t9_curr_yr_crdt_card_point_multi_min_91, + max(`last_mth_consm_cnt`) over t9_cust_id_an_data_date_0_100 as t9_last_mth_consm_cnt_multi_max_92, + max(`last_mth_consm_cnt`) over t9_cust_id_an_data_date_0_10 as t9_last_mth_consm_cnt_multi_max_93, + min(`last_mth_stmt_amt`) over t9_cust_id_an_data_date_0_100 as t9_last_mth_stmt_amt_multi_min_94, + min(`last_mth_stmt_amt`) over t9_cust_id_an_data_date_0_10 as t9_last_mth_stmt_amt_multi_min_95, + min(`m_amtbl_amt_accm`) over t9_cust_id_an_data_date_0s_32d as t9_m_amtbl_amt_accm_multi_min_96, + avg(`m_amtbl_amt_accm`) over t9_cust_id_an_data_date_0_10 as t9_m_amtbl_amt_accm_multi_avg_97, + min(`m_cash_amt_accm`) over t9_cust_id_an_data_date_0_100 as t9_m_cash_amt_accm_multi_min_98, + min(`m_cash_amt_accm`) over t9_cust_id_an_data_date_0_10 as t9_m_cash_amt_accm_multi_min_99, + min(`m_consm_amt_accm`) over t9_cust_id_an_data_date_0_100 as t9_m_consm_amt_accm_multi_min_100, + min(`m_consm_amt_accm`) over t9_cust_id_an_data_date_0_10 as t9_m_consm_amt_accm_multi_min_101, + avg(`m_ovrd_bal_accm`) over t9_cust_id_an_data_date_0_100 as t9_m_ovrd_bal_accm_multi_avg_102, + avg(`m_ovrd_bal_accm`) over t9_cust_id_an_data_date_0_10 as t9_m_ovrd_bal_accm_multi_avg_103, + max(`m_spl_pay_amt_accm`) over t9_cust_id_an_data_date_0_100 as t9_m_spl_pay_amt_accm_multi_max_104, + max(`m_spl_pay_amt_accm`) over t9_cust_id_an_data_date_0_10 as t9_m_spl_pay_amt_accm_multi_max_105, + avg(`ovrd_bal`) over t9_cust_id_an_data_date_0_100 as t9_ovrd_bal_multi_avg_106, + avg(`ovrd_bal`) over t9_cust_id_an_data_date_0_10 as t9_ovrd_bal_multi_avg_107, + max(`spl_pay_bal`) over t9_cust_id_an_data_date_0_100 as t9_spl_pay_bal_multi_max_108, + max(`spl_pay_bal`) over t9_cust_id_an_data_date_0_10 as t9_spl_pay_bal_multi_max_109, + fz_topn_frequency(`acct_stat_cd`, 3) over t9_cust_id_an_data_date_0_100 as t9_acct_stat_cd_multi_top3frequency_110, + distinct_count(`acct_stat_cd`) over t9_cust_id_an_data_date_0_100 as t9_acct_stat_cd_multi_unique_count_111, + fz_topn_frequency(`agmt_id_an`, 3) over t9_cust_id_an_data_date_0s_1d as t9_agmt_id_an_multi_top3frequency_112, + fz_topn_frequency(`agmt_id_an`, 3) over t9_cust_id_an_data_date_0s_32d as t9_agmt_id_an_multi_top3frequency_113, + fz_topn_frequency(`curr_ovrd_stat_cd`, 3) over t9_cust_id_an_data_date_0_100 as t9_curr_ovrd_stat_cd_multi_top3frequency_114, + fz_topn_frequency(`curr_ovrd_stat_cd`, 3) over t9_cust_id_an_data_date_0_10 as t9_curr_ovrd_stat_cd_multi_top3frequency_115, + fz_topn_frequency(`curr_yr_ovrd_cnt`, 3) over t9_cust_id_an_data_date_0_100 as t9_curr_yr_ovrd_cnt_multi_top3frequency_116, + fz_topn_frequency(`curr_yr_ovrd_cnt`, 3) over t9_cust_id_an_data_date_0_10 as t9_curr_yr_ovrd_cnt_multi_top3frequency_117 + from + (select `cust_id_an` as `cust_id_an`, int(0) as `agmt_id_an`, '' as `curr_ovrd_stat_cd`, int(0) as `curr_yr_ovrd_cnt`, double(0) as `curr_yr_crdt_card_point`, double(0) as `crdt_card_point`, '' as `acct_stat_cd`, double(0) as `consm_od_bal`, double(0) as `cash_od_bal`, double(0) as `amtbl_od_bal`, double(0) as `spl_pay_bal`, double(0) as `ovrd_bal`, double(0) as `last_mth_stmt_amt`, int(0) as `last_mth_consm_cnt`, double(0) as `m_consm_amt_accm`, double(0) as `m_cash_amt_accm`, double(0) as `m_amtbl_amt_accm`, double(0) as `m_spl_pay_amt_accm`, double(0) as `m_ovrd_bal_accm`, `ins_date` as `data_date`, id from `t1`) + window t9_cust_id_an_data_date_0s_32d as ( + UNION (select `cust_id_an`, `agmt_id_an`, `curr_ovrd_stat_cd`, `curr_yr_ovrd_cnt`, `curr_yr_crdt_card_point`, `crdt_card_point`, `acct_stat_cd`, `consm_od_bal`, `cash_od_bal`, `amtbl_od_bal`, `spl_pay_bal`, `ovrd_bal`, `last_mth_stmt_amt`, `last_mth_consm_cnt`, `m_consm_amt_accm`, `m_cash_amt_accm`, `m_amtbl_amt_accm`, `m_spl_pay_amt_accm`, `m_ovrd_bal_accm`, `data_date`, int(0) as id from `t9`) partition by `cust_id_an` order by `data_date` rows_range between 32d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t9_cust_id_an_data_date_0_10 as ( + UNION (select `cust_id_an`, `agmt_id_an`, `curr_ovrd_stat_cd`, `curr_yr_ovrd_cnt`, `curr_yr_crdt_card_point`, `crdt_card_point`, `acct_stat_cd`, `consm_od_bal`, `cash_od_bal`, `amtbl_od_bal`, `spl_pay_bal`, `ovrd_bal`, `last_mth_stmt_amt`, `last_mth_consm_cnt`, `m_consm_amt_accm`, `m_cash_amt_accm`, `m_amtbl_amt_accm`, `m_spl_pay_amt_accm`, `m_ovrd_bal_accm`, `data_date`, int(0) as id from `t9`) partition by `cust_id_an` order by `data_date` rows between 10 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW), + t9_cust_id_an_data_date_0_100 as ( + UNION (select `cust_id_an`, `agmt_id_an`, `curr_ovrd_stat_cd`, `curr_yr_ovrd_cnt`, `curr_yr_crdt_card_point`, `crdt_card_point`, `acct_stat_cd`, `consm_od_bal`, `cash_od_bal`, `amtbl_od_bal`, `spl_pay_bal`, `ovrd_bal`, `last_mth_stmt_amt`, `last_mth_consm_cnt`, `m_consm_amt_accm`, `m_cash_amt_accm`, `m_amtbl_amt_accm`, `m_spl_pay_amt_accm`, `m_ovrd_bal_accm`, `data_date`, int(0) as id from `t9`) partition by `cust_id_an` order by `data_date` rows between 100 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW), + t9_cust_id_an_data_date_0s_1d as ( + UNION (select `cust_id_an`, `agmt_id_an`, `curr_ovrd_stat_cd`, `curr_yr_ovrd_cnt`, `curr_yr_crdt_card_point`, `crdt_card_point`, `acct_stat_cd`, `consm_od_bal`, `cash_od_bal`, `amtbl_od_bal`, `spl_pay_bal`, `ovrd_bal`, `last_mth_stmt_amt`, `last_mth_consm_cnt`, `m_consm_amt_accm`, `m_cash_amt_accm`, `m_amtbl_amt_accm`, `m_spl_pay_amt_accm`, `m_ovrd_bal_accm`, `data_date`, int(0) as id from `t9`) partition by `cust_id_an` order by `data_date` rows_range between 1d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW)) + as out6 + on out0.id_1 = out6.id_83 + ; + expect: + success: true diff --git a/cases/integration_test/spark/test_fqz_studio.yaml b/cases/integration_test/spark/test_fqz_studio.yaml new file mode 100644 index 00000000000..cbbbaf5a5ec --- /dev/null +++ b/cases/integration_test/spark/test_fqz_studio.yaml @@ -0,0 +1,363 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 单表反欺诈场景 +db: test_fqz +cases: + - id: 1 + desc: 单表-反欺诈场景 + inputs: + - columns: [ "id int32", "bilabel int32", "D_TXN_TIME_std timestamp", "C_SK_SEQ string", "D_RHX_DATE_KEY string", "N_CMX_TRAN_ID int32", "D_TXN_DATE string", "D_TXN_TIME string", "C_ACCT_TYPE string" , "C_ACCT_CARD_NO string", "C_ACCT_CARD_FLAG string", "C_ACCT_ZONE string", "N_ISSUE_AMT double", "N_TXN_AMT_RMB double", "C_ISSUE_CURR string", "C_CUSTOMER_ID string", "N_TRXCODE string", "C_DAILY_OPENBUY double", "C_INDI_OPENBUY double", "N_PHONE_NO string", "N_BOUND_PHONE_NO string", "C_MAC_ADDR string", "C_TXN_IP string", "C_MERCH_ID string", "C_MAC_STAT string", "C_IP_STAT string", "C_GREYLIST_FLAG string", "C_RULE_ACT string", "RRF_RULE_DATA string", "RRF_BUILD_NUM int32", "C_PAY_NAME string", "C_TXN_TYPE string", "C_PAYEE_ACCT string", "C_PAYEE_NAME string", "C_PAYEE_BANK_NAME string", "C_TXN_CHANNEL string", "C_SERIAL_NO string", "D_REGISTER_DATETIME double", "C_PAYEE_ACCT_ZONE string", "C_COMMONLY_PAYEE_FLAG string", "C_TRUST_PAYEE_FLAG string", "C_MEDIUM_NO string", "C_TRUST_CLIENT_FLAG string", "C_VERIFY_TYPE string", "C_PAYEE_CUSTOMER_ID string", "C_CPU_ID string", "C_MEMORY_CAPACITY double", "C_SYSTEM_VERSION string", "C_BROWSER_VERSION string", "C_BROWSER_LANG string", "C_SCREEN_RESOLUTION double", "C_APP_VERSION string", "C_FACTORY_INFO string", "C_WHITE_CARD_FLAG string", "C_ACCOUNT_BALANCE double", "C_MOBILE_LOCATION double", "C_DEAL_RESULT string", "C_FINAL_DEAL_TYPE string", "N_MODEL_SCORE double", "C_TXN_TYPE_TMP string", "N_UNIT_PRICE double", "N_TXN_COUNT double", "PROV string", "CITY string", "MER_OPTIMESP string", "MER_GROUPID int32", "MER_ZONENO string", "MER_BRNO string", "MER_SHOP_BASE string", "MER_PACCTYPE int32", "MER_FRATEPC string", "MER_SPECACCT int32", "MER_SWITCH int32", "MER_AMTLIMI1 int32", "MER_RATLIMI1 int32", "MER_BUSIAREA string", "CUS_Gender_Cd int32", "CUS_Ethnic_Cd int32", "CUS_Birth_Cty_Cd string", "CUS_Edu_Degree_Cd int32", "CUS_Marriage_Status_Cd int32", "CUS_Vip_Cust_Ind int32", "CUS_Icbc_Emply_Ind int32", "CUS_Dom_Resdnt_Ind int32", "CUS_Belong_Corp_Type_Cd int32", "CUS_Proper_Career_Cd string", "CUS_Proper_Industry_Cd int32", "CUS_Integrality_Ind_Cd int32", "CUS_Integrality_Check_Result int32", "CUS_Identity_Actl_Result_Type_Cd int32", "CUS_Cert_Provi_Situ_Type_Cd int32", "CUS_Invalid_Acct_Cert_Actl_Result int32", "CUS_Start_Dt string", "CUS_Birth_Dt string", "CUS_Career_Cd string", "CARDSTAT int32", "CARDKIND int32", "SYNFLAG int32", "GOLDFLAG int32", "OPENDATE date", "CDSQUOTA int64", "CDTQUOTA int64", "BT_CARDSTAT int32", "BT_ACTCHANEL int32", "BT_ACTDATE date", "BT_SALECODE string" ] + indexs: ["index1:C_ACCT_CARD_NO:D_TXN_TIME_std", "index2:N_BOUND_PHONE_NO:D_TXN_TIME_std", "index3:N_PHONE_NO:D_TXN_TIME_std", "index4:C_CUSTOMER_ID:D_TXN_TIME_std"] + rows: + - [33, 250, 1609236827000, "c_sk_seq", "d_rhx_date_key", 11, "d_txn_date", "d_txn_time", "c_acct_type" , "c_acct_card_no", "c_acct_card_flag", "c_acct_zone", 12.00, 13.14, "c_issue_curr", "c_customer_id", "n_trxcode", 14.12, 128.99, "n_phone_no", "n_bound_phone_no", "c_mac_addr", "c_txn_ip", "c_merch_id", "c_mac_stat", "c_ip_stat", "c_greylist_flag", "c_rule_act", "rrf_rule_data", 19, "c_pay_name", "c_txn_type", "c_payee_acct", "c_payee_name", "c_payee_bank_name", "c_txn_channel", "c_serial_no", 88.88, "c_payee_acct_zone", "c_commonly_payee_flag", "c_trust_payee_flag", "c_medium_no", "c_trust_client_flag", "c_verify_type", "c_payee_customer_id", "c_cpu_id", 77.07, "c_system_version", "c_browser_version", "c_browser_lang", 100.00, "c_app_version", "c_factory_info", "c_white_card_flag", 99.19, 67.81, "c_deal_result", "c_final_deal_type", 34.43, "c_txn_type_tmp", 88.08, 128.12, "prov", "city", "mer_optimesp", 939, "mer_zoneno", "mer_brno", "mer_shop_base", 477, "mer_fratepc", 122, 355, 223, 211, "mer_busiarea", 334, 444, "cus_birth_cty_cd", 555, 566, 577, 588, 42020, 314, "cus_proper_career_cd", 333, 41212, 666, 677, 688, 699, "cus_start_dt", "cus_birth_dt", "cus_career_cd", 61010, 777, 711, 733, "2020-12-22", 122, 999, 977, 432, "2021-01-02", "bt_salecode" ] + sql: | + select + id as id_1, + id as t1_id_original_0, + bilabel as t1_bilabel_original_1, + D_TXN_TIME_std as t1_D_TXN_TIME_std_original_2, + C_SK_SEQ as t1_C_SK_SEQ_original_3, + D_RHX_DATE_KEY as t1_D_RHX_DATE_KEY_original_4, + N_CMX_TRAN_ID as t1_N_CMX_TRAN_ID_original_5, + D_TXN_DATE as t1_D_TXN_DATE_original_6, + D_TXN_TIME as t1_D_TXN_TIME_original_7, + C_ACCT_TYPE as t1_C_ACCT_TYPE_original_8, + C_ACCT_CARD_NO as t1_C_ACCT_CARD_NO_original_9, + C_ACCT_CARD_FLAG as t1_C_ACCT_CARD_FLAG_original_10, + C_ACCT_ZONE as t1_C_ACCT_ZONE_original_11, + N_ISSUE_AMT as t1_N_ISSUE_AMT_original_12, + N_TXN_AMT_RMB as t1_N_TXN_AMT_RMB_original_13, + C_ISSUE_CURR as t1_C_ISSUE_CURR_original_14, + C_CUSTOMER_ID as t1_C_CUSTOMER_ID_original_15, + N_TRXCODE as t1_N_TRXCODE_original_16, + C_DAILY_OPENBUY as t1_C_DAILY_OPENBUY_original_17, + C_INDI_OPENBUY as t1_C_INDI_OPENBUY_original_18, + N_PHONE_NO as t1_N_PHONE_NO_original_19, + N_BOUND_PHONE_NO as t1_N_BOUND_PHONE_NO_original_20, + C_MAC_ADDR as t1_C_MAC_ADDR_original_21, + C_TXN_IP as t1_C_TXN_IP_original_22, + C_MERCH_ID as t1_C_MERCH_ID_original_23, + C_MAC_STAT as t1_C_MAC_STAT_original_24, + C_IP_STAT as t1_C_IP_STAT_original_25, + C_GREYLIST_FLAG as t1_C_GREYLIST_FLAG_original_26, + C_RULE_ACT as t1_C_RULE_ACT_original_27, + RRF_RULE_DATA as t1_RRF_RULE_DATA_original_28, + RRF_BUILD_NUM as t1_RRF_BUILD_NUM_original_29, + C_PAY_NAME as t1_C_PAY_NAME_original_30, + C_TXN_TYPE as t1_C_TXN_TYPE_original_31, + C_PAYEE_ACCT as t1_C_PAYEE_ACCT_original_32, + C_PAYEE_NAME as t1_C_PAYEE_NAME_original_33, + C_PAYEE_BANK_NAME as t1_C_PAYEE_BANK_NAME_original_34, + C_TXN_CHANNEL as t1_C_TXN_CHANNEL_original_35, + C_SERIAL_NO as t1_C_SERIAL_NO_original_36, + D_REGISTER_DATETIME as t1_D_REGISTER_DATETIME_original_37, + C_PAYEE_ACCT_ZONE as t1_C_PAYEE_ACCT_ZONE_original_38, + C_COMMONLY_PAYEE_FLAG as t1_C_COMMONLY_PAYEE_FLAG_original_39, + C_TRUST_PAYEE_FLAG as t1_C_TRUST_PAYEE_FLAG_original_40, + C_MEDIUM_NO as t1_C_MEDIUM_NO_original_41, + C_TRUST_CLIENT_FLAG as t1_C_TRUST_CLIENT_FLAG_original_42, + C_VERIFY_TYPE as t1_C_VERIFY_TYPE_original_43, + C_PAYEE_CUSTOMER_ID as t1_C_PAYEE_CUSTOMER_ID_original_44, + C_CPU_ID as t1_C_CPU_ID_original_45, + C_MEMORY_CAPACITY as t1_C_MEMORY_CAPACITY_original_46, + C_SYSTEM_VERSION as t1_C_SYSTEM_VERSION_original_47, + C_BROWSER_VERSION as t1_C_BROWSER_VERSION_original_48, + C_BROWSER_LANG as t1_C_BROWSER_LANG_original_49, + C_SCREEN_RESOLUTION as t1_C_SCREEN_RESOLUTION_original_50, + C_APP_VERSION as t1_C_APP_VERSION_original_51, + C_FACTORY_INFO as t1_C_FACTORY_INFO_original_52, + C_WHITE_CARD_FLAG as t1_C_WHITE_CARD_FLAG_original_53, + C_ACCOUNT_BALANCE as t1_C_ACCOUNT_BALANCE_original_54, + C_MOBILE_LOCATION as t1_C_MOBILE_LOCATION_original_55, + C_DEAL_RESULT as t1_C_DEAL_RESULT_original_56, + C_FINAL_DEAL_TYPE as t1_C_FINAL_DEAL_TYPE_original_57, + N_MODEL_SCORE as t1_N_MODEL_SCORE_original_58, + C_TXN_TYPE_TMP as t1_C_TXN_TYPE_TMP_original_59, + N_UNIT_PRICE as t1_N_UNIT_PRICE_original_60, + N_TXN_COUNT as t1_N_TXN_COUNT_original_61, + PROV as t1_PROV_original_62, + CITY as t1_CITY_original_63, + MER_OPTIMESP as t1_MER_OPTIMESP_original_64, + MER_GROUPID as t1_MER_GROUPID_original_65, + MER_ZONENO as t1_MER_ZONENO_original_66, + MER_BRNO as t1_MER_BRNO_original_67, + MER_SHOP_BASE as t1_MER_SHOP_BASE_original_68, + MER_PACCTYPE as t1_MER_PACCTYPE_original_69, + MER_FRATEPC as t1_MER_FRATEPC_original_70, + MER_SPECACCT as t1_MER_SPECACCT_original_71, + MER_SWITCH as t1_MER_SWITCH_original_72, + MER_AMTLIMI1 as t1_MER_AMTLIMI1_original_73, + MER_RATLIMI1 as t1_MER_RATLIMI1_original_74, + MER_BUSIAREA as t1_MER_BUSIAREA_original_75, + CUS_Gender_Cd as t1_CUS_Gender_Cd_original_76, + CUS_Ethnic_Cd as t1_CUS_Ethnic_Cd_original_77, + CUS_Birth_Cty_Cd as t1_CUS_Birth_Cty_Cd_original_78, + CUS_Edu_Degree_Cd as t1_CUS_Edu_Degree_Cd_original_79, + CUS_Marriage_Status_Cd as t1_CUS_Marriage_Status_Cd_original_80, + CUS_Vip_Cust_Ind as t1_CUS_Vip_Cust_Ind_original_81, + CUS_Icbc_Emply_Ind as t1_CUS_Icbc_Emply_Ind_original_82, + CUS_Dom_Resdnt_Ind as t1_CUS_Dom_Resdnt_Ind_original_83, + CUS_Belong_Corp_Type_Cd as t1_CUS_Belong_Corp_Type_Cd_original_84, + CUS_Proper_Career_Cd as t1_CUS_Proper_Career_Cd_original_85, + CUS_Proper_Industry_Cd as t1_CUS_Proper_Industry_Cd_original_86, + CUS_Integrality_Ind_Cd as t1_CUS_Integrality_Ind_Cd_original_87, + CUS_Integrality_Check_Result as t1_CUS_Integrality_Check_Result_original_88, + CUS_Identity_Actl_Result_Type_Cd as t1_CUS_Identity_Actl_Result_Type_Cd_original_89, + CUS_Cert_Provi_Situ_Type_Cd as t1_CUS_Cert_Provi_Situ_Type_Cd_original_90, + CUS_Invalid_Acct_Cert_Actl_Result as t1_CUS_Invalid_Acct_Cert_Actl_Result_original_91, + CUS_Start_Dt as t1_CUS_Start_Dt_original_92, + CUS_Birth_Dt as t1_CUS_Birth_Dt_original_93, + CUS_Career_Cd as t1_CUS_Career_Cd_original_94, + CARDSTAT as t1_CARDSTAT_original_95, + CARDKIND as t1_CARDKIND_original_96, + SYNFLAG as t1_SYNFLAG_original_97, + GOLDFLAG as t1_GOLDFLAG_original_98, + OPENDATE as t1_OPENDATE_original_99, + CDSQUOTA as t1_CDSQUOTA_original_100, + CDTQUOTA as t1_CDTQUOTA_original_101, + BT_CARDSTAT as t1_BT_CARDSTAT_original_102, + BT_ACTCHANEL as t1_BT_ACTCHANEL_original_103, + BT_ACTDATE as t1_BT_ACTDATE_original_104, + BT_SALECODE as t1_BT_SALECODE_original_105, + distinct_count(C_SERIAL_NO) over t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_2764800s as t1_C_SERIAL_NO_window_unique_count_106, + distinct_count(C_FACTORY_INFO) over t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_1209600s as t1_C_FACTORY_INFO_window_unique_count_107, + distinct_count(C_FACTORY_INFO) over t1_N_BOUND_PHONE_NO_D_TXN_TIME_std_0s_2764800s as t1_C_FACTORY_INFO_window_unique_count_108, + distinct_count(C_FACTORY_INFO) over t1_N_PHONE_NO_D_TXN_TIME_std_0s_2764800s as t1_C_FACTORY_INFO_window_unique_count_109, + fz_top1_ratio(C_SERIAL_NO) over t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_1209600s as t1_C_SERIAL_NO_window_top1_ratio_110, + fz_top1_ratio(C_FACTORY_INFO) over t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_1209600s as t1_C_FACTORY_INFO_window_top1_ratio_111, + distinct_count(C_APP_VERSION) over t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_1209600s as t1_C_APP_VERSION_window_unique_count_112, + distinct_count(C_SERIAL_NO) over t1_N_BOUND_PHONE_NO_D_TXN_TIME_std_0s_1209600s as t1_C_SERIAL_NO_window_unique_count_113, + distinct_count(C_FACTORY_INFO) over t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_2764800s as t1_C_FACTORY_INFO_window_unique_count_114, + distinct_count(C_SERIAL_NO) over t1_N_PHONE_NO_D_TXN_TIME_std_0s_1209600s as t1_C_SERIAL_NO_window_unique_count_115, + distinct_count(C_FACTORY_INFO) over t1_N_BOUND_PHONE_NO_D_TXN_TIME_std_0s_1209600s as t1_C_FACTORY_INFO_window_unique_count_116, + max(C_SCREEN_RESOLUTION) over t1_N_BOUND_PHONE_NO_D_TXN_TIME_std_0s_1209600s as t1_C_SCREEN_RESOLUTION_window_max_117, + max(C_SCREEN_RESOLUTION) over t1_N_BOUND_PHONE_NO_D_TXN_TIME_std_0s_2764800s as t1_C_SCREEN_RESOLUTION_window_max_118, + distinct_count(C_FACTORY_INFO) over t1_C_CUSTOMER_ID_D_TXN_TIME_std_0s_1209600s as t1_C_FACTORY_INFO_window_unique_count_119, + distinct_count(C_FACTORY_INFO) over t1_N_PHONE_NO_D_TXN_TIME_std_0s_1209600s as t1_C_FACTORY_INFO_window_unique_count_120, + distinct_count(C_FACTORY_INFO) over t1_C_CUSTOMER_ID_D_TXN_TIME_std_0s_2764800s as t1_C_FACTORY_INFO_window_unique_count_121, + distinct_count(C_SERIAL_NO) over t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_1209600s as t1_C_SERIAL_NO_window_unique_count_122, + max(C_SCREEN_RESOLUTION) over t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_1209600s as t1_C_SCREEN_RESOLUTION_window_max_123, + C_IP_STAT as t1_C_IP_STAT_combine_124, + C_RULE_ACT as t1_C_RULE_ACT_combine_124, + CITY as t1_CITY_combine_124, + C_RULE_ACT as t1_C_RULE_ACT_combine_125, + C_FINAL_DEAL_TYPE as t1_C_FINAL_DEAL_TYPE_combine_125, + CITY as t1_CITY_combine_125, + C_IP_STAT as t1_C_IP_STAT_combine_126, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_126, + C_APP_VERSION as t1_C_APP_VERSION_combine_126, + C_RULE_ACT as t1_C_RULE_ACT_combine_127, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_127, + C_DEAL_RESULT as t1_C_DEAL_RESULT_combine_127, + C_IP_STAT as t1_C_IP_STAT_combine_128, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_128, + C_DEAL_RESULT as t1_C_DEAL_RESULT_combine_128, + C_RULE_ACT as t1_C_RULE_ACT_combine_129, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_129, + PROV as t1_PROV_combine_129, + C_MAC_STAT as t1_C_MAC_STAT_combine_130, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_130, + C_DEAL_RESULT as t1_C_DEAL_RESULT_combine_130, + C_RULE_ACT as t1_C_RULE_ACT_combine_131, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_131, + C_FINAL_DEAL_TYPE as t1_C_FINAL_DEAL_TYPE_combine_131, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_132, + C_VERIFY_TYPE as t1_C_VERIFY_TYPE_combine_132, + C_DEAL_RESULT as t1_C_DEAL_RESULT_combine_132, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_133, + C_MEDIUM_NO as t1_C_MEDIUM_NO_combine_133, + C_DEAL_RESULT as t1_C_DEAL_RESULT_combine_133, + C_MAC_STAT as t1_C_MAC_STAT_combine_134, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_134, + PROV as t1_PROV_combine_134, + C_RULE_ACT as t1_C_RULE_ACT_combine_135, + RRF_RULE_DATA as t1_RRF_RULE_DATA_combine_135, + C_VERIFY_TYPE as t1_C_VERIFY_TYPE_combine_135 + from + {0} + window t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_2764800s as ( partition by C_ACCT_CARD_NO order by D_TXN_TIME_std rows_range between 2764800s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_C_ACCT_CARD_NO_D_TXN_TIME_std_0s_1209600s as ( partition by C_ACCT_CARD_NO order by D_TXN_TIME_std rows_range between 1209600s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_N_BOUND_PHONE_NO_D_TXN_TIME_std_0s_2764800s as ( partition by N_BOUND_PHONE_NO order by D_TXN_TIME_std rows_range between 2764800s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_N_PHONE_NO_D_TXN_TIME_std_0s_2764800s as ( partition by N_PHONE_NO order by D_TXN_TIME_std rows_range between 2764800s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_N_BOUND_PHONE_NO_D_TXN_TIME_std_0s_1209600s as ( partition by N_BOUND_PHONE_NO order by D_TXN_TIME_std rows_range between 1209600s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_N_PHONE_NO_D_TXN_TIME_std_0s_1209600s as ( partition by N_PHONE_NO order by D_TXN_TIME_std rows_range between 1209600s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_C_CUSTOMER_ID_D_TXN_TIME_std_0s_1209600s as ( partition by C_CUSTOMER_ID order by D_TXN_TIME_std rows_range between 1209600s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_C_CUSTOMER_ID_D_TXN_TIME_std_0s_2764800s as ( partition by C_CUSTOMER_ID order by D_TXN_TIME_std rows_range between 2764800s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW); + expect: + success: true + # columns: [ + # "id_1 int32", + # "t1_id_original_0 int32", + # "t1_bilabel_original_1 int32", + # "t1_D_TXN_TIME_std_original_2 timestamp", + # "t1_C_SK_SEQ_original_3 string", + # "t1_D_RHX_DATE_KEY_original_4 string", + # "t1_N_CMX_TRAN_ID_original_5 int32", + # "t1_D_TXN_DATE_original_6 string", + # "t1_D_TXN_TIME_original_7 string", + # "t1_C_ACCT_TYPE_original_8 string", + # "t1_C_ACCT_CARD_NO_original_9 string", + # "t1_C_ACCT_CARD_FLAG_original_10 string", + # "t1_C_ACCT_ZONE_original_11 string", + # "t1_N_ISSUE_AMT_original_12 double", + # "t1_N_TXN_AMT_RMB_original_13 double", + # "t1_C_ISSUE_CURR_original_14 string", + # "t1_C_CUSTOMER_ID_original_15 string", + # "t1_N_TRXCODE_original_16 string", + # "t1_C_DAILY_OPENBUY_original_17 double", + # "t1_C_INDI_OPENBUY_original_18 double", + # "t1_N_PHONE_NO_original_19 string", + # "t1_N_BOUND_PHONE_NO_original_20 string", + # "t1_C_MAC_ADDR_original_21 string", + # "t1_C_TXN_IP_original_22 string", + # "t1_C_MERCH_ID_original_23 string", + # "t1_C_MAC_STAT_original_24 string", + # "t1_C_IP_STAT_original_25 string", + # "t1_C_GREYLIST_FLAG_original_26 string", + # "t1_C_RULE_ACT_original_27 string", + # "t1_RRF_RULE_DATA_original_28 string", + # "t1_RRF_BUILD_NUM_original_29 int32", + # "t1_C_PAY_NAME_original_30 string", + # "t1_C_TXN_TYPE_original_31 string", + # "t1_C_PAYEE_ACCT_original_32 string", + # "t1_C_PAYEE_NAME_original_33 string", + # "t1_C_PAYEE_BANK_NAME_original_34 string", + # "t1_C_TXN_CHANNEL_original_35 string", + # "t1_C_SERIAL_NO_original_36 string", + # "t1_D_REGISTER_DATETIME_original_37 double", + # "t1_C_PAYEE_ACCT_ZONE_original_38 string", + # "t1_C_COMMONLY_PAYEE_FLAG_original_39 string", + # "t1_C_TRUST_PAYEE_FLAG_original_40 string", + # "t1_C_MEDIUM_NO_original_41 string", + # "t1_C_TRUST_CLIENT_FLAG_original_42 string", + # "t1_C_VERIFY_TYPE_original_43 string", + # "t1_C_PAYEE_CUSTOMER_ID_original_44 string", + # "t1_C_CPU_ID_original_45 string", + # "t1_C_MEMORY_CAPACITY_original_46 double", + # "t1_C_SYSTEM_VERSION_original_47 string", + # "t1_C_BROWSER_VERSION_original_48 string", + # "t1_C_BROWSER_LANG_original_49 string", + # "t1_C_SCREEN_RESOLUTION_original_50 double", + # "t1_C_APP_VERSION_original_51 string", + # "t1_C_FACTORY_INFO_original_52 string", + # "t1_C_WHITE_CARD_FLAG_original_53 string", + # "t1_C_ACCOUNT_BALANCE_original_54 double", + # "t1_C_MOBILE_LOCATION_original_55 double", + # "t1_C_DEAL_RESULT_original_56 string", + # "t1_C_FINAL_DEAL_TYPE_original_57 string", + # "t1_N_MODEL_SCORE_original_58 double", + # "t1_C_TXN_TYPE_TMP_original_59 string", + # "t1_N_UNIT_PRICE_original_60 double", + # "t1_N_TXN_COUNT_original_61 double", + # "t1_PROV_original_62 string", + # "t1_CITY_original_63 string", + # "t1_MER_OPTIMESP_original_64 string", + # "t1_MER_GROUPID_original_65 int32", + # "t1_MER_ZONENO_original_66 string", + # "t1_MER_BRNO_original_67 string", + # "t1_MER_SHOP_BASE_original_68 string", + # "t1_MER_PACCTYPE_original_69 int32", + # "t1_MER_FRATEPC_original_70 string", + # "t1_MER_SPECACCT_original_71 int32", + # "t1_MER_SWITCH_original_72 int32", + # "t1_MER_AMTLIMI1_original_73 int32", + # "t1_MER_RATLIMI1_original_74 int32", + # "t1_MER_BUSIAREA_original_75 string", + # "t1_CUS_Gender_Cd_original_76 int32", + # "t1_CUS_Ethnic_Cd_original_77 int32", + # "t1_CUS_Birth_Cty_Cd_original_78 string", + # "t1_CUS_Edu_Degree_Cd_original_79 int32", + # "t1_CUS_Marriage_Status_Cd_original_80 int32", + # "t1_CUS_Vip_Cust_Ind_original_81 int32", + # "t1_CUS_Icbc_Emply_Ind_original_82 int32", + # "t1_CUS_Dom_Resdnt_Ind_original_83 int32", + # "t1_CUS_Belong_Corp_Type_Cd_original_84 int32", + # "t1_CUS_Proper_Career_Cd_original_85 string", + # "t1_CUS_Proper_Industry_Cd_original_86 int32", + # "t1_CUS_Integrality_Ind_Cd_original_87 int32", + # "t1_CUS_Integrality_Check_Result_original_88 int32", + # "t1_CUS_Identity_Actl_Result_Type_Cd_original_89 int32", + # "t1_CUS_Cert_Provi_Situ_Type_Cd_original_90 int32", + # "t1_CUS_Invalid_Acct_Cert_Actl_Result_original_91 int32", + # "t1_CUS_Start_Dt_original_92 string", + # "t1_CUS_Birth_Dt_original_93 string", + # "t1_CUS_Career_Cd_original_94 string", + # "t1_CARDSTAT_original_95 int32", + # "t1_CARDKIND_original_96 int32", + # "t1_SYNFLAG_original_97 int32", + # "t1_GOLDFLAG_original_98 int32", + # "t1_OPENDATE_original_99 date", + # "t1_CDSQUOTA_original_100 int64", + # "t1_CDTQUOTA_original_101 int64", + # "t1_BT_CARDSTAT_original_102 int32", + # "t1_BT_ACTCHANEL_original_103 int32", + # "t1_BT_ACTDATE_original_104 date", + # "t1_BT_SALECODE_original_105 string", + # "t1_C_SERIAL_NO_window_unique_count_106 int", + # "t1_C_FACTORY_INFO_window_unique_count_107 int", + # "t1_C_FACTORY_INFO_window_unique_count_108 int", + # "t1_C_FACTORY_INFO_window_unique_count_109 int", + # "t1_C_SERIAL_NO_window_top1_ratio_110 double", + # "t1_C_FACTORY_INFO_window_top1_ratio_111 double", + # "t1_C_APP_VERSION_window_unique_count_112 int", + # "t1_C_SERIAL_NO_window_unique_count_113 int", + # "t1_C_FACTORY_INFO_window_unique_count_114 int", + # "t1_C_SERIAL_NO_window_unique_count_115 int", + # "t1_C_FACTORY_INFO_window_unique_count_116 int", + # "t1_C_SCREEN_RESOLUTION_window_max_117 double", + # "t1_C_SCREEN_RESOLUTION_window_max_118 double", + # "t1_C_FACTORY_INFO_window_unique_count_119 int", + # "t1_C_FACTORY_INFO_window_unique_count_120 int", + # "t1_C_FACTORY_INFO_window_unique_count_121 int", + # "t1_C_SERIAL_NO_window_unique_count_122 int", + # "t1_C_SCREEN_RESOLUTION_window_max_123 double", + # "t1_C_IP_STAT_combine_124 string", + # "t1_C_RULE_ACT_combine_124 string", + # "t1_CITY_combine_124 string", + # "t1_C_RULE_ACT_combine_125 string", + # "t1_C_FINAL_DEAL_TYPE_combine_125 string", + # "t1_CITY_combine_125 string", + # "t1_C_IP_STAT_combine_126 string", + # "t1_RRF_RULE_DATA_combine_126 string", + # "t1_C_APP_VERSION_combine_126 string", + # "t1_C_RULE_ACT_combine_127 string", + # "t1_RRF_RULE_DATA_combine_127 string", + # "t1_C_DEAL_RESULT_combine_127 string", + # "t1_C_IP_STAT_combine_128 string", + # "t1_RRF_RULE_DATA_combine_128 string", + # "t1_C_DEAL_RESULT_combine_128 string", + # "t1_C_RULE_ACT_combine_129 string", + # "t1_RRF_RULE_DATA_combine_129 string", + # "t1_PROV_combine_129 string", + # "t1_C_MAC_STAT_combine_130 string", + # "t1_RRF_RULE_DATA_combine_130 string", + # "t1_C_DEAL_RESULT_combine_130 string", + # "t1_C_RULE_ACT_combine_131 string", + # "t1_RRF_RULE_DATA_combine_131 string", + # "C_FINAL_DEt1_C_FINAL_DEAL_TYPE_combine_131 string", + # "t1_RRF_RULE_DATA_combine_132 string", + # "t1_C_VERIFY_TYPE_combine_132 string", + # "t1_C_DEAL_RESULT_combine_132 string", + # "t1_RRF_RULE_DATA_combine_133 string", + # "t1_C_MEDIUM_NO_combine_133 string", + # "t1_C_DEAL_RESULT_combine_133 string", + # "t1_C_MAC_STAT_combine_134 string", + # "t1_RRF_RULE_DATA_combine_134 string", + # "t1_PROV_combine_134 string", + # "t1_C_RULE_ACT_combine_135 string", + # "t1_RRF_RULE_DATA_combine_135 string", + # "t1_C_VERIFY_TYPE_combine_135 string" + # ] + # diff --git a/cases/integration_test/spark/test_jd.yaml b/cases/integration_test/spark/test_jd.yaml new file mode 100644 index 00000000000..02744f958f4 --- /dev/null +++ b/cases/integration_test/spark/test_jd.yaml @@ -0,0 +1,307 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_db +cases: +- id: 1 + desc: 多表-京东数据场景 + inputs: + - columns: + - "id int32" + - "user_id int32" + - "sku_id int32" + - "date timestamp" + - "label int32" + indexs: ["index1:user_id:date"] + rows: + - - 459992740 + - -1311478396 + - 659918340 + - 1611146000000 + - -1939588571 + - - -543207062 + - 507763171 + - 954458270 + - 1611146000000 + - -1603336561 + - - -1304001546 + - -769990921 + - -2013336026 + - 1611146000000 + - -159697690 + - - 158625020 + - -945166892 + - -74761189 + - 1611146000000 + - -93625855 + - - 658374105 + - -1246658137 + - -1487653472 + - 1611146000000 + - -2042844456 + - - -1036345552 + - -1145428983 + - -322971158 + - 1611146000000 + - -2141990920 + - - -1454270183 + - 653071136 + - -1843758289 + - 1611146000000 + - -685391703 + - - -27071105 + - 630100915 + - 314469207 + - 1611146000000 + - 993761881 + - - 38809088 + - -1539014266 + - 295127280 + - 1611146000000 + - -1518440147 + - - -1037180916 + - -1318776756 + - 244202015 + - 1611146000000 + - -2111130440 + name: all + - columns: + - "user_id int32" + - "age string" + - "sex int32" + - "user_lv_cd int32" + - "user_reg_tm timestamp" + indexs: ["index_user:user_id:user_reg_tm"] + rows: + - - -1275547367 + - "age_KGJgiSMgcx" + - -1321603784 + - 679568701 + - 1611146001000 + - - 193784185 + - "age_z7XwDlSdzE" + - -918521235 + - -1839640562 + - 1611146001000 + - - -1500008039 + - "age_UxLHj6n5iG" + - -490726213 + - -2044459492 + - 1611146001000 + name: user + - columns: + - "sku_id int32" + - "a1 int32" + - "a2 int32" + - "a3 int32" + - "cate int32" + - "brand int32" + indexs: ["index_pdt:sku_id"] + rows: + - - 200135598 + - 620202989 + - -1819873162 + - 944811254 + - -1016957005 + - -348886786 + - - -1812792532 + - -548438081 + - 408684499 + - -546175077 + - 18157988 + - -1619495426 + - - 740971942 + - -995983125 + - -74505618 + - 875561670 + - -1701622561 + - -2066012196 + - - -1953481289 + - 394506620 + - -871334434 + - -1883922132 + - 337664649 + - -678183716 + - - 690079825 + - -124658147 + - -2013081012 + - 514316543 + - -1892105452 + - -398640514 + - - -1357806486 + - -1866091467 + - -848394605 + - -1321197691 + - 1037826917 + - 576025216 + name: product + - columns: + - "user_id int32" + - "sku_id int32" + - "time timestamp" + - "model_id int32" + - "type int32" + - "cate int32" + - "brand int32" + indexs: ["index:user_id:time"] + rows: + - - -946359508 + - -784482204 + - 1611146001000 + - 831631177 + - 50026040 + - 125260267 + - -1212429112 + - - 674634423 + - -608174802 + - 1611146001000 + - -1094861038 + - -1421894956 + - -3671335 + - -1054215935 + - - 548059146 + - -271665164 + - 1611146001000 + - 81808312 + - -1996872304 + - 660746138 + - 786421686 + - - -1970341445 + - -900311277 + - 1611146001000 + - -107428720 + - 746853108 + - -805673533 + - -860397196 + name: action + - columns: + - "sku_id int32" + - "comment_num int32" + - "has_bad_comment int32" + - "bad_comment_rate double" + - "dt timestamp" + indexs: ["index1:sku_id:dt"] + rows: + - - -2009402124 + - -130694795 + - -377940874 + - -38.93 + - 1611146001000 + - - -284125685 + - 216789062 + - 520778695 + - -73.75 + - 1611146001000 + - - -2059682888 + - 865555637 + - -370172128 + - -62.3 + - 1611146001000 + - - -1747089957 + - -720960620 + - -113399911 + - -109.97 + - 1611146001000 + - - -1446988855 + - 964829781 + - -796129056 + - 43.56 + - 1611146001000 + - - -931224783 + - 784179322 + - -1570583655 + - 7.31 + - 1611146001000 + - - -986441723 + - -1938361365 + - -986946742 + - 98.82 + - 1611146001000 + name: comment + sql: |- + select * from + ( + select + id as id_1, + `id` as all_id_original_0, + `user_id` as all_user_id_original_1, + `sku_id` as all_sku_id_original_2, + `date` as all_date_original_3, + `label` as all_label_original_4, + fz_top1_ratio(`id`) over all_user_id_date_0s_2764800s as all_id_window_top1_ratio_28, + fz_top1_ratio(`sku_id`) over all_user_id_date_0s_2764800s as all_sku_id_window_top1_ratio_29, + distinct_count(`sku_id`) over all_user_id_date_0s_2764800s as all_sku_id_window_unique_count_30, + fz_top1_ratio(`sku_id`) over all_user_id_date_0s_5529600s as all_sku_id_window_top1_ratio_31, + fz_top1_ratio(`id`) over all_user_id_date_0s_5529600s as all_id_window_top1_ratio_32, + `sku_id` as all_sku_id_combine_33, + `sku_id` as all_sku_id_combine_34, + `sku_id` as all_sku_id_combine_35, + `sku_id` as all_sku_id_combine_36, + `sku_id` as all_sku_id_combine_37, + `sku_id` as all_sku_id_combine_38, + `sku_id` as all_sku_id_combine_39 + from + `all` + window all_user_id_date_0s_2764800s as (partition by `user_id` order by `date` rows_range between 2764800s preceding and 0s preceding), + all_user_id_date_0s_5529600s as (partition by `user_id` order by `date` rows_range between 5529600s preceding and 0s preceding)) + as out0 + last join + ( + select + `all`.id as id_6, + `comment_sku_id__date_0s_1209600s`.`bad_comment_rate` as comment_bad_comment_rate_multi_last_value_5, + `comment_sku_id__date_0s_1209600s`.`comment_num` as comment_comment_num_multi_last_value_6, + `comment_sku_id__date_0s_1209600s`.`dt` as comment_dt_multi_last_value_7, + `comment_sku_id__date_0s_1209600s`.`has_bad_comment` as comment_has_bad_comment_multi_last_value_8, + `product_sku_id`.`a1` as product_a1_multi_direct_9, + `product_sku_id`.`a2` as product_a2_multi_direct_10, + `product_sku_id`.`a3` as product_a3_multi_direct_11, + `product_sku_id`.`brand` as product_brand_multi_direct_12, + `product_sku_id`.`cate` as product_cate_multi_direct_13, + `user_user_id`.`age` as user_age_multi_direct_14, + `user_user_id`.`sex` as user_sex_multi_direct_15, + `user_user_id`.`user_lv_cd` as user_user_lv_cd_multi_direct_16, + `user_user_id`.`user_reg_tm` as user_user_reg_tm_multi_direct_17 + from + `all` + last join `comment` as `comment_sku_id__date_0s_1209600s` order by comment_sku_id__date_0s_1209600s.`dt` on `all`.`sku_id` = `comment_sku_id__date_0s_1209600s`.`sku_id` and comment_sku_id__date_0s_1209600s.`dt` < `all`.`date` - 0 and comment_sku_id__date_0s_1209600s.`dt` > `all`.`date` - 1209600000 + last join `product` as `product_sku_id` on `all`.`sku_id` = `product_sku_id`.`sku_id` + last join `user` as `user_user_id` on `all`.`user_id` = `user_user_id`.`user_id`) + as out1 + on out0.id_1 = out1.id_6 + last join + ( + select + id as id_19, + fz_topn_frequency(`brand`, 3) over action_user_id_time_0s_32d as action_brand_multi_top3frequency_18, + distinct_count(`brand`) over action_user_id_time_0_100 as action_brand_multi_unique_count_19, + distinct_count(`cate`) over action_user_id_time_0_100 as action_cate_multi_unique_count_20, + distinct_count(`cate`) over action_user_id_time_0s_32d as action_cate_multi_unique_count_21, + fz_topn_frequency(`model_id`, 3) over action_user_id_time_0s_32d as action_model_id_multi_top3frequency_22, + distinct_count(`model_id`) over action_user_id_time_0_100 as action_model_id_multi_unique_count_23, + distinct_count(`sku_id`) over action_user_id_time_0_100 as action_sku_id_multi_unique_count_24, + distinct_count(`sku_id`) over action_user_id_time_0s_32d as action_sku_id_multi_unique_count_25, + fz_topn_frequency(`type`, 3) over action_user_id_time_0s_32d as action_type_multi_top3frequency_26, + fz_topn_frequency(`type`, 3) over action_user_id_time_0_100 as action_type_multi_top3frequency_27 + from + (select `user_id` as `user_id`, int(0) as `sku_id`, `date` as `time`, int(0) as `model_id`, int(0) as `type`, int(0) as `cate`, int(0) as `brand`, id from `all`) + window action_user_id_time_0s_32d as ( + UNION (select `user_id`, `sku_id`, `time`, `model_id`, `type`, `cate`, `brand`, int(0) as id from `action`) partition by `user_id` order by `time` rows_range between 32d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + action_user_id_time_0_100 as ( + UNION (select `user_id`, `sku_id`, `time`, `model_id`, `type`, `cate`, `brand`, int(0) as id from `action`) partition by `user_id` order by `time` rows between 100 preceding and 0 preceding INSTANCE_NOT_IN_WINDOW)) + as out2 + on out0.id_1 = out2.id_19 + ; + expect: + success: true diff --git a/cases/integration_test/spark/test_news.yaml b/cases/integration_test/spark/test_news.yaml new file mode 100644 index 00000000000..ff449b296c3 --- /dev/null +++ b/cases/integration_test/spark/test_news.yaml @@ -0,0 +1,439 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: template_db +cases: +- id: 1 + desc: 单表-新闻场景 + inputs: + - columns: + - "InstanceKey string" + - "RequestDatetime timestamp" + - "PageId string" + - "NewsId string" + - "CategoryId string" + - "TermScores string" + - "TitleTermScores string" + - "TagScores string" + - "UserTagScores string" + - "UserTermScores string" + - "MediaId string" + - "ContentWords int32" + - "TitleWords int32" + - "Tag string" + - "TotalLikes int32" + - "TotalDislikes int32" + - "TotalComments int32" + - "TotalImpressions int32" + - "TotalAdjustImpressions int32" + - "TotalClicks int32" + - "TotalShares int32" + - "UserId string" + - "RequestLatitude double" + - "RequestLongitude double" + - "DeviceId string" + - "UserIp string" + - "Clicked int32" + - "UserClickedMediaIdsIn1Times string" + - "UserClickedMediaIdsIn3Times string" + - "UserClickedMediaIdsIn10Times string" + - "UserClickedMediaIdsIn1Minutes string" + - "UserClickedMediaIdsIn5Minutes string" + - "UserClickedMediaIdsIn30Minutes string" + - "UserClickedMediaIdsIn360Minutes string" + - "UserClickedCatIdsIn1Times string" + - "UserClickedCatIdsIn3Times string" + - "UserClickedCatIdsIn10Times string" + - "UserClickedCatIdsIn1Minutes string" + - "UserClickedCatIdsIn5Minutes string" + - "UserClickedCatIdsIn30Minutes string" + - "UserClickedCatIdsIn360Minutes string" + - "UserClickedTagScoresIn1Times string" + - "UserClickedTagScoresIn3Times string" + - "UserClickedTagScoresIn10Times string" + - "UserClickedTagScoresIn1Minutes string" + - "UserClickedTagScoresIn5Minutes string" + - "UserClickedTagScoresIn30Minutes string" + - "UserClickedTagScoresIn360Minutes string" + - "UserClickedTermScoresIn1Times string" + - "UserClickedTermScoresIn3Times string" + - "UserClickedTermScoresIn10Times string" + - "UserClickedTermScoresIn1Minutes string" + - "UserClickedTermScoresIn5Minutes string" + - "UserClickedTermScoresIn30Minutes string" + - "UserClickedTermScoresIn360Minutes string" + - "UserClickedTitleTermScoresIn1Times string" + - "UserClickedTitleTermScoresIn3Times string" + - "UserClickedTitleTermScoresIn10Times string" + - "UserClickedTitleTermScoresIn1Minutes string" + - "UserClickedTitleTermScoresIn5Minutes string" + - "UserClickedTitleTermScoresIn30Minutes string" + - "UserClickedTitleTermScoresIn360Minutes string" + indexs: + - "index1:UserTermScores:RequestDatetime" + - "index2:UserTagScores:RequestDatetime" + - "index3:UserId:RequestDatetime" + - "index4:UserIp:RequestDatetime" + rows: + - - "InstanceKey_hdIp5qM957" + - 1609405780000 + - "PageId_2qfcb9EBP4" + - "NewsId_ErcZw6WqZC" + - "CategoryId_gWDyj6FMC6" + - "TermScores_xppEG6AJ38" + - "TitleTermScores_kw3z2g2K98" + - "TagScores_c9zE9v08wj" + - "UserTagScores_84fOPfN56G" + - "UserTermScores_pJVZ7lPMeI" + - "MediaId_i0stuPP10g" + - 829372349 + - 601942391 + - "Tag_ciC6wk19PJ" + - -1820777477 + - 883273961 + - 266011166 + - 625586443 + - -684001291 + - 902064193 + - 124534625 + - "UserId_N4VsmRmV5e" + - 3.7387905194494238 + - 125.52669722380091 + - "DeviceId_2zMD4oSYcI" + - "UserIp_HpEH1YJjRI" + - -1434651347 + - "UserClickedMediaIdsIn1Times_3HDiJhw431" + - "UserClickedMediaIdsIn3Times_dMlPGtTIhR" + - "UserClickedMediaIdsIn10Times_av0JnzlZTG" + - "UserClickedMediaIdsIn1Minutes_mOktj5LJiD" + - "UserClickedMediaIdsIn5Minutes_9rypts8eWg" + - "UserClickedMediaIdsIn30Minutes_rgvXB0uxwH" + - "UserClickedMediaIdsIn360Minutes_c5UxGaYceL" + - "UserClickedCatIdsIn1Times_LeHDkid2pj" + - "UserClickedCatIdsIn3Times_q1NIvIEMP7" + - "UserClickedCatIdsIn10Times_6u8Xg7cS9F" + - "UserClickedCatIdsIn1Minutes_oRKjk9HTtA" + - "UserClickedCatIdsIn5Minutes_GdLcy4lnLO" + - "UserClickedCatIdsIn30Minutes_hJqHlZOlXf" + - "UserClickedCatIdsIn360Minutes_6E2LKw7j2O" + - "UserClickedTagScoresIn1Times_cAkeiQEbZi" + - "UserClickedTagScoresIn3Times_tFexwMHFw4" + - "UserClickedTagScoresIn10Times_M5J9oPpbqM" + - "UserClickedTagScoresIn1Minutes_F9Ba3faBRO" + - "UserClickedTagScoresIn5Minutes_wCSaqSRatG" + - "UserClickedTagScoresIn30Minutes_BzJfoCf21a" + - "UserClickedTagScoresIn360Minutes_30l7jaJ4gB" + - "UserClickedTermScoresIn1Times_LqLUppsBv0" + - "UserClickedTermScoresIn3Times_Lokr3ory2y" + - "UserClickedTermScoresIn10Times_xTZVbQqHw0" + - "UserClickedTermScoresIn1Minutes_pBFLuGB0p0" + - "UserClickedTermScoresIn5Minutes_giEJ7skHMs" + - "UserClickedTermScoresIn30Minutes_C8JaxDwypo" + - "UserClickedTermScoresIn360Minutes_Rm6L1ywrhl" + - "UserClickedTitleTermScoresIn1Times_JxKKWwPfnI" + - "UserClickedTitleTermScoresIn3Times_whxcLRU2Px" + - "UserClickedTitleTermScoresIn10Times_TwsUNK2E5q" + - "UserClickedTitleTermScoresIn1Minutes_nzkQNp1WVM" + - "UserClickedTitleTermScoresIn5Minutes_1YOFOVlbvh" + - "UserClickedTitleTermScoresIn30Minutes_IfSQLmvSqa" + - "UserClickedTitleTermScoresIn360Minutes_r5sD1XpY2c" + - - "InstanceKey_pve2h4oBmM" + - 1609405780000 + - "PageId_KZoyi08pAP" + - "NewsId_TGIqBGEVHb" + - "CategoryId_Ie7ucdUYXe" + - "TermScores_1gZiIGPRQz" + - "TitleTermScores_yQyoGdHRNe" + - "TagScores_Y110SxqWpY" + - "UserTagScores_i0icat48DT" + - "UserTermScores_cL9G53KJhT" + - "MediaId_1tOAd6ZaZC" + - -1539942388 + - -645368500 + - "Tag_lstd2JNED7" + - -203531434 + - -1137889304 + - -1877229079 + - -1849242659 + - -1005223131 + - 32773880 + - -730536017 + - "UserId_pjFJNfdPYs" + - 118.13343685266054 + - -75.95372022179421 + - "DeviceId_kmtzlnZRbc" + - "UserIp_pRTNUjNjpf" + - 186372981 + - "UserClickedMediaIdsIn1Times_2EG9u6VG3z" + - "UserClickedMediaIdsIn3Times_U52gnngZpl" + - "UserClickedMediaIdsIn10Times_SZMJFndrWA" + - "UserClickedMediaIdsIn1Minutes_sUzsztqLo6" + - "UserClickedMediaIdsIn5Minutes_j8k1DEJ3K2" + - "UserClickedMediaIdsIn30Minutes_WQYr1ipJzJ" + - "UserClickedMediaIdsIn360Minutes_kNPuSmOLCh" + - "UserClickedCatIdsIn1Times_AWeuDDwzJX" + - "UserClickedCatIdsIn3Times_5oBau1ONjC" + - "UserClickedCatIdsIn10Times_nC04RrROot" + - "UserClickedCatIdsIn1Minutes_BCraczQzN8" + - "UserClickedCatIdsIn5Minutes_OYg6nwBjgB" + - "UserClickedCatIdsIn30Minutes_SR13pQy3Xn" + - "UserClickedCatIdsIn360Minutes_I8LR8qCAfD" + - "UserClickedTagScoresIn1Times_sLP8dEPBuF" + - "UserClickedTagScoresIn3Times_Z6wY8t1DdZ" + - "UserClickedTagScoresIn10Times_X9rXFAgUuH" + - "UserClickedTagScoresIn1Minutes_MazqtyoPcg" + - "UserClickedTagScoresIn5Minutes_16ltZzRQid" + - "UserClickedTagScoresIn30Minutes_pSlMAYSeYb" + - "UserClickedTagScoresIn360Minutes_0Zz8P4xjGH" + - "UserClickedTermScoresIn1Times_bvkzRyHAus" + - "UserClickedTermScoresIn3Times_0HMO3i4yns" + - "UserClickedTermScoresIn10Times_DT8xge6vdi" + - "UserClickedTermScoresIn1Minutes_2okBnnoBid" + - "UserClickedTermScoresIn5Minutes_lqNLfKvrh0" + - "UserClickedTermScoresIn30Minutes_ac2U74ym1H" + - "UserClickedTermScoresIn360Minutes_JSBVGmOT7m" + - "UserClickedTitleTermScoresIn1Times_xChAvlI0Hg" + - "UserClickedTitleTermScoresIn3Times_sASTrsDGA3" + - "UserClickedTitleTermScoresIn10Times_21cB10rAvK" + - "UserClickedTitleTermScoresIn1Minutes_SVXF4JVpJ5" + - "UserClickedTitleTermScoresIn5Minutes_LCLbuQVXs2" + - "UserClickedTitleTermScoresIn30Minutes_bwXZz631fl" + - "UserClickedTitleTermScoresIn360Minutes_sR95HAIcHx" + - - "InstanceKey_k4XtEfFsqT" + - 1609405780000 + - "PageId_BZWLnCZmQ9" + - "NewsId_YdHfQBoErt" + - "CategoryId_oard5Cne0T" + - "TermScores_e8dAwnunlf" + - "TitleTermScores_8eghaLsTjR" + - "TagScores_Igz3roJMYt" + - "UserTagScores_D0noZJ4FzI" + - "UserTermScores_p2ZShNACkv" + - "MediaId_7BELEeQo8t" + - -1400976088 + - -185610105 + - "Tag_qDw3zDu0Kf" + - -1424703288 + - 326020146 + - -1788522406 + - -894083919 + - -614604127 + - 836914113 + - -514315335 + - "UserId_cnDtbfUEMH" + - 77.52642088566631 + - 61.52004136781969 + - "DeviceId_88cLvltsp1" + - "UserIp_6QnBErDqMJ" + - -2147467600 + - "UserClickedMediaIdsIn1Times_dfNUH5v0a6" + - "UserClickedMediaIdsIn3Times_7C9bV4aMUz" + - "UserClickedMediaIdsIn10Times_y7bSntxLJ9" + - "UserClickedMediaIdsIn1Minutes_PLy8SqEQ84" + - "UserClickedMediaIdsIn5Minutes_5BnsVlthDt" + - "UserClickedMediaIdsIn30Minutes_GMdEG1RRGL" + - "UserClickedMediaIdsIn360Minutes_Zb85hck0aF" + - "UserClickedCatIdsIn1Times_1WG4dLVfOH" + - "UserClickedCatIdsIn3Times_HuZi6EaTCV" + - "UserClickedCatIdsIn10Times_QPL2TWKSN3" + - "UserClickedCatIdsIn1Minutes_rzk3a4Klss" + - "UserClickedCatIdsIn5Minutes_0X05NkhD7o" + - "UserClickedCatIdsIn30Minutes_jYleKJf8IF" + - "UserClickedCatIdsIn360Minutes_ar6mj9US4t" + - "UserClickedTagScoresIn1Times_P2MmbiyS4I" + - "UserClickedTagScoresIn3Times_8StMrSWAeI" + - "UserClickedTagScoresIn10Times_Bl7yrclqG2" + - "UserClickedTagScoresIn1Minutes_DqBqyScA9d" + - "UserClickedTagScoresIn5Minutes_K6ZgXsqw0u" + - "UserClickedTagScoresIn30Minutes_6lv8OvRI7W" + - "UserClickedTagScoresIn360Minutes_Hs54K7u27l" + - "UserClickedTermScoresIn1Times_H6SHDMGtuy" + - "UserClickedTermScoresIn3Times_DVVW13LIcd" + - "UserClickedTermScoresIn10Times_dZdjYFHvpd" + - "UserClickedTermScoresIn1Minutes_ZTBWK0VaYf" + - "UserClickedTermScoresIn5Minutes_aIfxNFWfaz" + - "UserClickedTermScoresIn30Minutes_XkLhwMM16w" + - "UserClickedTermScoresIn360Minutes_VccLPVQ0kC" + - "UserClickedTitleTermScoresIn1Times_bM308gVgrl" + - "UserClickedTitleTermScoresIn3Times_4jqy1Aeiar" + - "UserClickedTitleTermScoresIn10Times_FQ79yzLr4K" + - "UserClickedTitleTermScoresIn1Minutes_enU5HDPII1" + - "UserClickedTitleTermScoresIn5Minutes_X0YzeMlxE1" + - "UserClickedTitleTermScoresIn30Minutes_WAWIp5zsTD" + - "UserClickedTitleTermScoresIn360Minutes_SYU1A5lgJy" + - - "InstanceKey_Ik6w1GJ3ak" + - 1609405780000 + - "PageId_l8hTiHLe7c" + - "NewsId_U1l7n7Z1cz" + - "CategoryId_z93urYcLTz" + - "TermScores_05J4os5hvJ" + - "TitleTermScores_MGrW4hhUdP" + - "TagScores_1k3NEltzP4" + - "UserTagScores_1PHt2Sw8Z5" + - "UserTermScores_537uScy0i9" + - "MediaId_xc7NYROEZt" + - -1256228849 + - -110570093 + - "Tag_d4mRWCbrMO" + - 365243338 + - 873343892 + - 17923145 + - -681865200 + - -444619580 + - -1894396283 + - -1127215708 + - "UserId_fgmdPtLt87" + - -61.396138086485564 + - -87.37716465146411 + - "DeviceId_CCtZyRqhvh" + - "UserIp_CxGseOdjSM" + - -76661935 + - "UserClickedMediaIdsIn1Times_LEYaofr5Hl" + - "UserClickedMediaIdsIn3Times_3FSI83BEln" + - "UserClickedMediaIdsIn10Times_0uxy6hp2ql" + - "UserClickedMediaIdsIn1Minutes_iR7f3ML0Cy" + - "UserClickedMediaIdsIn5Minutes_5lifH8ACGz" + - "UserClickedMediaIdsIn30Minutes_veGUAV6ecL" + - "UserClickedMediaIdsIn360Minutes_4ZfwIYLjI0" + - "UserClickedCatIdsIn1Times_MsWvdpbriS" + - "UserClickedCatIdsIn3Times_OOQ3KsuFoC" + - "UserClickedCatIdsIn10Times_lSXIYryDz4" + - "UserClickedCatIdsIn1Minutes_lcgKRcqF1r" + - "UserClickedCatIdsIn5Minutes_APcl6yWNKU" + - "UserClickedCatIdsIn30Minutes_JA3aKMbLRU" + - "UserClickedCatIdsIn360Minutes_iRcC0hXYHY" + - "UserClickedTagScoresIn1Times_BsalAUhfaV" + - "UserClickedTagScoresIn3Times_4YgxkGeFO8" + - "UserClickedTagScoresIn10Times_JGEY6hnpRt" + - "UserClickedTagScoresIn1Minutes_qh78KhthQ9" + - "UserClickedTagScoresIn5Minutes_KwokIGT8ih" + - "UserClickedTagScoresIn30Minutes_esweRoZRlQ" + - "UserClickedTagScoresIn360Minutes_SEhVJL8Isv" + - "UserClickedTermScoresIn1Times_uiIHrsV6LB" + - "UserClickedTermScoresIn3Times_y3BznAylvB" + - "UserClickedTermScoresIn10Times_IU8v9wrb65" + - "UserClickedTermScoresIn1Minutes_YP8gIJCiEZ" + - "UserClickedTermScoresIn5Minutes_vDHmUEWZgj" + - "UserClickedTermScoresIn30Minutes_v3yee1Glcu" + - "UserClickedTermScoresIn360Minutes_7dWE2PTpRW" + - "UserClickedTitleTermScoresIn1Times_gnyIe4mq1F" + - "UserClickedTitleTermScoresIn3Times_UGzqsDJ5zr" + - "UserClickedTitleTermScoresIn10Times_498w6xB6Nc" + - "UserClickedTitleTermScoresIn1Minutes_jdo8wg4Qvj" + - "UserClickedTitleTermScoresIn5Minutes_u6pQFRC1AT" + - "UserClickedTitleTermScoresIn30Minutes_XyyNo9Vj1t" + - "UserClickedTitleTermScoresIn360Minutes_JlyEeiBHUZ" + sql: |- + select + InstanceKey as InstanceKey_1, + InstanceKey as t1_InstanceKey_0, + RequestDatetime as t1_RequestDatetime_1, + PageId as t1_PageId_2, + NewsId as t1_NewsId_3, + CategoryId as t1_CategoryId_4, + TermScores as t1_TermScores_5, + TitleTermScores as t1_TitleTermScores_6, + TagScores as t1_TagScores_7, + UserTagScores as t1_UserTagScores_8, + UserTermScores as t1_UserTermScores_9, + MediaId as t1_MediaId_10, + ContentWords as t1_ContentWords_11, + TitleWords as t1_TitleWords_12, + Tag as t1_Tag_13, + TotalLikes as t1_TotalLikes_14, + TotalDislikes as t1_TotalDislikes_15, + TotalComments as t1_TotalComments_16, + TotalImpressions as t1_TotalImpressions_17, + TotalAdjustImpressions as t1_TotalAdjustImpressions_18, + TotalClicks as t1_TotalClicks_19, + TotalShares as t1_TotalShares_20, + UserId as t1_UserId_21, + RequestLatitude as t1_RequestLatitude_22, + RequestLongitude as t1_RequestLongitude_23, + DeviceId as t1_DeviceId_24, + UserIp as t1_UserIp_25, + Clicked as t1_Clicked_26, + UserClickedMediaIdsIn1Times as t1_UserClickedMediaIdsIn1Times_27, + UserClickedMediaIdsIn3Times as t1_UserClickedMediaIdsIn3Times_28, + UserClickedMediaIdsIn10Times as t1_UserClickedMediaIdsIn10Times_29, + UserClickedMediaIdsIn1Minutes as t1_UserClickedMediaIdsIn1Minutes_30, + UserClickedMediaIdsIn5Minutes as t1_UserClickedMediaIdsIn5Minutes_31, + UserClickedMediaIdsIn30Minutes as t1_UserClickedMediaIdsIn30Minutes_32, + UserClickedMediaIdsIn360Minutes as t1_UserClickedMediaIdsIn360Minutes_33, + UserClickedCatIdsIn1Times as t1_UserClickedCatIdsIn1Times_34, + UserClickedCatIdsIn3Times as t1_UserClickedCatIdsIn3Times_35, + UserClickedCatIdsIn10Times as t1_UserClickedCatIdsIn10Times_36, + UserClickedCatIdsIn1Minutes as t1_UserClickedCatIdsIn1Minutes_37, + UserClickedCatIdsIn5Minutes as t1_UserClickedCatIdsIn5Minutes_38, + UserClickedCatIdsIn30Minutes as t1_UserClickedCatIdsIn30Minutes_39, + UserClickedCatIdsIn360Minutes as t1_UserClickedCatIdsIn360Minutes_40, + UserClickedTagScoresIn1Times as t1_UserClickedTagScoresIn1Times_41, + UserClickedTagScoresIn3Times as t1_UserClickedTagScoresIn3Times_42, + UserClickedTagScoresIn10Times as t1_UserClickedTagScoresIn10Times_43, + UserClickedTagScoresIn1Minutes as t1_UserClickedTagScoresIn1Minutes_44, + UserClickedTagScoresIn5Minutes as t1_UserClickedTagScoresIn5Minutes_45, + UserClickedTagScoresIn30Minutes as t1_UserClickedTagScoresIn30Minutes_46, + UserClickedTagScoresIn360Minutes as t1_UserClickedTagScoresIn360Minutes_47, + UserClickedTermScoresIn1Times as t1_UserClickedTermScoresIn1Times_48, + UserClickedTermScoresIn3Times as t1_UserClickedTermScoresIn3Times_49, + UserClickedTermScoresIn10Times as t1_UserClickedTermScoresIn10Times_50, + UserClickedTermScoresIn1Minutes as t1_UserClickedTermScoresIn1Minutes_51, + UserClickedTermScoresIn5Minutes as t1_UserClickedTermScoresIn5Minutes_52, + UserClickedTermScoresIn30Minutes as t1_UserClickedTermScoresIn30Minutes_53, + UserClickedTermScoresIn360Minutes as t1_UserClickedTermScoresIn360Minutes_54, + UserClickedTitleTermScoresIn1Times as t1_UserClickedTitleTermScoresIn1Times_55, + UserClickedTitleTermScoresIn3Times as t1_UserClickedTitleTermScoresIn3Times_56, + UserClickedTitleTermScoresIn10Times as t1_UserClickedTitleTermScoresIn10Times_57, + UserClickedTitleTermScoresIn1Minutes as t1_UserClickedTitleTermScoresIn1Minutes_58, + UserClickedTitleTermScoresIn5Minutes as t1_UserClickedTitleTermScoresIn5Minutes_59, + UserClickedTitleTermScoresIn30Minutes as t1_UserClickedTitleTermScoresIn30Minutes_60, + UserClickedTitleTermScoresIn360Minutes as t1_UserClickedTitleTermScoresIn360Minutes_61, + sum(TitleWords) over t1_UserTermScores_RequestDatetime_0s_7200s as t1_TitleWords_62, + fz_top1_ratio(NewsId) over t1_UserTermScores_RequestDatetime_0s_7200s as t1_NewsId_63, + sum(RequestLatitude) over t1_UserTermScores_RequestDatetime_0s_7200s as t1_RequestLatitude_64, + distinct_count(NewsId) over t1_UserTermScores_RequestDatetime_0s_7200s as t1_NewsId_65, + sum(ContentWords) over t1_UserTermScores_RequestDatetime_0s_7200s as t1_ContentWords_66, + case when !isnull(lag(UserClickedTagScoresIn1Times, 0)) over t1_UserTermScores_RequestDatetime_0s_7200s then count(UserClickedTagScoresIn1Times) over t1_UserTermScores_RequestDatetime_0s_7200s else null end as t1_UserClickedTagScoresIn1Times_67, + case when !isnull(lag(UserClickedTagScoresIn1Times, 0)) over t1_UserTagScores_RequestDatetime_0s_7200s then count(UserClickedTagScoresIn1Times) over t1_UserTagScores_RequestDatetime_0s_7200s else null end as t1_UserClickedTagScoresIn1Times_68, + case when !isnull(lag(UserClickedCatIdsIn1Times, 0)) over t1_UserTermScores_RequestDatetime_0s_7200s then count(UserClickedCatIdsIn1Times) over t1_UserTermScores_RequestDatetime_0s_7200s else null end as t1_UserClickedCatIdsIn1Times_69, + case when !isnull(lag(UserClickedMediaIdsIn1Times, 0)) over t1_UserTermScores_RequestDatetime_0s_7200s then count(UserClickedMediaIdsIn1Times) over t1_UserTermScores_RequestDatetime_0s_7200s else null end as t1_UserClickedMediaIdsIn1Times_70, + case when !isnull(lag(UserClickedTagScoresIn30Minutes, 0)) over t1_UserTagScores_RequestDatetime_0s_7200s then count(UserClickedTagScoresIn30Minutes) over t1_UserTagScores_RequestDatetime_0s_7200s else null end as t1_UserClickedTagScoresIn30Minutes_71, + fz_top1_ratio(NewsId) over t1_UserTagScores_RequestDatetime_0s_7200s as t1_NewsId_72, + case when !isnull(lag(UserClickedTagScoresIn3Times, 0)) over t1_UserTagScores_RequestDatetime_0s_7200s then count(UserClickedTagScoresIn3Times) over t1_UserTagScores_RequestDatetime_0s_7200s else null end as t1_UserClickedTagScoresIn3Times_73, + case when !isnull(lag(UserClickedTagScoresIn10Times, 0)) over t1_UserTagScores_RequestDatetime_0s_7200s then count(UserClickedTagScoresIn10Times) over t1_UserTagScores_RequestDatetime_0s_7200s else null end as t1_UserClickedTagScoresIn10Times_74, + case when !isnull(lag(UserClickedCatIdsIn1Times, 0)) over t1_UserTagScores_RequestDatetime_0s_7200s then count(UserClickedCatIdsIn1Times) over t1_UserTagScores_RequestDatetime_0s_7200s else null end as t1_UserClickedCatIdsIn1Times_75, + case when !isnull(lag(UserClickedTitleTermScoresIn1Times, 0)) over t1_UserTagScores_RequestDatetime_0s_7200s then count(UserClickedTitleTermScoresIn1Times) over t1_UserTagScores_RequestDatetime_0s_7200s else null end as t1_UserClickedTitleTermScoresIn1Times_76, + case when !isnull(lag(UserClickedTermScoresIn30Minutes, 0)) over t1_UserTagScores_RequestDatetime_0s_7200s then count(UserClickedTermScoresIn30Minutes) over t1_UserTagScores_RequestDatetime_0s_7200s else null end as t1_UserClickedTermScoresIn30Minutes_77, + case when !isnull(lag(UserClickedTermScoresIn1Times, 0)) over t1_UserTagScores_RequestDatetime_0s_7200s then count(UserClickedTermScoresIn1Times) over t1_UserTagScores_RequestDatetime_0s_7200s else null end as t1_UserClickedTermScoresIn1Times_78, + case when !isnull(lag(UserClickedMediaIdsIn10Times, 0)) over t1_UserId_RequestDatetime_0s_7200s then count(UserClickedMediaIdsIn10Times) over t1_UserId_RequestDatetime_0s_7200s else null end as t1_UserClickedMediaIdsIn10Times_79, + case when !isnull(lag(UserTermScores, 0)) over t1_UserIp_RequestDatetime_0s_7200s then count(UserTermScores) over t1_UserIp_RequestDatetime_0s_7200s else null end as t1_UserTermScores_80, + case when !isnull(lag(UserClickedMediaIdsIn10Times, 0)) over t1_UserIp_RequestDatetime_0s_7200s then count(UserClickedMediaIdsIn10Times) over t1_UserIp_RequestDatetime_0s_7200s else null end as t1_UserClickedMediaIdsIn10Times_81, + distinct_count(InstanceKey) over t1_UserTagScores_RequestDatetime_0s_7200s as t1_InstanceKey_82, + case when !isnull(lag(UserTagScores, 0)) over t1_UserIp_RequestDatetime_0s_7200s then count(UserTagScores) over t1_UserIp_RequestDatetime_0s_7200s else null end as t1_UserTagScores_83, + case when !isnull(lag(UserTagScores, 0)) over t1_UserId_RequestDatetime_0s_7200s then count(UserTagScores) over t1_UserId_RequestDatetime_0s_7200s else null end as t1_UserTagScores_84, + case when !isnull(lag(UserClickedTitleTermScoresIn3Times, 0)) over t1_UserId_RequestDatetime_0s_7200s then count(UserClickedTitleTermScoresIn3Times) over t1_UserId_RequestDatetime_0s_7200s else null end as t1_UserClickedTitleTermScoresIn3Times_85, + case when !isnull(lag(UserClickedMediaIdsIn360Minutes, 0)) over t1_UserId_RequestDatetime_0s_7200s then count(UserClickedMediaIdsIn360Minutes) over t1_UserId_RequestDatetime_0s_7200s else null end as t1_UserClickedMediaIdsIn360Minutes_86, + case when !isnull(lag(UserClickedTitleTermScoresIn10Times, 0)) over t1_UserId_RequestDatetime_0s_7200s then count(UserClickedTitleTermScoresIn10Times) over t1_UserId_RequestDatetime_0s_7200s else null end as t1_UserClickedTitleTermScoresIn10Times_87, + case when !isnull(lag(UserClickedTitleTermScoresIn3Times, 0)) over t1_UserIp_RequestDatetime_0s_7200s then count(UserClickedTitleTermScoresIn3Times) over t1_UserIp_RequestDatetime_0s_7200s else null end as t1_UserClickedTitleTermScoresIn3Times_88, + case when !isnull(lag(UserClickedTermScoresIn3Times, 0)) over t1_UserIp_RequestDatetime_0s_7200s then count(UserClickedTermScoresIn3Times) over t1_UserIp_RequestDatetime_0s_7200s else null end as t1_UserClickedTermScoresIn3Times_89, + case when !isnull(lag(UserClickedMediaIdsIn360Minutes, 0)) over t1_UserIp_RequestDatetime_0s_7200s then count(UserClickedMediaIdsIn360Minutes) over t1_UserIp_RequestDatetime_0s_7200s else null end as t1_UserClickedMediaIdsIn360Minutes_90, + case when !isnull(lag(UserClickedTermScoresIn10Times, 0)) over t1_UserId_RequestDatetime_0s_7200s then count(UserClickedTermScoresIn10Times) over t1_UserId_RequestDatetime_0s_7200s else null end as t1_UserClickedTermScoresIn10Times_91 + from + {0} + window t1_UserTermScores_RequestDatetime_0s_7200s as ( partition by UserTermScores order by RequestDatetime rows_range between 7200s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_UserTagScores_RequestDatetime_0s_7200s as ( partition by UserTagScores order by RequestDatetime rows_range between 7200s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_UserId_RequestDatetime_0s_7200s as ( partition by UserId order by RequestDatetime rows_range between 7200s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW), + t1_UserIp_RequestDatetime_0s_7200s as ( partition by UserIp order by RequestDatetime rows_range between 7200s preceding and 0s preceding INSTANCE_NOT_IN_WINDOW); + expect: + success: true diff --git a/cases/integration_test/test_batch_request.yaml b/cases/integration_test/test_batch_request.yaml new file mode 100644 index 00000000000..9f3134806e1 --- /dev/null +++ b/cases/integration_test/test_batch_request.yaml @@ -0,0 +1,358 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: batch request without common column + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + rows: + - [1,"a",1,30,1.0,2.0,1590738990000,"2020-05-01","a"] + - [3,"a",3,32,1.2,2.2,1590738992000,"2020-05-03","c"] + - [5,"a",5,34,1.4,2.4,1590738994000,"2020-05-05","d"] + - [6,"a",6,35,1.5,2.5,1590738995000,"2020-05-06","e"] + batch_request: + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + rows: + - [2,"a",2,31,1.1,2.1,1590738991000,"2020-05-02","b"] + - [4,"a",4,33,1.3,2.3,1590738993000,"2020-05-04","c"] + - [7,"a",6,36,1.6,2.6,1590738996000,"2020-05-07","f"] + sql: | + SELECT id, c1, sum(c3) OVER w1 as m3, sum(c4) OVER w1 as m4, sum(c5) OVER w1 as m5, + sum(c6) OVER w1 as m6, max(c7) OVER w1 as m7, max(c8) OVER w1 as m8, min(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m3 int","m4 bigint","m5 float","m6 double","m7 timestamp","m8 date","m9 string"] + rows: + - [2,"a",3,61,2.1,4.1,1590738991000,"2020-05-02","a"] + - [4,"a",8,95,3.5,6.5,1590738993000,"2020-05-04","a"] + - [7,"a",17,105,4.5,7.5,1590738996000,"2020-05-07","d"] + + - id: 1 + desc: batch request with all common columns + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + rows: + - [1,"a",1,30,1.0,2.0,1590738990000,"2020-05-01","a"] + - [3,"a",3,32,1.2,2.2,1590738992000,"2020-05-03","c"] + - [5,"a",5,34,1.4,2.4,1590738994000,"2020-05-05","d"] + - [6,"a",6,35,1.5,2.5,1590738995000,"2020-05-06","e"] + batch_request: + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 string"] + indexs: ["index1:c1:c7"] + common_column_indices: [0,1,2,3,4,5,6,7,8] + rows: + - [2,"a",2,31,1.1,2.1,1590738991000,"2020-05-02","b"] + - [2,"a",2,31,1.1,2.1,1590738991000,"2020-05-02","b"] + - [2,"a",2,31,1.1,2.1,1590738991000,"2020-05-02","b"] + sql: | + SELECT id, c1, sum(c3) OVER w1 as m3, sum(c4) OVER w1 as m4, sum(c5) OVER w1 as m5, + sum(c6) OVER w1 as m6, max(c7) OVER w1 as m7, max(c8) OVER w1 as m8, min(c9) OVER w1 as m9 FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + columns: ["id int","c1 string","m3 int","m4 bigint","m5 float","m6 double","m7 timestamp","m8 date","m9 string"] + rows: + - [2,"a",3,61,2.1,4.1,1590738991000,"2020-05-02","a"] + - [2,"a",3,61,2.1,4.1,1590738991000,"2020-05-02","a"] + - [2,"a",3,61,2.1,4.1,1590738991000,"2020-05-02","a"] + + - id: 2 + desc: batch request with non-trival common columns + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp"] + indexs: ["index1:c1:c7", "index2:id:c7"] + rows: + - [1,"a",1,30,1.0,2.0,1590738990000] + - [3,"a",3,32,1.2,2.2,1590738992000] + - [5,"a",5,34,1.4,2.4,1590738994000] + - [6,"a",6,35,1.5,2.5,1590738995000] + - + columns : ["id int","timecol timestamp","c8 date","c9 string"] + indexs: ["index2:id:timecol"] + rows: + - [1,1590738990000,"2020-05-01","a"] + - [2,1590738991000,"2020-05-02","b"] + - [3,1590738992000,"2020-05-03","c"] + - [4,1590738993000,"2020-05-04","d"] + - [5,1590738994000,"2020-05-05","e"] + - [6,1590738995000,"2020-05-06","f"] + - [7,1590738996000,"2020-05-07","g"] + batch_request: + indexs: ["index1:c1:c7"] + common_column_indices: [1,3,5] + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp"] + rows: + - [2,"a",2,31,1.1,2.1,1590738991000] + - [4,"a",3,31,1.2,2.1,1590738993000] + - [7,"a",4,31,1.3,2.1,1590738996000] + sql: | + SELECT {0}.id, c1, sum(c3) OVER w1 as m3, sum(c4) OVER w1 as m4, sum(c5) OVER w1 as m5, + sum(c6) OVER w1 as m6, max(c7) OVER w1 as m7, max(c8) OVER w1 as m8, min(c9) OVER w1 as m9 + FROM {0} last join {1} order by {1}.timecol on {0}.id={1}.id and {0}.c7={1}.timecol + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","m3 int","m4 bigint","m5 float","m6 double","m7 timestamp","m8 date","m9 string"] + rows: + - [2,"a",3,61,2.1,4.1,1590738991000,"2020-05-02","a"] + - [4,"a",7,93,3.4,6.3,1590738993000,"2020-05-04","a"] + - [7,"a",15,100,4.2,7.0,1590738996000,"2020-05-07","e"] + common_column_indices: [] + + - id: 3 + desc: batch request with non-trival output common columns, window is common + inputs: + - + columns : ["id int","c1 string","c2 int","c3 bigint","c4 float","c5 double","c6 timestamp"] + indexs: ["index1:c1:c6", "index2:id:c6"] + rows: + - [1,"a",1,30,1.0,2.0,1590738990000] + - [3,"a",3,32,1.2,2.2,1590738992000] + - [5,"a",5,34,1.4,2.4,1590738994000] + - [6,"a",6,35,1.5,2.5,1590738995000] + - + columns : ["id int","timecol timestamp","c7 date","c8 string"] + indexs: ["index2:id:timecol"] + rows: + - [1,1590738990000,"2020-05-01","a"] + - [2,1590738991000,"2020-05-02","b"] + - [3,1590738992000,"2020-05-03","c"] + - [4,1590738993000,"2020-05-04","d"] + - [5,1590738994000,"2020-05-05","e"] + - [6,1590738995000,"2020-05-06","f"] + - [7,1590738996000,"2020-05-07","g"] + batch_request: + indexs: ["index1:c1:c6"] + common_column_indices: [1,3,6] + columns : ["id int","c1 string","c2 int","c3 bigint","c4 float","c5 double","c6 timestamp"] + rows: + - [2,"a",2,31,1.1,2.1,1590738996000] + - [4,"a",3,31,1.2,2.2,1590738996000] + - [7,"a",4,31,1.3,2.3,1590738996000] + sql: | + SELECT {0}.id, c1 as m1, sum(c2) OVER w1 as m2, sum(c3) OVER w1 as m3, sum(c4) OVER w1 as m4, + sum(c5) OVER w1 as m5, max(c6) OVER w1 as m6, max(c7) OVER w1 as m7, min(c8) OVER w1 as m8 + FROM {0} last join {1} order by {1}.timecol on {0}.id={1}.id and {0}.c6={1}.timecol + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c6 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","m1 string","m2 int","m3 bigint","m4 float","m5 double","m6 timestamp","m7 date","m8 string"] + common_column_indices: [1,3,6] + rows: + - [2,"a",13,100,4.0,7.0,1590738996000,"2020-05-06","e"] + - [4,"a",14,100,4.1,7.1,1590738996000,"2020-05-06","e"] + - [7,"a",15,100,4.2,7.2,1590738996000,"2020-05-07","e"] + + - id: 4 + desc: batch request with non-trival output common columns, join is common and window non-common + inputs: + - + columns : ["id int","c1 string","c2 int","c3 bigint","c4 float","c5 double","c6 timestamp"] + indexs: ["index1:c1:c6", "index2:id:c6"] + rows: + - [1,"a",1,30,1.0,2.0,1590738990000] + - [3,"a",3,32,1.2,2.2,1590738992000] + - [5,"a",5,34,1.4,2.4,1590738994000] + - [6,"a",6,35,1.5,2.5,1590738995000] + - + columns : ["id int","timecol timestamp","c1 string", "c7 date","c8 string"] + indexs: ["index2:c1:timecol"] + rows: + - [1,1590738990000,"a","2020-05-01","a"] + - [2,1590738991000,"a","2020-05-02","b"] + - [3,1590738992000,"a","2020-05-03","c"] + - [4,1590738993000,"a","2020-05-04","d"] + - [5,1590738994000,"a","2020-05-05","e"] + - [6,1590738995000,"a","2020-05-06","f"] + - [7,1590738996000,"a","2020-05-07","g"] + batch_request: + indexs: ["index1:c1:c6"] + common_column_indices: [1,3] + columns : ["id int","c1 string","c2 int","c3 bigint","c4 float","c5 double","c6 timestamp"] + rows: + - [2,"a",2,31,1.1,2.1,1590738996000] + - [4,"a",3,31,1.2,2.2,1590738997000] + - [7,"a",4,31,1.3,2.3,1590738998000] + sql: | + SELECT {0}.id, {0}.c1 as m1, sum(c2) OVER w1 as m2, sum(c3) OVER w1 as m3, sum(c4) OVER w1 as m4, + sum(c5) OVER w1 as m5, max(c6) OVER w1 as m6, max(c7) OVER w1 as m7, min(c8) OVER w1 as m8 + FROM {0} last join {1} order by {1}.timecol on {0}.c1={1}.c1 + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c6 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","m1 string","m2 int","m3 bigint","m4 float","m5 double","m6 timestamp","m7 date","m8 string"] + common_column_indices: [] + rows: + - [2,"a",13,100,4.0,7.0,1590738996000,"2020-05-07","g"] + - [4,"a",14,100,4.1,7.1,1590738997000,"2020-05-07","g"] + - [7,"a",15,100,4.2,7.2,1590738998000,"2020-05-07","g"] + + - id: 5 + desc: batch request with non-trival output common columns, window and join are common + inputs: + - + columns : ["id int","c1 string","c2 int","c3 bigint","c4 float","c5 double","c6 timestamp"] + indexs: ["index1:c1:c6", "index2:id:c6"] + rows: + - [1,"a",1,30,1.0,2.0,1590738990000] + - [3,"a",3,32,1.2,2.2,1590738992000] + - [5,"a",5,34,1.4,2.4,1590738994000] + - [6,"a",6,35,1.5,2.5,1590738995000] + - + columns : ["id int","timecol timestamp","c1 string", "c7 date","c8 string"] + indexs: ["index2:c1:timecol"] + rows: + - [1,1590738990000,"a","2020-05-01","a"] + - [2,1590738991000,"a","2020-05-02","b"] + - [3,1590738992000,"a","2020-05-03","c"] + - [4,1590738993000,"a","2020-05-04","d"] + - [5,1590738994000,"a","2020-05-05","e"] + - [6,1590738995000,"a","2020-05-06","f"] + - [7,1590738996000,"a","2020-05-07","g"] + batch_request: + indexs: ["index1:c1:c6"] + common_column_indices: [1,3,6] + columns : ["id int","c1 string","c2 int","c3 bigint","c4 float","c5 double","c6 timestamp"] + rows: + - [2,"a",2,31,1.1,2.1,1590738996000] + - [4,"a",3,31,1.2,2.2,1590738996000] + - [7,"a",4,31,1.3,2.3,1590738996000] + sql: | + SELECT {0}.id, {0}.c1 as m1, sum(c2) OVER w1 as m2, sum(c3) OVER w1 as m3, sum(c4) OVER w1 as m4, + sum(c5) OVER w1 as m5, max(c6) OVER w1 as m6, max(c7) OVER w1 as m7, min(c8) OVER w1 as m8 + FROM {0} last join {1} order by {1}.timecol on {0}.c1={1}.c1 and {0}.c6={1}.timecol + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c6 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","m1 string","m2 int","m3 bigint","m4 float","m5 double","m6 timestamp","m7 date","m8 string"] + common_column_indices: [1,3,6,7,8] + rows: + - [2,"a",13,100,4.0,7.0,1590738996000,"2020-05-07","e"] + - [4,"a",14,100,4.1,7.1,1590738996000,"2020-05-07","e"] + - [7,"a",15,100,4.2,7.2,1590738996000,"2020-05-07","e"] + - id: 6 + desc: batch request with one common window and one non-common window + mode: disk-unsupport + inputs: + - + columns: ["id int","k1 bigint","k2 bigint","k3 timestamp", "k4 timestamp", + "c1 double","c2 double","c3 double","c4 double","c5 double","c6 double"] + indexs: ["index1:k1:k3", "index2:k2:k4"] + repeat: 10 + rows: + - [1,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + - [3,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + - [5,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + - [6,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + batch_request: + common_column_indices: [1,3,5,6,7] + columns : ["id int","k1 bigint","k2 bigint","k3 timestamp", "k4 timestamp", + "c1 double","c2 double","c3 double","c4 double","c5 double","c6 double"] + rows: + - [2,1,2,1590738991000,1590738991000,1.0,1.0,1.0,1.0,1.0,1.0] + - [4,1,2,1590738991000,1590738991000,1.0,1.0,1.0,1.0,1.0,1.0] + - [7,1,2,1590738991000,1590738991000,1.0,1.0,1.0,1.0,1.0,1.0] + sql: | + SELECT {0}.id, sum(c1) over w1 as m1, sum(c2) over w1 as m2, sum(c3) over w1 as m3, + sum(c4) over w2 as m4, sum(c5) over w2 as m5, sum(c6) over w2 as m6 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.k1 ORDER BY {0}.k3 ROWS_RANGE BETWEEN 20s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.k2 ORDER BY {0}.k4 ROWS_RANGE BETWEEN 20s PRECEDING AND CURRENT ROW); + expect: + success: true + order: id + columns: [ "id int","m1 double","m2 double","m3 double","m4 double","m5 double","m6 double"] + common_column_indices: [1,2,3] + rows: + - [2, 41.0, 41.0, 41.0, 41.0, 41.0, 41.0] + - [4, 41.0, 41.0, 41.0, 41.0, 41.0, 41.0] + - [7, 41.0, 41.0, 41.0, 41.0, 41.0, 41.0] + + - id: 7 + desc: batch request with common window and common and non-common aggregations, window is small + mode: disk-unsupport + inputs: + - + columns: ["id int","k1 bigint","k2 timestamp", + "c1 double","c2 double","c3 double", + "c4 double","c5 double","c6 double"] + indexs: ["index1:k1:k2",] + repeat: 10 + rows: + - [1,1,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + batch_request: + common_column_indices: [1,2,3,5,7] + columns : ["id int","k1 bigint","k2 timestamp", + "c1 double","c2 double","c3 double", + "c4 double","c5 double","c6 double"] + rows: + - [2,1,1590738991000,1.0,1.0,1.0,1.0,1.0,1.0] + - [4,1,1590738991000,1.0,1.0,1.0,1.0,1.0,1.0] + - [7,1,1590738991000,1.0,1.0,1.0,1.0,1.0,1.0] + sql: | + SELECT {0}.id, sum(c1) over w1 as m1, sum(c2) over w1 as m2, sum(c3) over w1 as m3, + sum(c4) over w1 as m4, sum(c5) over w1 as m5, sum(c6) over w1 as m6 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.k1 ORDER BY {0}.k2 ROWS_RANGE BETWEEN 20s PRECEDING AND CURRENT ROW); + expect: + success: true + order: id + common_column_indices: [1,3,5] + columns: [ "id int","m1 double","m2 double","m3 double","m4 double","m5 double","m6 double"] + rows: + - [2, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0] + - [4, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0] + - [7, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0] + + - id: 8 + desc: batch request with one common window and one non-common window, current time == history time + mode: disk-unsupport + inputs: + - + columns: ["id int","k1 bigint","k2 bigint","k3 timestamp", "k4 timestamp", + "c1 double","c2 double","c3 double","c4 double","c5 double","c6 double"] + indexs: ["index1:k1:k3", "index2:k2:k4"] + repeat: 10 + rows: + - [1,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + - [3,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + - [5,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + - [6,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + batch_request: + columns : ["id int","k1 bigint","k2 bigint","k3 timestamp", "k4 timestamp", + "c1 double","c2 double","c3 double","c4 double","c5 double","c6 double"] + rows: + - [2,1,2,1590738990000,1590738990000,1.0,1.0,1.0,1.0,1.0,1.0] + sql: | + SELECT {0}.id, sum(c1) over w1 as m1, sum(c2) over w1 as m2, sum(c3) over w1 as m3, + sum(c4) over w2 as m4, sum(c5) over w2 as m5, sum(c6) over w2 as m6 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.k1 ORDER BY {0}.k3 ROWS BETWEEN 10 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.k2 ORDER BY {0}.k4 ROWS BETWEEN 20 PRECEDING AND CURRENT ROW); + expect: + success: true + order: id + columns: [ "id int","m1 double","m2 double","m3 double","m4 double","m5 double","m6 double"] + rows: + - [2, 11.0, 11.0, 11.0, 21.0, 21.0, 21.0] diff --git a/cases/integration_test/test_feature_zero_function.yaml b/cases/integration_test/test_feature_zero_function.yaml new file mode 100644 index 00000000000..24876d3ce97 --- /dev/null +++ b/cases/integration_test/test_feature_zero_function.yaml @@ -0,0 +1,176 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_fz +debugs: [] +cases: + - id: 1 + desc: feature zero split utility functions + inputs: + - columns: ["id int64", "pk int64", "c1 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 0, "k1:v1,k2:v2"] + - [2, 0, "k3:v3"] + - [3, 0, "???,,k4:v4"] + - [4, 0, NULL] + - [5, 0, "k5:v5,k5:v3"] + sql: | + SELECT id, + identity(case when !isnull(lag(c1, 0)) then distinct_count(fz_window_split(c1, ",")) else null end) over w1 as table_2_kn_0, + identity(case when !isnull(lag(c1, 0)) then distinct_count(fz_window_split_by_key(c1, ",", ":")) else null end) over w1 as table_2_kn_1, + identity(case when !isnull(lag(c1, 0)) then distinct_count(fz_window_split_by_value(c1, ",", ":")) else null end) over w1 as table_2_kn_2, + fz_join(fz_window_split(c1, ","), " ") OVER w1 AS split_and_join, + fz_join(fz_window_split_by_key(c1, ",", ":"), " ") OVER w1 AS split_key_and_join, + fz_join(fz_window_split_by_value(c1, ",", ":"), " ") OVER w1 AS split_value_and_join, + count(fz_window_split_by_key(c1, ",", ":")) OVER w1 AS split_key_and_count, + distinct_count(fz_window_split_by_key(c1, ",", ":")) OVER w1 AS split_key_and_distinct_count + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int64", "table_2_kn_0 int64", "table_2_kn_1 int64", "table_2_kn_2 int64", "split_and_join string", "split_key_and_join string", "split_value_and_join string", "split_key_and_count int64", "split_key_and_distinct_count int64"] + rows: + - [1, 2, 2, 2, "k1:v1 k2:v2", "k1 k2", "v1 v2", 2, 2] + - [2, 3, 3, 3, "k3:v3 k1:v1 k2:v2", "k3 k1 k2", "v3 v1 v2", 3, 3] + - [3, 6, 4, 4, "??? k4:v4 k3:v3 k1:v1 k2:v2", "k4 k3 k1 k2", "v4 v3 v1 v2", 4, 4] + - [4, NULL, NULL, NULL, "??? k4:v4 k3:v3 k1:v1 k2:v2", "k4 k3 k1 k2", "v4 v3 v1 v2", 4, 4] + - [5, 8, 5, 5, "k5:v5 k5:v3 ??? k4:v4 k3:v3 k1:v1 k2:v2", "k5 k5 k4 k3 k1 k2", "v5 v3 v4 v3 v1 v2", 6, 5] + + - id: 2 + desc: feature zero split utility functions on single row + inputs: + - name: main + columns: ["id int64", "pk int64", "c1 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 0, "k1:v1,k2:v2"] + - [2, 0, "k3:v3"] + - [3, 0, "???,,k4:v4"] + - [4, 0, NULL] + - [5, 0, "k5:v5,k3:v3"] + sql: | + SELECT id, + fz_join(fz_split(c1, ","), " ") AS split_and_join, + fz_join(fz_split_by_key(c1, ",", ":"), " ") AS split_key_and_join, + fz_join(fz_split_by_value(c1, ",", ":"), " ") AS split_value_and_join + FROM main; + expect: + order: id + columns: ["id int64", "split_and_join string", "split_key_and_join string", "split_value_and_join string"] + rows: + - [1, "k1:v1 k2:v2", "k1 k2", "v1 v2"] + - [2, "k3:v3", "k3", "v3"] + - [3, "??? k4:v4", "k4", "v4"] + - [4, "", "", ""] + - [5, "k5:v5 k3:v3", "k5 k3", "v5 v3"] + + - id: 3 + desc: window top1 ratio + inputs: + - + columns : ["id bigint","pk bigint","c1 smallint","c2 int","c3 bigint","c4 float", + "c5 double", "c6 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 1, 1, 1, 1, 1.1, 2.1, "1:1 1:2"] + - [2, 1, 2, 2, 1, 1.4, 2.1, "1:1" ] + - [3, 1, NULL, 3, 1, 1.3, 2.3, "1:1 1:3"] + - [4, 2, NULL, 5, 1, NULL, NULL, "1:3"] + - [5, 2, 5, 4, 1, 1.5, 2.5, "1:2 1:3"] + sql: | + SELECT id, + fz_top1_ratio(c1) OVER w1 as r1, + fz_top1_ratio(c2) OVER w1 as r2, + fz_top1_ratio(c3) OVER w1 as r3, + fz_top1_ratio(c4) OVER w1 as r4, + fz_top1_ratio(c5) OVER w1 as r5, + fz_top1_ratio(fz_window_split_by_value(c6, " ", ":")) OVER w1 as r6, + fz_join(fz_window_split_by_value(c6, " ", ":")," ") OVER w1 as r7 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint","r1 double","r2 double","r3 double","r4 double","r5 double","r6 double","r7 string"] + rows: + - [1, 1.0, 1.0, 1, 1.0, 1.0, 0.5,"1 2"] + - [2, 0.5, 0.5, 1, 0.5, 1.0, 0.66666666666666663,"1 1 2"] + - [3, 0.5, 0.33333333333333331, 1, 0.33333333333333331, 0.66666666666666663, 0.6,"1 3 1 1 2"] + - [4, 0, 1, 1, 0, 0, 1,"3"] + - [5, 1, 0.5, 1, 1.0, 1, 0.66666666666666663,"2 3 3"] + + - id: 4 + desc: Multi Top 3 Frequency + inputs: + - + columns : ["id bigint","pk bigint","c1 string","c2 int","c3 string","c4 float", + "c5 double", "c6 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 1, "1:2 4:3", 1, "1:2 1:3", 1.1, 2.1, "1:1 1:2"] + - [2, 1, "4:2 8:3", NULL, "1:7 1:3", 1.4, 2.1, "1:1" ] + - [3, 1, NULL, 2, "1:2 1:3", 1.3, 2.3, "1:1 1:3"] + - [4, 2, NULL, NULL, "1:8 1:3", NULL, NULL, "1:3"] + - [5, 2, "1:2 1:3", 5, "1:8 1:3", 1, 1.5, "1:2 1:3"] + sql: | + SELECT id, + fz_topn_frequency(fz_window_split_by_key(c1, " ", ":"), 3) OVER w1 as r1, + fz_topn_frequency(c2, 3) OVER w1 as r2, + fz_topn_frequency(fz_window_split(c3, ","), 3) OVER w1 as r3, + fz_topn_frequency(c4, 3) OVER w1 as r4, + fz_topn_frequency(c5, 3) OVER w1 as r5, + fz_topn_frequency(fz_window_split_by_value(c6, " ", ":"), 3) OVER w1 as r6, + fz_join(fz_window_split_by_value(c6, " ", ":")," ") OVER w1 as r7 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint","r1 string","r2 string","r3 string","r4 string","r5 string","r6 string","r7 string"] + rows: + - [1, "1,4,NULL", "1,NULL,NULL", "1:2 1:3,NULL,NULL", "1.100000,NULL,NULL", "2.100000,NULL,NULL", "1,2,NULL", "1 2"] + - [2, "4,1,8", "1,NULL,NULL", "1:2 1:3,1:7 1:3,NULL", "1.100000,1.400000,NULL", "2.100000,NULL,NULL", "1,2,NULL","1 1 2"] + - [3, "4,1,8", "1,2,NULL","1:2 1:3,1:7 1:3,NULL", "1.100000,1.300000,1.400000", "2.100000,2.300000,NULL", "1,2,3","1 3 1 1 2"] + - [4, "", "NULL,NULL,NULL", "1:8 1:3,NULL,NULL", "NULL,NULL,NULL", "NULL,NULL,NULL", "3,NULL,NULL","3"] + - [5, "1,NULL,NULL", "5,NULL,NULL", "1:8 1:3,NULL,NULL", "1.000000,NULL,NULL", "1.500000,NULL,NULL", "3,2,NULL","2 3 3"] + + - id: 5 + desc: feature zero split utility functions on empty separator + inputs: + - columns: ["id int64", "pk int64", "c1 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 0, "a"] + - [2, 0, "b"] + - [3, 0, "c"] + - [4, 0, NULL] + - [5, 0, "e"] + sql: | + SELECT id, + fz_join(fz_split(c1, ""), "") OVER w1 AS r1, + fz_join(fz_split_by_key(c1, "", ""), "") OVER w1 AS r2, + fz_join(fz_split_by_value(c1, "", ""), "") OVER w1 AS r3, + fz_join(fz_window_split(c1, ""), " ") OVER w1 AS r4, + fz_join(fz_window_split_by_key(c1, "", ""), " ") OVER w1 AS r5, + fz_join(fz_window_split_by_value(c1, "", ""), " ") OVER w1 AS r6 + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int64", "r1 string", "r2 string", "r3 string", "r4 string", "r5 string", "r6 string"] + rows: + - [1, "", "", "", "", "", ""] + - [2, "", "", "", "", "", ""] + - [3, "", "", "", "", "", ""] + - [4, "", "", "", "", "", ""] + - [5, "", "", "", "", "", ""] diff --git a/cases/integration_test/test_fz_sql.yaml b/cases/integration_test/test_fz_sql.yaml new file mode 100644 index 00000000000..f79cecd1a27 --- /dev/null +++ b/cases/integration_test/test_fz_sql.yaml @@ -0,0 +1,156 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_fz +debugs: [] +cases: + - id: 0 + desc: feature zero split utility functions + inputs: + - columns: ["id int64", "pk int64", "c1 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 0, "k1:v1,k2:v2"] + - [2, 0, "k3:v3"] + - [3, 0, "???,,k4:v4"] + - [4, 0, NULL] + - [5, 0, "k5:v5,k5:v3"] + sql: | + SELECT id, + identity(case when !isnull(lag(c1, 0)) then distinct_count(fz_window_split(c1, ",")) else null end) over w1 as table_2_kn_0, + identity(case when !isnull(lag(c1, 0)) then distinct_count(fz_window_split_by_key(c1, ",", ":")) else null end) over w1 as table_2_kn_1, + identity(case when !isnull(lag(c1, 0)) then distinct_count(fz_window_split_by_value(c1, ",", ":")) else null end) over w1 as table_2_kn_2, + fz_join(fz_window_split(c1, ","), " ") OVER w1 AS split_and_join, + fz_join(fz_window_split_by_key(c1, ",", ":"), " ") OVER w1 AS split_key_and_join, + fz_join(fz_window_split_by_value(c1, ",", ":"), " ") OVER w1 AS split_value_and_join, + count(fz_window_split_by_key(c1, ",", ":")) OVER w1 AS split_key_and_count, + distinct_count(fz_window_split_by_key(c1, ",", ":")) OVER w1 AS split_key_and_distinct_count + FROM {0} + WINDOW w1 AS (PARTITION BY {0}.pk ORDER BY {0}.id ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int64", "table_2_kn_0 int64", "table_2_kn_1 int64", "table_2_kn_2 int64", "split_and_join string", "split_key_and_join string", "split_value_and_join string", "split_key_and_count int64", "split_key_and_distinct_count int64"] + rows: + - [1, 2, 2, 2, "k1:v1 k2:v2", "k1 k2", "v1 v2", 2, 2] + - [2, 3, 3, 3, "k3:v3 k1:v1 k2:v2", "k3 k1 k2", "v3 v1 v2", 3, 3] + - [3, 6, 4, 4, "??? k4:v4 k3:v3 k1:v1 k2:v2", "k4 k3 k1 k2", "v4 v3 v1 v2", 4, 4] + - [4, NULL, NULL, NULL, "??? k4:v4 k3:v3 k1:v1 k2:v2", "k4 k3 k1 k2", "v4 v3 v1 v2", 4, 4] + - [5, 8, 5, 5, "k5:v5 k5:v3 ??? k4:v4 k3:v3 k1:v1 k2:v2", "k5 k5 k4 k3 k1 k2", "v5 v3 v4 v3 v1 v2", 6, 5] + + - id: 1 + desc: feature zero split utility functions on single row + inputs: + - name: main + columns: ["id int64", "pk int64", "c1 string"] + indexs: ["index1:pk:id"] + rows: + - [1, 0, "k1:v1,k2:v2"] + - [2, 0, "k3:v3"] + - [3, 0, "???,,k4:v4"] + - [4, 0, NULL] + - [5, 0, "k5:v5,k3:v3"] + sql: | + SELECT id, + fz_join(fz_split(c1, ","), " ") AS split_and_join, + fz_join(fz_split_by_key(c1, ",", ":"), " ") AS split_key_and_join, + fz_join(fz_split_by_value(c1, ",", ":"), " ") AS split_value_and_join + FROM main; + expect: + order: id + columns: ["id int64", "split_and_join string", "split_key_and_join string", "split_value_and_join string"] + rows: + - [1, "k1:v1 k2:v2", "k1 k2", "v1 v2"] + - [2, "k3:v3", "k3", "v3"] + - [3, "??? k4:v4", "k4", "v4"] + - [4, "", "", ""] + - [5, "k5:v5 k3:v3", "k5 k3", "v5 v3"] + - id: 2 + desc: fz case 5 simple version debug + mode: rtidb-batch-unsupport + inputs: + - columns: ["id int64", "reqId string", "eventTime timestamp", "SK_ID_CURR string"] + indexs: ["index1:reqId:id"] + rows: + - [1, "col0", 1607473951299, "col3"] + - columns: [ "ingestionTime timestamp","eventTime timestamp", + "SK_ID_PREV string","SK_ID_CURR string", + "NAME_CONTRACT_TYPE string","AMT_ANNUITY double","AMT_APPLICATION double","AMT_CREDIT double","AMT_DOWN_PAYMENT double", + "AMT_GOODS_PRICE double","WEEKDAY_APPR_PROCESS_START string","HOUR_APPR_PROCESS_START int", + "FLAG_LAST_APPL_PER_CONTRACT string","NFLAG_LAST_APPL_IN_DAY int", + "RATE_DOWN_PAYMENT double","RATE_INTEREST_PRIMARY double","RATE_INTEREST_PRIVILEGED double", + "NAME_CASH_LOAN_PURPOSE string","NAME_CONTRACT_STATUS string","DAYS_DECISION int","NAME_PAYMENT_TYPE string", + "CODE_REJECT_REASON string","NAME_TYPE_SUITE string","NAME_CLIENT_TYPE string","NAME_GOODS_CATEGORY string", + "NAME_PORTFOLIO string","NAME_PRODUCT_TYPE string","CHANNEL_TYPE string","SELLERPLACE_AREA int", + "NAME_SELLER_INDUSTRY string","CNT_PAYMENT double","NAME_YIELD_GROUP string","PRODUCT_COMBINATION string", + "DAYS_FIRST_DRAWING double","DAYS_FIRST_DUE double","DAYS_LAST_DUE_1ST_VERSION double", + "DAYS_LAST_DUE double","DAYS_TERMINATION double", + "NFLAG_INSURED_ON_APPROVAL double"] + indexs: ["index1:SK_ID_CURR:ingestionTime"] + rows: + - [1607473951298, 1607473951298, + 'col2', 'col3', 'col4', 1.4, 1.4, 1.4, 1.4, 1.4, 'col10', 11, 'col12', 13, 1.4, 1.4, 1.4, + 'col17', 'col18', 19, 'col20', 'col21', 'col22', 'col23', 'col24', 'col25', 'col26', + 'col27', 28, 'col29', 1.4, 'col31', 'col32', 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] + sql: | + select reqId_1, reqId_243 from ( select reqId as reqId_1 from {0} ) as out0 last join + ( select + reqId as reqId_243, + case when !isnull(lag(NAME_CLIENT_TYPE, 1)) over previous_application_SK_ID_CURR_ingestionTime_0s_32d then count(NAME_CLIENT_TYPE) over previous_application_SK_ID_CURR_ingestionTime_0s_32d else null end as f1, + 1 as f2, + fz_topn_frequency(NAME_CONTRACT_STATUS, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as f3, + distinct_count(NAME_CONTRACT_TYPE) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as f4, + fz_topn_frequency(NAME_CONTRACT_TYPE, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as f5, + fz_topn_frequency(NAME_GOODS_CATEGORY, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as f6, + distinct_count(NAME_GOODS_CATEGORY) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as f7, + fz_topn_frequency(NAME_PAYMENT_TYPE, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as f8, + case when !isnull(lag(NAME_PAYMENT_TYPE, 1)) over previous_application_SK_ID_CURR_ingestionTime_0s_32d then count(NAME_PAYMENT_TYPE) over previous_application_SK_ID_CURR_ingestionTime_0s_32d else null end as f9, + distinct_count(NAME_PORTFOLIO) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as f10, + fz_topn_frequency(NAME_PORTFOLIO, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_NAME_PORTFOLIO_multi_top3frequency_299, + distinct_count(NAME_PRODUCT_TYPE) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_NAME_PRODUCT_TYPE_multi_unique_count_300, + fz_topn_frequency(NAME_PRODUCT_TYPE, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_NAME_PRODUCT_TYPE_multi_top3frequency_301, + fz_topn_frequency(NAME_SELLER_INDUSTRY, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_NAME_SELLER_INDUSTRY_multi_top3frequency_302, + case when !isnull(lag(NAME_SELLER_INDUSTRY, 1)) over previous_application_SK_ID_CURR_ingestionTime_0s_32d then count(NAME_SELLER_INDUSTRY) over previous_application_SK_ID_CURR_ingestionTime_0s_32d else null end as previous_application_NAME_SELLER_INDUSTRY_multi_count_303, + fz_topn_frequency(NAME_TYPE_SUITE, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_NAME_TYPE_SUITE_multi_top3frequency_304, + case when !isnull(lag(NAME_TYPE_SUITE, 1)) over previous_application_SK_ID_CURR_ingestionTime_0s_32d then count(NAME_TYPE_SUITE) over previous_application_SK_ID_CURR_ingestionTime_0s_32d else null end as previous_application_NAME_TYPE_SUITE_multi_count_305, + fz_topn_frequency(NAME_YIELD_GROUP, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_NAME_YIELD_GROUP_multi_top3frequency_306, + case when !isnull(lag(NAME_YIELD_GROUP, 1)) over previous_application_SK_ID_CURR_ingestionTime_0s_32d then count(NAME_YIELD_GROUP) over previous_application_SK_ID_CURR_ingestionTime_0s_32d else null end as previous_application_NAME_YIELD_GROUP_multi_count_307, + fz_topn_frequency(PRODUCT_COMBINATION, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_PRODUCT_COMBINATION_multi_top3frequency_308, + case when !isnull(lag(PRODUCT_COMBINATION, 1)) over previous_application_SK_ID_CURR_ingestionTime_0s_32d then count(PRODUCT_COMBINATION) over previous_application_SK_ID_CURR_ingestionTime_0s_32d else null end as previous_application_PRODUCT_COMBINATION_multi_count_309, + fz_topn_frequency(SK_ID_PREV, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_SK_ID_PREV_multi_top3frequency_310, + distinct_count(SK_ID_PREV) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_SK_ID_PREV_multi_unique_count_311, + fz_topn_frequency(WEEKDAY_APPR_PROCESS_START, 3) over previous_application_SK_ID_CURR_ingestionTime_0s_32d as previous_application_WEEKDAY_APPR_PROCESS_START_multi_top3frequency_312, + + case when !isnull(lag(WEEKDAY_APPR_PROCESS_START, 1)) over previous_application_SK_ID_CURR_ingestionTime_0s_32d then count(WEEKDAY_APPR_PROCESS_START) over previous_application_SK_ID_CURR_ingestionTime_0s_32d else null end as previous_application_WEEKDAY_APPR_PROCESS_START_multi_count_313 + from + (select eventTime as ingestionTime, timestamp('2019-07-18 09:20:20') as eventTime, '' as SK_ID_PREV, + SK_ID_CURR as SK_ID_CURR, '' as NAME_CONTRACT_TYPE, double(0) as AMT_ANNUITY, double(0) as AMT_APPLICATION, + double(0) as AMT_CREDIT, double(0) as AMT_DOWN_PAYMENT, double(0) as AMT_GOODS_PRICE, '' as WEEKDAY_APPR_PROCESS_START, + int(0) as HOUR_APPR_PROCESS_START, '' as FLAG_LAST_APPL_PER_CONTRACT, int(0) as NFLAG_LAST_APPL_IN_DAY, double(0) as RATE_DOWN_PAYMENT, + double(0) as RATE_INTEREST_PRIMARY, double(0) as RATE_INTEREST_PRIVILEGED, '' as NAME_CASH_LOAN_PURPOSE, '' as NAME_CONTRACT_STATUS, int(0) as DAYS_DECISION, + '' as NAME_PAYMENT_TYPE, '' as CODE_REJECT_REASON, '' as NAME_TYPE_SUITE, '' as NAME_CLIENT_TYPE, '' as NAME_GOODS_CATEGORY, '' as NAME_PORTFOLIO, '' as NAME_PRODUCT_TYPE, + '' as CHANNEL_TYPE, int(0) as SELLERPLACE_AREA, '' as NAME_SELLER_INDUSTRY, double(0) as CNT_PAYMENT, '' as NAME_YIELD_GROUP, '' as PRODUCT_COMBINATION, + double(0) as DAYS_FIRST_DRAWING, double(0) as DAYS_FIRST_DUE, double(0) as DAYS_LAST_DUE_1ST_VERSION, double(0) as DAYS_LAST_DUE, double(0) as DAYS_TERMINATION, + double(0) as NFLAG_INSURED_ON_APPROVAL, reqId from {0}) + window previous_application_SK_ID_CURR_ingestionTime_0s_32d as ( UNION (select ingestionTime, + eventTime, SK_ID_PREV, SK_ID_CURR, NAME_CONTRACT_TYPE, AMT_ANNUITY, AMT_APPLICATION, AMT_CREDIT, AMT_DOWN_PAYMENT, AMT_GOODS_PRICE, WEEKDAY_APPR_PROCESS_START, HOUR_APPR_PROCESS_START, + FLAG_LAST_APPL_PER_CONTRACT, NFLAG_LAST_APPL_IN_DAY, RATE_DOWN_PAYMENT, RATE_INTEREST_PRIMARY, RATE_INTEREST_PRIVILEGED, NAME_CASH_LOAN_PURPOSE, NAME_CONTRACT_STATUS, + DAYS_DECISION, NAME_PAYMENT_TYPE, CODE_REJECT_REASON, NAME_TYPE_SUITE, NAME_CLIENT_TYPE, NAME_GOODS_CATEGORY, NAME_PORTFOLIO, NAME_PRODUCT_TYPE, CHANNEL_TYPE, SELLERPLACE_AREA, + NAME_SELLER_INDUSTRY, CNT_PAYMENT, NAME_YIELD_GROUP, PRODUCT_COMBINATION, DAYS_FIRST_DRAWING, DAYS_FIRST_DUE, DAYS_LAST_DUE_1ST_VERSION, DAYS_LAST_DUE, DAYS_TERMINATION, NFLAG_INSURED_ON_APPROVAL, + '' as reqId from {1}) + partition by SK_ID_CURR order by ingestionTime rows_range between 32d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW)) as out7 on out0.reqId_1 = out7.reqId_243 ; + expect: + success: true + columns: ["reqId_1 string", "reqId_243 string"] + rows: + - ["col0", "col0"] diff --git a/cases/integration_test/test_index_optimized.yaml b/cases/integration_test/test_index_optimized.yaml new file mode 100644 index 00000000000..78e05a96131 --- /dev/null +++ b/cases/integration_test/test_index_optimized.yaml @@ -0,0 +1,184 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: window optimized one key one ts + inputs: + - columns: [ "c1 string","c3 int","c6 timestamp","c7 timestamp" ] + indexs: ["index1:c1:c6" ] + rows: + - [ "aa",1, 1590738990000, 1590738990000 ] + - [ "aa",2, 1590738991000, 1590738991000 ] + - [ "aa",3, 1590738992000, 1590738992000 ] + - [ "aa",4, 1590738993000, 1590738993000 ] + - [ "aa",5, 1590739001000, 1590738994000 ] + - [ "aa",6, 1590739002000, 1590738995000 ] + sql: | + SELECT c1, c3, c6, c7, + count(c1) OVER w1 as w1_cnt + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c6 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW); + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c6, 3000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c6 timestamp", "c7 timestamp", "w1_cnt bigint"] + rows: + - [ "aa", 1, 1590738990000, 1590738990000, 1] + - [ "aa", 2, 1590738991000, 1590738991000, 2] + - [ "aa", 3, 1590738992000, 1590738992000, 3] + - [ "aa", 4, 1590738993000, 1590738993000, 4] + - [ "aa", 5, 1590739001000, 1590738994000, 1] + - [ "aa", 6, 1590739002000, 1590738995000, 2] + - id: 1 + desc: window optimized different key same ts + inputs: + - columns: [ "c1 string","c3 int","c6 timestamp","c7 timestamp" ] + indexs: ["index0:c3:c6", "index1:c1:c6" ] + rows: + - [ "aa",1, 1590738990000, 1590738990000 ] + - [ "aa",2, 1590738991000, 1590738991000 ] + - [ "aa",3, 1590738992000, 1590738992000 ] + - [ "aa",4, 1590738993000, 1590738993000 ] + - [ "aa",5, 1590739001000, 1590738994000 ] + - [ "aa",6, 1590739002000, 1590738995000 ] + sql: | + SELECT c1, c3, c6, c7, + count(c1) OVER w1 as w1_cnt + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c6 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW); + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c6, 3000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c6 timestamp", "c7 timestamp", "w1_cnt bigint"] + rows: + - [ "aa", 1, 1590738990000, 1590738990000, 1] + - [ "aa", 2, 1590738991000, 1590738991000, 2] + - [ "aa", 3, 1590738992000, 1590738992000, 3] + - [ "aa", 4, 1590738993000, 1590738993000, 4] + - [ "aa", 5, 1590739001000, 1590738994000, 1] + - [ "aa", 6, 1590739002000, 1590738995000, 2] + - id: 2 + desc: window optimized same key different ts + inputs: + - columns: [ "c1 string","c3 int","c6 timestamp","c7 timestamp" ] + indexs: [ "index0:c3:c7", "index1:c3:c6", "index2:c1:c7", "index3:c1:c6" ] + rows: + - [ "aa",1, 1590738990000, 1590738990000 ] + - [ "aa",2, 1590738991000, 1590738991000 ] + - [ "aa",3, 1590738992000, 1590738992000 ] + - [ "aa",4, 1590738993000, 1590738993000 ] + - [ "aa",5, 1590739001000, 1590738994000 ] + - [ "aa",6, 1590739002000, 1590738995000 ] + sql: | + SELECT c1, c3, c6, c7, + count(c1) OVER w1 as w1_cnt, + count(c1) OVER w2 as w2_cnt + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c6 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW); + request_plan: | + SIMPLE_PROJECT(sources=(c1, c3, c6, c7, w1_cnt, w2_cnt)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c6, 3000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index3) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 3000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index2) + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c6 timestamp", "c7 timestamp", "w1_cnt bigint", "w2_cnt bigint" ] + rows: + - [ "aa", 1, 1590738990000, 1590738990000, 1, 1 ] + - [ "aa", 2, 1590738991000, 1590738991000, 2, 2 ] + - [ "aa", 3, 1590738992000, 1590738992000, 3, 3 ] + - [ "aa", 4, 1590738993000, 1590738993000, 4, 4 ] + - [ "aa", 5, 1590739001000, 1590738994000, 1, 4 ] + - [ "aa", 6, 1590739002000, 1590738995000, 2, 4 ] + - id: 3 + desc: LastJoin optimized one key one ts + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: [ "index1:c1:c3", "index2:c1:c4" ] + rows: + - [ "aa",2,13,1590738990000 ] + - [ "aa",21,131,1590738989000 ] + - [ "bb",41,151,1590738988000 ] + sql: | + select {0}.c1,{0}.c2, t1.c3 as t1_c3, t1.c4 as t1_c4 from {0} + last join {1} as t1 ORDER BY t1.c3 on {0}.c1 = t1.c1; + request_plan: | + SIMPLE_PROJECT(sources=(auto_t0.c1, auto_t0.c2, t1.c3 -> t1_c3, t1.c4 -> t1_c4)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=, left_keys=(), right_keys=(), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index1) + expect: + order: c1 + columns: [ "c1 string","c2 int","t1_c3 bigint","t1_c4 timestamp" ] + rows: + - [ "aa",2, 131, 1590738989000] + - [ "bb",21,151, 1590738988000] + - id: 4 + desc: LastJoin optimized one key two ts + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp"] + indexs: [ "index0:c2:c3", "index1:c1:c3", "index2:c1:c4" ] + rows: + - [ "aa",2,13,1590738990000 ] + - [ "aa",21,131,1590738989000 ] + - [ "bb",41,151,1590738988000 ] + sql: | + select {0}.c1,{0}.c2, t1.c3 as t1_c3, t1.c4 as t1_c4, t2.c3 as t2_c3, t2.c4 as t2_c4 from {0} + last join {1} as t1 ORDER BY t1.c3 on {0}.c1 = t1.c1 + last join {1} as t2 ORDER BY t2.c4 on {0}.c1 = t2.c1; + request_plan: | + SIMPLE_PROJECT(sources=(auto_t0.c1, auto_t0.c2, t1.c3 -> t1_c3, t1.c4 -> t1_c4, t2.c3 -> t2_c3, t2.c4 -> t2_c4)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=, left_keys=(), right_keys=(), index_keys=(auto_t0.c1)) + REQUEST_JOIN(type=LastJoin, right_sort=(ASC), condition=, left_keys=(), right_keys=(), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index1) + RENAME(name=t2) + DATA_PROVIDER(type=Partition, table=auto_t1, index=index2) + expect: + order: c1 + columns: [ "c1 string","c2 int","t1_c3 bigint","t1_c4 timestamp", "t2_c3 bigint","t2_c4 timestamp" ] + rows: + - [ "aa",2, 131, 1590738989000, 13, 1590738990000 ] + - [ "bb",21,151, 1590738988000, 151,1590738988000 ] diff --git a/cases/integration_test/test_performance_insensitive/test_performance_insensitive.yaml b/cases/integration_test/test_performance_insensitive/test_performance_insensitive.yaml new file mode 100644 index 00000000000..f03b0d0235a --- /dev/null +++ b/cases/integration_test/test_performance_insensitive/test_performance_insensitive.yaml @@ -0,0 +1,401 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +cases: + - id: 0 + desc: where不命中素索引= + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + sql: select * from {0} where c2=20; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "aa", 20, 30, 1590738991000 ] + - id: 1 + desc: where不命中素索引== + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + sql: select * from {0} where c2==20; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "aa", 20, 30, 1590738991000 ] + - id: 2 + desc: where不命中索引不等值查询 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + sql: select * from {0} where c2>20; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "bb", 21, 31, 1590738990000 ] + - [ "dd", 41, 51, 1590738990000 ] + - id: 3 + desc: where两个条件第一个命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + sql: select * from {0} where c1='aa' and c2>2; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "aa", 20, 30, 1590738991000 ] + - id: 4 + desc: where命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + sql: select * from {0} where c1='bb'; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "bb", 21, 31, 1590738990000 ] + - id: 5 + desc: where两个条件第二个命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + sql: select * from {0} where c1='aa' and c2>2; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "aa", 20, 30, 1590738991000 ] + - id: 6 + desc: where两个条件都命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4","index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + sql: select * from {0} where c1='aa' and c2>2; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "aa", 20, 30, 1590738991000 ] + - id: 7 + desc: where两个条件都不命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",20,30,1590738991000 ] + - [ "bb",21,31,1590738990000 ] + - [ "dd",41,51,1590738990000 ] + sql: select * from {0} where c1='aa' and c2>2; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "aa", 20, 30, 1590738991000 ] + - id: 8 + desc: lastjoin-拼表条件没有命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} order by {1}.c4 on {0}.c1={1}.c1; + expect: + columns: [ "c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [ "aa", 2, 13, 1590738989000 ] + - [ "bb", 21, 131, 1590738990000 ] + - id: 9 + desc: Last Join 无order by, 拼表条件命中部分的组合索引(前缀索引) + mode: offline-unsupport + inputs: + - columns: ["id int", "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ 1,"aa",2,3,1590738989000 ] + - [ 2,"aa",20,30,1590738991000 ] + - [ 3,"bb",21,31,1590738990000 ] + - [ 4,"dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1|c2:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",3,14,1590738990000 ] + - [ "aa",4,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.id,{0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1 and {0}.c4={1}.c4; + expect: + order: id + columns: [ "id int","c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [1, "aa", 2, 13, 1590738989000 ] + - [2, "aa", 20, 15, 1590738991000 ] + - [3, "bb", 21, 131, 1590738990000 ] + - [4, "dd", 41, null, null ] + - id: 10 + desc: Last Join 无order by, 拼表条件命中部分的组合索引(后缀索引) + mode: offline-unsupport + inputs: + - columns: [ "id int","c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ 1,"aa",2,3,1590738989000 ] + - [ 2,"aa",20,30,1590738991000 ] + - [ 3,"bb",21,31,1590738990000 ] + - [ 4,"dd",41,51,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2|c1:c4" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "aa",3,14,1590738990000 ] + - [ "aa",4,15,1590738991000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,121,1590738991000 ] + sql: select {0}.id,{0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} on {0}.c1={1}.c1 and {0}.c4={1}.c4; + expect: + order: id + columns: [ "id int","c1 string", "c2 int", "c3 bigint", "c4 timestamp" ] + rows: + - [1, "aa", 2, 13, 1590738989000 ] + - [2, "aa", 20, 15, 1590738991000 ] + - [3, "bb", 21, 131, 1590738990000 ] + - [4, "dd", 41, null, null ] + - id: 11 + desc: 不等值拼接-未命中索引 + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c2:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "bb",21,31,1590738990000 ] + - [ "bb",21,32,1590738993000 ] + - [ "bb",21,31,1590738992000 ] + - [ "bb",21,31,1590738991000 ] + sql: select {0}.c1,{0}.c2,{1}.c3,{1}.c4 from {0} last join {1} ORDER BY {1}.c4 on {0}.c3<{1}.c3; + expect: + columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + order: c1 + rows: + - [ "aa",2,32,1590738993000 ] + - [ "bb",21,32,1590738993000 ] + - id: 12 + desc: 两个子查询lastjoin-子查询带窗口特征-没有使用索引-不带orderby + mode: offline-unsupport + tags: ["offline-unsupport, @chendihao", "离线结果不对"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-02"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-02"] + sql: | + select id,t2.c1,t2.c3,t1.c4, t2.w2_c3_sum, t1.w3_c4_sum from + (select id,c1,c3,c4,c7,c8,sum({0}.c3) OVER w2 as w2_c3_sum from {0} WINDOW w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)) as t2 + last join (select c1,c4,c7,c8,sum({0}.c4) OVER w3 as w3_c4_sum from {0} WINDOW w3 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 1 PRECEDING AND CURRENT ROW)) as t1 + on t2.c8=t1.c8 + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint", "w2_c3_sum int", "w3_c4_sum bigint"] + rows: + - [1,"aa",20,30, 20, 30] + - [2,"aa",21,31, 41, 30] + - [3,"aa",22,32, 63, 33] + - [4,"bb",23,33, 23, 33] + - [5,"bb",24,34, 47, 33] + - + id: 14 + desc: rows-float为partition by-未命中索引 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.1,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.1,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.2,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c5, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c5 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 15 + desc: rows-double为partition by-未命中索引 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c6, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c6 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 16 + desc: rows-int为partition by-未命中索引 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [2,"bb",20,61] + - [3,"cc",20,93] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 17 + desc: rows_range-float为partition by-未命中索引 + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.1,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.1,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.1,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.2,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c5, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c5 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 18 + desc: rows_range-double为partition by-未命中索引 + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c6, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c6 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 19 + desc: rows_range-int为partition by-未命中索引 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [2,"bb",20,61] + - [3,"cc",20,93] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 20 + desc: 样本表使用索引,UNION表未命中索引 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] \ No newline at end of file diff --git a/cases/integration_test/tmp/test_current_time.yaml b/cases/integration_test/tmp/test_current_time.yaml new file mode 100644 index 00000000000..528113cf3e5 --- /dev/null +++ b/cases/integration_test/tmp/test_current_time.yaml @@ -0,0 +1,106 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +cases: + - id: 0 + desc: ts列的值为0 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,0,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,0,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,30 ] + - [ "aa",21,31 ] + - [ "aa",22,32 ] + - [ "aa",23,33 ] + - [ "bb",24,34 ] + - id: 1 + desc: ts列的值为0 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,0,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 0s OPEN PRECEDING EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,null ] + - [ "aa",23,32 ] + - [ "bb",24,null ] + - id: 2 + desc: ts列的值为-1 + tags: ["TODO","ts为负数有问题,带支持后再验证"] + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 bigint","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,-1,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,-1,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,-1,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,30 ] + - [ "aa",21,31 ] + - [ "aa",22,32 ] + - [ "aa",23,33 ] + - [ "bb",24,34 ] +# - id: 2 +# desc: ts列的值为1 +# inputs: +# - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 bigint","c8 date" ] +# indexs: [ "index1:c1:c7" ] +# rows: +# - [ "aa",20,30,1.1,2.1,1,"2020-05-01" ] +# - [ "aa",21,31,1.2,2.2,1,"2020-05-02" ] +# - [ "aa",22,32,1.3,2.3,1,"2020-05-03" ] +# - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] +# - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] +# sql: | +# SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); +# expect: +# order: c3 +# columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] +# rows: +# - [ "aa",20,30 ] +# - [ "aa",21,31 ] +# - [ "aa",22,32 ] +# - [ "aa",23,33 ] +# - [ "bb",24,34 ] diff --git a/cases/integration_test/ut_case/test_unique_expect.yaml b/cases/integration_test/ut_case/test_unique_expect.yaml new file mode 100644 index 00000000000..61865e1a2f0 --- /dev/null +++ b/cases/integration_test/ut_case/test_unique_expect.yaml @@ -0,0 +1,56 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +cases: + - + id: 0 + desc: ts乱序 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3) + ; + unequalExpect: + batch_expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + request_expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",32] + - [4,"aa",33] + - [5,"aa",99] diff --git a/cases/integration_test/v040/test_execute_mode.yaml b/cases/integration_test/v040/test_execute_mode.yaml new file mode 100644 index 00000000000..dabae313d0d --- /dev/null +++ b/cases/integration_test/v040/test_execute_mode.yaml @@ -0,0 +1,81 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +cases: + - + id: 0 + desc: 测试EXECUTE_MODE=online + sqls: + - set @@SESSION.execute_mode="online"; + - show variables; + expect: + columns: ["Variable_name string","Value string"] + rows: + - ["execute_mode","online"] + - + id: 1 + desc: EXECUTE_MODE=offline + sqls: + - set @@SESSION.execute_mode="offline"; + - show variables; + expect: + columns: ["Variable_name","Value"] + rows: + - ["execute_mode","offline"] + - + id: 2 + desc: EXECUTE_MODE为其他字符 + sqls: + - set @@SESSION.execute_olol = "offline"; + - show variables; + expect: + success: false + - + id: 3 + desc: EXECUTE_MODE为小写 + sqls: + - set @@SESSION.execute_mode = "online"; + - show variables; + expect: + success: false + - + id: 4 + desc: EXECUTE_MODE=online,创建表,insert数据,并查询 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + sqls: + - set @@SESSION.execute_mode = "online"; + - insert into {0} value ("aa",1,2,1590738989000); + - select * from {0}; + expect: + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + - + id: 5 + desc: EXECUTE_MODE=offline,创建表,insert数据,并查询 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + sqls: + - set @@SESSION.execute_mode = "offline"; + - insert into {0} values ("bb",2,3,1590738989000); + - select * from {0}; + expect: + colunms: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["bb",2,3,1590738989000] \ No newline at end of file diff --git a/cases/integration_test/v040/test_groupby.yaml b/cases/integration_test/v040/test_groupby.yaml new file mode 100644 index 00000000000..7150588bedd --- /dev/null +++ b/cases/integration_test/v040/test_groupby.yaml @@ -0,0 +1,560 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +sqlDialect: ["HybridSQL"] +cases: + - id: 0 + desc: "group by一个索引列" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 string","v1 bigint"] + rows: + - ["aa",2] + - ["bb",2] + - ["a%",1] + - id: 1 + desc: "group by一个非索引列" + mode: request-unsupport + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 string","v1 bigint"] + rows: + - ["aa",2] + - ["bb",2] + - ["a%",1] + - id: 2 + desc: "group by 两个列,组合索引" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1,c2:c7"] + rows: + - [1,"aa",11,1590738990000] + - [2,"bb",11,1590738991000] + - [3,"aa",12,1590738992000] + - [4,"a%",11,1590738993000] + - [5,"bb",11,1590738994000] + - [6,"aa",11,1590738995000] + sql: select c1,c2,count(*) as v1 from {0} group by c1,c2; + expect: + order: c1 + columns: ["c1 string","c2 int","v1 bigint"] + rows: + - ["aa",11,2] + - ["bb",11,2] + - ["a%",11,1] + - ["aa",12,1] + - id: 3 + desc: "group by int类型" + inputs: + - + columns : ["id bigint","c1 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,11,1590738990000] + - [2,22,1590738991000] + - [3,11,1590738992000] + - [4,33,1590738993000] + - [5,22,1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 int","v1 bigint"] + rows: + - [11,2] + - [22,2] + - [33,1] + - id: 4 + desc: "group by bigint类型" + inputs: + - + columns : ["id bigint","c1 bigint","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,11,1590738990000] + - [2,22,1590738991000] + - [3,11,1590738992000] + - [4,33,1590738993000] + - [5,22,1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 bigint","v1 bigint"] + rows: + - [11,2] + - [22,2] + - [33,1] + - id: 5 + desc: "group by smallint类型" + inputs: + - + columns : ["id bigint","c1 smallint","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,11,1590738990000] + - [2,22,1590738991000] + - [3,11,1590738992000] + - [4,33,1590738993000] + - [5,22,1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 smallint","v1 bigint"] + rows: + - [11,2] + - [22,2] + - [33,1] + - id: 6 + desc: "group by float类型" + mode: request-unsupport + inputs: + - + columns: ["id bigint","c1 float","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,11.1,1590738990000] + - [2,22.1,1590738991000] + - [3,11.1,1590738992000] + - [4,33.1,1590738993000] + - [5,22.1,1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + success: false + - id: 7 + desc: "group by double类型" + mode: request-unsupport + inputs: + - + columns : ["id bigint","c1 double","c7 timestamp"] + indexs: ["index1:id:c7"] + rows: + - [1,11.1,1590738990000] + - [2,22.1,1590738991000] + - [3,11.1,1590738992000] + - [4,33.1,1590738993000] + - [5,22.1,1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + success: false + - id: 8 + desc: "group by date类型" + inputs: + - + columns : ["id bigint","c1 date","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"2020-05-01",1590738990000] + - [2,"2020-05-02",1590738991000] + - [3,"2020-05-01",1590738992000] + - [4,"2020-05-03",1590738993000] + - [5,"2020-05-02",1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 date","v1 bigint"] + rows: + - ["2020-05-01",2] + - ["2020-05-02",2] + - ["2020-05-03",1] + - id: 9 + desc: "group by timestamp类型" + inputs: + - + columns : ["id bigint","c1 timestamp","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,11,1590738990000] + - [2,22,1590738991000] + - [3,11,1590738992000] + - [4,33,1590738993000] + - [5,22,1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 timestamp","v1 bigint"] + rows: + - [11,2] + - [22,2] + - [33,1] + - id: 10 + desc: "group by bool类型" + inputs: + - + columns : ["id bigint","c1 bool","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,true,1590738990000] + - [2,false,1590738991000] + - [3,false,1590738992000] + - [4,true,1590738993000] + - [5,true,1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 bool","v1 bigint"] + rows: + - [true,3] + - [false,2] + - id: 11 + desc: "列有空串和null" + mode: cli-unsupport + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"",1590738990000] + - [2,null,1590738991000] + - [3,"",1590738992000] + - [4,"a%",1590738993000] + - [5,null,1590738994000] + sql: select c1,count(*) as v1 from {0} group by c1; + expect: + order: c1 + columns: ["c1 string","v1 bigint"] + rows: + - ["",2] + - [null,2] + - ["a%",1] + - id: 12 + desc: "group by 两个列,其中一个列有索引" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1,c2:c7"] + rows: + - [1,"aa",11,1590738990000] + - [2,"bb",11,1590738991000] + - [3,"aa",12,1590738992000] + - [4,"a%",11,1590738993000] + - [5,"bb",11,1590738994000] + - [6,"aa",11,1590738995000] + sql: select c1,c2,count(*) as v1 from {0} group by c1,c2; + expect: + order: c1 + columns: ["c1 string","c2 int","v1 bigint"] + rows: + - ["aa",11,2] + - ["bb",11,2] + - ["a%",11,1] + - ["aa",12,1] + - id: 13 + desc: "group by 两个列,两个索引" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7","index2:c2:c7"] + rows: + - [1,"aa",11,1590738990000] + - [2,"bb",11,1590738991000] + - [3,"aa",12,1590738992000] + - [4,"a%",11,1590738993000] + - [5,"bb",11,1590738994000] + - [6,"aa",11,1590738995000] + sql: select c1,c2,count(*) as v1 from {0} group by c1,c2; + expect: + columns: ["c1 string","c2 int","v1 bigint"] + rows: + - ["aa",12,1] + - ["bb",11,2] + - ["aa",11,2] + - ["a%",11,1] + + - id: 14 + desc: "select的列不在group by后面" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select id,c1,count(*) as v1 from {0} group by c1; + expect: + success: false + - id: 15 + desc: "group by结合count/sum/max/min/avg" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1590738990000] + - [2,"bb",2,1590738991000] + - [3,"aa",3,1590738992000] + - [4,"cc",4,1590738993000] + - [5,"bb",5,1590738994000] + - [6,"aa",6,1590738995000] + sql: select c1,count(c2) as v1,max(c2) as v2,min(c2) as v3,avg(c2) as v4,sum(c2) as v5 from {0} group by c1; + expect: + order: c1 + columns: ["c1 string","v1 bigint","v2 int","v3 int","v4 double","v5 int"] + rows: + - ["aa",3,6,1,3.333333,10] + - ["bb",2,5,2,3.5,7] + - ["cc",1,4,4,4,4] + - id: 16 + desc: "select的列不在group by后面" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select c2,count(*) as v1 from {0} group by c2; + expect: + success: false + - id: 17 + desc: "group by结合having" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1590738990000] + - [2,"bb",2,1590738991000] + - [3,"aa",3,1590738992000] + - [4,"cc",4,1590738993000] + - [5,"bb",5,1590738994000] + - [6,"aa",6,1590738995000] + sql: select c1,count(c2) as v1 from {0} group by c1 having count(c2)>1; + expect: + order: c1 + columns: ["c1 string","v1 bigint"] + rows: + - ["aa",3] + - ["bb",2] + - id: 18 + desc: "group by结合having,使用别名" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1590738990000] + - [2,"bb",2,1590738991000] + - [3,"aa",3,1590738992000] + - [4,"cc",4,1590738993000] + - [5,"bb",5,1590738994000] + - [6,"aa",6,1590738995000] + sql: select c1,count(c2) as v1 from {0} group by c1 having v1>1; + expect: + success: false + - id: 19 + desc: "group by使用where根据粗函数筛选" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1590738990000] + - [2,"bb",2,1590738991000] + - [3,"aa",3,1590738992000] + - [4,"cc",4,1590738993000] + - [5,"bb",5,1590738994000] + - [6,"aa",6,1590738995000] + sql: select c1,count(c2) as v1 from {0} group by c1 where count(c2)>1; + expect: + success: false + - id: 20 + desc: "group by结合where" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1590738990000] + - [2,"bb",2,1590738991000] + - [3,"aa",3,1590738992000] + - [4,"cc",4,1590738993000] + - [5,"bb",5,1590738994000] + - [6,"aa",6,1590738995000] + sql: select c1,count(c2) as v1 from {0} group by c1 where c1='aa'; + expect: + success: false + - id: 21 + desc: lastjoin后group by + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "bb",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select {0}.c1,sum({1}.c3) as v1 from {0} last join {1} ORDER BY {1}.c3 on {0}.c1={1}.c1 group by {0}.c1; + expect: + order: c1 + columns: [ "c1 string","v1 bigint"] + rows: + - [ "aa",26 ] + - [ "cc",151 ] + - id: 22 + desc: group by在lastjoin + mode: request-unsupport + inputs: + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c4" ] + rows: + - [ "aa",2,3,1590738989000 ] + - [ "aa",21,31,1590738990000 ] + - [ "cc",41,51,1590738991000 ] + - columns: [ "c1 string","c2 int","c3 bigint","c4 timestamp" ] + indexs: [ "index1:c1:c3" ] + rows: + - [ "aa",2,13,1590738989000 ] + - [ "cc",21,131,1590738990000 ] + - [ "cc",41,151,1590738992000 ] + sql: select t1.c1,t1.v1,t2.v1 from (select c1,sum(c2) as v1 from {0} group by c1) as t1 last join (select c1,sum(c2) as v1 from {1} group by c1) as t2 on t1.c1=t2.c1; + expect: + order: c1 + columns: [ "c1 string","v1 int","v1 int"] + rows: + - [ "aa",23,2 ] + - [ "cc",41,62 ] + - + id: 23 + desc: winhow后group by + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, max(sum(c4) OVER w1) as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) group by c1; + expect: + success: false + - id: 24 + desc: "子查询后group by" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select c1,count(*) as v1 from (select * from {0}) as t group by c1; + expect: + order: c1 + columns: ["c1 string","v1 bigint"] + rows: + - ["aa",2] + - ["bb",2] + - ["a%",1] + - id: 25 + desc: "group by后在子查询" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select * from (select c1,count(*) as v1 from {0} group by c1); + expect: + order: c1 + columns: ["c1 string","v1 bigint"] + rows: + - ["aa",2] + - ["bb",2] + - ["a%",1] + - id: 26 + desc: "group by where后面使用组函数别名" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1590738990000] + - [2,"bb",2,1590738991000] + - [3,"aa",3,1590738992000] + - [4,"cc",4,1590738993000] + - [5,"bb",5,1590738994000] + - [6,"aa",6,1590738995000] + sql: select c1,count(c2) as v1 from {0} group by c1 where v1>1; + expect: + success: false + - id: 27 + desc: "group by后在子查询,使用where" + mode: request-unsupport + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select * from (select c1,count(*) as v1 from {0} group by c1) where v1=2; + expect: + order: c1 + columns: ["c1 string","v1 bigint"] + rows: + - ["aa",2] + - ["bb",2] + + + + + diff --git a/cases/integration_test/v040/test_job.yaml b/cases/integration_test/v040/test_job.yaml new file mode 100644 index 00000000000..74b6a0fd4a4 --- /dev/null +++ b/cases/integration_test/v040/test_job.yaml @@ -0,0 +1,176 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debus: [] +cases: + - + id: 0 + desc: show jobs + sqls: + - use __INTERNAL_DB; + - set @@SESSION.execute_mode = "offline"; + - insert into JOB_INFO values (1,'SparkBatchSql','Running',11111,22222,'','local','application_1111',''); + - show jobs; + expects: + columns: ["JOBID string","JOB_TYPE string","STATUS string"] + rows: + - ["JOB-11220021","OFFLINE LOAD","RUNNING"] + - + id: 1 + desc: showjobs + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - use test_zw; + - set @@SESSION.execute_mode = "offline"; + - insert into JOB_INFO values (1,'SparkBatchSql','Running',11111,22222,'','local','application_1111',''); + - showjobs; + expects: + success: false + - + id: 2 + desc: 切换不同的db,show jobs + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - use test_zw; + - set @@SESSION.execute_mode = "offline"; + - insert into JOB_INFO values (1,'SparkBatchSql','Running',11111,22222,'','local','application_1111',''); + - use other_db; + - show jobs; + expects: + columns: ["JOBID string","JOB_TYPE string","STATUS string"] + rows: + - ["JOB-11220021","OFFLINE LOAD","RUNNING"] + - + id: 3 + desc: show job jobID + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - insert into JOB_INFO values (1,'SparkBatchSql','Running',11111,22222,'','local','application_1111',''); + - show job 1; + expects: + columns: ["JOBID string","JOB_TYPE string","URL string","CONTENT string"] + rows: + - ["JOB-11220021","OFFLINE LOAD","xxxx","LOAD DATA INFILE"] + - + id: 4 + desc: jobID不存在 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + insert into JOB_INFO values (1,'SparkBatchSql','Running',11111,22222,'','local','application_1111',''); + - show job 1111; + expects: + - + id: 5 + desc: 语法错误 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - insert into JOB_INFO values (1,'SparkBatchSql','Running',11111,22222,'','local','application_1111',''); + - show jobe 1; + expects: + success: false + - + id: 6 + desc: delete job jobID + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - delete job JOB-11220021; + expects: + - + id: 7 + desc: jobID不存在 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - delete job JOB-xxxxxx; + expects: + - + id: 8 + desc: 语法错误 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - delete jobe JOB-11220021; + expects: + - + id: 9 + desc: stop job jobID + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - set @@SESSION.execute_mode="offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table test_smoke options(deep_copy=true,mode='append'); + - stop job JOB-11220021; + expects: + columns: ["id int","job_state string","state string","start_time timestamp","end_time timestamp","parameter string","cluster string","application_id string","error string"] + rows: + - [1,"ImportOfflineData","STOPPED","","","load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table test_smoke options(deep_copy=true,mode='append');", + "local","local-1640683224470",""] + - + id: 10 + desc: jobID不存在 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - stop job JOB-xxxxxx; + expects: + success: false + - + id: 11 + desc: 语法错误 + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - stop jobe JOB-11220021; + expects: + success: false; \ No newline at end of file diff --git a/cases/integration_test/v040/test_load_data.yaml b/cases/integration_test/v040/test_load_data.yaml new file mode 100644 index 00000000000..41a446a8e76 --- /dev/null +++ b/cases/integration_test/v040/test_load_data.yaml @@ -0,0 +1,467 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +db: test_zw +debugs: [] +cases: + - + id: 0 + desc: Load data 集群版,EXECUTE_MODE=online,load parquet文件 + inputs: + - + columns: ["id int","job_state string","state string","start_time timestamp","end_time timestamp","parameter string","cluster string","application_id string","error string"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp timestamp, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "online"; + - LOAD DATA INFILE 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/user/zhaowei/openmldb/load_data/parquet' INTO TABLE {0}; + - SHOW JOBS; + expect: + columns: ["id int","job_state string","state string","start_time timestamp","end_time timestamp","parameter string","cluster string","application_id string","error string"] + + - + id: 1 + desc: 集群版,EXECUTE_MODE=offline,load parquet文件 + inputs: + - + columns: ["id int","job_state string","state string","start_time timestamp","end_time timestamp","parameter string","cluster string","application_id string","error string"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp timestamp, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - LOAD DATA INFILE 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/user/zhaowei/openmldb/load_data/parquet' INTO TABLE {0} options(format='parquet',foo='bar',deep_copy=false,header=false,mode='append'); + - SHOW JOBS; + expect: + + + - + id: 2 + desc: 集群版,EXECUTE_MODE=online,load csv文件,mode默认不写 + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "online"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0}; + - SHOW JOBS; + expect: + columns: ["id int","job_state string","state string","start_time timestamp","end_time timestamp","parameter string","cluster string","application_id string","error string"] + rows: + - [1,"ImportOfflineData","FINISHED","","","load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table test_smoke options(deep_copy=true,mode='append');", + "local","local-1640683224470",""] + - + id: 3 + desc: 集群版,execute_mode=online, load csv文件,mode=append + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "online"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(mode='append'); + - SHOW JOBS; + expect: + + - + id: 4 + desc: 集群版,execute_mode=online, load csv文件,mode=overwrite + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "online"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(mode='overwrite'); + - SHOW JOBS; + expect: + - + id: 5 + desc: 集群版,集群版 execute_mode=offline, load csv文件,deep_copy=true, mode默认不写,如果文件不存在 + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(deep_copy=true); + - SHOW JOBS; + expect: + + - + id: 6 + desc: 集群版 execute_mode=offline, load csv文件,deep_copy=true, mode默认不写,如果文件存在 + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(deep_copy=true); + - SHOW JOBS; + expect: + + - + id: 7 + desc: 集群版 execute_mode=offline, load csv文件, deep_copy=true, mode=append + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(deep_copy=true,mode='append'); + - SHOW JOBS; + expect: + - + id: 8 + desc: 集群版 execute_mode=offline, load csv文件, deep_copy=true, mode=overwrite + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(deep_copy=true,mode='overwrite'); + - SHOW JOBS; + expect: + - + id: 9 + desc: 集群版 execute_mode=offline, load csv文件, deep_copy=false, mode=append + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(deep_copy=false,mode='append'); + - SHOW JOBS; + expect: + - + id: 10 + desc: 集群版 execute_mode=offline, load csv文件, deep_copy=false, mode=overwrite + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(deep_copy=false,mode='overwrite'); + - desc {0}; + expect: + - + id: 11 + desc: 集群版 execute_mode=offline, load csv文件, deep_copy=false,mode默认不写,没有load + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(deep_copy=false); + - desc {0}; + expect: + - + id: 12 + desc: 集群版 execute_mode=offline, load csv文件, deep_copy=false,mode默认不写,已经load过 + inputs: + - + columns: ["id int","c1_smallint smallint","c2_int int","c3_bigint bigint","c4_float float","c5_double double","c6_string string","c7_timestamp bigint","c8_date date","c9_bool bool"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp bigint, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - load data infile 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/csv-import-10000-1.csv' into table {0} options(deep_copy=false); + - desc {0}; + expect: + + + + + + + + + + + + + + + + + + + + + + + - + id: 4 + desc: 集群版,EXECUTE_MODE=offline,load parquet文件,method=duplicate + inputs: + - + columns: ["id int","job_state string","state string","start_time timestamp","end_time timestamp","parameter string","cluster string","application_id string","error string"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp timestamp, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - LOAD DATA INFILE 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/user/zhaowei/openmldb/load_data/parquet' INTO TABLE {0} options(format='parquet',foo='bar',deep_copy=false,header=false,mode='duplicate'); + - SHOW JOBS; + expect: + - + id: 5 + desc: 集群版,EXECUTE_MODE=online,load parquet文件,method=duplicate + inputs: + - + columns: ["id int","job_state string","state string","start_time timestamp","end_time timestamp","parameter string","cluster string","application_id string","error string"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp timestamp, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "online"; + - LOAD DATA INFILE 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/user/zhaowei/openmldb/load_data/parquet' INTO TABLE {0} options(format='parquet',foo='bar',deep_copy=false,header=false,mode='duplicate'); + - SHOW JOBS; + expect: + - + id: 6 + desc: 集群版,EXECUTE_MODE=offline,load parquet文件,method=symbolic_link + inputs: + - + columns: ["id int","job_state string","state string","start_time timestamp","end_time timestamp","parameter string","cluster string","application_id string","error string"] + create: | + create table {0}( + id int, + c1_smallint smallint, + c2_int int, + c3_bigint bigint, + c4_float float, + c5_double double, + c6_string string, + c7_timestamp timestamp, + c8_date date, + c9_bool bool, + index(key=c6_string,ts=c7_timestamp,ttl=0m,ttl_type=absolute) + )options(partitionnum = 1,replicanum = 1); + sqls: + - set @@SESSION.execute_mode = "offline"; + - LOAD DATA INFILE 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/user/zhaowei/openmldb/load_data/parquet' INTO TABLE {0} options(format='parquet',deep_copy=false); + - SHOW JOBS; + expect: + - + id: 7 + desc: 集群版,EXECUTE_MODE=online,load parquet文件,method=symbolic_link + inputs: + - + columns: ["c1 string","c2 smallint","c3 int","c4 timestamp"] + rows: + - ["aa",1,2,1590738989000] + sqls: + - set @@SESSION.execute_mode = "online"; + - LOAD DATA INFILE 'hdfs://m7-common-cdh02:8022/user/zhaowei/openmldb/load_data/user/zhaowei/openmldb/load_data/parquet' INTO TABLE {0} options(format='parquet',foo='bar',deep_copy=false,header=false,mode='symbolic_link'); + - SHOW JOBS; + expect: + + + diff --git a/cases/integration_test/v040/test_out_in_offline.yaml b/cases/integration_test/v040/test_out_in_offline.yaml new file mode 100644 index 00000000000..9edd35ebf00 --- /dev/null +++ b/cases/integration_test/v040/test_out_in_offline.yaml @@ -0,0 +1,894 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: ["数据里有null、空串、特殊字符"] +cases: + - + id: 0 + desc: 数据里有null、空串、特殊字符 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [4,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [5,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - [6,"~!@#$%^&*()_+<",3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] +# - +# columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] +# indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; +# - load data infile '{0}.csv' into table {1}; +# - select * from {1}; + expect: + count: 6 + - + id: 1 + desc: 全部数据类型测试 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 2 + desc: 复杂sql结果导出 + inputs: + - + columns : ["id int", "card_no string","merchant_id int", "trx_time timestamp", "trx_amt float"] + indexs: ["index1:card_no:trx_time"] + rows: + - [1, "aaaaaaaaaa",1, 1590738989000, 1.1] + - [2, "aaaaaaaaaa",1, 1590738990000, 2.2] + - [3, "bb",10, 1590738990000, 3.3] + - + columns : ["crd_lst_isu_dte timestamp", "crd_nbr string"] + indexs: ["index2:crd_nbr:crd_lst_isu_dte"] + rows: + - [1590738988000, "aaaaaaaaaa"] + - [1590738990000, "aaaaaaaaaa"] + - [1590738989000, "cc"] + - [1590738992000, "cc"] + - + columns: ["id int", "card_no string", "trx_time timestamp", "card_no_prefix string","sum_trx_amt float", "count_merchant_id int64", "crd_lst_isu_dte timestamp","crd_nbr string"] + sqls: + - select * from + (select + id, + card_no, + trx_time, + substr(card_no, 1, 6) as card_no_prefix, + sum(trx_amt) over w30d as sum_trx_amt, + count(merchant_id) over w10d as count_merchant_id + from {0} + window w30d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 30d PRECEDING AND CURRENT ROW), + w10d as (PARTITION BY {0}.card_no ORDER BY {0}.trx_time ROWS_RANGE BETWEEN 10d PRECEDING AND CURRENT ROW)) as trx_fe + last join {1} order by {1}.crd_lst_isu_dte on trx_fe.card_no = {1}.crd_nbr and trx_fe.trx_time >= {1}.crd_lst_isu_dte + into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {2}; + - select * from {2}; + expect: + columns: ["id int", "card_no string", "trx_time timestamp", "card_no_prefix string","sum_trx_amt float", "count_merchant_id int64", "crd_lst_isu_dte timestamp","crd_nbr string"] + order: id + rows: + - [1, "aaaaaaaaaa", 1590738989000, "aaaaaa", 1.1, 1, 1590738988000, "aaaaaaaaaa"] + - [2, "aaaaaaaaaa", 1590738990000, "aaaaaa", 3.3, 2, 1590738990000, "aaaaaaaaaa"] + - [3, "bb", 1590738990000, "bb", 3.3, 1, null, null] + - + id: 3 + desc: 全部数据类型测试 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 4 + desc: 执行其他库查询 + inputs: + - + db: db1 + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from db1.{0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 5 + desc: 导出insert结果 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + sqls: + - insert into {0} values (1,"aa",1590738989000) outfile '{0}.csv'; + expect: + success: false + - + id: 6 + desc: sql执行错误 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from db1.{0} into outfile '{0}.csv'; + expect: + success: false + - + id: 7 + desc: mode默认值,文件已经存在 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {0} into outfile '{0}.csv'; + expect: + success: false + - + id: 8 + desc: mode=overwrite,先到处大数据量,再到处小数据量 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {1} into outfile '{0}.csv' options(mode='overwrite'); + - load data infile '{0}.csv' into table {2}; + - select * from {2}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - + id: 9 + desc: mode=append,相同的表到处两次 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {0} into outfile '{0}.csv' options(mode='append',header=false); + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 10 + desc: mode=append,不同的表导出,第二次header=false + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {1} into outfile '{0}.csv' options(mode='append',header=false); + - load data infile '{0}.csv' into table {2}; + - select * from {2}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 11 + desc: mode=append,不同的表导出,第二次header=true + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - select * from {1} into outfile '{0}.csv' options(mode='append',header=true); + expect: + cat: + path: "{0}.csv" + lines: + - id,c1,c2,c3,c4,c5,c6,c7,c8,c9 + - 1,aa,1,2,3,1.100000,2.100000,1590738989000,2020-05-01,true + - 2,bb,2,21,31,1.200000,2.200000,1590738990000,2020-05-02,false + - id,c1,c2,c3,c4,c5,c6,c7,c8,c9 + - 3,cc,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - + id: 12 + desc: option key错误 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv' options(head=true); + expect: + success: false + - + id: 13 + desc: option header 值错误 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv' options(header='true'); + expect: + success: false + - + id: 14 + desc: format 其他格式 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv' options(format='txt'); + expect: + success: false + - + id: 15 + desc: delimiter为一些特殊字符 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(delimiter='@'); + - load data infile '{0}.csv' into table {1} options(delimiter='@'); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 16 + desc: null_value为特殊字符 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value='~!@#$%^&*()_+'); + - load data infile '{0}.csv' into table {1} options(null_value='~!@#$%^&*()_+'); + - select * from {1}; + expect: + count: 3 + - + id: 17 + desc: String 有null 空串 ”null“ null_value为”“ + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [4,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [5,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - [6,"~!@#$%^&*()_+<",3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value=''); + expect: + cat: + path: "{0}.csv" + lines: + - id,c1,c2,c3,c4,c5,c6,c7,c8,c9 + - 3,,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - 5,,3,22,32,1.300000,2.300000,1590738991000,2020-05-03, + - 4,,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - 1,aa,1,2,3,1.100000,2.100000,1590738989000,2020-05-01,true + - 6,~!@#$%^&*()_+<,3,22,32,1.300000,2.300000,1590738991000,2020-05-03, + - 2,null,2,21,31,1.200000,2.200000,1590738990000,2020-05-02,false + - + id: 18 + desc: String 有null 空串 ”null“ null_value为”null“ + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [4,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [5,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - [6,"~!@#$%^&*()_+<",3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value='null'); + expect: + cat: + path: "{0}.csv" + lines: + - id,c1,c2,c3,c4,c5,c6,c7,c8,c9 + - 3,,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - 5,null,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,null + - 4,null,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,true + - 1,aa,1,2,3,1.100000,2.100000,1590738989000,2020-05-01,true + - 6,~!@#$%^&*()_+<,3,22,32,1.300000,2.300000,1590738991000,2020-05-03,null + - 2,null,2,21,31,1.200000,2.200000,1590738990000,2020-05-02,false + - + id: 19 + desc: header=false导出数据 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=false); + - load data infile '{0}.csv' into table {1} options(header=false); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 20 + desc: format=csv,导出数据 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(format='csv'); + - load data infile '{0}.csv' into table {1} options(format='csv'); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 21 + desc: 路径文件夹不存在 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '/{0}/{0}.csv'; + expect: + success: false + - + id: 22 + desc: 数据类型不匹配 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 int","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + expect: + success: false + - + id: 23 + desc: header=true导出数据 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=true); + - load data infile '{0}.csv' into table {1} options(header=true); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 24 + desc: header=true,csv没有header + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=false); + - load data infile '{0}.csv' into table {1} options(header=true); + expect: + success: false + - + id: 25 + desc: header=false,csv有header + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=true); + - load data infile '{0}.csv' into table {1} options(header=false); + expect: + success: false + - + id: 26 + desc: 表不存在 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(header=true); + - load data infile '{0}.csv' into table {1}11 options(header=true); + expect: + success: false + - + id: 27 + desc: format=csv,csv格式的文件,文件名不是csv结尾 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.txt' ; + - load data infile '{0}.txt' into table {1} options(format='csv'); + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 28 + desc: format=其他值 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1} options(format='txt'); + expect: + success: false + - + id: 29 + desc: 路径错误 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}1.csv' into table {1}; + expect: + success: false + - + id: 30 + desc: 导入其他库的表 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + db: db1 + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table db1.{1}; + - select * from db1.{1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 31 + desc: 导出后导入 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {0}; + - select * from {0}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 32 + desc: 创建表的列和csv对不上 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","cc smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}1.csv' into table {1}; + expect: + success: false + - + id: 33 + desc: 表中已经有数据,然后导入 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + order: id + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"bb",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + id: 34 + desc: delimiter为,数据中有, + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"b,b",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,"cc",3,22,32,1.3,2.3,1590738991000,"2020-05-03",true] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1} options(delimiter=','); + expect: + success: false + - + id: 35 + desc: 导入-null_value=null + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value='null'); + - load data infile '{0}.csv' into table {1} options(null_value='null'); + - select * from {1}; + expect: + count: 3 + - + id: 36 + desc: 导入-null_value=空串 + inputs: + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,2,3,1.1,2.1,1590738989000,"2020-05-01",true] + - [2,"null",2,21,31,1.2,2.2,1590738990000,"2020-05-02",false] + - [3,null,3,22,32,1.3,2.3,1590738991000,"2020-05-03",null] + - + columns : ["id int","c1 string","c2 smallint","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 bool"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv' options(null_value=''); + - load data infile '{0}.csv' into table {1} options(null_value=''); + - select * from {1}; + expect: + count: 3 + - + id: 37 + desc: 表删除后再次导入 +# tags: ["TODO","下个版本修复,@huangwei"] + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + - [2,"bb",1590738990000] + - [3,"cc",1590738991000] + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + sqls: + - select * from {0} into outfile '{0}.csv'; + - load data infile '{0}.csv' into table {1}; + - drop table {1}; + - create table {1}( + id int, + c1 string, + c7 timestamp, + index(key=(c1),ts=c7))options(partitionnum=1,replicanum=1); + - load data infile '{0}.csv' into table {1}; + - select * from {1}; + expect: + columns : ["id int","c1 string","c7 timestamp"] + order: id + rows: + - [1,"aa",1590738989000] + - [2,"bb",1590738990000] + - [3,"cc",1590738991000] + - + id: 38 + desc: mode 值错误 + inputs: + - + columns : ["id int","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738989000] + sqls: + - select * from {0} into outfile '{0}.csv' options(mode='true'); + expect: + success: false + + + diff --git a/cases/integration_test/v040/test_udaf.yaml b/cases/integration_test/v040/test_udaf.yaml new file mode 100644 index 00000000000..fee7f58b800 --- /dev/null +++ b/cases/integration_test/v040/test_udaf.yaml @@ -0,0 +1,108 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +sqlDialect: ["HybridSQL"] +cases: + - id: 0 + desc: "count(*)" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select count(*) as v1 from {0}; + expect: + columns: ["v1 bigint"] + rows: + - [5] + - id: 1 + desc: "count(1)" + inputs: + - + columns : ["id bigint","c1 string","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1590738990000] + - [2,"bb",1590738991000] + - [3,"aa",1590738992000] + - [4,"a%",1590738993000] + - [5,"bb",1590738994000] + sql: select count(1) as v1 from {0}; + expect: + success: false + - id: 2 + desc: "count/sum/max/min/avg一个列" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1590738990000] + - [2,"bb",2,1590738991000] + - [3,"aa",3,1590738992000] + - [4,"cc",4,1590738993000] + - [5,"bb",5,1590738994000] + - [6,"aa",6,1590738995000] + sql: select count(c2) as v1,max(c2) as v2,min(c2) as v3,avg(c2) as v4,sum(c2) as v5 from {0}; + expect: + order: c1 + columns: ["v1 bigint","v2 int","v3 int","v4 double","v5 int"] + rows: + - [6,6,1,3.5,21] + - id: 3 + desc: "表是空的" + tags: ["TODO","@chengjing,bug,"] + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + sql: select count(c2) as v1,max(c2) as v2,min(c2) as v3,avg(c2) as v4,sum(c2) as v5 from {0}; + expect: + order: c1 + columns: ["v1 int","v2 int","v3 int","v4 double","v5 int"] + rows: + - [0,0,0,0,0] + - id: 4 + desc: "列有null和空串" + inputs: + - + columns : ["id bigint","c1 string","c2 int","c7 timestamp"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",1,1590738990000] + - [2,"bb",2,1590738991000] + - [3,"aa",null,1590738992000] + - [4,null,4,1590738993000] + - [5,"",5,1590738994000] + - [6,"aa",6,1590738995000] + sql: select count(c1) as v1,max(c2) as v2,min(c2) as v3,avg(c2) as v4,sum(c2) as v5 from {0}; + expect: + order: c1 + columns: ["v1 bigint","v2 int","v3 int","v4 double","v5 int"] + rows: + - [5,6,1,3.6,18] + + + + + + + diff --git a/cases/integration_test/window/error_window.yaml b/cases/integration_test/window/error_window.yaml new file mode 100644 index 00000000000..9e9419bc74f --- /dev/null +++ b/cases/integration_test/window/error_window.yaml @@ -0,0 +1,303 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: no order by + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c8:c4" ] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 1 + desc: no partition by + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c8:c4" ] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 2 + desc: float为partition by - 未命中索引 - rtidb下不支持 + mode: offline-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.1,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.1,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.2,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c5, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c5 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 3 + desc: double为partition by - 未命中索引 - rtidb下不支持 + mode: offline-unsupport + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c6, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c6 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 4 + desc: string为order by + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c1 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 5 + desc: float为order by + mode: offline-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c8:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.3,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c5, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c5 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 6 + desc: double为order by + mode: offline-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.3,2.3,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738990000,"2020-05-01"] + - [5,"ee",21,34,1.5,2.5,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c6, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c6 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 7 + desc: date为order by + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738990000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738990000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738990000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738991000,"2020-05-05"] + sql: | + SELECT id, c1, c8, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c8 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + + - + id: 8 + desc: BETWEEN加单位 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 9 + desc: window名不存在 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w2 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 10 + desc: window使用的表名不存在 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}1.c3 ORDER BY {0}1.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 11 + desc: window使用的列名不存在 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c33 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 12 + desc: window1 expression + window2 expression + tags: ["目前属于功能边界外, @chenjing计划支持依赖同类窗口的表达式"] + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["bb",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, c4, + (sum(c4) over w1 + sum(c3) over w2) as sum_c3_c4_w1 FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 10 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 13 + desc: ROWS Window 不支持MAXSIZE + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW MAXSIZE 10); + expect: + success: false + - + id: 14 + desc: window名不存在 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w2 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 15 + desc: window使用的表名不存在 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}1.c3 ORDER BY {0}1.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 16 + desc: window使用的列名不存在 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c33 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false diff --git a/cases/integration_test/window/test_current_row.yaml b/cases/integration_test/window/test_current_row.yaml new file mode 100644 index 00000000000..5b2243e23a4 --- /dev/null +++ b/cases/integration_test/window/test_current_row.yaml @@ -0,0 +1,1506 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: ["两个窗口,一个rows,一个rows_range,current_row"] +version: 0.6.0 +cases: + - id: 0 + desc: rows-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 1 + desc: rows_range-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 2 + desc: rows-current_row-有和当前行ts一致的数据 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738990000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 3 + desc: rows_range-current_row-有和当前行ts一致的数据 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738990000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738991000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,32 ] + - [ "bb",24,null ] + - id: 4 + desc: rows-纯历史窗口-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 5 + desc: rows_range-纯历史窗口-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 1s PRECEDING EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 6 + desc: rows-current_row-ts=0 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,0,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 7 + desc: rows_range-current_row-ts=0 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,0,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,null ] + - [ "aa",23,32 ] + - [ "bb",24,null ] + - id: 8 + desc: rows-current_row-ts=-1 + tags: ["TODO","ts为负数有问题,带支持后再验证"] + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 bigint","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,-1,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,-1,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 9 + desc: rows_range-current_row-ts=-1 + tags: ["TODO","ts为负数有问题,带支持后再验证"] + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 bigint","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,-1,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,-1,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,null ] + - [ "aa",23,32 ] + - [ "bb",24,null ] + - id: 10 + desc: rows-current_row-ts=负数和0 + tags: ["TODO","ts为负数有问题,带支持后再验证"] + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 bigint","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,-1000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 11 + desc: rows_range-current_row-ts=负数和0 + tags: ["TODO","ts为负数有问题,带支持后再验证"] + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 bigint","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,-1000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,null ] + - [ "aa",23,32 ] + - [ "bb",24,null ] + - id: 12 + desc: rows-open-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,0,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 0 OPEN PRECEDING EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 13 + desc: rows_range-open-current_row + tags: ["TODO","bug,修复后验证"] + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,0,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "aa",24,34,1.5,2.5,1590738993000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 0s OPEN PRECEDING EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,null ] + - [ "aa",23,32 ] + - [ "aa",24,32 ] + - id: 14 + desc: rows_range-current_row-maxsize小于窗口 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 15 + desc: rows_range-current_row-maxsize大于窗口 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW MAXSIZE 3 EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 16 + desc: rows-current_row-current_time + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738990000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 17 + desc: rows_range-current_row-current_time + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738990000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738991000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,61 ] + - [ "aa",23,32 ] + - [ "bb",24,null ] + - id: 18 + desc: window union rows-current_row-instance_not_in_window + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,63] + - [4,"dd",20,63] + - [5,"ee",21,null] + - id: 19 + desc: window union rows_range-current_row-instance_not_in_window + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,63] + - [4,"dd",20,32] + - [5,"ee",21,null] + - id: 20 + desc: window union rows-current_row + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,63] + - [4,"dd",20,62] + - [5,"ee",21,null] + - id: 21 + desc: window union rows_range-current_row + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,63] + - [4,"dd",20,62] + - [5,"ee",21,null] + - id: 22 + desc: rows窗口包含open/maxsize/instance_not_in_window/current_time/current_row + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [6,"cc",20,35,1.3,2.3,1590738993000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 0 OPEN PRECEDING EXCLUDE CURRENT_ROW EXCLUDE CURRENT_TIME INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,63] + - [4,"dd",20,67] + - [5,"ee",21,null] + - id: 23 + desc: rows_range窗口包含open/maxsize/instance_not_in_window/current_time/current_row + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [6,"cc",20,35,1.3,2.3,1590738993000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 0s OPEN PRECEDING MAXSIZE 1 EXCLUDE CURRENT_ROW EXCLUDE CURRENT_TIME INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,32] + - [4,"dd",20,35] + - [5,"ee",21,null] + - id: 24 + desc: rows-lag-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, lag(c4,2) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,30 ] + - [ "aa",23,31 ] + - [ "bb",24,null ] + - id: 25 + desc: rows_range-lag-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, lag(c4,2) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,30 ] + - [ "aa",23,31 ] + - [ "bb",24,null ] + - id: 26 + desc: rows-at-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, at(c4,2) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,30 ] + - [ "aa",23,31 ] + - [ "bb",24,null ] + - id: 27 + desc: rows_range-at-current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, at(c4,2) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,30 ] + - [ "aa",23,31 ] + - [ "bb",24,null ] + - id: 28 + desc: 两个窗口,一个rows,一个rows_range,current_row + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c5) OVER w2 as w2_c5_count FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 rows_range BETWEEN 2s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint","w2_c5_count bigint" ] + rows: + - [ "aa",20,null,0 ] + - [ "aa",21,30,1 ] + - [ "aa",22,61,2 ] + - [ "aa",23,63,2 ] + - [ "bb",24,null,0 ] + - id: 29 + desc: current_row小写 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW exclude current_row); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 30 + desc: maxsize位置错误 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW MAXSIZE 2); + expect: + success: false + - id: 31 + desc: rows-纯历史窗口-current_row-ts=0 + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,0,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,30 ] + - [ "aa",22,61 ] + - [ "aa",23,63 ] + - [ "bb",24,null ] + - id: 32 + desc: rows_range-纯历史窗口-current_row-ts=0 + tags: ["TODO","bug,修复后验证"] + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,0,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,0,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,2000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 1s PRECEDING EXCLUDE CURRENT_ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,null ] + - [ "aa",21,null ] + - [ "aa",22,61 ] + - [ "aa",23,93 ] + - [ "bb",24,null ] + + ################################################### + # tests for window attribute 'EXCLUDE CURRENT_ROW' + # - id: 20 - 23: exclude current_row window + lag window + # - id: 24 - 30: exclude current_row window + (maxsize, exclude current_time, instance_not_in_window) + ################################################### + - id: 20 + desc: | + rows_range window union with exclude current_row. batch not support see 1807 + mode: batch-unsupport + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_ROW, partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=(g)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + +-UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding and 0s preceding EXCLUDE CURRENT_ROW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 2, 233, 200, 200 + 2, 3, 233, 21, 21 + - id: 21 + desc: | + rows_range window union with exclude current_row and exclude current_time + mode: batch-unsupport + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 40 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW, partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=(g)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_TIME, partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + +-UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding and 0s preceding + EXCLUDE CURRENT_ROW EXCLUDE CURRENT_TIME); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 1, 233, 233, 233 + 2, 1, 233, 233, 233 + 3, 4, 233, 5, 5 + - id: 22 + desc: | + rows_range window union with exclude current_row and instance_not_in_window + mode: batch-unsupport + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW, partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(table=t1) + PROJECT(type=Aggregation) + REQUEST_UNION(INSTANCE_NOT_IN_WINDOW, partition_keys=(g), orders=(ts ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=) + +-UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(table=t1) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding and 0s preceding + EXCLUDE CURRENT_ROW INSTANCE_NOT_IN_WINDOW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 2, 233, 200, 200 + 2, 2, 233, 200, 200 + - id: 23 + desc: | + rows_range window union with exclude current_row, instance_not_in_window and exclude_current_time + mode: batch-unsupport + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 40 + 4, 102, 111, 0 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW, partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(table=t1) + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_TIME, INSTANCE_NOT_IN_WINDOW, partition_keys=(g), orders=(ts ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=) + +-UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(table=t1) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding and 0s preceding + EXCLUDE CURRENT_ROW INSTANCE_NOT_IN_WINDOW EXCLUDE CURRENT_TIME); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 1, 233, 233, 233 + 2, 1, 233, 233, 233 + 3, 2, 233, 200, 200 + 4, 3, 233, 17, 17 + + # rows_range union window with exclude current_row, single window + - id: 24 + desc: | + rows_range union window with exclude_current_row + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 0 + 4, 102, 111, -1 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + batch_plan: | + PROJECT(type=WindowAggregation, EXCLUDE_CURRENT_ROW) + +-WINDOW(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_ROW, partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=(g)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 PRECEDING), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding and 0s preceding + EXCLUDE CURRENT_ROW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + order: id + data: | + 1, 2, 233, 200 + 2, 3, 233, 21 + 3, 5, 233, 5 + 4, 6, 233, 0 + - id: 25 + desc: | + rows_range union window with exclude_current_row and exclude_current_time + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 0 + 4, 102, 111, 0 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + batch_plan: | + PROJECT(type=WindowAggregation, EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW) + +-WINDOW(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW, partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT), index_keys=(g)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding AND CURRENT ROW + EXCLUDE CURRENT_ROW EXCLUDE CURRENT_TIME); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + order: id + data: | + 1, 1, 233, 233 + 2, 1, 233, 233 + 3, 4, 233, 5 + 4, 6, 233, 0 + - id: 26 + desc: | + rows_range union window with exclude_current_row and instance_not_in_window + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 0 + 4, 102, 111, 0 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + # instance_not_in_window not optimize main table + batch_plan: | + PROJECT(type=WindowAggregation, EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW) + +-WINDOW(partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 CURRENT)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(table=t1) + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW, partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 CURRENT), index_keys=) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(table=t1) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding AND CURRENT ROW + EXCLUDE CURRENT_ROW INSTANCE_NOT_IN_WINDOW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + order: id + data: | + 1, 2, 233, 200 + 2, 2, 233, 200 + 3, 3, 233, 17 + 4, 3, 233, 17 + - id: 27 + desc: | + rows_range union window with exclude_current_row, exclude current_time and instance_not_in_window + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 0 + 4, 102, 111, 0 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + batch_plan: | + PROJECT(type=WindowAggregation, EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW) + +-WINDOW(partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 CURRENT)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(table=t1) + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW, partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 CURRENT), index_keys=) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(table=t1) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding AND CURRENT ROW + EXCLUDE CURRENT_ROW INSTANCE_NOT_IN_WINDOW EXCLUDE CURRENT_TIME); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + order: id + data: | + 1, 1, 233, 233 + 2, 1, 233, 233 + 3, 2, 233, 200 + 4, 3, 233, 17 + - id: 28 + desc: | + rows_range union window with exclude_current_row, exclude current_time, instance_not_in_window and maxsize + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 0 + 4, 102, 111, 0 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + batch_plan: | + PROJECT(type=WindowAggregation, EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW) + +-WINDOW(partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(table=t1) + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW, partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2), index_keys=) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(table=t1) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding AND CURRENT ROW + MAXSIZE 2 + EXCLUDE CURRENT_ROW INSTANCE_NOT_IN_WINDOW EXCLUDE CURRENT_TIME); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + order: id + data: | + 1, 1, 233, 233 + 2, 1, 233, 233 + 3, 2, 233, 200 + 4, 2, 200, 17 + - id: 29 + desc: | + rows_range union window with exclude_current_row, instance_not_in_window and maxsize + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 0 + 4, 102, 111, 0 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + batch_plan: | + PROJECT(type=WindowAggregation, EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW) + +-WINDOW(partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(table=t1) + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_ROW, INSTANCE_NOT_IN_WINDOW, partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2), index_keys=) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(table=t1) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding AND CURRENT ROW + MAXSIZE 2 + EXCLUDE CURRENT_ROW INSTANCE_NOT_IN_WINDOW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + order: id + data: | + 1, 2, 233, 200 + 2, 2, 233, 200 + 3, 2, 200, 17 + 4, 2, 200, 17 + - id: 30 + desc: | + rows_range union window with exclude_current_row, exclude_current_time and maxsize + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 5 + 3, 101, 111, 0 + 4, 102, 111, 0 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + batch_plan: | + PROJECT(type=WindowAggregation, EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW) + +-WINDOW(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_TIME, EXCLUDE_CURRENT_ROW, partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2), index_keys=(g)) + +-UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 CURRENT, maxsize=2), index_keys=(g)) + RENAME(name=t1) + DATA_PROVIDER(type=Partition, table=t2, index=idx) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 3s preceding AND CURRENT ROW + MAXSIZE 2 + EXCLUDE CURRENT_ROW EXCLUDE CURRENT_TIME); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + order: id + data: | + 1, 1, 233, 233 + 2, 1, 233, 233 + 3, 2, 21, 5 + 4, 2, 17, 0 \ No newline at end of file diff --git a/cases/integration_test/window/test_maxsize.yaml b/cases/integration_test/window/test_maxsize.yaml new file mode 100644 index 00000000000..28af076d27a --- /dev/null +++ b/cases/integration_test/window/test_maxsize.yaml @@ -0,0 +1,789 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: maxsize小于窗口的大小 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + - + id: 1 + desc: maxsize大于窗口的大小 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW MAXSIZE 5); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + - + id: 2 + desc: maxsize等于窗口的大小 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW MAXSIZE 3); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + - + id: 3 + desc: maxsize=0 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW MAXSIZE 0); + expect: + success: false + - + id: 4 + desc: maxsize=1 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW MAXSIZE 1); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",31] + - [3,"aa",32] + - [4,"aa",33] + - [5,"aa",34] + - + id: 5 + desc: maxsize=-1 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW MAXSIZE -1); + expect: + success: false + - + id: 6 + desc: 纯历史窗口-maxsize + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 5 PRECEDING AND 1 PRECEDING MAXSIZE 3); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa", NULL] + - [2,"aa",30] + - [3,"aa",61] + - [4,"aa",93] + - [5,"aa",96] + - + id: 7 + desc: 没有数据进入maxsize的窗口 + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 5 PRECEDING AND 3 PRECEDING MAXSIZE 3); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa", NULL] + - [2,"aa", NULL] + - [3,"aa", NULL] + - + id: 8 + desc: 两个pk,都大于maxsize + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - [6,"bb",24,35,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND 0 PRECEDING MAXSIZE 2); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",63] + - [4,"bb",33] + - [5,"bb",67] + - [6,"bb",69] + - + id: 9 + desc: 两个pk,一个大于maxsize,一个小于maxsize + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND 0 PRECEDING MAXSIZE 2); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",63] + - [4,"bb",33] + - [5,"bb",67] + - + id: 10 + desc: 两个窗口的maxsize一致 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,96] + - [5,"aa",99,99] + - + id: 11 + desc: 两个窗口的maxsize不一致 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 2) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,63] + - [4,"aa",96,65] + - [5,"aa",99,67] + - + id: 12 + desc: 两个窗口不同的key的maxsize一致 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",21,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",21,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,33] + - [5,"aa",99,67] + - + id: 13 + desc: 两个窗口不同的ts的maxsize一致 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c1:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,96] + - [5,"aa",99,99] + - + id: 14 + desc: 两个窗口一个带有maxsize,一个没有 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,126] + - [5,"aa",99,160] + - + id: 15 + desc: 两个窗口不同的key的maxsize不一致 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",21,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",21,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 2) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,63] + - [4,"aa",96,33] + - [5,"aa",99,67] + - + id: 16 + desc: 两个窗口的不同的ts的maxsize不一致 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c1:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 4) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,126] + - [5,"aa",99,130] + - + id: 17 + desc: 两个窗口相同的key的一个maxsize大于窗口一个小于窗口 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 5), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 3) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",126,96] + - [5,"aa",130,99] + - + id: 18 + desc: 两个窗口不同的key的一个maxsize大于窗口一个小于窗口 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",20,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",21,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 5), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 3) + ; + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",126,96] + - [5,"aa",130,34] + - + id: 19 + desc: union结合maxsize + mode: cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 2); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [5,"aa",67] + - + id: 20 + desc: union结合maxsize-两个窗口 + mode: cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 2); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [5,"aa",95,67] + - + id: 21 + desc: union+maxsize+INSTANCE_NOT_IN_WINDOW + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 2 INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",31] + - [5,"aa",67] + - + id: 22 + desc: union子查询结合maxsize + mode: cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION (select * from {1}) PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 2); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [5,"aa",67] + - + id: 23-1 + desc: lastjoin结合maxsize + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c4, + sum({1}.c4) OVER w1 as w1_c4_sum + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 2) + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,32,32] + - [2,"aa",21,32,64] + - [3,"aa",22,32,64] + - [4,"bb",23,34,34] + - [5,"bb",24,34,68] + - + id: 23-2 + desc: lastjoin结合maxsize, last join副表有ts列为null + tags: ["TODO"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"bb",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,null,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"bb",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"bb",21,34,1.2,2.2,1590738990004,"2020-05-02"] + sql: | + select {0}.id,{0}.c1,{0}.c3,{1}.c4, + sum({1}.c4) OVER w1 as w1_c4_sum + from {0} + last join {1} ORDER BY {1}.c7 on {0}.c1={1}.c1 + WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 2) + ; + expect: + order: id + columns: ["id int","c1 string","c3 int","c4 bigint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,31,31] + - [2,"aa",21,31,62] + - [3,"aa",22,31,62] + - [4,"bb",23,34,34] + - [5,"bb",24,34,68] + - + id: 24 + desc: union多表结合maxsize + mode: cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1},{2} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW MAXSIZE 2); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [5,"aa",67] + - + id: 25 + desc: maxsize-rows + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW MAXSIZE 3); + expect: + success: false + - + id: 26 + desc: 两个union,不同的maxsize + mode: cluster-unsupport + tags: ["TODO", "@chenjing support online batch", "@chendihao support offline batch", "cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 5 PRECEDING AND CURRENT ROW MAXSIZE 4), + w2 AS (UNION {1},{2} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 5 PRECEDING AND CURRENT ROW MAXSIZE 2); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [5,"aa",127,67] diff --git a/cases/integration_test/window/test_window.yaml b/cases/integration_test/window/test_window.yaml new file mode 100644 index 00000000000..80731888843 --- /dev/null +++ b/cases/integration_test/window/test_window.yaml @@ -0,0 +1,1223 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: 一个pk窗口的大小大于所有数据 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 6 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",126] + - [5,"aa",160] + - + id: 1 + desc: 一个pk窗口的大小等于所有数据 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 4 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",126] + - [5,"aa",160] + - + id: 2 + desc: 一个pk窗口的大小小于所有数据 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + - + id: 3 + desc: 一个pk所有数据都不在窗口内 + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 5 PRECEDING AND 3 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",null] + - + id: 4 + desc: 窗口只要当前行 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 0 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",31] + - [3,"aa",32] + - + id: 5 + desc: 窗口只要当前行 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 0 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",31] + - [3,"aa",32] + - + id: 6 + desc: 最后一行进入窗口 + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 3 PRECEDING AND 2 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",null] + - [2,"aa",null] + - [3,"aa",30] + - + id: 7 + desc: 纯历史窗口-滑动 + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND 1 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",null] + - [2,"aa",30] + - [3,"aa",61] + - [4,"aa",63] + - [5,"aa",65] + - + id: 8 + desc: 两个pk,一个没有进入窗口,一个滑动 + version: 0.6.0 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND 1 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",null] + - [2,"aa",30] + - [3,"aa",61] + - [4,"aa",63] + - [5,"bb",null] + - + id: 9 + desc: 两个pk,一个全部进入窗口,一个滑动 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND 0 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"bb",34] + - + id: 10 + desc: 两个pk都滑动 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + - [6,"bb",24,35,1.5,2.5,1590738990005,"2020-05-05"] + - [7,"bb",24,36,1.5,2.5,1590738990006,"2020-05-05"] + - [8,"bb",24,37,1.5,2.5,1590738990007,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND 0 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",63] + - [4,"aa",65] + - [5,"bb",34] + - [6,"bb",69] + - [7,"bb",71] + - [8,"bb",73] + - + id: 11 + desc: ts列乱序 + mode: request-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",93] + - [4,"aa",96] + - [5,"aa",99] + - + id: 12 + desc: ts列乱序 + mode: batch-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + rows: + - [1,"aa",30] + - [2,"aa",61] + - [3,"aa",62] + - [4,"aa",33] + - [5,"aa",99] + - + id: 13 + desc: ts列相同 + mode: disk-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",23,33,1.4,2.4,1590738990000,"2020-05-04"] + - [2,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",21,31,1.2,2.2,1590738990005,"2020-05-02"] + - [5,"aa",24,34,1.5,2.5,1590738990005,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + expectProvider: + 0: + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + 1: + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",1] + - [5,"aa",2] + - + id: 14 + desc: 每次上一条都划出 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",23,30,1.4,2.4,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590738990003,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990006,"2020-05-03"] + - [4,"aa",21,33,1.2,2.2,1590738990009,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990012,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, count(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + expectProvider: + 0: + rows: + - [1,"aa",1] + - [2,"aa",2] + - [3,"aa",3] + - [4,"aa",3] + - [5,"aa",3] + 1: + rows: + - [1,"aa",1] + - [2,"aa",1] + - [3,"aa",1] + - [4,"aa",1] + - [5,"aa",1] + - + id: 15 + desc: pk包含null + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,null,21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,null,22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,null,23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + expectProvider: + 0: + rows: + - [1,"aa",30] + - [2,null,31] + - [3,null,63] + - [4,null,65] + - [5,"aa",64] + 1: + rows: + - [1,"aa",30] + - [2,null,31] + - [3,null,63] + - [4,null,65] + - [5,"aa",34] + - + id: 16 + desc: pk包含空串 + mode: cli-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + expectProvider: + 0: + rows: + - [1,"aa",30] + - [2,"",31] + - [3,"",63] + - [4,"",65] + - [5,"aa",64] + 1: + rows: + - [1,"aa",30] + - [2,"",31] + - [3,"",63] + - [4,"",65] + - [5,"aa",34] + - + id: 17 + desc: pk包含空串和null + mode: cli-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,null,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,null,24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint"] + expectProvider: + 0: + rows: + - [1,null,30] + - [2,"",31] + - [3,"",63] + - [4,"",65] + - [5,null,64] + 1: + rows: + - [1,null,30] + - [2,"",31] + - [3,"",63] + - [4,"",65] + - [5,null,34] + - + id: 18 + desc: 两个窗口相同的pk,相同的ts,相同的聚合函数 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,96] + - [5,"aa",99,99] + - + id: 19 + desc: 两个窗口相同的pk,相同的ts,不同的列 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c3) OVER w2 as w2_c3_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c3_sum int"] + rows: + - [1,"aa",30,20] + - [2,"aa",61,41] + - [3,"aa",93,63] + - [4,"aa",96,66] + - [5,"aa",99,69] + - + id: 20 + desc: 两个窗口相同的pk,相同的ts,不同的函数 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"aa",61,2] + - [3,"aa",93,3] + - [4,"aa",96,3] + - [5,"aa",99,3] + - + id: 21 + desc: sum超过int的范围 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",2147483647,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c3) OVER w1 as w1_c3_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c3_sum int"] + rows: + - [1,"aa",20] + - [2,"aa",41] + - [3,"aa",63] + - [4,"aa",66] + - [5,"aa",-2147483604] + - + id: 22 + desc: 两个窗口相同的pk,不同的ts,相同的聚合函数 + tags: ["TODO","@chenjing by@zhaowei","sql执行失败","http://jira.4paradigm.com/browse/FEX-924"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c1:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-05"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c4 d[0] BETWEEN 1 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,63] + - [4,"aa",96,65] + - [5,"aa",99,67] + - + id: 23 + desc: 两个窗口不同的pk,相同的ts,相同的聚合函数 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c8:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-01"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c8 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,96] + - [5,"aa",99,99] + - + id: 24 + desc: 两个窗口不同的pk,相同的ts,相同的聚合函数,一个窗口两个pk + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c8:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c8 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,96] + - [5,"aa",99,34] + - + id: 25 + desc: 两个窗口不同的pk,不同的ts,相同的聚合函数 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c8:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c8 ORDER BY {0}.c4 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [3,"aa",93,93] + - [4,"aa",96,96] + - [5,"aa",99,34] + - + id: 26 + desc: 两个窗口不同的ts,一个都在窗口内,一个都不进入窗口 + tags: ["TODO","@chenjing by@zhaowei","sql执行失败,应该和 22 case是一个问题"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 5 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c4 d[0] BETWEEN 6 PRECEDING AND 5 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,0] + - [2,"aa",61,0] + - [3,"aa",93,0] + - [4,"aa",126,0] + - [5,"aa",160,0] + - + id: 27 + desc: 两个窗口,一个union,一个不union + mode: rtidb-batch-unsupport,cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + expectProvider: + 0: + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [5,"aa",95,99] + 1: + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [5,"aa",34,99] + - + id: 28 + desc: 两个窗口,一个union一个表,一个union两个表 + mode: rtidb-batch-unsupport,cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (UNION {1},{2} PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + expectProvider: + 0: + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [5,"aa",97,99] + 1: + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [5,"aa",66,99] + - + id: 29 + desc: 两个窗口,一个union,一个INSTANCE_NOT_IN_WINDOW + mode: rtidb-batch-unsupport,cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,31] + - [4,"aa",96,65] + - [5,"aa",99,66] + - + id: 30 + desc: 两个窗口,一个union一个表,一个union使用子查询 + mode: rtidb-batch-unsupport,cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + dataProvider: + - ["ROWS","ROWS_RANGE"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (UNION (select * from {1}) PARTITION BY {0}.c1 ORDER BY {0}.c7 d[0] BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,30] + - [2,"aa",61,61] + - [5,"aa",99,99] + - + id: 31 + desc: 多个窗口-rows + mode: rtidb-batch-unsupport,cluster-unsupport + tags: ["cluster-执行失败", "@chenjing batch online fix for multi window with union", "@tobe batch offline fix"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"aa",24,34,1.5,2.5,1590738990004,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [2,"aa",21,31,1.2,2.2,1590738990001,"2020-05-01"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [3,"aa",22,32,1.3,2.3,1590738990002,"2020-05-01"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [4,"aa",23,33,1.4,2.4,1590738990003,"2020-05-01"] + sql: | + SELECT id, c1, sum(c4) OVER w1 as w1_c4_sum, sum(c4) OVER w2 as w2_c4_sum FROM {0} WINDOW + w1 AS (UNION {1},{2},{3} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 4 PRECEDING AND CURRENT ROW), + w2 AS (UNION {1},{2} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 4 PRECEDING AND 1 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint"] + rows: + - [1,"aa",30,0] + - [5,"aa",160,93] + - + id: 32 + desc: 多个窗口包含不同的单位 + mode: cluster-unsupport + tags: ["cluster-执行失败"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"aa",20,32,1.1,2.1,1590738992000,"2020-05-01"] + - [4,"aa",20,33,1.1,2.1,1590739110000,"2020-05-01"] + - [5,"aa",20,34,1.1,2.1,1590746190000,"2020-05-01"] + - [6,"aa",20,35,1.1,2.1,1590911790000,"2020-05-01"] + - + columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738991000,"2020-05-01"] + - [2,"aa",21,31,1.2,2.2,1590738993000,"2020-05-02"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590739050000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590739170000,"2020-05-01"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590742590000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590749790000,"2020-05-01"] + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590825390000,"2020-05-01"] + - [2,"aa",20,31,1.1,2.1,1590998190000,"2020-05-01"] + sql: | + SELECT id, c1, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum, + sum(c4) OVER w3 as w3_c4_sum, + sum(c4) OVER w4 as w4_c4_sum, + sum(c4) OVER w5 as w5_c4_sum + FROM {0} WINDOW + w1 AS (UNION {1},{2},{3},{4} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (UNION {1},{2},{3},{4} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w3 AS (UNION {1},{2},{3},{4} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2m PRECEDING AND CURRENT ROW), + w4 AS (UNION {1},{2},{3},{4} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2h PRECEDING AND CURRENT ROW), + w5 AS (UNION {1},{2},{3},{4} PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2d PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","w1_c4_sum bigint","w2_c4_sum bigint","w3_c4_sum bigint","w4_c4_sum bigint","w5_c4_sum bigint"] + rows: + - [1,"aa",30,30,30,30,30] + - [2,"aa",61,61,61,61,61] + - [3,"aa",32,123,123,123,123] + - [4,"aa",33,33,217,217,217] + - [5,"aa",34,34,34,312,312] + - [6,"aa",35,35,35,35,408] + + - id: 33 + desc: | + first_value results in two rows_range window, refer https://github.com/4paradigm/OpenMLDB/issues/1587 + inputs: + - columns: [ "id int","ts timestamp","group1 string","val1 int" ] + indexs: [ "index1:group1:ts" ] + name: t1 + data: | + 1, 1612130400000, g1, 1 + 2, 1612130401000, g1, 2 + 3, 1612130402000, g1, 3 + 4, 1612130403000, g1, 4 + 5, 1612130404000, g1, 5 + 6, 1612130404000, g2, 4 + 7, 1612130405000, g2, 3 + 8, 1612130406000, g2, 2 + sql: | + select + `id`, + `val1`, + first_value(val1) over w1 as agg1, + first_value(val1) over w2 as agg2, + from `t1` WINDOW + w1 as (partition by `group1` order by `ts` rows_range between 5s preceding and 0s preceding), + w2 as (partition by `group1` order by `ts` rows_range between 5s preceding and 1s preceding); + expect: + columns: ["id int", "val1 int", "agg1 int", "agg2 int"] + order: id + rows: + - [1, 1, 1, NULL] + - [2, 2, 2, 1] + - [3, 3, 3, 2] + - [4, 4, 4, 3] + - [5, 5, 5, 4] + - [6, 4, 4, NULL] + - [7, 3, 3, 4] + - [8, 2, 2, 3] + + - id: 34 + desc: | + first_value results in two rows windows + inputs: + - columns: [ "id int","ts timestamp","group1 string","val1 int" ] + indexs: [ "index1:group1:ts" ] + name: t1 + rows: + - [1, 1612130400000, g1, 1] + - [2, 1612130401000, g1, 2] + - [3, 1612130402000, g1, 3] + - [4, 1612130403000, g1, 4] + - [5, 1612130404000, g1, 5] + - [6, 1612130404000, g2, 4] + - [7, 1612130405000, g2, 3] + - [8, 1612130406000, g2, 2] + sql: | + select + `id`, + `val1`, + first_value(val1) over w1 as agg1, + first_value(val1) over w2 as agg2, + from `t1` WINDOW + w1 as (partition by `group1` order by `ts` rows between 5 preceding and 0 preceding), + w2 as (partition by `group1` order by `ts` rows between 5 preceding and 1 preceding); + expect: + columns: ["id int", "val1 int", "agg1 int", "agg2 int"] + order: id + rows: + - [1, 1, 1, NULL] + - [2, 2, 2, 1] + - [3, 3, 3, 2] + - [4, 4, 4, 3] + - [5, 5, 5, 4] + - [6, 4, 4, NULL] + - [7, 3, 3, 4] + - [8, 2, 2, 3] + + - id: 35 + desc: | + first_value results in rows/rows_range windows + inputs: + - columns: [ "id int","ts timestamp","group1 string","val1 int" ] + indexs: [ "index1:group1:ts" ] + name: t1 + data: | + 1, 1612130400000, g1, 1 + 2, 1612130401000, g1, 2 + 3, 1612130402000, g1, 3 + 4, 1612130403000, g1, 4 + 5, 1612130404000, g1, 5 + 6, 1612130404000, g2, 4 + 7, 1612130405000, g2, 3 + 8, 1612130406000, g2, 2 + sql: | + select + `id`, + `val1`, + first_value(val1) over w1 as agg1, + first_value(val1) over w2 as agg2, + from `t1` WINDOW + w1 as (partition by `group1` order by `ts` rows_range between 5s preceding and 0s preceding), + w2 as (partition by `group1` order by `ts` rows between 5 preceding and 1 preceding); + expect: + columns: ["id int", "val1 int", "agg1 int", "agg2 int"] + order: id + rows: + - [1, 1, 1, NULL] + - [2, 2, 2, 1] + - [3, 3, 3, 2] + - [4, 4, 4, 3] + - [5, 5, 5, 4] + - [6, 4, 4, NULL] + - [7, 3, 3, 4] + - [8, 2, 2, 3] + + - id: 36 + version: 0.6.0 + desc: | + correctness for window functions over window whose border is open + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 21 + 2, 100, 111, 22 + 3, 101, 111, 23 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + partition by `g` order by `ts` + ROWS between 3 OPEN preceding and 0 OPEN PRECEDING); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 0, NULL, NULL, NULL + 2, 1, 21, 21, 21 + 3, 2, 22, 21, 22 + + - id: 37 + version: 0.6.0 + desc: | + correctness for rows_range window functions over window whose border is open + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + partition by `g` order by `ts` + ROWS_RANGE between 2s OPEN PRECEDING and 0s OPEN preceding); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 0, NULL, NULL, NULL + 2, 1, 21, 21, 21 + 3, 1, 22, 22, 22 diff --git a/cases/integration_test/window/test_window_exclude_current_time.yaml b/cases/integration_test/window/test_window_exclude_current_time.yaml new file mode 100644 index 00000000000..2f00fff56e1 --- /dev/null +++ b/cases/integration_test/window/test_window_exclude_current_time.yaml @@ -0,0 +1,761 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +version: 0.5.0 +cases: + - id: 0 + mode: disk-unsupport + desc: ROWS_RANGE Window OPEN PRECEDING EXCLUDE CURRENT_TIME + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",-2, 1.0, 0 ] + - [ "aa",-1, 1.0, 0 ] + - [ "aa",0, 1.0, 0 ] + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double" ] + rows: + - [ "aa", -2, 0, 1.0 ] + - [ "aa", -1, 0, 1.0 ] + - [ "aa", 0, 0, 1.0 ] + - [ "aa", 1, 1590738990000, 1.0 ] + - [ "aa", 2, 1590738990000, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0 ] + - [ "aa", 6, 1590738994000, 3.0 ] + - [ "aa", 7, 1590738999000, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0 ] + - id: 1 + desc: ROWS_RANGE Window with MaxSize 2 OPEN PRECEDING EXCLUDE CURRENT_TIME + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0 ] + - [ "aa", 2, 1590738990000, 1.0 ] + - [ "aa", 3, 1590738992000, 2.0 ] + - [ "aa", 4, 1590738993000, 2.0 ] + - [ "aa", 5, 1590738994000, 2.0 ] + - [ "aa", 6, 1590738994000, 2.0 ] + - [ "aa", 7, 1590738999000, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0 ] + - [ "aa", 9, 1590739002000, 2.0 ] + - id: 2 + desc: ROWS_RANGE Window with MaxSize 10 OPEN PRECEDING EXCLUDE CURRENT_TIME + mode: disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",-1, 1.0, 0 ] + - [ "aa", 0, 1.0, 0 ] + - [ "aa", 1, 1.0, 1590738990000 ] + - [ "aa", 2, 1.0, 1590738990000 ] + - [ "aa", 3, 1.0, 1590738992000 ] + - [ "aa", 4, 1.0, 1590738993000 ] + - [ "aa", 5, 1.0, 1590738994000 ] + - [ "aa", 6, 1.0, 1590738994000 ] + - [ "aa", 7, 1.0, 1590738999000 ] + - [ "aa", 8, 1.0, 1590739001000 ] + - [ "aa", 9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 10 EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double" ] + rows: + - [ "aa",-1, 0, 1.0 ] + - [ "aa", 0, 0, 1.0 ] + - [ "aa", 1, 1590738990000, 1.0 ] + - [ "aa", 2, 1590738990000, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0 ] + - [ "aa", 6, 1590738994000, 3.0 ] + - [ "aa", 7, 1590738999000, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0 ] + - id: 3 + desc: ROWS Window OPEN PRECEDING EXCLUDE CURRENT_TIME + mode: disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",-1, 1.0, 0] + - [ "aa", 0, 1.0, 0] + - [ "aa", 1, 1.0, 1590738990000 ] + - [ "aa", 2, 1.0, 1590738990000 ] + - [ "aa", 3, 1.0, 1590738992000 ] + - [ "aa", 4, 1.0, 1590738993000 ] + - [ "aa", 5, 1.0, 1590738994000 ] + - [ "aa", 6, 1.0, 1590738994000 ] + - [ "aa", 7, 1.0, 1590738999000 ] + - [ "aa", 8, 1.0, 1590739001000 ] + - [ "aa", 9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double" ] + rows: + - [ "aa",-1, 0, 1.0 ] + - [ "aa", 0, 0, 1.0 ] + - [ "aa", 1, 1590738990000, 3.0 ] + - [ "aa", 2, 1590738990000, 3.0 ] + - [ "aa", 3, 1590738992000, 5.0 ] + - [ "aa", 4, 1590738993000, 6.0 ] + - [ "aa", 5, 1590738994000, 7.0 ] + - [ "aa", 6, 1590738994000, 7.0 ] + - [ "aa", 7, 1590738999000, 7.0 ] + - [ "aa", 8, 1590739001000, 7.0 ] + - [ "aa", 9, 1590739002000, 7.0 ] + - id: 4 + desc: ROWS and ROWS Window OPEN PRECEDING EXCLUDE CURRENT_TIME + mode: disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 1.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0, 5.0 ] + - [ "aa", 6, 1590738994000, 3.0, 5.0 ] + - [ "aa", 7, 1590738999000, 1.0, 7.0 ] + - [ "aa", 8, 1590739001000, 2.0, 7.0 ] + - [ "aa", 9, 1590739002000, 3.0, 7.0 ] + + - id: 5 + mode: offline-unsupport,disk-unsupport + desc: ROWS_RANGE Window and EXCLUDE CURRENT_TIME Window + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0, 3.0 ] + - [ "aa", 6, 1590738994000, 4.0, 3.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0, 3.0 ] + - id: 6 + desc: ROWS_RANGE Window with MaxSize 2 and EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 2.0, 2.0 ] + - [ "aa", 4, 1590738993000, 2.0, 2.0 ] + - [ "aa", 5, 1590738994000, 2.0, 2.0 ] + - [ "aa", 6, 1590738994000, 2.0, 2.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0 ] + - [ "aa", 9, 1590739002000, 2.0, 2.0 ] + - id: 7 + desc: ROWS_RANGE Window with MaxSize 10 and EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 10), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 10 EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0, 3.0 ] + - [ "aa", 6, 1590738994000, 4.0, 3.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0, 3.0 ] + - id: 8 + desc: ROWS Window and EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 5.0, 5.0 ] + - [ "aa", 6, 1590738994000, 6.0, 5.0 ] + - [ "aa", 7, 1590738999000, 7.0, 7.0 ] + - [ "aa", 8, 1590739001000, 7.0, 7.0 ] + - [ "aa", 9, 1590739002000, 7.0, 7.0 ] + - id: 9 + desc: ROWS and ROWS Window and EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum, + sum(c4) OVER w3 as w3_c4_sum, + sum(c4) OVER w4 as w4_c4_sum, + sum(c4) OVER w5 as w5_c4_sum, + sum(c4) OVER w6 as w6_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME), + w3 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2), + w4 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_TIME), + w5 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW), + w6 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double", + "w3_c4_sum double", "w4_c4_sum double", + "w5_c4_sum double", "w6_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0, 2.0, 1.0, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0, 2.0, 2.0, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0, 2.0, 2.0, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0, 3.0, 2.0, 2.0, 5.0, 5.0 ] + - [ "aa", 6, 1590738994000, 4.0, 3.0, 2.0, 2.0, 6.0, 5.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0, 1.0, 1.0, 7.0, 7.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0, 2.0, 2.0, 7.0, 7.0 ] + - [ "aa", 9, 1590739002000, 3.0, 3.0, 2.0, 2.0, 7.0, 7.0 ] + + - id: 10 + desc: ROWS_RANGE Window OPEN PRECEDING and EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0, 3.0 ] + - [ "aa", 6, 1590738994000, 4.0, 3.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0, 3.0 ] + - id: 11 + desc: ROWS_RANGE Window with MaxSize 2 OPEN PRECEDING amd EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 2), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 2.0, 2.0 ] + - [ "aa", 4, 1590738993000, 2.0, 2.0 ] + - [ "aa", 5, 1590738994000, 2.0, 2.0 ] + - [ "aa", 6, 1590738994000, 2.0, 2.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0 ] + - [ "aa", 9, 1590739002000, 2.0, 2.0 ] + - id: 12 + desc: ROWS_RANGE Window with MaxSize 10 OPEN PRECEDING and EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 10), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 10 EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0, 3.0 ] + - [ "aa", 6, 1590738994000, 4.0, 3.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0, 3.0 ] + - id: 13 + desc: ROWS Window OPEN PRECEDING and EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 OPEN PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 5.0, 5.0 ] + - [ "aa", 6, 1590738994000, 6.0, 5.0 ] + - [ "aa", 7, 1590738999000, 7.0, 7.0 ] + - [ "aa", 8, 1590739001000, 7.0, 7.0 ] + - [ "aa", 9, 1590739002000, 7.0, 7.0 ] + - id: 14 + desc: ROWS and ROWS Window OPEN PRECEDING and EXCLUDE CURRENT_TIME Window + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum, + sum(c4) OVER w3 as w3_c4_sum, + sum(c4) OVER w4 as w4_c4_sum, + sum(c4) OVER w5 as w5_c4_sum, + sum(c4) OVER w6 as w6_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME), + w3 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 2), + w4 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_TIME), + w5 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 OPEN PRECEDING AND CURRENT ROW), + w6 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double", + "w3_c4_sum double", "w4_c4_sum double", + "w5_c4_sum double", "w6_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0, 2.0, 1.0, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0, 2.0, 2.0, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0, 2.0, 2.0, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0, 3.0, 2.0, 2.0, 5.0, 5.0 ] + - [ "aa", 6, 1590738994000, 4.0, 3.0, 2.0, 2.0, 6.0, 5.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0, 1.0, 1.0, 7.0, 7.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0, 2.0, 2.0, 7.0, 7.0 ] + - [ "aa", 9, 1590739002000, 3.0, 3.0, 2.0, 2.0, 7.0, 7.0 ] + - id: 16 + desc: ROWS and ROWS Window 各类窗口混合 + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738994000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum, + sum(c4) OVER w3 as w3_c4_sum, + sum(c4) OVER w4 as w4_c4_sum, + sum(c4) OVER w5 as w5_c4_sum, + sum(c4) OVER w6 as w6_c4_sum, + sum(c4) OVER w7 as w7_c4_sum, + sum(c4) OVER w8 as w8_c4_sum, + sum(c4) OVER w9 as w9_c4_sum, + sum(c4) OVER w10 as w10_c4_sum, + sum(c4) OVER w11 as w11_c4_sum, + sum(c4) OVER w12 as w12_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME), + w3 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2), + w4 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_TIME), + w5 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW), + w6 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME), + w7 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW), + w8 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME), + w9 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 2), + w10 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 4s OPEN PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_TIME), + w11 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 OPEN PRECEDING AND CURRENT ROW), + w12 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", + "w1_c4_sum double", "w2_c4_sum double", + "w3_c4_sum double", "w4_c4_sum double", + "w5_c4_sum double", "w6_c4_sum double", + "w7_c4_sum double", "w8_c4_sum double", + "w9_c4_sum double", "w10_c4_sum double", + "w11_c4_sum double", "w12_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] + - [ "aa", 2, 1590738990000, 2.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, 1.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 2.0, 2.0, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0, 2.0, 2.0, 4.0, 4.0, 4.0, 4.0, 2.0, 2.0, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 3.0, 3.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 2.0, 2.0, 5.0, 5.0 ] + - [ "aa", 6, 1590738994000, 4.0, 3.0, 2.0, 2.0, 6.0, 5.0, 4.0, 3.0, 2.0, 2.0, 6.0, 5.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0, 1.0, 1.0, 7.0, 7.0, 1.0, 1.0, 1.0, 1.0, 7.0, 7.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0, 2.0, 2.0, 7.0, 7.0, 2.0, 2.0, 2.0, 2.0, 7.0, 7.0 ] + - [ "aa", 9, 1590739002000, 3.0, 3.0, 2.0, 2.0, 7.0, 7.0, 3.0, 3.0, 2.0, 2.0, 7.0, 7.0 ] + - id: 17 + desc: ROWS Window with same timestamp + mode: offline-unsupport,disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738990000 ] + - [ "aa",4, 1.0, 1590738990000 ] + - [ "aa",5, 1.0, 1590738990000 ] + - [ "aa",6, 1.0, 1590738990000 ] + - [ "aa",7, 1.0, 1590738991000 ] + - [ "aa",8, 1.0, 1590738992000 ] + - [ "aa",9, 1.0, 1590738993000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double"] + rows: + - [ "aa", 1, 1590738990000, 1.0] + - [ "aa", 2, 1590738990000, 2.0] + - [ "aa", 3, 1590738990000, 3.0] + - [ "aa", 4, 1590738990000, 4.0] + - [ "aa", 5, 1590738990000, 4.0] + - [ "aa", 6, 1590738990000, 4.0] + - [ "aa", 7, 1590738991000, 4.0] + - [ "aa", 8, 1590738992000, 4.0] + - [ "aa", 9, 1590738993000, 4.0] + - id: 18 + desc: ROWS Window with same timestamp Exclude CurretTime + mode: disk-unsupport + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738990000 ] + - [ "aa",4, 1.0, 1590738990000 ] + - [ "aa",5, 1.0, 1590738990000 ] + - [ "aa",6, 1.0, 1590738990000 ] + - [ "aa",7, 1.0, 1590738991000 ] + - [ "aa",8, 1.0, 1590738992000 ] + - [ "aa",9, 1.0, 1590738993000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double"] + rows: + - [ "aa", 1, 1590738990000, 1.0] + - [ "aa", 2, 1590738990000, 1.0] + - [ "aa", 3, 1590738990000, 1.0] + - [ "aa", 4, 1590738990000, 1.0] + - [ "aa", 5, 1590738990000, 1.0] + - [ "aa", 6, 1590738990000, 1.0] + - [ "aa", 7, 1590738991000, 4.0] + - [ "aa", 8, 1590738992000, 4.0] + - [ "aa", 9, 1590738993000, 4.0] + - id: 19 + desc: ROWS, ROWS_RANGE Window, Normal Window, OPEN Window, EXCLUDE CURRENT TIME Window + mode: batch-unsupport,disk-unsupport + tags: ["@chendihao, @baoxinqi, 测试的时候spark需要保证输入数据滑入顺序"] + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738990000 ] + - [ "aa",3, 1.0, 1590738990000 ] + - [ "aa",4, 1.0, 1590738990000 ] + - [ "aa",5, 1.0, 1590738990000 ] + - [ "aa",6, 1.0, 1590738990000 ] + - [ "aa",7, 1.0, 1590738991000 ] + - [ "aa",8, 1.0, 1590738992000 ] + - [ "aa",9, 1.0, 1590738993000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum, + sum(c4) OVER w3 as w3_c4_sum, + sum(c4) OVER w4 as w4_c4_sum, + sum(c4) OVER w5 as w5_c4_sum, + sum(c4) OVER w6 as w6_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 OPEN PRECEDING AND CURRENT ROW), + w3 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME), + w4 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW), + w5 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s OPEN PRECEDING AND CURRENT ROW), + w6 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s OPEN PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME); + + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double", "w3_c4_sum double", + "w4_c4_sum double", "w5_c4_sum double", "w6_c4_sum double"] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] + - [ "aa", 2, 1590738990000, 2.0, 2.0, 1.0, 2.0, 2.0, 1.0] + - [ "aa", 3, 1590738990000, 3.0, 3.0, 1.0, 3.0, 3.0, 1.0] + - [ "aa", 4, 1590738990000, 4.0, 3.0, 1.0, 4.0, 4.0, 1.0] + - [ "aa", 5, 1590738990000, 4.0, 3.0, 1.0, 5.0, 5.0, 1.0] + - [ "aa", 6, 1590738990000, 4.0, 3.0, 1.0, 6.0, 6.0, 1.0] + - [ "aa", 7, 1590738991000, 4.0, 3.0, 3.0, 7.0, 7.0, 7.0] + - [ "aa", 8, 1590738992000, 4.0, 3.0, 3.0, 8.0, 8.0, 8.0] + - [ "aa", 9, 1590738993000, 4.0, 3.0, 3.0, 9.0, 3.0, 3.0] diff --git a/cases/integration_test/window/test_window_row.yaml b/cases/integration_test/window/test_window_row.yaml new file mode 100644 index 00000000000..c4b0814f8ba --- /dev/null +++ b/cases/integration_test/window/test_window_row.yaml @@ -0,0 +1,920 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - + id: 0 + desc: string为partition by + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,30] + - ["aa",21,61] + - ["aa",22,93] + - ["aa",23,96] + - ["bb",24,34] + - + id: 1 + desc: int为partition by + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [2,"bb",20,61] + - [3,"cc",20,93] + - [4,"dd",20,96] + - [5,"ee",21,34] + - + id: 2 + desc: float为partition by - 未命中索引 + mode: rtidb-unsupport + tags: ["TODO", "@chenjing", "0.3.0", "window partition by float under non-performance-sensitive mode"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.1,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.1,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.2,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c5, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c5 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c5 float","w1_c4_sum bigint"] + rows: + - [1,"aa",1.1,30] + - [2,"bb",1.1,61] + - [3,"cc",1.1,93] + - [4,"dd",1.1,96] + - [5,"ee",1.2,34] + - + id: 3 + desc: double为partition by - 未命中索引 + mode: rtidb-unsupport + tags: ["TODO", "@chenjing", "0.3.0", "window partition by float under non-performance-sensitive mode"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c6, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c6 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c6 double","w1_c4_sum bigint"] + rows: + - [1,"aa",2.1,30] + - [2,"bb",2.1,61] + - [3,"cc",2.1,93] + - [4,"dd",2.1,96] + - [5,"ee",2.2,34] + - + id: 4 + desc: date为partition by + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c8:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-02"] + sql: | + SELECT id, c1, c8, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c8 date","w1_c4_sum bigint"] + rows: + - [1,"aa","2020-05-01",30] + - [2,"bb","2020-05-01",61] + - [3,"cc","2020-05-01",93] + - [4,"dd","2020-05-01",96] + - [5,"ee","2020-05-02",34] + - + id: 5 + desc: timestamp为partition by + inputs: + - + columns : ["id bigint","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c7:id"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c7, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.id ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint","c1 string","c7 timestamp","w1_c4_sum bigint"] + rows: + - [1,"aa",1590738990000,30] + - [2,"bb",1590738990000,61] + - [3,"cc",1590738990000,93] + - [4,"dd",1590738990000,96] + - [5,"ee",1590738991000,34] + - + id: 6 + desc: bigint为partition by + inputs: + - + columns : ["id bigint","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c4:id"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c4 ORDER BY {0}.id ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id bigint","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",30,2] + - [3,"cc",30,3] + - [4,"dd",30,3] + - [5,"ee",31,1] + - + id: 7 + desc: bigint为order by + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c8:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c4 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",31,2] + - [3,"cc",32,3] + - [4,"dd",33,3] + - [5,"ee",34,1] + - + id: 8 + desc: 多个pk + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"aa",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - [6,"bb",24,35,1.5,2.5,1590738995000,"2020-05-06"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [2,"aa",20,61] + - [3,"aa",20,93] + - [4,"aa",20,96] + - [5,"aa",24,34] + - [6,"bb",24,35] + - + id: 9 + desc: 两个pk都使用了索引 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1|c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"aa",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - [6,"bb",24,35,1.5,2.5,1590738995000,"2020-05-06"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [2,"aa",20,61] + - [3,"aa",20,93] + - [4,"aa",20,96] + - [5,"aa",24,34] + - [6,"bb",24,35] + - + id: 13-2 + desc: 两个pk都使用了索引 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"aa",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"aa",24,34,1.5,2.5,1590738994000,"2020-05-05"] + - [6,"bb",24,35,1.5,2.5,1590738995000,"2020-05-06"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [2,"aa",20,61] + - [3,"aa",20,93] + - [4,"aa",20,96] + - [5,"aa",24,34] + - [6,"bb",24,35] + - + id: 10 + desc: 多个window指定相同的pk + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"bb",20,61,2] + - [3,"cc",20,93,3] + - [4,"dd",20,96,3] + - [5,"ee",21,34,1] + - + id: 11 + desc: 多个window指定相不同的pk + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7", "index2:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"cc",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY c3 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY c1 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"aa",20,61,2] + - [3,"cc",20,93,1] + - [4,"cc",20,96,2] + - [5,"ee",21,34,1] + - + id: 12 + desc: 多个windowpk是table.column模式 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7", "index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"cc",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"aa",20,61,2] + - [3,"cc",20,93,1] + - [4,"cc",20,96,2] + - [5,"ee",21,34,1] + - + id: 13-1 + desc: 多个window指定不同的ts, 数据时间乱序插入,batch模式预期 + mode: request-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7", "index2:c3:c4"] + rows: + - [1,"aa",20,33,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,30,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,32,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,33,3] + - [2,"bb",20,64,2] + - [3,"cc",20,94,1] + - [4,"dd",20,93,3] + - [5,"ee",21,34,1] + - + id: 13-2 + desc: 多个window指定不同的ts, 数据时间乱序插入,request模式预期 + mode: batch-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7", "index2:c3:c4"] + rows: + - [1,"aa",20,33,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,30,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,32,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,33,1] + - [2,"bb",20,64,1] + - [3,"cc",20,94,1] + - [4,"dd",20,93,3] + - [5,"ee",21,34,1] + - + id: 13-3 + desc: 多个window指定不同的ts, 数据按时间顺序插入 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7", "index2:c3:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"bb",20,61,2] + - [3,"cc",20,93,3] + - [4,"dd",20,96,3] + - [5,"ee",21,34,1] + - + id: 14 + desc: 两个window其中两个pk为索引列 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"cc",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"aa",20,61,2] + - [3,"cc",20,93,1] + - [4,"cc",20,96,2] + - [5,"ee",21,34,1] + - + id: 15 + desc: 两个window其中一个pk和两个pk + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7","index2:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"cc",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"cc",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint"] + rows: + - [1,"aa",20,30,1] + - [2,"aa",20,61,2] + - [3,"cc",20,93,1] + - [4,"cc",20,96,2] + - [5,"cc",21,34,1] + - + id: 16 + desc: 全部window + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, count(c3) OVER w1 as w1_c3_count, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + columns: ["id int", "w1_c3_count bigint","w1_c4_sum bigint"] + order: id + rows: + - [1, 1,30] + - [2, 2,61] + - [3, 3,93] + - [4, 3,96] + - [5, 1,34] + - + id: 17 + desc: 结合limit + tags: ["TODO", "LIMIT批模式没有确定性输出"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) limit 2; + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [5,"ee",21,34] + - + id: 18 + desc: window的计算结果不使用别名 + mode: cli-unsupport + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","sum(c4)over w1 bigint"] + rows: + - [1,"aa",20,30] + - [2,"bb",20,61] + - [3,"cc",20,93] + - [4,"dd",20,96] + - [5,"ee",21,34] + - + id: 19 + desc: case when window expression then window expression else null end + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["bb",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c4, + case when lag(c1, 0) OVER w1 == "aa" then sum(c4) over w1 + else null end + as sum_c1_w1 FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: c4 + columns: ["c1 string","c4 bigint","sum_c1_w1 bigint"] + rows: + - ["aa",30,30] + - ["aa",31,61] + - ["aa",32,93] + - ["bb",33,NULL] + - ["bb",34,NULL] + - + id: 20 + desc: case when window expr then window expr else window expr + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["bb",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c4, + case when lag(c1, 0) OVER w1 == "aa" then sum(c4) over w1 + else min(c4) over w1 end + as sum_c1_w1 FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: c4 + columns: ["c1 string","c4 bigint","sum_c1_w1 bigint"] + rows: + - ["aa",30,30] + - ["aa",31,61] + - ["aa",32,93] + - ["bb",33,33] + - ["bb",34,33] + - + id: 21 + desc: case when simple expression then window expression else null end + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["bb",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c4, + case when c1 == "aa" then sum(c4) over w1 + else null end + as sum_c1_w1 FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: c4 + columns: ["c1 string","c4 bigint","sum_c1_w1 bigint"] + rows: + - ["aa",30,30] + - ["aa",31,61] + - ["aa",32,93] + - ["bb",33,NULL] + - ["bb",34,NULL] + - + id: 22 + desc: window expression + window expression + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["bb",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, c4, + (sum(c4) over w1 + sum(c3) over w1) as sum_c3_c4_w1 FROM {0} + WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: c4 + columns: ["c1 string","c3 int", "c4 bigint","sum_c3_c4_w1 bigint"] + rows: + - ["aa",20, 30, 50] + - ["aa",21, 31, 102] + - ["aa",22, 32, 156] + - ["bb",23, 33, 56] + - ["bb",24, 34, 114] + + - + id: 28 + desc: 匿名窗口 + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as w1_c4_sum FROM {0}; + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,30] + - ["aa",21,61] + - ["aa",22,93] + - ["aa",23,96] + - ["bb",24,34] + - + id: 29 + desc: 匿名窗口-没有小括号 + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW as w1_c4_sum FROM {0}; + expect: + success: false + - + id: 30 + desc: smallint为partition by + inputs: + - + columns : ["id int","c1 string","c3 smallint","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 smallint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [2,"bb",20,61] + - [3,"cc",20,93] + - [4,"dd",20,96] + - [5,"ee",21,34] + - + id: 31 + desc: bool为partition by + tags: ["TODO", "bug"] + inputs: + - + columns : ["id int","c1 string","c2 bool","c3 smallint","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c2:c7"] + rows: + - [1,"aa",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",true,20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",true,20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",true,20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",false,21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c2, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c2 bool","w1_c4_sum bigint"] + rows: + - [1,"aa",true,30] + - [2,"bb",true,61] + - [3,"cc",true,93] + - [4,"dd",true,96] + - [5,"ee",false,34] + - + id: 33 + desc: int为order by + tags: ["TODO"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c3 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 34 + desc: smallint为order by + tags: ["TODO"] + inputs: + - + columns : ["id int","c1 string","c3 smallint","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c3 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 35 + desc: bool为order by + inputs: + - + columns : ["id int","c1 string","c2 bool","c3 smallint","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",false,21,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c2 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 37 + desc: no frame + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7); + expect: + success: false + + - + id: 38 + desc: rows 1-2 + version: 0.6.0 + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,NULL] + - ["aa",21,30] + - ["aa",22,61] + - ["aa",23,63] + - ["bb",24,NULL] + - + id: 39 + desc: rows 0-2 + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND 0 PRECEDING); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,30] + - ["aa",21,61] + - ["aa",22,93] + - ["aa",23,96] + - ["bb",24,34] + - + id: 40 + desc: rows -1-2 + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND -1 PRECEDING); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,30] + - ["aa",21,61] + - ["aa",22,93] + - ["aa",23,96] + - ["bb",24,34] diff --git a/cases/integration_test/window/test_window_row_range.yaml b/cases/integration_test/window/test_window_row_range.yaml new file mode 100644 index 00000000000..71681b7d41e --- /dev/null +++ b/cases/integration_test/window/test_window_row_range.yaml @@ -0,0 +1,1497 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: string为partition by + inputs: + - columns: [ "c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ "aa",21,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ "aa",22,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ "aa",23,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ "bb",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: c3 + columns: [ "c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ "aa",20,30 ] + - [ "aa",21,61 ] + - [ "aa",22,93 ] + - [ "aa",23,96 ] + - [ "bb",24,34 ] + - id: 1 + desc: int为partition by + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ 1,"aa",20,30 ] + - [ 2,"bb",20,61 ] + - [ 3,"cc",20,93 ] + - [ 4,"dd",20,96 ] + - [ 5,"ee",21,34 ] + - id: 2 + desc: float为partition by - 未命中索引 + mode: rtidb-unsupport + tags: ["TODO", "@chenjing", "0.3.0", "window partition by float under non-performance-sensitive mode"] + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.1,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.1,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.1,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.2,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c5, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c5 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c5 float","w1_c4_sum bigint" ] + rows: + - [ 1,"aa",1.1,30 ] + - [ 2,"bb",1.1,61 ] + - [ 3,"cc",1.1,93 ] + - [ 4,"dd",1.1,96 ] + - [ 5,"ee",1.2,34 ] + - id: 3 + desc: double为partition by - 未命中索引 + mode: rtidb-unsupport + tags: ["TODO", "@chenjing", "0.3.0", "window partition by float under non-performance-sensitive mode"] + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c6, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c6 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c6 double","w1_c4_sum bigint" ] + rows: + - [ 1,"aa",2.1,30 ] + - [ 2,"bb",2.1,61 ] + - [ 3,"cc",2.1,93 ] + - [ 4,"dd",2.1,96 ] + - [ 5,"ee",2.2,34 ] + - id: 4 + desc: date为partition by + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c8:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.1,2.1,1590738991000,"2020-05-01" ] + - [ 3,"cc",20,32,1.1,2.1,1590738992000,"2020-05-01" ] + - [ 4,"dd",20,33,1.1,2.1,1590738993000,"2020-05-01" ] + - [ 5,"ee",21,34,1.2,2.2,1590738994000,"2020-05-02" ] + sql: | + SELECT id, c1, c8, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c8 date","w1_c4_sum bigint" ] + rows: + - [ 1,"aa","2020-05-01",30 ] + - [ 2,"bb","2020-05-01",61 ] + - [ 3,"cc","2020-05-01",93 ] + - [ 4,"dd","2020-05-01",96 ] + - [ 5,"ee","2020-05-02",34 ] + - id: 5 + desc: timestamp为partition by + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date","c9 timestamp" ] + indexs: [ "index1:c7:c9" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01",1590738990000 ] + - [ 2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01",1590738991000 ] + - [ 3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01",1590738992000 ] + - [ 4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01",1590738993000 ] + - [ 5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02",1590738994000 ] + sql: | + SELECT id, c1, c7, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c9 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c7 timestamp","w1_c4_sum bigint" ] + rows: + - [ 1,"aa",1590738990000,30 ] + - [ 2,"bb",1590738990000,61 ] + - [ 3,"cc",1590738990000,93 ] + - [ 4,"dd",1590738990000,96 ] + - [ 5,"ee",1590738991000,34 ] + - id: 6 + desc: bigint为partition by + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c4:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,30,1.1,2.1,1590738991000,"2020-05-01" ] + - [ 3,"cc",20,30,1.1,2.1,1590738992000,"2020-05-01" ] + - [ 4,"dd",20,30,1.1,2.1,1590738993000,"2020-05-01" ] + - [ 5,"ee",21,31,1.2,2.2,1590738994000,"2020-05-02" ] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c4 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c4 bigint","w1_c4_count bigint" ] + rows: + - [ 1,"aa",30,1 ] + - [ 2,"bb",30,2 ] + - [ 3,"cc",30,3 ] + - [ 4,"dd",30,3 ] + - [ 5,"ee",31,1 ] + - id: 7 + desc: string为order by + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,30,1.1,2.1,1590738991000,"2020-05-01" ] + - [ 3,"cc",20,30,1.1,2.1,1590738992000,"2020-05-01" ] + - [ 4,"dd",20,30,1.1,2.1,1590738993000,"2020-05-01" ] + - [ 5,"ee",21,31,1.2,2.2,1590738994000,"2020-05-02" ] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c1 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + + - + id: 8 + desc: bigint为order by-不加单位-bigint + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02" ] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c4 bigint","w1_c4_count bigint" ] + rows: + - [ 1,"aa",30,1 ] + - [ 2,"bb",31,2 ] + - [ 3,"cc",32,3 ] + - [ 4,"dd",33,3 ] + - [ 5,"ee",34,1 ] + - id: 8-2 + desc: int为order by-未命中TS + mode: rtidb-unsupport,cli-unsupport + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c8:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",21,31,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 3,"cc",22,32,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 4,"dd",23,33,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 5,"ee",24,34,1.2,2.2,1590738991000,"2020-05-02" ] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c3 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c4 bigint","w1_c4_count bigint" ] + rows: + - [ 1,"aa",30,1 ] + - [ 2,"bb",31,2 ] + - [ 3,"cc",32,3 ] + - [ 4,"dd",33,3 ] + - [ 5,"ee",34,1 ] + - id: 8-3 + desc: bigint为order by-加单位 + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c4" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02" ] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c4 bigint","w1_c4_count bigint" ] + rows: + - [ 1,"aa",30,1 ] + - [ 2,"bb",31,2 ] + - [ 3,"cc",32,3 ] + - [ 4,"dd",33,4 ] + - [ 5,"ee",34,1 ] + - id: 8-4 + desc: int为order by-加单位-未命中索引 + mode: rtidb-unsupport,cli-unsupport + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",21,31,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 3,"cc",22,32,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 4,"dd",23,33,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 5,"ee",24,34,1.2,2.2,1590738991000,"2020-05-02" ] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c3 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c4 bigint","w1_c4_count bigint" ] + rows: + - [ 1,"aa",30,1 ] + - [ 2,"bb",31,2 ] + - [ 3,"cc",32,3 ] + - [ 4,"dd",33,4 ] + - [ 5,"ee",34,1 ] + - id: 9 + desc: float为order by + mode: rtidb-unsupport + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c8:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.1,1590738990000,"2020-05-01" ] + - [ 3,"cc",20,32,1.3,2.1,1590738990000,"2020-05-01" ] + - [ 4,"dd",20,33,1.4,2.1,1590738990000,"2020-05-01" ] + - [ 5,"ee",21,34,1.5,2.2,1590738991000,"2020-05-02" ] + sql: | + SELECT id, c1, c5, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c5 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 10 + desc: double为order by + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738990000,"2020-05-01" ] + - [ 3,"cc",20,32,1.3,2.3,1590738990000,"2020-05-01" ] + - [ 4,"dd",20,33,1.4,2.4,1590738990000,"2020-05-01" ] + - [ 5,"ee",21,34,1.5,2.5,1590738991000,"2020-05-02" ] + sql: | + SELECT id, c1, c6, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ORDER BY {0}.c6 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 11 + desc: date为order by-未命中索引 + mode: offline-unsupport + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738990000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738990000,"2020-05-03" ] + - [ 4,"dd",20,33,1.4,2.4,1590738990000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738991000,"2020-05-05" ] + sql: | + SELECT id, c1, c8, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c8 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 12 + desc: 多个pk + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1|c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"aa",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"aa",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"aa",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + - [ 6,"bb",24,35,1.5,2.5,1590738995000,"2020-05-06" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ 1,"aa",20,30 ] + - [ 2,"aa",20,61 ] + - [ 3,"aa",20,93 ] + - [ 4,"aa",20,96 ] + - [ 5,"aa",24,34 ] + - [ 6,"bb",24,35 ] + - id: 13 + desc: 两个pk都使用了索引 + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1|c3:c7","index2:c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"aa",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"aa",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"aa",24,34,1.5,2.5,1590738994000,"2020-05-05" ] + - [ 6,"bb",24,35,1.5,2.5,1590738995000,"2020-05-06" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ 1,"aa",20,30 ] + - [ 2,"aa",20,61 ] + - [ 3,"aa",20,93 ] + - [ 4,"aa",20,96 ] + - [ 5,"aa",24,34 ] + - [ 6,"bb",24,35 ] + - id: 14 + desc: 多个window指定相同的pk + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint" ] + rows: + - [ 1,"aa",20,30,1 ] + - [ 2,"bb",20,61,2 ] + - [ 3,"cc",20,93,3 ] + - [ 4,"dd",20,96,3 ] + - [ 5,"ee",21,34,1 ] + - id: 15 + desc: 多个window指定相不同的pk + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7", "index2:c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"cc",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint" ] + rows: + - [ 1,"aa",20,30,1 ] + - [ 2,"aa",20,61,2 ] + - [ 3,"cc",20,93,1 ] + - [ 4,"cc",20,96,2 ] + - [ 5,"ee",21,34,1 ] + - id: 16-1 + desc: 多个window指定不同的ts, 数据时间乱序插入,batch模式预期 + mode: request-unsupport + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c7", "index2:c3:c4" ] + rows: + - [ 1,"aa",20,33,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,30,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,32,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint" ] + rows: + - [ 1,"aa",20,33,3 ] + - [ 2,"bb",20,64,2 ] + - [ 3,"cc",20,94,1 ] + - [ 4,"dd",20,93,3 ] + - [ 5,"ee",21,34,1 ] + + - id: 16-2 + desc: 多个window指定不同的ts, 数据时间乱序插入,request模式预期 + mode: batch-unsupport + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c7", "index2:c3:c4" ] + rows: + - [ 1,"aa",20,33,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,30,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,32,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint" ] + rows: + - [ 1,"aa",20,33,1 ] + - [ 2,"bb",20,64,1 ] + - [ 3,"cc",20,94,1 ] + - [ 4,"dd",20,93,3 ] + - [ 5,"ee",21,34,1 ] + - id: 16-3 + desc: 多个window指定不同的ts, 数据时间按序插入 + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c7", "index2:c3:c4" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint" ] + rows: + - [ 1,"aa",20,30,1 ] + - [ 2,"bb",20,61,2 ] + - [ 3,"cc",20,93,3 ] + - [ 4,"dd",20,96,3 ] + - [ 5,"ee",21,34,1 ] + - id: 17 + desc: 两个window其中两个pk为索引列 + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7","index2:c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"cc",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint" ] + rows: + - [ 1,"aa",20,30,1 ] + - [ 2,"aa",20,61,2 ] + - [ 3,"cc",20,93,1 ] + - [ 4,"cc",20,96,2 ] + - [ 5,"ee",21,34,1 ] + - id: 18 + desc: 两个window其中一个pk和两个pk + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7","index2:c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"cc",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"cc",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum, count(c4) OVER w2 as w2_c4_count FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint","w2_c4_count bigint" ] + rows: + - [ 1,"aa",20,30,1 ] + - [ 2,"aa",20,61,2 ] + - [ 3,"cc",20,93,1 ] + - [ 4,"cc",20,96,2 ] + - [ 5,"cc",21,34,1 ] + - id: 19 + desc: 全部window + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, count(c3) OVER w1 as w1_c3_count, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + columns: [ "id int", "w1_c3_count bigint","w1_c4_sum bigint" ] + order: id + rows: + - [ 1, 1,30 ] + - [ 2, 2,61 ] + - [ 3, 3,93 ] + - [ 4, 3,96 ] + - [ 5, 1,34 ] + - id: 20 + tags: [ "TODO", "@zhaowei暂时不要引入LIMIT的case,LIMIT的case需要spark,rtidb分别预期结果" ] + desc: 结合limit + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW) limit 2; + expect: + order: id + columns: [ "id int","c1 string","c3 int","w1_c4_sum bigint" ] + rows: + - [ 1,"aa",20,30 ] + - [ 5,"ee",21,34 ] + - id: 22 + desc: window的计算结果不使用别名 + mode: cli-unsupport + inputs: + - columns: [ "id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date" ] + indexs: [ "index1:c3:c7" ] + rows: + - [ 1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01" ] + - [ 2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02" ] + - [ 3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03" ] + - [ 4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04" ] + - [ 5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05" ] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: [ "id int","c1 string","c3 int","sum(c4)over w1 bigint" ] + rows: + - [ 1,"aa",20,30 ] + - [ 2,"bb",20,61 ] + - [ 3,"cc",20,93 ] + - [ 4,"dd",20,96 ] + - [ 5,"ee",21,34 ] + - id: 23-1 + desc: ROWS_RANGE Window with MaxSize + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0 ] + - [ "aa", 2, 1590738991000, 2.0 ] + - [ "aa", 3, 1590738992000, 2.0 ] + - [ "aa", 4, 1590738993000, 2.0 ] + - [ "aa", 5, 1590738994000, 2.0 ] + - [ "aa", 6, 1590738995000, 2.0 ] + - [ "aa", 7, 1590738999000, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0 ] + - [ "aa", 9, 1590739002000, 2.0 ] + - id: 23-2 + desc: ROWS_RANGE Current History Window with MaxSize 2 + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 10); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0 ] + - [ "aa", 2, 1590738991000, 2.0 ] + - [ "aa", 3, 1590738992000, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0 ] + - [ "aa", 5, 1590738994000, 4.0 ] + - [ "aa", 6, 1590738995000, 4.0 ] + - [ "aa", 7, 1590738999000, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0 ] + - id: 24-1 + desc: ROWS_RANGE Pure History Window + version: 0.6.0 + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND 1s PRECEDING); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, NULL ] + - [ "aa", 2, 1590738991000, 1.0 ] + - [ "aa", 3, 1590738992000, 2.0 ] + - [ "aa", 4, 1590738993000, 3.0 ] + - [ "aa", 5, 1590738994000, 3.0 ] + - [ "aa", 6, 1590738995000, 3.0 ] + - [ "aa", 7, 1590738999000, NULL ] + - [ "aa", 8, 1590739001000, 1.0 ] + - [ "aa", 9, 1590739002000, 2.0 ] + - id: 24-2 + desc: ROWS_RANGE Pure History Window With MaxSize + version: 0.6.0 + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 3000 PRECEDING, 1000 PRECEDING, maxsize=2), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + + batch_plan: | + PROJECT(type=WindowAggregation) + +-WINDOW(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 3000 PRECEDING, 1000 PRECEDING, maxsize=2)) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND 1s PRECEDING MAXSIZE 2); + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, NULL ] + - [ "aa", 2, 1590738991000, 1.0 ] + - [ "aa", 3, 1590738992000, 2.0 ] + - [ "aa", 4, 1590738993000, 2.0 ] + - [ "aa", 5, 1590738994000, 2.0 ] + - [ "aa", 6, 1590738995000, 2.0 ] + - [ "aa", 7, 1590738999000, NULL ] + - [ "aa", 8, 1590739001000, 1.0 ] + - [ "aa", 9, 1590739002000, 2.0 ] + - id: 25 + desc: ROWS_RANGE Current History Window with MaxSize Merge + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 4), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW MAXSIZE 4); + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 3000 PRECEDING, 0 CURRENT, maxsize=4), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + batch_plan: | + PROJECT(type=WindowAggregation) + +-WINDOW(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 3000 PRECEDING, 0 CURRENT, maxsize=4)) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738991000, 2.0, 2.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 3.0 ] + - [ "aa", 5, 1590738994000, 4.0, 3.0 ] + - [ "aa", 6, 1590738995000, 4.0, 3.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0, 2.0 ] + - id: 26 + desc: ROWS_RANGE Window with MaxSize Not Merge + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2); + request_plan: | + SIMPLE_PROJECT(sources=(c1, c3, c7, w1_c4_sum, w2_c4_sum)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 3000 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 3000 PRECEDING, 0 CURRENT, maxsize=2), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738991000, 2.0, 2.0 ] + - [ "aa", 3, 1590738992000, 3.0, 2.0 ] + - [ "aa", 4, 1590738993000, 4.0, 2.0 ] + - [ "aa", 5, 1590738994000, 4.0, 2.0 ] + - [ "aa", 6, 1590738995000, 4.0, 2.0 ] + - [ "aa", 7, 1590738999000, 1.0, 1.0 ] + - [ "aa", 8, 1590739001000, 2.0, 2.0 ] + - [ "aa", 9, 1590739002000, 3.0, 2.0 ] + + - id: 27-1 + desc: ROWS and ROWS_RANGE Current History Window with MaxSize Merge + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6s PRECEDING AND CURRENT ROW MAXSIZE 5); + request_plan: | + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 6000 PRECEDING, 0 CURRENT, maxsize=5), rows=(auto_t0.c7, 3 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + batch_plan: | + PROJECT(type=WindowAggregation) + +-WINDOW(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 6000 PRECEDING, 0 CURRENT, maxsize=5), rows=(auto_t0.c7, 3 PRECEDING, 0 CURRENT)) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738991000, 2.0, 2.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 4.0, 5.0 ] + - [ "aa", 6, 1590738995000, 4.0, 5.0 ] + - [ "aa", 7, 1590738999000, 4.0, 4.0 ] + - [ "aa", 8, 1590739001000, 4.0, 3.0 ] + - [ "aa", 9, 1590739002000, 4.0, 3.0 ] + - id: 27-2 + desc: ROWS and ROWS_RANGE Current History Window with MaxSize, MaxSize < ROWS Preceding, Can't Merge Frame + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 7 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6s PRECEDING AND CURRENT ROW MAXSIZE 5); + request_plan: | + SIMPLE_PROJECT(sources=(c1, c3, c7, w1_c4_sum, w2_c4_sum)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(auto_t0.c7, 7 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 6000 PRECEDING, 0 CURRENT, maxsize=5), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, 1.0 ] + - [ "aa", 2, 1590738991000, 2.0, 2.0 ] + - [ "aa", 3, 1590738992000, 3.0, 3.0 ] + - [ "aa", 4, 1590738993000, 4.0, 4.0 ] + - [ "aa", 5, 1590738994000, 5.0, 5.0 ] + - [ "aa", 6, 1590738995000, 6.0, 5.0 ] + - [ "aa", 7, 1590738999000, 7.0, 4.0 ] + - [ "aa", 8, 1590739001000, 8.0, 3.0 ] + - [ "aa", 9, 1590739002000, 8.0, 3.0 ] + + - id: 27-3 + desc: ROWS and ROWS_RANGE Pure History Window Cant' Be Merge + version: 0.6.0 + inputs: + - columns: [ "c1 string","c3 int","c4 double","c7 timestamp" ] + indexs: [ "index1:c1:c7" ] + rows: + - [ "aa",1, 1.0, 1590738990000 ] + - [ "aa",2, 1.0, 1590738991000 ] + - [ "aa",3, 1.0, 1590738992000 ] + - [ "aa",4, 1.0, 1590738993000 ] + - [ "aa",5, 1.0, 1590738994000 ] + - [ "aa",6, 1.0, 1590738995000 ] + - [ "aa",7, 1.0, 1590738999000 ] + - [ "aa",8, 1.0, 1590739001000 ] + - [ "aa",9, 1.0, 1590739002000 ] + sql: | + SELECT c1, c3, c7, + sum(c4) OVER w1 as w1_c4_sum, + sum(c4) OVER w2 as w2_c4_sum + FROM {0} WINDOW + w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW), + w2 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 6s PRECEDING AND 2s PRECEDING); + request_plan: | + SIMPLE_PROJECT(sources=(c1, c3, c7, w1_c4_sum, w2_c4_sum)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(auto_t0.c7, 3 PRECEDING, 0 CURRENT), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(auto_t0.c7, 6000 PRECEDING, 2000 PRECEDING), index_keys=(auto_t0.c1)) + DATA_PROVIDER(request=auto_t0) + DATA_PROVIDER(type=Partition, table=auto_t0, index=index1) + + expect: + order: c3 + columns: [ "c1 string", "c3 int", "c7 timestamp", "w1_c4_sum double", "w2_c4_sum double" ] + rows: + - [ "aa", 1, 1590738990000, 1.0, NULL ] + - [ "aa", 2, 1590738991000, 2.0, NULL ] + - [ "aa", 3, 1590738992000, 3.0, 1.0 ] + - [ "aa", 4, 1590738993000, 4.0, 2.0 ] + - [ "aa", 5, 1590738994000, 4.0, 3.0 ] + - [ "aa", 6, 1590738995000, 4.0, 4.0 ] + - [ "aa", 7, 1590738999000, 4.0, 3.0 ] + - [ "aa", 8, 1590739001000, 4.0, 2.0 ] + - [ "aa", 9, 1590739002000, 4.0, 1.0 ] + - + id: 28 + desc: 匿名窗口 + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) as w1_c4_sum FROM {0}; + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,30] + - ["aa",21,61] + - ["aa",22,93] + - ["aa",23,96] + - ["bb",24,34] + - + id: 29 + desc: 匿名窗口-没有小括号 + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW as w1_c4_sum FROM {0}; + expect: + success: false + - + id: 30 + desc: smallint为partition by + inputs: + - + columns : ["id int","c1 string","c3 smallint","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 smallint","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [2,"bb",20,61] + - [3,"cc",20,93] + - [4,"dd",20,96] + - [5,"ee",21,34] + - + id: 31 + desc: bool为partition by + tags: ["TODO", "bug"] + inputs: + - + columns : ["id int","c1 string","c2 bool","c3 smallint","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c2:c7"] + rows: + - [1,"aa",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",true,20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",true,20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",true,20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",false,21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c2, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c2 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c2 bool","w1_c4_sum bigint"] + rows: + - [1,"aa",true,30] + - [2,"bb",true,61] + - [3,"cc",true,93] + - [4,"dd",true,96] + - [5,"ee",false,34] + - + id: 32 + desc: no partition by + tags: ["TODO"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 33 + desc: int为order by + tags: ["TODO"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c3 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 34 + desc: smallint为order by + tags: ["TODO"] + inputs: + - + columns : ["id int","c1 string","c3 smallint","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c3 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 35 + desc: bool为order by + inputs: + - + columns : ["id int","c1 string","c2 bool","c3 smallint","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",true,20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",false,21,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c7 ORDER BY {0}.c2 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + + - + id: 36 + desc: no order by + tags: ["TODO","bug待修复"] + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c8:c4"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c8 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - + id: 37 + desc: no frame + inputs: + - + columns: ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7); + expect: + success: false + - + id: 38 + desc: bigint为order by-加单位 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2s PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",31,2] + - [3,"cc",32,3] + - [4,"dd",33,4] + - [5,"ee",34,1] + - + id: 39 + desc: timestamp为order by-不加单位 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738990001,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1590738990002,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1590738990003,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",31,2] + - [3,"cc",32,3] + - [4,"dd",33,3] + - [5,"ee",34,1] + - + id: 40 + desc: timestamp为order by-加单位-m + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755660000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1606755720000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1606755780000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1606755840000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1606755660000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2m PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",31,2] + - [3,"cc",32,3] + - [4,"dd",33,3] + - [5,"ee",34,1] + - + id: 41 + desc: timestamp为order by-加单位-h + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606755600000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1606759200000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1606762800000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1606766400000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1606766400000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2h PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",31,2] + - [3,"cc",32,3] + - [4,"dd",33,3] + - [5,"ee",34,1] + - + id: 42 + desc: timestamp为order by-加单位-d + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1606752000000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1606838400000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1606924800000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1607011200000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1606752000000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2d PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",31,2] + - [3,"cc",32,3] + - [4,"dd",33,3] + - [5,"ee",34,1] + - + id: 43 + desc: bigint为order by-前后都不加单位,1-2 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,0] + - [2,"bb",31,1] + - [3,"cc",32,2] + - [4,"dd",33,2] + - [5,"ee",34,0] + - + id: 44 + desc: bigint为order by-前后都不加单位,0-2 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2 PRECEDING AND 0 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",31,2] + - [3,"cc",32,3] + - [4,"dd",33,3] + - [5,"ee",34,1] + - + id: 45 + desc: bigint为order by-前后都不加单位,-1-2 + inputs: + - + columns : ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c4"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,31,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.1,2.1,1590738990000,"2020-05-01"] + - [5,"ee",21,34,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c4, count(c4) OVER w1 as w1_c4_count FROM {0} WINDOW w1 AS (PARTITION BY {0}.c3 ORDER BY {0}.c4 ROWS_RANGE BETWEEN 2 PRECEDING AND -1 PRECEDING); + expect: + order: id + columns: ["id int","c1 string","c4 bigint","w1_c4_count bigint"] + rows: + - [1,"aa",30,1] + - [2,"bb",31,2] + - [3,"cc",32,3] + - [4,"dd",33,3] + - [5,"ee",34,1] + - + id: 46 + desc: timestamp为order by-2s-1s + version: 0.6.0 + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 1s PRECEDING); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,NULL] + - ["aa",21,30] + - ["aa",22,61] + - ["aa",23,63] + - ["bb",24,NULL] + - + id: 47 + desc: timestamp为order by-2s-0s + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 0s PRECEDING); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,30] + - ["aa",21,61] + - ["aa",22,93] + - ["aa",23,96] + - ["bb",24,34] + - + id: 48 + desc: timestamp为order by-2s-0 + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 0 PRECEDING); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,30] + - ["aa",21,61] + - ["aa",22,93] + - ["aa",23,96] + - ["bb",24,34] + - + id: 49 + desc: timestamp为order by-2s-1 + version: 0.6.0 + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738990001,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738990002,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738990003,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738990004,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 1 PRECEDING); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20, NULL] + - ["aa",21,30] + - ["aa",22,61] + - ["aa",23,93] + - ["bb",24, NULL] + - + id: 50 + desc: timestamp为order by-前后单位不一样 + version: 0.6.0 + inputs: + - + columns : ["c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - ["aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - ["aa",21,31,1.2,2.2,1590738991000,"2020-05-02"] + - ["aa",22,32,1.3,2.3,1590738992000,"2020-05-03"] + - ["aa",23,33,1.4,2.4,1590738993000,"2020-05-04"] + - ["bb",24,34,1.5,2.5,1590738994000,"2020-05-05"] + sql: | + SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (PARTITION BY {0}.c1 ORDER BY {0}.c7 ROWS_RANGE BETWEEN 2m PRECEDING AND 1s PRECEDING); + expect: + order: c3 + columns: ["c1 string","c3 int","w1_c4_sum bigint"] + rows: + - ["aa",20,NULL] + - ["aa",21,30] + - ["aa",22,61] + - ["aa",23,93] + - ["bb",24,NULL] diff --git a/cases/integration_test/window/test_window_union.yaml b/cases/integration_test/window/test_window_union.yaml new file mode 100644 index 00000000000..b11957c25e6 --- /dev/null +++ b/cases/integration_test/window/test_window_union.yaml @@ -0,0 +1,1152 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: 正常union + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 1 + desc: union的表列个数不一致 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000] + - [3,"cc",20,32,1.3,2.3,1590738992000] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 2 + desc: 列类型不一致 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 string"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 3 + desc: 列名不一致 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c9 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + success: false + - id: 4 + desc: 使用列别名后schema一致 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c9 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION (select id, c1,c3,c4,c5,c6,c7,c9 as c8 from {1}) + PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 5 + desc: 样本表使用索引,UNION表未命中索引 + mode: rtidb-unsupport + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 6 + desc: union表使用索引,样本表未命中索引 + mode: rtidb-unsupport + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 7 + desc: 样本表union表都使用索引 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 8 + desc: union多表 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [6,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1},{2} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,126] + - [5,"dd",20,129] + - [6,"ee",21,34] + - id: 9 + desc: 结合limit + tags: ["TODO", "@zhaowei remove limit case here"] + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) limit 2; + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [5,"ee",21,34] + - id: 10 + desc: 使用两个pk + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1|c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"aa",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - [6,"ee",21,33,1.4,2.4,1590738995000,"2020-05-04"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1|c3:c7"] + rows: + - [2,"aa",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"aa",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c1,{0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"aa",20,96] + - [5,"ee",21,34] + - [6,"ee",21,67] + - id: 11 + desc: 样本表和union表都使用子查询 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM (select * from {0}) WINDOW w1 AS (UNION (select * from {1}) PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 12 + desc: union多表,其中一个子查询 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [6,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION (select * from {1}),{2} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 3 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,126] + - [5,"dd",20,129] + - [6,"ee",21,34] + - id: 13 + desc: 样本表不进入window + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW + w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,93] + - [4,"dd",20,96] + - [5,"ee",21,34] + + - id: 14-1 + desc: WINDOW UNION 子查询, column cast 和 const cast子查询, string cast as date + mode: offline-unsupport + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4str string","c5 float","c6 double","c7 timestamp"] + indexs: ["index1:c3:c7"] + rows: + - [2, "bb", 20, "31", 1.2, 2.2, 1590738991000] + - [3, "cc", 20, "32", 1.3, 2.3, 1590738992000] + sql: | + SELECT id, c1, c3, c8, + distinct_count(c8) OVER w1 as w1_c8_dis_cnt, + sum(c4) OVER w1 as w1_c4_sum + FROM {0} WINDOW + w1 AS (UNION (select id, c1, c3, bigint(c4str) as c4, c5, c6, c7, date("2020-10-01") as c8 from {1}) + PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int", "c1 string", "c3 int", "c8 date", "w1_c8_dis_cnt bigint", "w1_c4_sum bigint"] + rows: + - [1, "aa", 20, "2020-05-01", 2, 93] + - [4, "dd", 20, "2020-05-04", 2, 96] + - [5, "ee", 21, "2020-05-05", 1, 34] + - id: 14-2 + desc: WINDOW UNION 子查询, column cast 和 const cast子查询. cast column as partition key + mode: offline-unsupport + inputs: + - columns: ["id int","c1 string","c3f float","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c1:c7"] + rows: + - [1,"aa",20.0, 30,1.1,2.1,1590738993000,"2020-05-01"] + - [4,"dd",20.1, 33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21.2, 34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000] + - [3,"cc",20,32,1.3,2.3,1590738992000] + sql: | + SELECT id, c1, c3, c8, + distinct_count(c8) OVER w1 as w1_c8_dis_cnt, + sum(c4) OVER w1 as w1_c4_sum + FROM (select id, c1, int(c3f) as c3, c4, c5, c6, c7, c8 from {0}) WINDOW + w1 AS (UNION (select id, c1, c3, c4, c5, c6, c7, date("2020-10-01") as c8 from {1}) + PARTITION BY c3 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int", "c1 string", "c3 int", "c8 date", "w1_c8_dis_cnt bigint", "w1_c4_sum bigint"] + rows: + - [1, "aa", 20, "2020-05-01", 2, 93] + - [4, "dd", 20, "2020-05-04", 2, 96] + - [5, "ee", 21, "2020-05-05", 1, 34] + - id: 14-3 + desc: WINDOW UNION 子查询, timestamp(string) as window ts + mode: offline-unsupport + inputs: + - columns: ["id int","c1 string","c3f float","c4 bigint","c5 float","c6 double","c7str string","c8 date"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa",20.0, 30,1.1,2.1,"2020-05-29 15:56:33","2020-05-01"] + - [4,"dd",20.1, 33,1.4,2.4,"2020-05-29 15:56:34","2020-05-04"] + - [5,"ee",21.2, 34,1.5,2.5,"2020-05-29 15:56:35","2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2, 1590738991000] + - [3,"cc",20,32,1.3,2.3, 1590738992000] + sql: | + SELECT id, c1, c3, c7, c8, + distinct_count(c8) OVER w1 as w1_c8_dis_cnt, + sum(c4) OVER w1 as w1_c4_sum + FROM (select id, c1, int(c3f) as c3, c4, c5, c6, timestamp(c7str) as c7, c8 from {0}) WINDOW + w1 AS (UNION (select id, c1, c3, c4, c5, c6, c7, date("2020-10-01") as c8 from {1}) + PARTITION BY c3 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int", "c1 string", "c3 int", "c7 timestamp", "c8 date", "w1_c8_dis_cnt bigint", "w1_c4_sum bigint"] + rows: + - [1, "aa", 20, 1590738993000, "2020-05-01", 2, 93] + - [4, "dd", 20, 1590738994000, "2020-05-04", 2, 96] + - [5, "ee", 21, 1590738995000, "2020-05-05", 1, 34] + - id: 14-4 + desc: WINDOW UNION 子查询, cast另一种写法 cast(column as timestamp) as window ts + mode: offline-unsupport + inputs: + - columns: ["id int","c1 string","c3f float","c4 bigint","c5 float","c6 double","c7str string","c8 date"] + indexs: ["index1:c1:c4"] + rows: + - [1,"aa",20.0, 30,1.1,2.1,"2020-05-29 15:56:33","2020-05-01"] + - [4,"dd",20.1, 33,1.4,2.4,"2020-05-29 15:56:34","2020-05-04"] + - [5,"ee",21.2, 34,1.5,2.5,"2020-05-29 15:56:35","2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2, 1590738991000] + - [3,"cc",20,32,1.3,2.3, 1590738992000] + sql: | + SELECT id, c1, c3, c7, c8, + distinct_count(c8) OVER w1 as w1_c8_dis_cnt, + sum(c4) OVER w1 as w1_c4_sum + FROM (select id, c1, cast(c3f as int) as c3, c4, c5, c6, cast(c7str as timestamp) as c7, c8 from {0}) WINDOW + w1 AS (UNION (select id, c1, c3, c4, c5, c6, c7, cast("2020-10-01" as date) as c8 from {1}) + PARTITION BY c3 ORDER BY c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW INSTANCE_NOT_IN_WINDOW); + expect: + order: id + columns: ["id int", "c1 string", "c3 int", "c7 timestamp", "c8 date", "w1_c8_dis_cnt bigint", "w1_c4_sum bigint"] + rows: + - [1, "aa", 20, 1590738993000, "2020-05-01", 2, 93] + - [4, "dd", 20, 1590738994000, "2020-05-04", 2, 96] + - [5, "ee", 21, 1590738995000, "2020-05-05", 1, 34] + - id: 16 + desc: 主表window 添加 INSTANCE_NOT_IN_WINDOW 没有明显错误日志 + mode: offline-unsupport + db: db_wzx + sql: | + select + c1, + min(c1) over table_1_s2_t1 as table_1_c1_9, + min(c2) over table_1_s2_t1 as table_1_c2_10, + identity(case when lag(d1, 1) != null then distinct_count(d1) else null end) over table_1_s2_t1 as table_1_d1_11, + identity(case when lag(d2, 1) != null then distinct_count(d2) else null end) over table_1_s2_t1 as table_1_d2_12, + identity(case when lag(s1, 1) != null then distinct_count(s1) else null end) over table_1_s2_t1 as table_1_s1_13 + from + {0} as main + window table_1_s2_t1 as (partition by s2 order by t1 rows_range between 1d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW); + inputs: + - columns: ["label int", "s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s2:t1", "index2:s1:t1", "index3:d1:t1", "index4:d2:t1"] + rows: + - [1, "1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s2:t1"] + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s1:t1"] + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s1:t1"] + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + expect: + order: c1 + columns: ["c1 int", "table_1_c1_9 int", "table_1_c2_10 bigint", "table_1_d1_11 bigint", "table_1_d2_12 bigint", "table_1_s1_13 bigint"] + rows: + - [1, 1, 2, NULL, NULL, NULL] + + - id: 16-2 + desc: 主表window 添加 INSTANCE_NOT_IN_WINDOW 没有明显错误日志 case when写法优化 + mode: offline-unsupport + db: db_wzx + sql: | + select + c1, + min(c1) over table_1_s2_t1 as table_1_c1_9, + min(c2) over table_1_s2_t1 as table_1_c2_10, + case when !isnull(lag(d1, 1) over table_1_s2_t1) then distinct_count(d1) over table_1_s2_t1 else null end as table_1_d1_11, + case when !isnull(lag(d2, 1) over table_1_s2_t1) then distinct_count(d2) over table_1_s2_t1 else null end as table_1_d2_12, + case when !isnull(lag(s1, 1) over table_1_s2_t1) then distinct_count(s1) over table_1_s2_t1 else null end as table_1_s1_13 + from + {0} as main + window table_1_s2_t1 as (partition by s2 order by t1 rows_range between 1d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW); + inputs: + - columns: ["label int", "s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s2:t1", "index2:s1:t1", "index3:d1:t1", "index4:d2:t1"] + rows: + - [1, "1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s2:t1"] + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s1:t1"] + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s1:t1"] + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + expect: + order: c1 + columns: ["c1 int", "table_1_c1_9 int", "table_1_c2_10 bigint", "table_1_d1_11 bigint", "table_1_d2_12 bigint", "table_1_s1_13 bigint"] + rows: + - [1, 1, 2, NULL, NULL, NULL] + - id: 17 + desc: 两个索引不一致的表union + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7","index2:c1:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + + # test correctness for window union when there are rows in union rows and original rows whose ts/key is the same + # refer https://github.com/4paradigm/OpenMLDB/issues/1776#issuecomment-1121258571 for the specification + # - 18-1 & 18-2 test simple case for UNION ROWS_RANGE and UNION ROWS + # - 18-3 test test UNION ROWS_RANGE with MAXSIZE + # - 18-4 & 18-5 test EXCLUDE CURRENT_TIME for UNION ROWS_RANGE/ROWS + - id: 18-1 + desc: | + when UNION ROWS_RANGE has the same key with original rows, original rows first then union rows + mode: disk-unsupport + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 400 + 3, 200, 112, 999 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + 3, 199, 112, 44 + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + union t2 + partition by `g` order by `ts` + rows_range between 1s preceding and 0s preceding); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 3, 233, 21, 200 + 2, 4, 400, 21, 21 + 3, 2, 999, 44, 44 + - id: 18-2 + desc: | + when UNION ROWS has the same key with original rows, original rows first then union rows, + union rows filtered out first for max window size limitation + mode: disk-unsupport + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 400 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 88, 111, 999 + 1, 100, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from (select * from t1) window w as( + union (select * from t2) + partition by `g` order by `ts` + ROWS BETWEEN 2 preceding and 0 preceding); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 3, 233, 21, 200 + 2, 3, 400, 21, 21 + - id: 18-3 + mode: disk-unsupport + desc: | + when UNION ROWS_RANGE MAXSIZE has the same key with original rows, original rows first then union rows + union rows filtered out for max window size first + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 0 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from (select * from t1) window w as( + union (select * from t2) + partition by `g` order by `ts` + rows_range between 1s preceding and 0s preceding MAXSIZE 2); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 2, 200, 21, 200 + 2, 2, 21, 0, 21 + - id: 18-4 + mode: disk-unsupport + desc: | + when UNION ROWS_RANGE EXCLUDE CURRENT_TIME has the same key with original rows, original rows first then union rows + other rows except current row filtered out by EXCLUDE CURRENT_TIME + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 0, 0, 111, 19 + 1, 0, 111, 18 + 2, 100, 111, 21 + 3, 100, 111, 5 + 4, 101, 111, 100 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + # raw union window (before filter) + # 0, 0, 111, 19 + # 1, 0, 111, 18 + # 1, 99, 111, 233 (t2) + # 1, 100, 111, 200 (t2) + # 2, 100, 111, 21 + # 3, 100, 111, 5 + # 1, 101, 111, 17 (t2) + # 4, 101, 111, 100 + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from (select * from t1) window w as( + union (select * from t2) + partition by `g` order by `ts` + rows_range between 1s preceding and 0s preceding EXCLUDE CURRENT_TIME); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [0, 1, 19, 19, NULL] + - [1, 1, 18, 18, NULL] + - [2, 4, 233, 18, 233] + - [3, 4, 233, 5, 233] + - [4, 7, 233, 5, 5] + + - id: 18-5 + mode: disk-unsupport + desc: | + UNION ROWS current time rows filtered out + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 10000 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 87, 111, 300 + 1, 88, 111, 999 + 1, 99, 111, 233 + 1, 100, 111, 200 + 1, 101, 111, 17 + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from (select * from t1) window w as( + union (select * from t2) + partition by `g` order by `ts` + ROWS BETWEEN 2 preceding and 0 preceding EXCLUDE CURRENT_TIME); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 3, 999, 21, 233 + 2, 3, 10000, 233, 233 + + # for the case that window unions multiple tables + # the order for rows between those multiple union tables that has same ts key, + # is undefined by specification. + # However, SQL engine explicitly use the order as master table -> first union table in SQL -> second union table in SQL -> .... + # + # 19-* series test case tests for this for SQL engine only, you should never reply on this behavior anyway + - id: 19-1 + mode: disk-unsupport + desc: | + window unions multiple tables, the order for rows in union tables with same ts is explicitly as the order in SQL + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 10000 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 88, 111, 999 + 1, 100, 111, 233 + 1, 100, 111, 200 + - name: t3 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 0 + 1, 100, 111, 33 + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1, + lag(val, 2) over w as l2 + from t1 window w as( + union t2,t3 + partition by `g` order by `ts` + ROWS_RANGE BETWEEN 2s preceding and 0s preceding); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + - l2 int + order: id + data: | + 1, 6, 999, 0, 200, 233 + 2, 7, 10000, 0, 21, 200 + - id: 19-2 + mode: disk-unsupport + desc: | + rows order for pure history window union + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 21 + 2, 100, 111, 10000 + - name: t2 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 88, 111, 999 + 1, 100, 111, 233 + 1, 100, 111, 200 + - name: t3 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 100, 111, 0 + 1, 100, 111, 33 + sql: | + select + id, count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1, + lag(val, 2) over w as l2, + lag(val, 3) over w as l3 + from t1 window w as( + union t2,t3 + partition by `g` order by `ts` + ROWS BETWEEN 3 preceding and 1 preceding INSTANCE_NOT_IN_WINDOW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + - l2 int + - l3 int + order: id + data: | + 1, 3, 233, 33, 200, 233, 33 + 2, 3, 233, 33, 200, 233, 33 + - id: 18 + desc: 主表ts都大于副表的 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738995000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,93] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 19 + desc: 主表ts都小于副表的 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738991000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738992000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738993000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738994000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,63] + - [5,"ee",21,34] + - id: 20 + desc: 主表副表ts有交集 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 21 + desc: 主表和副表分片在同一节点上 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + replicaNum: 3 + partitionNum: 1 + distribution: + - leader: "{tb_endpoint_1}" + followers: [ "{tb_endpoint_0}","{tb_endpoint_2}" ] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + replicaNum: 3 + partitionNum: 1 + distribution: + - leader: "{tb_endpoint_1}" + followers: [ "{tb_endpoint_0}","{tb_endpoint_2}" ] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 21 + desc: 主表和副表分片在不同的节点上 + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + distribution: + - leader: "{tb_endpoint_1}" + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738994000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738995000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + distribution: + - leader: "{tb_endpoint_0}" + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,30] + - [4,"dd",20,96] + - [5,"ee",21,34] + - id: 22 + desc: 两张副表,一张和主表在同一节点,另一张不在 + db: db_wzx + sql: | + select + c1, + min(c1) over table_1_s2_t1 as table_1_c1_9, + min(c2) over table_1_s2_t1 as table_1_c2_10, + case when !isnull(lag(d1, 1) over table_1_s2_t1) then distinct_count(d1) over table_1_s2_t1 else null end as table_1_d1_11, + case when !isnull(lag(d2, 1) over table_1_s2_t1) then distinct_count(d2) over table_1_s2_t1 else null end as table_1_d2_12, + case when !isnull(lag(s1, 1) over table_1_s2_t1) then distinct_count(s1) over table_1_s2_t1 else null end as table_1_s1_13 + from + {0} as main + window table_1_s2_t1 as (partition by s2 order by t1 rows_range between 1d preceding and 0s preceding INSTANCE_NOT_IN_WINDOW); + inputs: + - columns: ["label int", "s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s2:t1", "index2:s1:t1", "index3:d1:t1", "index4:d2:t1"] + distribution: + - leader: "{tb_endpoint_1}" + rows: + - [1, "1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s2:t1"] + distribution: + - leader: "{tb_endpoint_1}" + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s1:t1"] + distribution: + - leader: "{tb_endpoint_0}" + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + - columns: ["s1 string","s2 string", "t1 timestamp","t2 date","d1 string", "d2 string", "c1 int", "c2 bigint", + "ai string", "kn string", "ks string"] + indexs: ["index1:s1:t1"] + distribution: + - leader: "{tb_endpoint_0}" + rows: + - ["1", "2", 1600946381104, "2019-07-18", "xx", "xx", 1, 2 , "3x","4x","kx"] + expect: + order: c1 + columns: ["c1 int", "table_1_c1_9 int", "table_1_c2_10 bigint", "table_1_d1_11 bigint", "table_1_d2_12 bigint", "table_1_s1_13 bigint"] + rows: + - [1, 1, 2, NULL, NULL, NULL] diff --git a/cases/integration_test/window/test_window_union_cluster_thousand.yaml b/cases/integration_test/window/test_window_union_cluster_thousand.yaml new file mode 100644 index 00000000000..aa12f1b549f --- /dev/null +++ b/cases/integration_test/window/test_window_union_cluster_thousand.yaml @@ -0,0 +1,1044 @@ +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + + +db: test_zw +debugs: [] +version: 0.5.0 +cases: + - id: 0 + desc: 正常union + mode: disk-unsupport + inputs: + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [1,"aa",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [4,"dd",20,33,1.4,2.4,1590738993000,"2020-05-04"] + - [5,"ee",21,34,1.5,2.5,1590738994000,"2020-05-05"] + - columns: ["id int","c1 string","c3 int","c4 bigint","c5 float","c6 double","c7 timestamp","c8 date"] + indexs: ["index1:c3:c7"] + rows: + - [2,"bb",20,31,1.2,2.2,1590738991000,"2020-05-02"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [2,"bb",20,30,1.1,2.1,1590738990000,"2020-05-01"] + - [3,"cc",20,32,1.3,2.3,1590738992000,"2020-05-03"] + sql: | + SELECT id, c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM {0} WINDOW w1 AS (UNION {1} PARTITION BY {0}.c3 ORDER BY {0}.c7 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW); + expect: + order: id + columns: ["id int","c1 string","c3 int","w1_c4_sum bigint"] + rows: + - [1,"aa",20,90] + - [4,"dd",20,96] + - [5,"ee",21,34] \ No newline at end of file diff --git a/cases/integration_test/window/window_attributes.yaml b/cases/integration_test/window/window_attributes.yaml new file mode 100644 index 00000000000..c77844b7b00 --- /dev/null +++ b/cases/integration_test/window/window_attributes.yaml @@ -0,0 +1,536 @@ +# window query test with OpenMLDB specific window attributes: +# - EXCLUDE CURRENT_TIME +# - EXCLUDE CURRENT_ROW +# - INSTANCE_NOT_IN_WINDOW +# - MAXSIZE + +debugs: [] +version: 0.6.0 +db: test_java +cases: + - id: 0 + desc: ROWS_RANGE window with exclude_current_row + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 0, 0, 111, 0 + 1, 0, 111, 0 + 2, 99000, 111, 21 + 3, 100000, 111, 22 + 4, 101000, 111, 23 + 5, 100000, 114, 56 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + partition by `g` order by `ts` + ROWS_RANGE between 2s PRECEDING and 0s preceding EXCLUDE CURRENT_ROW); + batch_plan: | + PROJECT(type=WindowAggregation, EXCLUDE_CURRENT_ROW) + +-WINDOW(partition_keys=(g), orders=(ts ASC), range=(ts, 2000 PRECEDING, 0 PRECEDING)) + PROJECT(type=WindowAggregation, NEED_APPEND_INPUT) + +-WINDOW(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT)) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(EXCLUDE_CURRENT_ROW, partition_keys=(), orders=(ASC), range=(ts, 2000 PRECEDING, 0 PRECEDING), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [0, 0, NULL, NULL, NULL] + - [1, 1, 0, 0, 0] + - [2, 0, NULL, NULL, 0] + - [3, 1, 21, 21, 21] + - [4, 2, 22, 21, 22] + - [5, 0, NULL, NULL, NULL] + - id: 1 + desc: | + ROWS window with exclude_current_row, '0 PRECEDING EXCLUDE CURRENT_ROW' actually is the same as '0 OPEN PRECEDING' + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 100000, 114, 56 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + from t1 window w as( + partition by `g` order by `ts` + ROWS between 2 PRECEDING and 0 preceding EXCLUDE CURRENT_ROW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [1, 0, NULL, NULL, NULL] + - [2, 1, 21, 21, 21] + - [3, 2, 22, 21, 22] + - [4, 0, NULL, NULL, NULL] + - id: 2 + desc: | + ROWS_RANGE pure-history window with exclude_current_row + whether EXCLUDE CURRENT_ROW is set do not matter + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 100000, 114, 56 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + FROM t1 WINDOW w as( + PARTITION by `g` ORDER by `ts` + ROWS_RANGE BETWEEN 2s PRECEDING AND 1s PRECEDING EXCLUDE CURRENT_ROW); + batch_plan: | + PROJECT(type=WindowAggregation) + +-WINDOW(partition_keys=(g), orders=(ts ASC), range=(ts, 2000 PRECEDING, 1000 PRECEDING)) + PROJECT(type=WindowAggregation, NEED_APPEND_INPUT) + +-WINDOW(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT)) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(ts, 2000 PRECEDING, 1000 PRECEDING), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [1, 0, NULL, NULL, NULL] + - [2, 1, 21, 21, 21] + - [3, 2, 22, 21, 22] + - [4, 0, NULL, NULL, NULL] + - id: 3 + desc: | + ROWS pure-history window with exclude_current_row + whether EXCLUDE CURRENT_ROW is set do not matter + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 100000, 114, 56 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + FROM t1 WINDOW w as( + PARTITION by `g` ORDER by `ts` + ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING EXCLUDE CURRENT_ROW); + batch_plan: | + PROJECT(type=WindowAggregation) + +-WINDOW(partition_keys=(g), orders=(ts ASC), rows=(ts, 2 PRECEDING, 0 OPEN PRECEDING)) + PROJECT(type=WindowAggregation, NEED_APPEND_INPUT) + +-WINDOW(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT)) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(ts, 2 PRECEDING, 0 OPEN PRECEDING), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [1, 0, NULL, NULL, NULL] + - [2, 1, 21, 21, 21] + - [3, 2, 22, 21, 22] + - [4, 0, NULL, NULL, NULL] + + - id: 4 + desc: | + rows_range current history window, exclude current_row with maxsize + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 102000, 111, 44 + 5, 100000, 114, 56 + 6, 102000, 114, 52 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + FROM t1 WINDOW w as( + PARTITION by `g` ORDER by `ts` + ROWS_RANGE BETWEEN 3s PRECEDING AND 0s PRECEDING MAXSIZE 2 EXCLUDE CURRENT_ROW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [1, 0, NULL, NULL, NULL] + - [2, 1, 21, 21, 21] + - [3, 2, 22, 21, 22] + - [4, 2, 23, 22, 23] + - [5, 0, NULL, NULL, NULL] + - [6, 1, 56, 56, 56] + + - id: 5 + desc: | + ROWS_RANGE window with end frame OPEN, exclude current_row do not matter + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 102000, 111, 44 + 5, 100000, 114, 56 + 6, 102000, 114, 52 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + FROM t1 WINDOW w as( + PARTITION by `g` ORDER by `ts` + ROWS_RANGE BETWEEN 3s PRECEDING AND 0s OPEN PRECEDING MAXSIZE 2 EXCLUDE CURRENT_ROW); + batch_plan: | + PROJECT(type=WindowAggregation) + +-WINDOW(partition_keys=(g), orders=(ts ASC), range=(ts, 3000 PRECEDING, 0 OPEN PRECEDING, maxsize=2)) + PROJECT(type=WindowAggregation, NEED_APPEND_INPUT) + +-WINDOW(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT)) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), range=(ts, 3000 PRECEDING, 0 OPEN PRECEDING, maxsize=2), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [1, 0, NULL, NULL, NULL] + - [2, 1, 21, 21, 21] + - [3, 2, 22, 21, 22] + - [4, 2, 23, 22, 23] + - [5, 0, NULL, NULL, NULL] + - [6, 1, 56, 56, 56] + + - id: 6 + desc: | + ROWS window with end frame OPEN, exclude current_row do not matter + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 102000, 111, 44 + 5, 100000, 114, 56 + 6, 102000, 114, 52 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + FROM t1 WINDOW w as( + PARTITION by `g` ORDER by `ts` + ROWS BETWEEN 3 PRECEDING AND 0 OPEN PRECEDING EXCLUDE CURRENT_ROW); + batch_plan: | + PROJECT(type=WindowAggregation) + +-WINDOW(partition_keys=(g), orders=(ts ASC), rows=(ts, 3 PRECEDING, 0 OPEN PRECEDING)) + PROJECT(type=WindowAggregation, NEED_APPEND_INPUT) + +-WINDOW(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT)) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + request_plan: | + SIMPLE_PROJECT(sources=(id, cnt, mv, mi, l1)) + REQUEST_JOIN(type=kJoinTypeConcat) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(ts, 3 PRECEDING, 0 OPEN PRECEDING), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + PROJECT(type=Aggregation) + REQUEST_UNION(partition_keys=(), orders=(ASC), rows=(ts, 1 PRECEDING, 0 CURRENT), index_keys=(g)) + DATA_PROVIDER(request=t1) + DATA_PROVIDER(type=Partition, table=t1, index=idx) + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [1, 0, NULL, NULL, NULL] + - [2, 1, 21, 21, 21] + - [3, 2, 22, 21, 22] + - [4, 3, 23, 21, 23] + - [5, 0, NULL, NULL, NULL] + - [6, 1, 56, 56, 56] + + - id: 7 + desc: | + ROWS_RANGE window with end frame 'CURRENT_ROW', exclude current_row + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 102000, 111, 44 + 5, 100000, 114, 56 + 6, 102000, 114, 52 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + FROM t1 WINDOW w as( + PARTITION by `g` ORDER by `ts` + ROWS_RANGE BETWEEN 3s PRECEDING AND CURRENT ROW MAXSIZE 2 EXCLUDE CURRENT_ROW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + rows: + - [1, 0, NULL, NULL, NULL] + - [2, 1, 21, 21, 21] + - [3, 2, 22, 21, 22] + - [4, 2, 23, 22, 23] + - [5, 0, NULL, NULL, NULL] + - [6, 1, 56, 56, 56] + + - id: 8 + desc: | + ROWS window with end frame 'CURRENT_ROW', exclude current_row + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 102000, 111, 44 + 5, 100000, 114, 56 + 6, 102000, 114, 52 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + FROM t1 WINDOW w as( + PARTITION by `g` ORDER by `ts` + ROWS BETWEEN 3 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_ROW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 0, NULL, NULL, NULL + 2, 1, 21, 21, 21 + 3, 2, 22, 21, 22 + 4, 3, 23, 21, 23 + 5, 0, NULL, NULL, NULL + 6, 1, 56, 56, 56 + - id: 9 + desc: | + ROWS Window with exclude current_time and exclude current_row + mode: disk-unsupport + inputs: + - name: t1 + columns: + - id int + - ts timestamp + - g int + - val int + indexs: + - idx:g:ts + data: | + 1, 99000, 111, 21 + 2, 100000, 111, 22 + 3, 101000, 111, 23 + 4, 102000, 111, 44 + 5, 0, 114, 0 + 6, 0, 114, 99 + 7, 100000, 114, 56 + 8, 102000, 114, 52 + 9, 104000, 114, 33 + sql: | + select + id, + count(val) over w as cnt, + max(val) over w as mv, + min(val) over w as mi, + lag(val, 1) over w as l1 + FROM t1 WINDOW w as( + PARTITION by `g` ORDER by `ts` + ROWS BETWEEN 3 PRECEDING AND CURRENT ROW EXCLUDE CURRENT_TIME EXCLUDE CURRENT_ROW); + expect: + columns: + - id int + - cnt int64 + - mv int + - mi int + - l1 int + order: id + data: | + 1, 0, NULL, NULL, NULL + 2, 1, 21, 21, 21 + 3, 2, 22, 21, 22 + 4, 3, 23, 21, 23 + 5, 0, NULL, NULL, NULL + 6, 0, NULL, NULL, NULL + 7, 2, 99, 0, 99 + 8, 3, 99, 0, 56 + 9, 3, 99, 52, 52 diff --git a/cases/query/const_query.yaml b/cases/query/const_query.yaml index c68706f8b22..304f0486073 100644 --- a/cases/query/const_query.yaml +++ b/cases/query/const_query.yaml @@ -122,6 +122,7 @@ cases: - id: 8 desc: cast NULL常量 using type(NULL) function mode: request-unsupport + db: db1 inputs: - columns: ["c1 int", "c2 string", "c5 bigint"] indexs: ["index1:c1:c5"] @@ -136,6 +137,7 @@ cases: - id: 9 desc: differnt const node type mode: request-unsupport + db: db1 sql: | select true c1, int16(3) c2, 13 c3, 10.0 c4, 'a string' c5, date(timestamp(1590115420000)) c6, timestamp(1590115420000) c7; expect: diff --git a/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/java/com/_4paradigm/qa/openmldb_deploy/bean/OpenMLDBInfo.java b/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/java/com/_4paradigm/qa/openmldb_deploy/bean/OpenMLDBInfo.java index d37f11100c2..bf63e7adb7c 100644 --- a/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/java/com/_4paradigm/qa/openmldb_deploy/bean/OpenMLDBInfo.java +++ b/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/java/com/_4paradigm/qa/openmldb_deploy/bean/OpenMLDBInfo.java @@ -18,6 +18,7 @@ import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.ArrayList; import java.util.List; @@ -27,7 +28,7 @@ * @date 2021/2/7 12:10 PM */ @Data -@Builder +//@Builder public class OpenMLDBInfo { private OpenMLDBDeployType deployType; private String host; @@ -53,6 +54,7 @@ public class OpenMLDBInfo { private List apiServerNames = new ArrayList<>(); private List taskManagerEndpoints = new ArrayList<>(); private String runCommand; + private String sparkHome; public String getRunCommand(){ if(deployType==OpenMLDBDeployType.CLUSTER) { diff --git a/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/java/com/_4paradigm/qa/openmldb_deploy/common/OpenMLDBDeploy.java b/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/java/com/_4paradigm/qa/openmldb_deploy/common/OpenMLDBDeploy.java index 5b315279d78..2ca68aa3d94 100644 --- a/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/java/com/_4paradigm/qa/openmldb_deploy/common/OpenMLDBDeploy.java +++ b/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/java/com/_4paradigm/qa/openmldb_deploy/common/OpenMLDBDeploy.java @@ -40,6 +40,7 @@ public class OpenMLDBDeploy { private String version; private String openMLDBUrl; private String openMLDBDirectoryName; + private String sparkHome; private String openMLDBPath; private boolean useName; private boolean isCluster = true; @@ -70,16 +71,17 @@ public OpenMLDBInfo deployStandalone(){ file.mkdirs(); } downloadOpenMLDB(testPath); - OpenMLDBInfo fedbInfo = deployStandalone(testPath,ip); - log.info("openmldb-info:"+fedbInfo); - return fedbInfo; + OpenMLDBInfo openMLDBInfo = deployStandalone(testPath,ip); + log.info("openmldb-info:"+openMLDBInfo); + return openMLDBInfo; } public OpenMLDBInfo deployCluster(int ns, int tablet){ return deployCluster(null,ns,tablet); } public OpenMLDBInfo deployCluster(String clusterName, int ns, int tablet){ - OpenMLDBInfo.OpenMLDBInfoBuilder builder = OpenMLDBInfo.builder(); - builder.deployType(OpenMLDBDeployType.CLUSTER); + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); +// OpenMLDBInfo.OpenMLDBInfoBuilder builder = OpenMLDBInfo.builder(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); String testPath = DeployUtil.getTestPath(version); if(StringUtils.isNotEmpty(installPath)){ testPath = installPath+"/"+version; @@ -87,7 +89,10 @@ public OpenMLDBInfo deployCluster(String clusterName, int ns, int tablet){ if(StringUtils.isNotEmpty(clusterName)) { testPath = testPath + "/" + clusterName; } - builder.nsNum(ns).tabletNum(tablet).basePath(testPath); + openMLDBInfo.setNsNum(ns); + openMLDBInfo.setTabletNum(tablet); + openMLDBInfo.setBasePath(testPath); +// builder.nsNum(ns).tabletNum(tablet).basePath(testPath); String ip = LinuxUtil.hostnameI(); File file = new File(testPath); if(!file.exists()){ @@ -96,24 +101,35 @@ public OpenMLDBInfo deployCluster(String clusterName, int ns, int tablet){ int zkPort = deployZK(testPath); String openMLDBDirectoryName = downloadOpenMLDB(testPath); String zk_point = ip+":"+zkPort; - builder.zk_cluster(zk_point).zk_root_path("/openmldb"); - builder.nsEndpoints(Lists.newArrayList()).nsNames(Lists.newArrayList()); - builder.tabletEndpoints(Lists.newArrayList()).tabletNames(Lists.newArrayList()); - builder.apiServerEndpoints(Lists.newArrayList()).apiServerNames(Lists.newArrayList()); - builder.taskManagerEndpoints(Lists.newArrayList()); - builder.openMLDBPath(testPath+"/openmldb-ns-1/bin/openmldb"); - builder.openMLDBDirectoryName(openMLDBDirectoryName); - OpenMLDBInfo fedbInfo = builder.build(); + openMLDBInfo.setZk_cluster(zk_point); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList()); + openMLDBInfo.setNsNames(Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList()); + openMLDBInfo.setTabletNames(Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList()); + openMLDBInfo.setApiServerNames(Lists.newArrayList()); + openMLDBInfo.setTaskManagerEndpoints(Lists.newArrayList()); + openMLDBInfo.setOpenMLDBPath(testPath+"/openmldb-ns-1/bin/openmldb"); + openMLDBInfo.setOpenMLDBDirectoryName(openMLDBDirectoryName); +// builder.zk_cluster(zk_point).zk_root_path("/openmldb"); +// builder.nsEndpoints(Lists.newArrayList()).nsNames(Lists.newArrayList()); +// builder.tabletEndpoints(Lists.newArrayList()).tabletNames(Lists.newArrayList()); +// builder.apiServerEndpoints(Lists.newArrayList()).apiServerNames(Lists.newArrayList()); +// builder.taskManagerEndpoints(Lists.newArrayList()); +// builder.openMLDBPath(testPath+"/openmldb-ns-1/bin/openmldb"); +// builder.openMLDBDirectoryName(openMLDBDirectoryName); +// OpenMLDBInfo openMLDBInfo = builder.build(); for(int i=1;i<=tablet;i++) { int tablet_port ; if(useName){ String tabletName = clusterName+"-tablet-"+i; tablet_port = deployTablet(testPath,null, i, zk_point,tabletName); - fedbInfo.getTabletNames().add(tabletName); + openMLDBInfo.getTabletNames().add(tabletName); }else { tablet_port = deployTablet(testPath, ip, i, zk_point,null); } - fedbInfo.getTabletEndpoints().add(ip+":"+tablet_port); + openMLDBInfo.getTabletEndpoints().add(ip+":"+tablet_port); Tool.sleep(SLEEP_TIME); } for(int i=1;i<=ns;i++){ @@ -121,11 +137,11 @@ public OpenMLDBInfo deployCluster(String clusterName, int ns, int tablet){ if(useName){ String nsName = clusterName+"-ns-"+i; ns_port = deployNS(testPath,null, i, zk_point,nsName); - fedbInfo.getNsNames().add(nsName); + openMLDBInfo.getNsNames().add(nsName); }else { ns_port = deployNS(testPath, ip, i, zk_point,null); } - fedbInfo.getNsEndpoints().add(ip+":"+ns_port); + openMLDBInfo.getNsEndpoints().add(ip+":"+ns_port); Tool.sleep(SLEEP_TIME); } @@ -134,24 +150,25 @@ public OpenMLDBInfo deployCluster(String clusterName, int ns, int tablet){ if(useName){ String apiserverName = clusterName+"-apiserver-"+i; apiserver_port = deployApiserver(testPath,null, i, zk_point,apiserverName); - fedbInfo.getApiServerNames().add(apiserverName); + openMLDBInfo.getApiServerNames().add(apiserverName); }else { apiserver_port = deployApiserver(testPath, ip, i, zk_point,null); } - fedbInfo.getApiServerEndpoints().add(ip+":"+apiserver_port); + openMLDBInfo.getApiServerEndpoints().add(ip+":"+apiserver_port); Tool.sleep(SLEEP_TIME); } if(version.equals("tmp")||version.compareTo("0.4.0")>=0) { for (int i = 1; i <= 1; i++) { int task_manager_port = deployTaskManager(testPath, ip, i, zk_point); - fedbInfo.getTaskManagerEndpoints().add(ip + ":" + task_manager_port); + openMLDBInfo.getTaskManagerEndpoints().add(ip + ":" + task_manager_port); + openMLDBInfo.setSparkHome(sparkHome); } } - log.info("openmldb-info:"+fedbInfo); - return fedbInfo; + log.info("openmldb-info:"+openMLDBInfo); + return openMLDBInfo; } - private String downloadOpenMLDB(String testPath){ + public String downloadOpenMLDB(String testPath){ try { String command; log.info("openMLDBUrl:{}",openMLDBUrl); @@ -362,19 +379,22 @@ public String deploySpark(String testPath){ ExecutorUtil.run("wget -P "+testPath+" -q "+ OpenMLDBDeployConfig.getSparkUrl(version)); String tarName = ExecutorUtil.run("ls "+ testPath +" | grep spark").get(0); ExecutorUtil.run("tar -zxvf " + testPath + "/"+tarName+" -C "+testPath); - String sparkHome = ExecutorUtil.run("ls "+ testPath +" | grep spark | grep -v .tgz ").get(0); - String sparkPath = testPath+"/"+sparkHome; + String sparkDirectoryName = ExecutorUtil.run("ls "+ testPath +" | grep spark | grep -v .tgz ").get(0); + String sparkPath = testPath+"/"+sparkDirectoryName; + this.sparkHome = sparkPath; return sparkPath; }catch (Exception e){ e.printStackTrace(); } throw new RuntimeException("spark 部署失败"); } - public int deployTaskManager(String testPath, String ip, int index, String zk_endpoint){ + int port = LinuxUtil.getNoUsedPort(); + return deployTaskManager(testPath,ip,port,index,zk_endpoint); + } + public int deployTaskManager(String testPath, String ip, int port, int index, String zk_endpoint){ try { String sparkHome = deploySpark(testPath); - int port = LinuxUtil.getNoUsedPort(); String task_manager_name = "/openmldb-task_manager-"+index; ExecutorUtil.run("cp -r " + testPath + "/" + openMLDBDirectoryName + " " + testPath + task_manager_name); if(batchJobJarPath==null) { @@ -445,20 +465,35 @@ public OpenMLDBInfo deployStandalone(String testPath, String ip){ boolean apiServerOk = LinuxUtil.checkPortIsUsed(apiServerPort,3000,30); if(nsOk&&tabletOk&&apiServerOk){ log.info(String.format("standalone 部署成功,nsPort:{},tabletPort:{},apiServerPort:{}",nsPort,tabletPort,apiServerPort)); - OpenMLDBInfo fedbInfo = OpenMLDBInfo.builder() - .deployType(OpenMLDBDeployType.STANDALONE) - .openMLDBPath(testPath+"/openmldb-standalone/bin/openmldb") - .apiServerEndpoints(Lists.newArrayList()) - .basePath(testPath) - .nsEndpoints(Lists.newArrayList(nsEndpoint)) - .nsNum(1) - .host(ip) - .port(nsPort) - .tabletNum(1) - .tabletEndpoints(Lists.newArrayList(tabletEndpoint)) - .apiServerEndpoints(Lists.newArrayList(apiServerEndpoint)) - .build(); - return fedbInfo; + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.STANDALONE); + openMLDBInfo.setNsNum(1); + openMLDBInfo.setTabletNum(1); + openMLDBInfo.setBasePath(testPath); + openMLDBInfo.setHost(ip); + openMLDBInfo.setPort(nsPort); + openMLDBInfo.setNsEndpoints(Lists.newArrayList(nsEndpoint)); + openMLDBInfo.setNsNames(Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList(tabletEndpoint)); + openMLDBInfo.setTabletNames(Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList(apiServerEndpoint)); + openMLDBInfo.setApiServerNames(Lists.newArrayList()); + openMLDBInfo.setOpenMLDBPath(testPath+"/openmldb-standalone/bin/openmldb"); + +// OpenMLDBInfo openMLDBInfo = OpenMLDBInfo.builder() +// .deployType(OpenMLDBDeployType.STANDALONE) +// .openMLDBPath(testPath+"/openmldb-standalone/bin/openmldb") +// .apiServerEndpoints(Lists.newArrayList()) +// .basePath(testPath) +// .nsEndpoints(Lists.newArrayList(nsEndpoint)) +// .nsNum(1) +// .host(ip) +// .port(nsPort) +// .tabletNum(1) +// .tabletEndpoints(Lists.newArrayList(tabletEndpoint)) +// .apiServerEndpoints(Lists.newArrayList(apiServerEndpoint)) +// .build(); + return openMLDBInfo; } }catch (Exception e){ e.printStackTrace(); diff --git a/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/resources/deploy.properties b/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/resources/deploy.properties index cf67073c54e..0cb6fa1d848 100644 --- a/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/resources/deploy.properties +++ b/test/integration-test/openmldb-test-java/openmldb-deploy/src/main/resources/deploy.properties @@ -4,11 +4,11 @@ zk_url=https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4. main=https://github.com/4paradigm/OpenMLDB/releases/download/v0.2.3/openmldb-0.2.3-linux.tar.gz 0.2.2=https://github.com/4paradigm/OpenMLDB/releases/download/0.2.2/openmldb-0.2.2-linux.tar.gz 0.2.3=https://github.com/4paradigm/OpenMLDB/releases/download/v0.2.3/openmldb-0.2.3-linux.tar.gz -spark_url=https://github.com/4paradigm/spark/releases/download/v3.0.0-openmldb0.3.2/spark-3.0.0-bin-openmldbspark.tgz +spark_url=https://github.com/4paradigm/spark/releases/download/v3.0.0-openmldb0.6.1/spark-3.0.0-bin-openmldbspark.tgz -tmp=http://pkg.4paradigm.com:81/rtidb/test/openmldb-0.5.3-linux.tar.gz +tmp=http://pkg.4paradigm.com:81/rtidb/test/openmldb-pkg/openmldb-0.6.0-linux.tar.gz tmp_zk_url=http://pkg.4paradigm.com:81/rtidb/test/zookeeper-3.4.14.tar.gz -tmp_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-3.0.0-bin-openmldbspark-v052.tgz +tmp_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-pkg/spark-3.0.0-bin-openmldbspark-v060.tgz single=http://pkg.4paradigm.com:81/rtidb/test/openmldb-0.5.3-linux.tar.gz single_zk_url=http://pkg.4paradigm.com:81/rtidb/test/zookeeper-3.4.14.tar.gz @@ -16,10 +16,23 @@ single_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-3.0.0-bin-openmldb standalone=http://pkg.4paradigm.com:81/rtidb/test/openmldb-0.5.2-linux.tar.gz -tmp2=http://pkg.4paradigm.com:81/rtidb/test/openmldb-snapshot-linux.tar.gz +tmp2=http://pkg.4paradigm.com:81/rtidb/test/openmldb-pkg/openmldb-0.6.0-linux.tar.gz tmp2_zk_url=http://pkg.4paradigm.com:81/rtidb/test/zookeeper-3.4.14.tar.gz -tmp2_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-3.0.0-bin-openmldbspark-v052.tgz +tmp2_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-pkg/spark-3.0.0-bin-openmldbspark-v060.tgz -tmp_mac=http://pkg.4paradigm.com:81/rtidb/test/openmldb-0.5.2-darwin.tar.gz +tmp_mac=http://pkg.4paradigm.com:81/rtidb/test/openmldb-pkg/openmldb-0.6.0-darwin.tar.gz tmp_mac_zk_url=http://pkg.4paradigm.com:81/rtidb/test/zookeeper-3.4.14.tar.gz -tmp_mac_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-3.0.0-bin-openmldbspark-v052.tgz \ No newline at end of file +tmp_mac_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-pkg/spark-3.0.0-bin-openmldbspark-v060.tgz + +0.4.0=http://pkg.4paradigm.com:81/rtidb/test/openmldb-0.4.0-linux.tar.gz +0.4.0_zk_url=http://pkg.4paradigm.com:81/rtidb/test/zookeeper-3.4.14.tar.gz +0.4.0_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-3.0.0-bin-openmldbspark-v052.tgz +0.5.0=http://pkg.4paradigm.com:81/rtidb/test/openmldb-pkg/openmldb-0.5.0-linux.tar.gz +0.5.0_zk_url=http://pkg.4paradigm.com:81/rtidb/test/zookeeper-3.4.14.tar.gz +0.5.0_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-pkg/spark-3.0.0-bin-openmldbspark-v050.tgz +0.5.3=http://pkg.4paradigm.com:81/rtidb/test/openmldb-pkg/openmldb-0.5.3-linux.tar.gz +0.5.3_zk_url=http://pkg.4paradigm.com:81/rtidb/test/zookeeper-3.4.14.tar.gz +0.5.3_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-pkg/spark-3.0.0-bin-openmldbspark-v053.tgz +0.6.0=http://pkg.4paradigm.com:81/rtidb/test/openmldb-pkg/openmldb-0.6.0-linux.tar.gz +0.6.0_zk_url=http://pkg.4paradigm.com:81/rtidb/test/zookeeper-3.4.14.tar.gz +0.6.0_spark_url=http://pkg.4paradigm.com:81/rtidb/test/spark-pkg/spark-3.0.0-bin-openmldbspark-v060.tgz diff --git a/test/integration-test/openmldb-test-java/openmldb-deploy/test-suite/test_deploy-standalone.xml b/test/integration-test/openmldb-test-java/openmldb-deploy/test-suite/test_deploy-standalone.xml index 95763f349fb..8a6659af952 100644 --- a/test/integration-test/openmldb-test-java/openmldb-deploy/test-suite/test_deploy-standalone.xml +++ b/test/integration-test/openmldb-test-java/openmldb-deploy/test-suite/test_deploy-standalone.xml @@ -2,7 +2,7 @@ - + diff --git a/test/integration-test/openmldb-test-java/openmldb-deploy/test-suite/test_deploy.xml b/test/integration-test/openmldb-test-java/openmldb-deploy/test-suite/test_deploy.xml index 46a07223367..7a98bf98efd 100644 --- a/test/integration-test/openmldb-test-java/openmldb-deploy/test-suite/test_deploy.xml +++ b/test/integration-test/openmldb-test-java/openmldb-deploy/test-suite/test_deploy.xml @@ -4,7 +4,7 @@ - + diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/java/com/_4paradigm/openmldb/devops_test/common/ClusterTest.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/java/com/_4paradigm/openmldb/devops_test/common/ClusterTest.java index b4abcf6600c..39da842080d 100644 --- a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/java/com/_4paradigm/openmldb/devops_test/common/ClusterTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/java/com/_4paradigm/openmldb/devops_test/common/ClusterTest.java @@ -20,6 +20,7 @@ import com._4paradigm.openmldb.sdk.SqlExecutor; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBClient; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; +import com._4paradigm.openmldb.test_common.provider.YamlUtil; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBDeployType; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; @@ -30,6 +31,7 @@ import org.testng.annotations.Optional; import org.testng.annotations.Parameters; +import java.io.File; import java.sql.Statement; /** @@ -56,56 +58,38 @@ public void beforeTest(@Optional("qa") String env,@Optional("main") String versi OpenMLDBDeploy openMLDBDeploy = new OpenMLDBDeploy(version);; openMLDBDeploy.setOpenMLDBPath(openMLDBPath); openMLDBDeploy.setCluster(true); + openMLDBDeploy.setSystemTableReplicaNum(1); OpenMLDBGlobalVar.mainInfo = openMLDBDeploy.deployCluster(1, 1); }else{ -// OpenMLDBGlobalVar.mainInfo = OpenMLDBInfo.builder() -// .deployType(OpenMLDBDeployType.CLUSTER) -// .openMLDBDirectoryName("openmldb-0.5.2-darwin") -// .basePath("/Users/zhaowei/openmldb-auto-test/tmp_mac") -// .openMLDBPath("/Users/zhaowei/openmldb-auto-test/tmp_mac/openmldb-ns-1/bin/openmldb") -// .zk_cluster("127.0.0.1:30000") -// .zk_root_path("/openmldb") -// .nsNum(2).tabletNum(3) -// .nsEndpoints(Lists.newArrayList("127.0.0.1:30004", "127.0.0.1:30005")) -// .tabletEndpoints(Lists.newArrayList("127.0.0.1:30001", "127.0.0.1:30002", "127.0.0.1:30003")) -// .apiServerEndpoints(Lists.newArrayList("127.0.0.1:30006")) -// .build(); -// OpenMLDBGlobalVar.env = "cluster"; + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); + openMLDBInfo.setNsNum(2); + openMLDBInfo.setTabletNum(3); + openMLDBInfo.setBasePath("/home/zhaowei01/openmldb-auto-test/tmp"); + openMLDBInfo.setZk_cluster("172.24.4.55:30000"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")); + openMLDBInfo.setNsNames(Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")); + openMLDBInfo.setTabletNames(Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")); + openMLDBInfo.setApiServerNames(Lists.newArrayList()); + openMLDBInfo.setTaskManagerEndpoints(Lists.newArrayList("172.24.4.55:30007")); + openMLDBInfo.setOpenMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb"); -// OpenMLDBGlobalVar.mainInfo = OpenMLDBInfo.builder() -// .openMLDBDirectoryName("openmldb-0.5.2-linux") -// .deployType(OpenMLDBDeployType.CLUSTER) -// .basePath("/home/zhaowei01/openmldb-auto-test/tmp") -// .openMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb") -// .zk_cluster("172.24.4.55:30000") -// .zk_root_path("/openmldb") -// .nsNum(2).tabletNum(3) -// .nsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")) -// .tabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")) -// .apiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")) -// .build(); -// OpenMLDBGlobalVar.env = "cluster"; - - OpenMLDBGlobalVar.mainInfo = OpenMLDBInfo.builder() - .deployType(OpenMLDBDeployType.CLUSTER) - .basePath("/home/zhaowei01/openmldb-auto-test/single") - .openMLDBPath("/home/zhaowei01/openmldb-auto-test/single/openmldb-ns-1/bin/openmldb") - .zk_cluster("172.24.4.55:30008") - .zk_root_path("/openmldb") - .nsNum(1).tabletNum(1) - .nsEndpoints(Lists.newArrayList("172.24.4.55:30010")) - .tabletEndpoints(Lists.newArrayList("172.24.4.55:30009")) - .apiServerEndpoints(Lists.newArrayList("172.24.4.55:30011")) - .taskManagerEndpoints(Lists.newArrayList("172.24.4.55:30012")) - .build(); + OpenMLDBGlobalVar.mainInfo = openMLDBInfo; OpenMLDBGlobalVar.env = "cluster"; - } + File outFile = new File("out"); + if(!outFile.exists()){ + outFile.mkdir(); + } + YamlUtil.writeYamlFile(OpenMLDBGlobalVar.mainInfo,"out/openmldb_info.yaml"); String caseEnv = System.getProperty("caseEnv"); if (!StringUtils.isEmpty(caseEnv)) { OpenMLDBGlobalVar.env = caseEnv; } - log.info("fedb global var env: {}", env); + log.info("openmldb global var env: {}", env); OpenMLDBClient openMLDBClient = new OpenMLDBClient(OpenMLDBGlobalVar.mainInfo.getZk_cluster(), OpenMLDBGlobalVar.mainInfo.getZk_root_path()); executor = openMLDBClient.getExecutor(); log.info("executor:{}",executor); diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/java/com/_4paradigm/openmldb/devops_test/util/CheckUtil.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/java/com/_4paradigm/openmldb/devops_test/util/CheckUtil.java new file mode 100644 index 00000000000..357be47cfcb --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/java/com/_4paradigm/openmldb/devops_test/util/CheckUtil.java @@ -0,0 +1,48 @@ +package com._4paradigm.openmldb.devops_test.util; + +import com._4paradigm.openmldb.test_common.openmldb.NsClient; +import com._4paradigm.openmldb.test_common.openmldb.SDKClient; +import com._4paradigm.qa.openmldb_deploy.util.Tool; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.RandomStringUtils; +import org.testng.Assert; +import org.testng.collections.Lists; + +import java.util.ArrayList; +import java.util.List; + +public class CheckUtil { + public static void addDataCheckByOffset(SDKClient sdkClient, NsClient nsClient, String dbName, List tableNames, int originalCount, int addCount){ + List> addDataList = new ArrayList<>(); + for(int i=0;i list = Lists.newArrayList(c1 + i, 1, 2, 3, 1.1, 2.1, 1590738989000L, "2020-05-01", true); + addDataList.add(list); + } + String msg = "table add data check count failed."; + for(String tableName:tableNames){ + if (CollectionUtils.isNotEmpty(addDataList)) { + sdkClient.insertList(tableName,addDataList); + Tool.sleep(10*1000); + } + Assert.assertEquals(sdkClient.getTableRowCount(tableName),originalCount+addCount,msg); + Assert.assertEquals(nsClient.getTableCount(dbName,tableName),originalCount+addCount,msg); + } + nsClient.checkTableOffSet(dbName,null); + } + public static void addDataCheckByCount(SDKClient sdkClient, List tableNames, int originalCount, int addCount){ + List> addDataList = new ArrayList<>(); + for(int i=0;i list = Lists.newArrayList(c1 + i, 1, 2, 3, 1.1, 2.1, 1590738989000L, "2020-05-01", true); + addDataList.add(list); + } + String msg = "table add data check count failed."; + for(String tableName:tableNames){ + if (CollectionUtils.isNotEmpty(addDataList)) { + sdkClient.insertList(tableName,addDataList); + } + Assert.assertEquals(sdkClient.getTableRowCount(tableName),originalCount+addCount,msg); + } + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/resources/log4j.properties b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/resources/log4j.properties new file mode 100755 index 00000000000..8aa7e8e77dc --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/main/resources/log4j.properties @@ -0,0 +1,51 @@ +### set log levels ### +log4j.rootLogger=debug,info,stdout,warn,error + +# console log +log4j.appender.stdout = org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target = System.out +log4j.appender.stdout.Threshold = INFO +log4j.appender.stdout.layout = org.apache.log4j.PatternLayout +log4j.appender.stdout.Encoding=UTF-8 +log4j.appender.stdout.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n + +#info log +log4j.logger.info=info +log4j.appender.info=org.apache.log4j.DailyRollingFileAppender +log4j.appender.info.DatePattern='_'yyyy-MM-dd'.log' +log4j.appender.info.File=logs/info.log +log4j.appender.info.Append=true +log4j.appender.info.Threshold=INFO +log4j.appender.info.Encoding=UTF-8 +log4j.appender.info.layout=org.apache.log4j.PatternLayout +log4j.appender.info.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n +#debugs log +log4j.logger.debug=debug +log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender +log4j.appender.debug.DatePattern='_'yyyy-MM-dd'.log' +log4j.appender.debug.File=logs/debug.log +log4j.appender.debug.Append=true +log4j.appender.debug.Threshold=DEBUG +log4j.appender.debug.Encoding=UTF-8 +log4j.appender.debug.layout=org.apache.log4j.PatternLayout +log4j.appender.debug.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n +#warn log +log4j.logger.warn=warn +log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender +log4j.appender.warn.DatePattern='_'yyyy-MM-dd'.log' +log4j.appender.warn.File=logs/warn.log +log4j.appender.warn.Append=true +log4j.appender.warn.Threshold=WARN +log4j.appender.warn.Encoding=UTF-8 +log4j.appender.warn.layout=org.apache.log4j.PatternLayout +log4j.appender.warn.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n +#error +log4j.logger.error=error +log4j.appender.error = org.apache.log4j.DailyRollingFileAppender +log4j.appender.error.DatePattern='_'yyyy-MM-dd'.log' +log4j.appender.error.File = logs/error.log +log4j.appender.error.Append = true +log4j.appender.error.Threshold = ERROR +log4j.appender.error.Encoding=UTF-8 +log4j.appender.error.layout = org.apache.log4j.PatternLayout +log4j.appender.error.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/high_availability/TestCluster.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/high_availability/TestCluster.java index 91a5917dd73..0e008864a8c 100644 --- a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/high_availability/TestCluster.java +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/high_availability/TestCluster.java @@ -1,11 +1,10 @@ package com._4paradigm.openmldb.devops_test.high_availability; import com._4paradigm.openmldb.devops_test.common.ClusterTest; +import com._4paradigm.openmldb.devops_test.util.CheckUtil; import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; import com._4paradigm.openmldb.test_common.openmldb.*; import com._4paradigm.qa.openmldb_deploy.util.Tool; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.RandomStringUtils; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -21,7 +20,7 @@ public class TestCluster extends ClusterTest { private OpenMLDBDevops openMLDBDevops; @BeforeClass public void beforeClass(){ - dbName = "test_devops2"; + dbName = "test_devops"; sdkClient = SDKClient.of(executor); nsClient = NsClient.of(OpenMLDBGlobalVar.mainInfo); openMLDBDevops = OpenMLDBDevops.of(OpenMLDBGlobalVar.mainInfo,dbName); @@ -85,41 +84,41 @@ public void testMoreReplica(){ Assert.assertEquals(sdkClient.getTableRowCount(hddTable),dataCount,oneTabletStopMsg); // tablet start,数据可以回复,要看磁盘表和内存表。 openMLDBDevops.operateTablet(0,"start"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount,10); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount,10); //创建磁盘表和内存表,在重启tablet,数据可回复,内存表和磁盘表可以正常访问。 openMLDBDevops.operateTablet(0,"restart"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+10,10); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+10,10); //创建磁盘表和内存表,插入一些数据,然后make snapshot,在重启tablet,数据可回复。 nsClient.makeSnapshot(dbName,memoryTable); nsClient.makeSnapshot(dbName,ssdTable); nsClient.makeSnapshot(dbName,hddTable); //tablet 依次restart,数据可回复,可以访问。 openMLDBDevops.operateTablet("restart"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+20,10); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+20,10); //1个ns stop,可以正常访问。 openMLDBDevops.operateNs(0,"stop"); resetClient(); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); // 1个ns start 可以访问。 openMLDBDevops.operateNs(0,"start"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); // 1个ns restart 可以访问。 openMLDBDevops.operateNs(0,"restart"); resetClient(); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); // 单zk stop 在start后 可以访问 openMLDBDevops.operateZKOne("stop"); Tool.sleep(3000); openMLDBDevops.operateZKOne("start"); Tool.sleep(3000); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); // 单zk restart 后可以访问 openMLDBDevops.operateZKOne("restart"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); // 2个tablet stop 可以访问 openMLDBDevops.operateTablet(0,"stop"); openMLDBDevops.operateTablet(1,"stop"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); //3个tablet stop,不能访问。 openMLDBDevops.operateTablet(2,"stop"); OpenMLDBResult openMLDBResult = sdkClient.execute(String.format("select * from %s",memoryTable)); @@ -127,7 +126,7 @@ public void testMoreReplica(){ // // 1个tablet启动,数据可回复,分片所在的表,可以访问。 // openMLDBDevops.operateTablet(0,"start"); -// addDataCheck(sdkClient,nsClient,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); +// CheckUtil.addDataCheck(sdkClient,nsClient,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+30,0); //2个ns stop,不能访问。 // openMLDBDevops.operateNs(1,"stop"); @@ -201,24 +200,24 @@ public void testSingle(){ Assert.assertTrue(openMLDBResult.getMsg().contains("fail")); // tablet start,数据可以回复,要看磁盘表和内存表。 openMLDBDevops.operateTablet(0,"start"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount,10); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount,10); //make snapshot,在重启tablet,数据可回复。 nsClient.makeSnapshot(dbName,memoryTable); nsClient.makeSnapshot(dbName,ssdTable); nsClient.makeSnapshot(dbName,hddTable); //重启tablet,数据可回复,内存表和磁盘表可以正常访问。 openMLDBDevops.operateTablet(0,"restart"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+10,10); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+10,10); //ns stop start 可以正常访问。 openMLDBDevops.operateNs(0,"stop"); // resetClient(); //ns start 可以访问。 openMLDBDevops.operateNs(0,"start"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+20,0); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+20,0); //ns restart 可以访问。 openMLDBDevops.operateNs(0,"restart"); // resetClient(); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+20,0); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+20,0); // stop tablet ns 后 在启动 ns tablet 可以访问 openMLDBDevops.operateTablet(0,"stop"); openMLDBDevops.operateNs(0,"stop"); @@ -226,24 +225,7 @@ public void testSingle(){ openMLDBDevops.operateNs(0,"start"); Tool.sleep(10*1000); openMLDBDevops.operateTablet(0,"start"); - addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+20,10); - } - - public void addDataCheck(SDKClient sdkClient, NsClient nsClient,String dbName,List tableNames,int originalCount,int addCount){ - List> addDataList = new ArrayList<>(); - for(int i=0;i list = Lists.newArrayList(c1 + i, 1, 2, 3, 1.1, 2.1, 1590738989000L, "2020-05-01", true); - addDataList.add(list); - } - String msg = "table add data check count failed."; - for(String tableName:tableNames){ - if (CollectionUtils.isNotEmpty(addDataList)) { - sdkClient.insertList(tableName,addDataList); - } - Assert.assertEquals(sdkClient.getTableRowCount(tableName),originalCount+addCount,msg); - } - nsClient.checkTableOffSet(dbName,null); + CheckUtil.addDataCheckByOffset(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTable,ssdTable,hddTable),dataCount+20,10); } public void resetClient(){ OpenMLDBClient openMLDBClient = new OpenMLDBClient(OpenMLDBGlobalVar.mainInfo.getZk_cluster(), OpenMLDBGlobalVar.mainInfo.getZk_root_path()); diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestClusterLinux.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestClusterLinux.java index 0ef9fa8408d..86ffac5626d 100644 --- a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestClusterLinux.java +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestClusterLinux.java @@ -25,17 +25,23 @@ public class TestClusterLinux { private SqlExecutor executor; @BeforeClass public void init() throws SQLException { - OpenMLDBGlobalVar.mainInfo = OpenMLDBInfo.builder() - .deployType(OpenMLDBDeployType.CLUSTER) - .basePath("/home/zhaowei01/openmldb-auto-test/tmp") - .openMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb") - .zk_cluster("172.24.4.55:30000") - .zk_root_path("/openmldb") - .nsNum(2).tabletNum(3) - .nsEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")) - .tabletEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")) - .apiServerEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:30006")) - .build(); + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); + openMLDBInfo.setNsNum(2); + openMLDBInfo.setTabletNum(3); + openMLDBInfo.setBasePath("/home/zhaowei01/openmldb-auto-test/tmp"); + openMLDBInfo.setZk_cluster("172.24.4.55:30000"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")); + openMLDBInfo.setNsNames(com.google.common.collect.Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")); + openMLDBInfo.setTabletNames(com.google.common.collect.Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:30006")); + openMLDBInfo.setApiServerNames(com.google.common.collect.Lists.newArrayList()); + openMLDBInfo.setTaskManagerEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:30007")); + openMLDBInfo.setOpenMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb"); + + OpenMLDBGlobalVar.mainInfo = openMLDBInfo; OpenMLDBGlobalVar.env = "cluster"; OpenMLDBClient openMLDBClient = new OpenMLDBClient(OpenMLDBGlobalVar.mainInfo.getZk_cluster(), OpenMLDBGlobalVar.mainInfo.getZk_root_path()); executor = openMLDBClient.getExecutor(); diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestCommand.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestCommand.java index 6542cfa361a..75f868091dc 100644 --- a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestCommand.java +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestCommand.java @@ -1,5 +1,10 @@ package com._4paradigm.openmldb.devops_test.tmp; +import com._4paradigm.openmldb.devops_test.common.ClusterTest; +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFacade; +import com._4paradigm.openmldb.test_common.command.chain.SqlChainManager; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.test_tool.command_tool.common.CommandUtil; import com._4paradigm.test_tool.command_tool.common.ExecUtil; import com._4paradigm.test_tool.command_tool.common.ExecutorUtil; @@ -7,7 +12,7 @@ import java.util.List; -public class TestCommand { +public class TestCommand extends ClusterTest { @Test public void test1(){ List list = ExecutorUtil.run("/Users/zhaowei/openmldb-auto-test/tmp_mac/openmldb-ns-1/bin/openmldb --zk_cluster=127.0.0.1:30000 --zk_root_path=/openmldb --role=ns_client --interactive=false --database=test_devops4 --cmd='showopstatus'"); @@ -35,4 +40,16 @@ public void test5(){ String str = ExecUtil.exeCommand("/Users/zhaowei/openmldb-auto-test/tmp_mac/openmldb-ns-1/bin/openmldb --zk_cluster=127.0.0.1:30000 --zk_root_path=/openmldb --role=sql_client --interactive=false --database=test_devops --cmd='select * from test_ssd;'"); System.out.println("str = " + str); } + @Test + public void test6(){ + OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(OpenMLDBGlobalVar.mainInfo, "test1", "show table status;"); + List> result = openMLDBResult.getResult(); + result.forEach(l->System.out.println(l)); + } + @Test + public void test7(){ + OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(OpenMLDBGlobalVar.mainInfo, "test1", "show databases;"); + List> result = openMLDBResult.getResult(); + result.forEach(l->System.out.println(l)); + } } diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestSDKClient.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestSDKClient.java index f867f227131..4c0e84912ba 100644 --- a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestSDKClient.java +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestSDKClient.java @@ -1,10 +1,8 @@ package com._4paradigm.openmldb.devops_test.tmp; import com._4paradigm.openmldb.devops_test.common.ClusterTest; -import com._4paradigm.openmldb.test_common.command.OpenMLDBComamndFacade; -import com._4paradigm.openmldb.test_common.openmldb.NsClient; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFacade; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; -import com._4paradigm.openmldb.test_common.openmldb.SDKClient; import org.testng.annotations.Test; public class TestSDKClient extends ClusterTest { @@ -17,7 +15,7 @@ public void testComponents(){ // NsClient nsClient = NsClient.of(OpenMLDBGlobalVar.mainInfo); // boolean flag = nsClient.checkOPStatusDone("test_devops4",null); - OpenMLDBComamndFacade.sql(OpenMLDBGlobalVar.mainInfo,"test_devops","select * from test_ssd;"); + OpenMLDBCommandFacade.sql(OpenMLDBGlobalVar.mainInfo,"test_devops","select * from test_ssd;"); } diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestYaml.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestYaml.java new file mode 100644 index 00000000000..e6065d00b96 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/tmp/TestYaml.java @@ -0,0 +1,35 @@ +package com._4paradigm.openmldb.devops_test.tmp; + +import com._4paradigm.openmldb.test_common.provider.YamlUtil; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBDeployType; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import com.google.common.collect.Lists; +import org.testng.annotations.Test; + +public class TestYaml { + @Test + public void testWriteYaml(){ + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); + openMLDBInfo.setNsNum(2); + openMLDBInfo.setTabletNum(3); + openMLDBInfo.setBasePath("/home/zhaowei01/openmldb-auto-test/tmp"); + openMLDBInfo.setZk_cluster("172.24.4.55:30000"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")); + openMLDBInfo.setNsNames(Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")); + openMLDBInfo.setTabletNames(Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")); + openMLDBInfo.setApiServerNames(Lists.newArrayList()); + openMLDBInfo.setTaskManagerEndpoints(Lists.newArrayList("172.24.4.55:30007")); + openMLDBInfo.setOpenMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb"); + + YamlUtil.writeYamlFile(openMLDBInfo,"out/test.yaml"); + } + @Test + public void testLoadYaml(){ + OpenMLDBInfo openMLDBInfo = YamlUtil.getObject("out/test.yaml", OpenMLDBInfo.class); + System.out.println(openMLDBInfo); + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeCluster.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeCluster.java new file mode 100644 index 00000000000..c59d20f4643 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeCluster.java @@ -0,0 +1,146 @@ +package com._4paradigm.openmldb.devops_test.upgrade_test; + +import com._4paradigm.openmldb.devops_test.common.ClusterTest; +import com._4paradigm.openmldb.devops_test.util.CheckUtil; +import com._4paradigm.openmldb.test_common.openmldb.NsClient; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBDevops; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; +import com._4paradigm.openmldb.test_common.openmldb.SDKClient; +import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; +import com._4paradigm.qa.openmldb_deploy.util.DeployUtil; +import com._4paradigm.test_tool.command_tool.common.ExecutorUtil; +import lombok.extern.slf4j.Slf4j; +import org.testng.Assert; +import org.testng.annotations.*; +import org.testng.collections.Lists; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +public class UpgradeCluster extends ClusterTest { + private String dbName; + private String memoryTableName; + private String ssdTableName; + private String hddTableName; + private SDKClient sdkClient; + private NsClient nsClient; + private OpenMLDBDevops openMLDBDevops; + private String openMLDBPath; + private String newBinPath; + private String confPath; + private String upgradePath; + private OpenMLDBDeploy openMLDBDeploy; + @BeforeClass + @Parameters("upgradeVersion") + public void beforeClass(@Optional("0.6.0") String upgradeVersion){ + dbName = "test_upgrade"; + memoryTableName = "test_memory"; + ssdTableName = "test_ssd"; + hddTableName = "test_hdd"; + sdkClient = SDKClient.of(executor); + nsClient = NsClient.of(OpenMLDBGlobalVar.mainInfo); + openMLDBDevops = OpenMLDBDevops.of(OpenMLDBGlobalVar.mainInfo,dbName); + + int dataCount = 100; + + sdkClient.createAndUseDB(dbName); + String memoryTableDDL = "create table test_memory(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=2,replicanum=3);"; + String ssdTableDDL = "create table test_ssd(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=2,replicanum=3,storage_mode=\"SSD\");"; + String hddTableDDL = "create table test_hdd(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=2,replicanum=3,storage_mode=\"HDD\");"; + List> dataList = new ArrayList<>(); + for(int i=0;i list = Lists.newArrayList("aa" + i, 1, 2, 3, 1.1, 2.1, 1590738989000L, "2020-05-01", true); + dataList.add(list); + } + sdkClient.execute(Lists.newArrayList(memoryTableDDL)); + sdkClient.insertList(memoryTableName,dataList); + if(version.compareTo("0.5.0")>=0) { + sdkClient.execute(Lists.newArrayList(ssdTableDDL, hddTableDDL)); + sdkClient.insertList(ssdTableName, dataList); + sdkClient.insertList(hddTableName, dataList); + } + upgradePath = DeployUtil.getTestPath(version)+"/upgrade_"+upgradeVersion; + File file = new File(upgradePath); + if(!file.exists()){ + file.mkdirs(); + } + openMLDBDeploy = new OpenMLDBDeploy(upgradeVersion); + String upgradeDirectoryName = openMLDBDeploy.downloadOpenMLDB(upgradePath); + openMLDBPath = upgradePath+"/"+upgradeDirectoryName+"/bin/openmldb"; + newBinPath = upgradePath+"/"+upgradeDirectoryName+"/bin/"; + confPath = upgradePath+"/"+upgradeDirectoryName+"/conf"; + } + @Test + public void testUpgrade(){ + Map> map1 = nsClient.getTableOffset(dbName); + log.info("升级前offset:"+map1); + openMLDBDevops.upgradeNs(newBinPath,confPath); + openMLDBDevops.upgradeTablet(newBinPath,confPath); + openMLDBDevops.upgradeApiServer(newBinPath,confPath); + openMLDBDevops.upgradeTaskManager(openMLDBDeploy); + Map> map2 = nsClient.getTableOffset(dbName); + log.info("升级后offset:"+map2); + Assert.assertEquals(map1,map2); + CheckUtil.addDataCheckByOffset(sdkClient, nsClient, dbName, Lists.newArrayList(memoryTableName), 100, 10); + if(version.compareTo("0.5.0")>=0) { + CheckUtil.addDataCheckByOffset(sdkClient, nsClient, dbName, Lists.newArrayList(ssdTableName, hddTableName), 100, 10); + } + } + +// public void upgradeNs(){ +// Map> map1 = nsClient.getTableOffset(dbName); +// log.info("升级前offset:"+map1); +// openMLDBDevops.upgradeNs(openMLDBPath,confPath); +// Map> map2 = nsClient.getTableOffset(dbName); +// log.info("升级后offset:"+map2); +// Assert.assertEquals(map1,map2); +// } +// public void upgradeTablet(){ +// Map> map1 = nsClient.getTableOffset(dbName); +// log.info("升级前offset:"+map1); +// openMLDBDevops.upgradeTablet(openMLDBPath,confPath); +// Map> map2 = nsClient.getTableOffset(dbName); +// log.info("升级后offset:"+map2); +// Assert.assertEquals(map1,map2); +// CheckUtil.addDataCheck(sdkClient,nsClient,dbName,Lists.newArrayList(memoryTableName,ssdTableName,hddTableName),100,10); +// } + +// @AfterClass + public void afterClass(){ + String command = "rm -rf "+upgradePath; + ExecutorUtil.run(command); + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeClusterByCLI.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeClusterByCLI.java new file mode 100644 index 00000000000..f04b5e5f0a4 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeClusterByCLI.java @@ -0,0 +1,153 @@ +package com._4paradigm.openmldb.devops_test.upgrade_test; + +import com._4paradigm.openmldb.devops_test.common.ClusterTest; +import com._4paradigm.openmldb.devops_test.util.CheckUtil; +import com._4paradigm.openmldb.test_common.openmldb.*; +import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; +import com._4paradigm.qa.openmldb_deploy.util.DeployUtil; +import com._4paradigm.test_tool.command_tool.common.ExecutorUtil; +import lombok.extern.slf4j.Slf4j; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; +import org.testng.collections.Lists; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +public class UpgradeClusterByCLI extends ClusterTest { + private String dbName; + private String memoryTableName; + private String ssdTableName; + private String hddTableName; + private CliClient cliClient; + private NsClient nsClient; + private OpenMLDBDevops openMLDBDevops; + private String openMLDBPath; + private SDKClient sdkClient; + private String newBinPath; + private String confPath; + private String upgradePath; + private OpenMLDBDeploy openMLDBDeploy; + private String upgradeVersion; + private String upgradeDirectoryName; + @BeforeClass + @Parameters("upgradeVersion") + public void beforeClass(@Optional("0.6.0") String upgradeVersion){ + this.upgradeVersion = upgradeVersion; + dbName = "test_upgrade"; + memoryTableName = "test_memory"; + ssdTableName = "test_ssd"; + hddTableName = "test_hdd"; + cliClient = CliClient.of(OpenMLDBGlobalVar.mainInfo,dbName); + nsClient = NsClient.of(OpenMLDBGlobalVar.mainInfo); + openMLDBDevops = OpenMLDBDevops.of(OpenMLDBGlobalVar.mainInfo,dbName); + cliClient.setGlobalOnline(); + int dataCount = 100; + cliClient.create(dbName); + String memoryTableDDL = "create table test_memory(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=2,replicanum=3);"; + String ssdTableDDL = "create table test_ssd(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=2,replicanum=3,storage_mode=\"SSD\");"; + String hddTableDDL = "create table test_hdd(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=2,replicanum=3,storage_mode=\"HDD\");"; + List> dataList = new ArrayList<>(); + for(int i=0;i list = Lists.newArrayList("aa" + i, 1, 2, 3, 1.1, 2.1, 1590738989000L, "2020-05-01", true); + dataList.add(list); + } + cliClient.execute(Lists.newArrayList(memoryTableDDL)); + cliClient.insertList(memoryTableName,dataList); + if(version.compareTo("0.5.0")>=0) { + cliClient.execute(Lists.newArrayList(ssdTableDDL, hddTableDDL)); + cliClient.insertList(ssdTableName, dataList); + cliClient.insertList(hddTableName, dataList); + } + upgradePath = DeployUtil.getTestPath(version)+"/upgrade_"+upgradeVersion; + File file = new File(upgradePath); + if(!file.exists()){ + file.mkdirs(); + } + openMLDBDeploy = new OpenMLDBDeploy(upgradeVersion); + upgradeDirectoryName = openMLDBDeploy.downloadOpenMLDB(upgradePath); + openMLDBPath = upgradePath+"/"+upgradeDirectoryName+"/bin/openmldb"; + newBinPath = upgradePath+"/"+upgradeDirectoryName+"/bin/"; + confPath = upgradePath+"/"+upgradeDirectoryName+"/conf"; + } + @Test + public void testUpgrade(){ + Map> beforeMap; + if(version.compareTo("0.6.0")>=0){ + beforeMap = nsClient.getTableOffset(dbName); + }else{ + beforeMap = cliClient.showTableStatus(); + } + log.info("升级前offset:"+beforeMap); + openMLDBDevops.upgradeNs(newBinPath,confPath); + openMLDBDevops.upgradeTablet(newBinPath,confPath); + openMLDBDevops.upgradeApiServer(newBinPath,confPath); + ExecutorUtil.run("cp -r " + upgradePath+"/"+upgradeDirectoryName + " " + OpenMLDBGlobalVar.mainInfo.getBasePath()); + openMLDBDevops.upgradeTaskManager(openMLDBDeploy); + Map> afterMap; + if(version.compareTo("0.6.0")>=0){ + afterMap = nsClient.getTableOffset(dbName); + }else{ + afterMap = cliClient.showTableStatus(); + } + log.info("升级后offset:"+afterMap); + Assert.assertEquals(beforeMap,afterMap); + sdkClient = SDKClient.of(executor); + sdkClient.useDB(dbName); + if(upgradeVersion.compareTo("0.6.0")>=0) { + if(version.compareTo("0.5.0")>=0) { + CheckUtil.addDataCheckByOffset(sdkClient, nsClient, dbName, Lists.newArrayList(memoryTableName, ssdTableName, hddTableName), 100, 10); + }else{ + CheckUtil.addDataCheckByOffset(sdkClient, nsClient, dbName, Lists.newArrayList(memoryTableName), 100, 10); + } + }else{ + if(version.compareTo("0.5.0")>=0) { + CheckUtil.addDataCheckByCount(sdkClient, Lists.newArrayList(memoryTableName, ssdTableName, hddTableName), 100, 10); + }else{ + CheckUtil.addDataCheckByCount(sdkClient, Lists.newArrayList(memoryTableName), 100, 10); + } + } + } + +// @AfterClass + public void afterClass(){ + String command = "rm -rf "+upgradePath; + ExecutorUtil.run(command); + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeStandalone.java b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeStandalone.java new file mode 100644 index 00000000000..2ca68ca8636 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/src/test/java/com/_4paradigm/openmldb/devops_test/upgrade_test/UpgradeStandalone.java @@ -0,0 +1,124 @@ +package com._4paradigm.openmldb.devops_test.upgrade_test; + +import com._4paradigm.openmldb.devops_test.common.ClusterTest; +import com._4paradigm.openmldb.devops_test.util.CheckUtil; +import com._4paradigm.openmldb.test_common.openmldb.NsClient; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBDevops; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; +import com._4paradigm.openmldb.test_common.openmldb.SDKClient; +import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; +import com._4paradigm.qa.openmldb_deploy.util.DeployUtil; +import com._4paradigm.test_tool.command_tool.common.ExecutorUtil; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; +import org.testng.collections.Lists; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +@Slf4j +public class UpgradeStandalone extends ClusterTest { + private String dbName; + private String memoryTableName; + private String ssdTableName; + private String hddTableName; + private SDKClient sdkClient; + private NsClient nsClient; + private OpenMLDBDevops openMLDBDevops; + private String newBinPath; + private String confPath; + private String upgradePath; + @BeforeClass + @Parameters("upgradeVersion") + public void beforeClass(@Optional("0.6.0") String upgradeVersion){ + dbName = "test_upgrade"; + memoryTableName = "test_memory"; + ssdTableName = "test_ssd"; + hddTableName = "test_hdd"; + sdkClient = SDKClient.of(executor); + nsClient = NsClient.of(OpenMLDBGlobalVar.mainInfo); + openMLDBDevops = OpenMLDBDevops.of(OpenMLDBGlobalVar.mainInfo,dbName); + + sdkClient.createAndUseDB(dbName); + upgradePath = DeployUtil.getTestPath(version)+"/upgrade_"+upgradeVersion; + File file = new File(upgradePath); + if(!file.exists()){ + file.mkdirs(); + } + OpenMLDBDeploy openMLDBDeploy = new OpenMLDBDeploy(upgradeVersion); + String upgradeDirectoryName = openMLDBDeploy.downloadOpenMLDB(upgradePath); + newBinPath = upgradeDirectoryName+"/bin/"; + confPath = upgradeDirectoryName+"/conf"; + } + @Test + public void testUpgrade(){ +// Map> map1 = nsClient.getTableOffset(dbName); +// log.info("升级前offset:"+map1); + openMLDBDevops.upgradeStandalone(newBinPath,confPath); +// Map> map2 = nsClient.getTableOffset(dbName); +// log.info("升级后offset:"+map2); +// Assert.assertEquals(map1,map2); + String memoryTableDDL = "create table test_memory(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=1,replicanum=1);"; + String ssdTableDDL = "create table test_ssd(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=1,replicanum=1,storage_mode=\"SSD\");"; + String hddTableDDL = "create table test_hdd(\n" + + "c1 string,\n" + + "c2 smallint,\n" + + "c3 int,\n" + + "c4 bigint,\n" + + "c5 float,\n" + + "c6 double,\n" + + "c7 timestamp,\n" + + "c8 date,\n" + + "c9 bool,\n" + + "index(key=(c1),ts=c7))options(partitionnum=1,replicanum=1,storage_mode=\"HDD\");"; + // 插入一定量的数据 + int dataCount = 100; + List> dataList = new ArrayList<>(); + for(int i=0;i list = Lists.newArrayList("aa" + i, 1, 2, 3, 1.1, 2.1, 1590738989000L, "2020-05-01", true); + dataList.add(list); + } + sdkClient.execute(Lists.newArrayList(memoryTableDDL)); + sdkClient.insertList(memoryTableName,dataList); + if(version.compareTo("0.5.0")>=0) { + sdkClient.execute(Lists.newArrayList(ssdTableDDL, hddTableDDL)); + sdkClient.insertList(ssdTableName, dataList); + sdkClient.insertList(hddTableName, dataList); + } + + CheckUtil.addDataCheckByOffset(sdkClient, nsClient, dbName, Lists.newArrayList(memoryTableName), 100, 10); + if(version.compareTo("0.5.0")>=0) { + CheckUtil.addDataCheckByOffset(sdkClient, nsClient, dbName, Lists.newArrayList(ssdTableName, hddTableName), 100, 10); + } + } + +// @AfterClass + public void afterClass(){ + String command = "rm -rf "+upgradePath; + ExecutorUtil.run(command); + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_cluster.xml b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_cluster.xml index b313b52acbc..f8282b2883d 100644 --- a/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_cluster.xml +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_cluster.xml @@ -2,6 +2,8 @@ + + diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_node_expansion.xml b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_node_expansion.xml index d9c9d9e5edb..e69bdc129e8 100644 --- a/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_node_expansion.xml +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_node_expansion.xml @@ -2,6 +2,8 @@ + + diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_single.xml b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_single.xml index bbdc8aa901a..e665adb7951 100644 --- a/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_single.xml +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_single.xml @@ -2,6 +2,8 @@ + + diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_upgrade.xml b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_upgrade.xml new file mode 100644 index 00000000000..d4703f3f3c1 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_upgrade.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_upgrade_single.xml b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_upgrade_single.xml new file mode 100644 index 00000000000..05388c38578 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-devops-test/test_suite/test_upgrade_single.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/test/integration-test/openmldb-test-java/openmldb-ecosystem/pom.xml b/test/integration-test/openmldb-test-java/openmldb-ecosystem/pom.xml new file mode 100644 index 00000000000..c860e8329c5 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-ecosystem/pom.xml @@ -0,0 +1,38 @@ + + + + openmldb-test-java + com.4paradigm.openmldb + 0.1.0-SNAPSHOT + + 4.0.0 + + openmldb-ecosystem + + + 8 + 8 + + + + + com.4paradigm.openmldb + openmldb-test-common + ${project.version} + + + com.4paradigm.openmldb + openmldb-deploy + ${project.version} + + + + org.apache.kafka + kafka-clients + 2.7.0 + + + + \ No newline at end of file diff --git a/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/main/java/com/_4paradigm/openmldb/ecosystem/common/KafkaTest.java b/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/main/java/com/_4paradigm/openmldb/ecosystem/common/KafkaTest.java new file mode 100644 index 00000000000..a224960b8d5 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/main/java/com/_4paradigm/openmldb/ecosystem/common/KafkaTest.java @@ -0,0 +1,90 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com._4paradigm.openmldb.ecosystem.common; + + +import com._4paradigm.openmldb.sdk.SqlExecutor; +import com._4paradigm.openmldb.test_common.common.BaseTest; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBClient; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBDeployType; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; +import com.google.common.collect.Lists; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Optional; +import org.testng.annotations.Parameters; + +import java.sql.Statement; + +/** + * @author zhaowei + * @date 2020/6/11 2:02 PM + */ +@Slf4j +public class KafkaTest extends BaseTest { + protected static SqlExecutor executor; + + @BeforeTest() + @Parameters({"env","version","openMLDBPath"}) + public void beforeTest(@Optional("qa") String env,@Optional("main") String version,@Optional("")String openMLDBPath) throws Exception { + OpenMLDBGlobalVar.env = env; + if(env.equalsIgnoreCase("cluster")){ + OpenMLDBDeploy openMLDBDeploy = new OpenMLDBDeploy(version);; + openMLDBDeploy.setOpenMLDBPath(openMLDBPath); + openMLDBDeploy.setCluster(true); + OpenMLDBGlobalVar.mainInfo = openMLDBDeploy.deployCluster(2, 3); + }else if(env.equalsIgnoreCase("standalone")){ + OpenMLDBDeploy openMLDBDeploy = new OpenMLDBDeploy(version); + openMLDBDeploy.setOpenMLDBPath(openMLDBPath); + openMLDBDeploy.setCluster(false); + OpenMLDBGlobalVar.mainInfo = openMLDBDeploy.deployCluster(2, 3); + }else{ + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); + openMLDBInfo.setNsNum(2); + openMLDBInfo.setTabletNum(3); + openMLDBInfo.setBasePath("/home/zhaowei01/openmldb-auto-test/tmp"); + openMLDBInfo.setZk_cluster("172.24.4.55:30000"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")); + openMLDBInfo.setNsNames(Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")); + openMLDBInfo.setTabletNames(Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")); + openMLDBInfo.setApiServerNames(Lists.newArrayList()); + openMLDBInfo.setTaskManagerEndpoints(Lists.newArrayList("172.24.4.55:30007")); + openMLDBInfo.setOpenMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb"); + + OpenMLDBGlobalVar.mainInfo = openMLDBInfo; + OpenMLDBGlobalVar.env = "cluster"; + + } + String caseEnv = System.getProperty("caseEnv"); + if (!StringUtils.isEmpty(caseEnv)) { + OpenMLDBGlobalVar.env = caseEnv; + } + log.info("fedb global var env: {}", env); + OpenMLDBClient fesqlClient = new OpenMLDBClient(OpenMLDBGlobalVar.mainInfo.getZk_cluster(), OpenMLDBGlobalVar.mainInfo.getZk_root_path()); + executor = fesqlClient.getExecutor(); + log.info("executor:{}",executor); + Statement statement = executor.getStatement(); + statement.execute("SET @@execute_mode='online';"); + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/main/resources/kafka.properties b/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/main/resources/kafka.properties new file mode 100644 index 00000000000..4416bdb5dcf --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/main/resources/kafka.properties @@ -0,0 +1,4 @@ +bootstrap.servers=172.24.4.55:39092 +topic=test_kafka +table.create=create table test_kafka(c1 string,c2 smallint,c3 int,c4 bigint,c5 float,c6 double,c7 timestamp,c8 date,c9 bool,index(key=(c1),ts=c7)); + diff --git a/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/test/java/com/_4paradigm/openmldb/ecosystem/tmp/TestKafka.java b/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/test/java/com/_4paradigm/openmldb/ecosystem/tmp/TestKafka.java new file mode 100644 index 00000000000..6adaf44660e --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-ecosystem/src/test/java/com/_4paradigm/openmldb/ecosystem/tmp/TestKafka.java @@ -0,0 +1,85 @@ +package com._4paradigm.openmldb.ecosystem.tmp; + +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.testng.annotations.Test; + +import java.util.Collections; +import java.util.Properties; + +public class TestKafka { + @Test + public void test(){ + //1.创建Kafka生产者的配置信息 + Properties properties = new Properties(); + //指定链接的kafka集群 + properties.put("bootstrap.servers","172.24.4.55:39092"); + //ack应答级别 +// properties.put("acks","all");//all等价于-1 0 1 + //重试次数 + properties.put("retries",1); + //批次大小 + properties.put("batch.size",16384);//16k + //等待时间 + properties.put("linger.ms",1); + //RecordAccumulator缓冲区大小 + properties.put("buffer.memory",33554432);//32m + //Key,Value的序列化类 + properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + + //创建生产者对象 + KafkaProducer producer = new KafkaProducer<>(properties); +// String message = "{\"schema\":{\"type\":\"struct\",\"fields\":[{\"type\":\"int16\",\"optional\":true,\"field\":\"c1_int16\"},{\"type\":\"int32\",\"optional\":true,\"field\":\"c2_int32\"},{\"type\":\"int64\",\"optional\":true,\"field\":\"c3_int64\"},{\"type\":\"float\",\"optional\":true,\"field\":\"c4_float\"},{\"type\":\"double\",\"optional\":true,\"field\":\"c5_double\"},{\"type\":\"boolean\",\"optional\":true,\"field\":\"c6_boolean\"},{\"type\":\"string\",\"optional\":true,\"field\":\"c7_string\"},{\"type\":\"int64\",\"name\":\"org.apache.kafka.connect.data.Date\",\"optional\":true,\"field\":\"c8_date\"},{\"type\":\"int64\",\"name\":\"org.apache.kafka.connect.data.Timestamp\",\"optional\":true,\"field\":\"c9_timestamp\"}],\"optional\":false,\"name\":\"foobar\"},\"payload\":{\"c1_int16\":1,\"c2_int32\":2,\"c3_int64\":3,\"c4_float\":4.4,\"c5_double\":5.555,\"c6_boolean\":true,\"c7_string\":\"c77777\",\"c8_date\":19109,\"c9_timestamp\":1651051906000}}"; +// String message = "{\"data\":[{\"ID\":20,\"UUID\":\"11\",\"PID\":11,\"GID\":11,\"CID\":11}],\"database\":\"d1\",\"table\":\"test_kafka\",\"type\":\"insert\"}"; + String message = "{\"data\":[{\"c1\":\"dd\",\"c2\":1,\"c3\":2,\"c4\":3,\"c5\":1.1,\"c6\":2.2,\"c7\":11,\"c8\":1659512628000,\"c9\":true}],\"type\":\"insert\"}"; +// String message = "{\"schema\":{\"type\":\"struct\",\"fields\":[{\"type\":\"string\",\"optional\":true,\"field\":\"c1\"},{\"type\":\"int16\",\"optional\":true,\"field\":\"c2\"},{\"type\":\"int32\",\"optional\":true,\"field\":\"c3\"},{\"type\":\"int64\",\"optional\":true,\"field\":\"c4\"},{\"type\":\"float\",\"optional\":true,\"field\":\"c5\"},{\"type\":\"double\",\"optional\":true,\"field\":\"c6\"},{\"type\":\"int64\",\"name\":\"org.apache.kafka.connect.data.Date\",\"optional\":true,\"field\":\"c7\"},{\"type\":\"int64\",\"name\":\"org.apache.kafka.connect.data.Timestamp\",\"optional\":true,\"field\":\"c8\"},{\"type\":\"boolean\",\"optional\":true,\"field\":\"c9\"}],\"optional\":false,\"name\":\"foobar\"},\"payload\":{\"c1\":\"ee\",\"c2\":1,\"c3\":2,\"c4\":3,\"c5\":1.1,\"c6\":2.2,\"c7\":11,\"c8\":1659512628000,\"c9\":true}}"; + //发送数据 + producer.send(new ProducerRecord("m2",message)); +// for (int i=0;i<10;i++){ +// producer.send(new ProducerRecord("study","luzelong"+i)); +// } + + //关闭资源 + producer.close(); + } + @Test + public void test1() {//自动提交 + //1.创建消费者配置信息 + Properties properties = new Properties(); + //链接的集群 + properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,"172.24.4.55:39092"); + //开启自动提交 + properties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG,true); + //自动提交的延迟 + properties.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG,"1000"); + //key,value的反序列化 + properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,"org.apache.kafka.common.serialization.StringDeserializer"); + properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,"org.apache.kafka.common.serialization.StringDeserializer"); + //消费者组 + properties.put(ConsumerConfig.GROUP_ID_CONFIG,"test-consumer-group1"); + properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,"earliest");//重置消费者offset的方法(达到重复消费的目的),设置该属性也只在两种情况下生效:1.上面设置的消费组还未消费(可以更改组名来消费)2.该offset已经过期 + + + //创建生产者 + KafkaConsumer consumer = new KafkaConsumer<>(properties); + consumer.subscribe(Collections.singletonList("test_kafka")); //Arrays.asList() + + while (true) { + //获取数据 + ConsumerRecords consumerRecords = consumer.poll(100); + + //解析并打印consumerRecords + for (ConsumerRecord consumerRecord : consumerRecords) { + System.out.println(consumerRecord.key() + "----" + consumerRecord.value()); + } + } + + //consumer无需close() + } + +} diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/ClusterTest.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/ClusterTest.java index 207a5c52617..b24d2de1652 100644 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/ClusterTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/ClusterTest.java @@ -53,17 +53,22 @@ public void beforeTest(@Optional("qa") String env, @Optional("main") String vers openMLDBDeploy.setCluster(false); RestfulGlobalVar.mainInfo = openMLDBDeploy.deployCluster(2, 3); } else { - RestfulGlobalVar.mainInfo = OpenMLDBInfo.builder() - .deployType(OpenMLDBDeployType.CLUSTER) - .basePath("/home/zhaowei01/fedb-auto-test/tmp") - .openMLDBPath("/home/zhaowei01/fedb-auto-test/tmp/openmldb-ns-1/bin/openmldb") - .zk_cluster("172.24.4.55:30000") - .zk_root_path("/openmldb") - .nsNum(2).tabletNum(3) - .nsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")) - .tabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")) - .apiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")) - .build(); + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); + openMLDBInfo.setNsNum(2); + openMLDBInfo.setTabletNum(3); + openMLDBInfo.setBasePath("/home/zhaowei01/openmldb-auto-test/tmp"); + openMLDBInfo.setZk_cluster("172.24.4.55:30000"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")); + openMLDBInfo.setNsNames(Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")); + openMLDBInfo.setTabletNames(Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")); + openMLDBInfo.setApiServerNames(Lists.newArrayList()); + openMLDBInfo.setTaskManagerEndpoints(Lists.newArrayList("172.24.4.55:30007")); + openMLDBInfo.setOpenMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb"); + RestfulGlobalVar.mainInfo = openMLDBInfo; OpenMLDBGlobalVar.env = "cluster"; } OpenMLDBClient openMLDBClient = new OpenMLDBClient(RestfulGlobalVar.mainInfo.getZk_cluster(),RestfulGlobalVar.mainInfo.getZk_root_path()); diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/StandaloneTest.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/StandaloneTest.java index 744c788fb2f..828130a17a5 100644 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/StandaloneTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/common/StandaloneTest.java @@ -16,6 +16,7 @@ package com._4paradigm.openmldb.http_test.common; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBDeployType; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; @@ -43,17 +44,21 @@ public void beforeTest(@Optional("qa") String env, @Optional("main") String vers fedbDeploy.setOpenMLDBPath(fedbPath); RestfulGlobalVar.mainInfo = fedbDeploy.deployStandalone(); }else{ - RestfulGlobalVar.mainInfo = OpenMLDBInfo.builder() - .deployType(OpenMLDBDeployType.STANDALONE) - .basePath("/home/zhaowei01/fedb-auto-test/standalone") - .openMLDBPath("/home/zhaowei01/fedb-auto-test/standalone/openmldb-standalone/bin/openmldb") - .nsNum(1).tabletNum(1) - .nsEndpoints(Lists.newArrayList("172.24.4.55:10018")) - .tabletEndpoints(Lists.newArrayList("172.24.4.55:10019")) - .apiServerEndpoints(Lists.newArrayList("172.24.4.55:10020")) - .host("172.24.4.55") - .port(10018) - .build(); + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.STANDALONE); + openMLDBInfo.setHost("172.24.4.55"); + openMLDBInfo.setPort(30013); + openMLDBInfo.setNsNum(1); + openMLDBInfo.setTabletNum(1); + openMLDBInfo.setBasePath("/home/wangkaidong/fedb-auto-test/standalone"); + openMLDBInfo.setZk_cluster("172.24.4.55:30000"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30013")); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30014")); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30015")); + openMLDBInfo.setOpenMLDBPath("/home/wangkaidong/fedb-auto-test/standalone/openmldb-standalone/bin/openmldb"); + + RestfulGlobalVar.mainInfo = openMLDBInfo; } } } diff --git a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/executor/RestfulCliExecutor.java b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/executor/RestfulCliExecutor.java index d946b5b699b..feb76c966ce 100644 --- a/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/executor/RestfulCliExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-http-test/src/main/java/com/_4paradigm/openmldb/http_test/executor/RestfulCliExecutor.java @@ -20,10 +20,9 @@ import com._4paradigm.openmldb.http_test.common.RestfulGlobalVar; import com._4paradigm.openmldb.http_test.config.FedbRestfulConfig; import com._4paradigm.openmldb.java_sdk_test.checker.ResultChecker; -import com._4paradigm.openmldb.test_common.command.OpenMLDBComamndFacade; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFacade; import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandUtil; import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.test_common.common.Checker; import com._4paradigm.openmldb.test_common.model.ExpectDesc; import com._4paradigm.openmldb.test_common.model.InputDesc; @@ -91,7 +90,7 @@ public void prepare() { return sql; }) .collect(Collectors.toList()); - OpenMLDBComamndFacade.sqls(RestfulGlobalVar.mainInfo,FedbRestfulConfig.DB_NAME,sqls); + OpenMLDBCommandFacade.sqls(RestfulGlobalVar.mainInfo,FedbRestfulConfig.DB_NAME,sqls); } logger.info("prepare end"); } @@ -125,7 +124,7 @@ public void tearDown() { return sql; }) .collect(Collectors.toList()); - fesqlResult = OpenMLDBComamndFacade.sqls(RestfulGlobalVar.mainInfo, FedbRestfulConfig.DB_NAME, sqls); + fesqlResult = OpenMLDBCommandFacade.sqls(RestfulGlobalVar.mainInfo, FedbRestfulConfig.DB_NAME, sqls); } } @@ -137,7 +136,7 @@ public void tearDown() { for (InputDesc table : tables) { if(table.isDrop()) { String drop = "drop table " + table.getName() + ";"; - OpenMLDBComamndFacade.sql(RestfulGlobalVar.mainInfo, FedbRestfulConfig.DB_NAME, drop); + OpenMLDBCommandFacade.sql(RestfulGlobalVar.mainInfo, FedbRestfulConfig.DB_NAME, drop); } } } @@ -151,7 +150,7 @@ protected void afterAction(){ List sqls = afterAction.getSqls().stream() .map(sql -> SQLUtil.formatSql(sql,tableNames, RestfulGlobalVar.mainInfo)) .collect(Collectors.toList()); - fesqlResult = OpenMLDBComamndFacade.sqls(RestfulGlobalVar.mainInfo, FedbRestfulConfig.DB_NAME, sqls); + fesqlResult = OpenMLDBCommandFacade.sqls(RestfulGlobalVar.mainInfo, FedbRestfulConfig.DB_NAME, sqls); } ExpectDesc expect = afterAction.getExpect(); if(expect!=null){ diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/cluster_dist.yaml b/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/cluster_dist.yaml new file mode 100644 index 00000000000..17119b4c799 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/cluster_dist.yaml @@ -0,0 +1,32 @@ +mode: cluster +zookeeper: + zk_cluster: 172.24.4.55:30019 + zk_root_path: /openmldb +nameserver: + - + endpoint: 172.24.4.55:30023 + path: /home/zhaowei01/openmldb-auto-test/tmp2/openmldb-ns-1 + is_local: true + - + endpoint: 172.24.4.55:30024 + path: /home/zhaowei01/openmldb-auto-test/tmp2/openmldb-ns-2 + is_local: true +tablet: + - + endpoint: 172.24.4.55:30020 + path: /home/zhaowei01/openmldb-auto-test/tmp2/openmldb-tablet-1 + is_local: true + - + endpoint: 172.24.4.55:30021 + path: /home/zhaowei01/openmldb-auto-test/tmp2/openmldb-tablet-2 + is_local: true + - + endpoint: 172.24.4.55:30022 + path: /home/zhaowei01/openmldb-auto-test/tmp2/openmldb-tablet-3 + is_local: true +taskmanager: + - + endpoint: 172.24.4.55:30026 + path: /home/zhaowei01/openmldb-auto-test/tmp2/openmldb-task_manager-1 + spark_master: local + is_local: true \ No newline at end of file diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/onebox.yaml b/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/onebox.yaml new file mode 100644 index 00000000000..62e48ecb6f0 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/onebox.yaml @@ -0,0 +1,24 @@ +mode: cluster +zookeeper: + zk_cluster: 172.24.4.55:30019 + zk_root_path: /onebox +nameserver: + - + endpoint: 172.24.4.55:31000 + path: /home/zhaowei01/openmldb-auto-test/onebox/openmldb-0.5.3-linux + is_local: true +tablet: + - + endpoint: 172.24.4.55:31001 + path: /home/zhaowei01/openmldb-auto-test/onebox/openmldb-0.5.3-linux + is_local: true + - + endpoint: 172.24.4.55:31002 + path: /home/zhaowei01/openmldb-auto-test/onebox/openmldb-0.5.3-linux + is_local: true +taskmanager: + - + endpoint: 172.24.4.55:31004 + path: /home/zhaowei01/openmldb-auto-test/onebox/openmldb-0.5.3-linux + spark_master: local + is_local: true \ No newline at end of file diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/standalone_dist.yaml b/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/standalone_dist.yaml new file mode 100644 index 00000000000..b3155d3c5c6 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/standalone_dist.yaml @@ -0,0 +1,11 @@ +mode: standalone +nameserver: + - + endpoint: 172.24.4.55:30013 + path: /home/zhaowei01/openmldb-auto-test/standalone/openmldb-standalone + is_local: true +tablet: + - + endpoint: 172.24.4.55:30014 + path: /home/zhaowei01/openmldb-auto-test/standalone/openmldb-standalone + is_local: true diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/stop-openmldb.sh b/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/stop-openmldb.sh index 996aa02cc30..af22cc3d7c3 100755 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/stop-openmldb.sh +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/shell/stop-openmldb.sh @@ -54,4 +54,5 @@ rm -rf openmldb-ns-1/bin/openmldb rm -rf openmldb-ns-2/bin/openmldb rm -rf openmldb-tablet-1/bin/openmldb rm -rf openmldb-tablet-2/bin/openmldb -rm -rf openmldb-tablet-3/bin/openmldb \ No newline at end of file +rm -rf openmldb-tablet-3/bin/openmldb + diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/BaseChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/BaseChecker.java index 212f39806d1..07fa19a2b50 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/BaseChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/BaseChecker.java @@ -27,17 +27,17 @@ * @date 2020/6/16 3:37 PM */ public abstract class BaseChecker implements Checker { - protected OpenMLDBResult fesqlResult; + protected OpenMLDBResult openMLDBResult; protected Map resultMap; protected ExpectDesc expect; - public BaseChecker(ExpectDesc expect, OpenMLDBResult fesqlResult){ + public BaseChecker(ExpectDesc expect, OpenMLDBResult openMLDBResult){ this.expect = expect; - this.fesqlResult = fesqlResult; + this.openMLDBResult = openMLDBResult; } - public BaseChecker(OpenMLDBResult fesqlResult, Map resultMap){ - this.fesqlResult = fesqlResult; + public BaseChecker(OpenMLDBResult openMLDBResult, Map resultMap){ + this.openMLDBResult = openMLDBResult; this.resultMap = resultMap; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CatCheckerByCli.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CatCheckerByCli.java index 0a0502f6256..3481bdc8970 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CatCheckerByCli.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CatCheckerByCli.java @@ -2,7 +2,6 @@ import com._4paradigm.openmldb.test_common.command.CommandUtil; import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.test_common.model.CatFile; import com._4paradigm.openmldb.test_common.model.ExpectDesc; import com._4paradigm.openmldb.test_common.util.SQLUtil; @@ -22,7 +21,7 @@ public void check() throws Exception { log.info("cat check"); CatFile expectCat = expect.getCat(); String path = expectCat.getPath(); - path = SQLUtil.formatSql(path, fesqlResult.getTableNames()); + path = SQLUtil.formatSql(path, openMLDBResult.getTableNames()); String command = "cat "+path; List actualList = CommandUtil.run(command); List expectList = expectCat.getLines(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/Checker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/Checker.java index 050bd035918..0db10f4baa1 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/Checker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/Checker.java @@ -17,6 +17,5 @@ package com._4paradigm.openmldb.java_sdk_test.checker; public interface Checker { - void check() throws Exception; } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CheckerStrategy.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CheckerStrategy.java index 6d38d16c138..8fe3bce709c 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CheckerStrategy.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CheckerStrategy.java @@ -17,6 +17,7 @@ package com._4paradigm.openmldb.java_sdk_test.checker; +import com._4paradigm.openmldb.sdk.SqlExecutor; import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; import com._4paradigm.openmldb.test_common.model.ExpectDesc; import com._4paradigm.openmldb.test_common.model.SQLCase; @@ -30,60 +31,68 @@ public class CheckerStrategy { - public static List build(SQLCase fesqlCase, OpenMLDBResult fesqlResult, SQLCaseType executorType) { + public static List build(SqlExecutor executor,SQLCase sqlCase, OpenMLDBResult openMLDBResult, SQLCaseType executorType) { List checkList = new ArrayList<>(); - if (null == fesqlCase) { + if (null == sqlCase) { return checkList; } - ExpectDesc expect = fesqlCase.getOnlineExpectByType(executorType); - - checkList.add(new SuccessChecker(expect, fesqlResult)); + ExpectDesc expect = sqlCase.getOnlineExpectByType(executorType); + if (null == expect) { + return checkList; + } + checkList.add(new SuccessChecker(expect, openMLDBResult)); if (CollectionUtils.isNotEmpty(expect.getColumns())) { if(executorType==SQLCaseType.kSQLITE3 || executorType==SQLCaseType.kMYSQL){ - checkList.add(new ColumnsCheckerByJBDC(expect, fesqlResult)); + checkList.add(new ColumnsCheckerByJBDC(expect, openMLDBResult)); }else if(executorType==SQLCaseType.kCLI||executorType==SQLCaseType.kStandaloneCLI||executorType==SQLCaseType.kClusterCLI){ - checkList.add(new ColumnsCheckerByCli(expect, fesqlResult)); + checkList.add(new ColumnsCheckerByCli(expect, openMLDBResult)); }else { - checkList.add(new ColumnsChecker(expect, fesqlResult)); + checkList.add(new ColumnsChecker(expect, openMLDBResult)); } } if (!expect.getRows().isEmpty()) { if(executorType==SQLCaseType.kSQLITE3){ - checkList.add(new ResultCheckerByJDBC(expect, fesqlResult)); + checkList.add(new ResultCheckerByJDBC(expect, openMLDBResult)); }else if(executorType==SQLCaseType.kCLI||executorType==SQLCaseType.kStandaloneCLI||executorType==SQLCaseType.kClusterCLI){ - checkList.add(new ResultCheckerByCli(expect, fesqlResult)); + checkList.add(new ResultCheckerByCli(expect, openMLDBResult)); }else { - checkList.add(new ResultChecker(expect, fesqlResult)); + checkList.add(new ResultChecker(expect, openMLDBResult)); } } if (expect.getCount() >= 0) { - checkList.add(new CountChecker(expect, fesqlResult)); + checkList.add(new CountChecker(expect, openMLDBResult)); } if(MapUtils.isNotEmpty(expect.getOptions())){ - checkList.add(new OptionsChecker(expect, fesqlResult)); + checkList.add(new OptionsChecker(expect, openMLDBResult)); } if(CollectionUtils.isNotEmpty(expect.getIdxs())){ - checkList.add(new IndexChecker(expect, fesqlResult)); + checkList.add(new IndexChecker(expect, openMLDBResult)); } if (expect.getIndexCount() >= 0) { - checkList.add(new IndexCountChecker(expect, fesqlResult)); + checkList.add(new IndexCountChecker(expect, openMLDBResult)); } if(expect.getDeployment()!=null){ - checkList.add(new DeploymentCheckerByCli(expect, fesqlResult)); + checkList.add(new DeploymentCheckerByCli(expect, openMLDBResult)); } if(expect.getDeploymentContains()!=null){ - checkList.add(new DeploymentContainsCheckerByCli(expect, fesqlResult)); + checkList.add(new DeploymentContainsCheckerByCli(expect, openMLDBResult)); } if(expect.getDeploymentCount()>=0){ - checkList.add(new DeploymentCountCheckerByCli(expect, fesqlResult)); + checkList.add(new DeploymentCountCheckerByCli(expect, openMLDBResult)); } if(expect.getCat()!=null){ - checkList.add(new CatCheckerByCli(expect, fesqlResult)); + checkList.add(new CatCheckerByCli(expect, openMLDBResult)); } if(StringUtils.isNotEmpty(expect.getMsg())){ - checkList.add(new MessageChecker(expect, fesqlResult)); + checkList.add(new MessageChecker(expect, openMLDBResult)); + } + if(expect.getPreAgg()!=null){ + checkList.add(new PreAggChecker(executor, expect, openMLDBResult)); + } + if(CollectionUtils.isNotEmpty(expect.getPreAggList())){ + checkList.add(new PreAggListChecker(executor, expect, openMLDBResult)); } return checkList; } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsChecker.java index b352280c23b..f9cf540610d 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsChecker.java @@ -43,8 +43,8 @@ public void check() throws Exception { if (expectColumns == null || expectColumns.size() == 0) { return; } - List columnNames = fesqlResult.getColumnNames(); - List columnTypes = fesqlResult.getColumnTypes(); + List columnNames = openMLDBResult.getColumnNames(); + List columnTypes = openMLDBResult.getColumnTypes(); Assert.assertEquals(expectColumns.size(),columnNames.size(), "Illegal schema size"); for (int i = 0; i < expectColumns.size(); i++) { // Assert.assertEquals(columnNames.get(i)+" "+columnTypes.get(i),expectColumns.get(i)); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsCheckerByCli.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsCheckerByCli.java index 0a81899ef47..b6b9feac768 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsCheckerByCli.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsCheckerByCli.java @@ -42,7 +42,7 @@ public void check() throws Exception { if (expectColumns == null || expectColumns.size() == 0) { return; } - List columnNames = fesqlResult.getColumnNames(); + List columnNames = openMLDBResult.getColumnNames(); Assert.assertEquals(expectColumns.size(),columnNames.size(), "Illegal schema size"); for (int i = 0; i < expectColumns.size(); i++) { Assert.assertEquals(columnNames.get(i), Table.getColumnName(expectColumns.get(i)).replace(" ","")); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsCheckerByJBDC.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsCheckerByJBDC.java index 1e3c3f0abda..49752a46b99 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsCheckerByJBDC.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ColumnsCheckerByJBDC.java @@ -42,7 +42,7 @@ public void check() throws Exception { if (expectColumns == null || expectColumns.size() == 0) { return; } - List columnNames = fesqlResult.getColumnNames(); + List columnNames = openMLDBResult.getColumnNames(); Assert.assertEquals(expectColumns.size(),columnNames.size(), "Illegal schema size"); for (int i = 0; i < expectColumns.size(); i++) { Assert.assertEquals(columnNames.get(i), Table.getColumnName(expectColumns.get(i)).replace(" ","")); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CountChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CountChecker.java index 0a8e707b2dd..0aa916d237e 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CountChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/CountChecker.java @@ -38,7 +38,7 @@ public CountChecker(ExpectDesc expect, OpenMLDBResult fesqlResult){ public void check() throws Exception { log.info("count check"); int expectCount = expect.getCount(); - int actual = fesqlResult.getCount(); + int actual = openMLDBResult.getCount(); Assert.assertEquals(actual,expectCount,"count验证失败"); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentCheckerByCli.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentCheckerByCli.java index c3b202627e7..970fc673a8b 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentCheckerByCli.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentCheckerByCli.java @@ -18,7 +18,6 @@ import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.test_common.model.ExpectDesc; import com._4paradigm.openmldb.test_common.model.OpenmldbDeployment; import com._4paradigm.openmldb.test_common.util.SQLUtil; @@ -40,15 +39,15 @@ public void check() throws Exception { log.info("deployment check"); OpenmldbDeployment expectDeployment = expect.getDeployment(); String name = expectDeployment.getName(); - name = SQLUtil.formatSql(name, fesqlResult.getTableNames()); + name = SQLUtil.formatSql(name, openMLDBResult.getTableNames()); expectDeployment.setName(name); String sql = expectDeployment.getSql(); - sql = SQLUtil.formatSql(sql, fesqlResult.getTableNames()); + sql = SQLUtil.formatSql(sql, openMLDBResult.getTableNames()); expectDeployment.setSql(sql); if (expectDeployment == null) { return; } - OpenmldbDeployment actualDeployment = fesqlResult.getDeployment(); + OpenmldbDeployment actualDeployment = openMLDBResult.getDeployment(); Assert.assertEquals(actualDeployment,expectDeployment); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentContainsCheckerByCli.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentContainsCheckerByCli.java index 3ad385e9f50..c82260708dd 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentContainsCheckerByCli.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentContainsCheckerByCli.java @@ -42,7 +42,7 @@ public void check() throws Exception { if (expectDeployment == null) { return; } - List actualDeployments = fesqlResult.getDeployments(); + List actualDeployments = openMLDBResult.getDeployments(); long count = actualDeployments.stream() .filter(d -> d.getDbName().equals(expectDeployment.getDbName()) && d.getName().equals(expectDeployment.getName())) .count(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentCountCheckerByCli.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentCountCheckerByCli.java index c75a200920c..e76267e4fbb 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentCountCheckerByCli.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DeploymentCountCheckerByCli.java @@ -39,8 +39,8 @@ public DeploymentCountCheckerByCli(ExpectDesc expect, OpenMLDBResult fesqlResult public void check() throws Exception { log.info("deployment count check"); int expectDeploymentCount = expect.getDeploymentCount(); - List actualDeployments = fesqlResult.getDeployments(); - Integer deploymentCount = fesqlResult.getDeploymentCount(); + List actualDeployments = openMLDBResult.getDeployments(); + Integer deploymentCount = openMLDBResult.getDeploymentCount(); Assert.assertEquals((int) deploymentCount,expectDeploymentCount); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DiffResultChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DiffResultChecker.java index bf1cdf1231c..e6a39441957 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DiffResultChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DiffResultChecker.java @@ -51,12 +51,12 @@ public void check() throws Exception { public void checkMysql(OpenMLDBResult mysqlResult) throws Exception { log.info("diff mysql check"); //验证success - boolean fesqlOk = fesqlResult.isOk(); + boolean fesqlOk = openMLDBResult.isOk(); boolean sqlite3Ok = mysqlResult.isOk(); Assert.assertEquals(fesqlOk,sqlite3Ok,"success 不一致,fesql:"+fesqlOk+",sqlite3:"+sqlite3Ok); if(!fesqlOk) return; //验证result - List> fesqlRows = fesqlResult.getResult(); + List> fesqlRows = openMLDBResult.getResult(); List> mysqlRows = mysqlResult.getResult(); log.info("fesqlRows:{}", fesqlRows); log.info("mysqlRows:{}", mysqlRows); @@ -67,12 +67,12 @@ public void checkMysql(OpenMLDBResult mysqlResult) throws Exception { public void checkSqlite3(OpenMLDBResult sqlite3Result) throws Exception { log.info("diff sqlite3 check"); //验证success - boolean fesqlOk = fesqlResult.isOk(); + boolean fesqlOk = openMLDBResult.isOk(); boolean sqlite3Ok = sqlite3Result.isOk(); Assert.assertEquals(fesqlOk,sqlite3Ok,"success 不一致,fesql:"+fesqlOk+",sqlite3:"+sqlite3Ok); if(!fesqlOk) return; //验证result - List> fesqlRows = fesqlResult.getResult(); + List> fesqlRows = openMLDBResult.getResult(); List> sqlite3Rows = sqlite3Result.getResult(); log.info("fesqlRows:{}", fesqlRows); log.info("sqlite3Rows:{}", sqlite3Rows); @@ -98,7 +98,7 @@ public void checkSqlite3(OpenMLDBResult sqlite3Result) throws Exception { "ResultChecker fail: row=%d column=%d sqlite3=%s fesql=%s\nsqlite3 %s\nfesql %s", i, j, sqlite3_val, fesql_val, sqlite3Result.toString(), - fesqlResult.toString())); + openMLDBResult.toString())); }else if (sqlite3_val != null && sqlite3_val instanceof Double) { // Assert.assertTrue(expect_val != null && expect_val instanceof Double); if(fesql_val instanceof Float){ @@ -113,7 +113,7 @@ public void checkSqlite3(OpenMLDBResult sqlite3Result) throws Exception { String.format("ResultChecker fail: row=%d column=%d sqlite3=%s fesql=%s\nsqlite3 %s\nfesql %s", i, j, sqlite3_val, fesql_val, sqlite3Result.toString(), - fesqlResult.toString()) + openMLDBResult.toString()) ); } else if(fesql_val != null && fesql_val instanceof Timestamp){ @@ -122,13 +122,13 @@ public void checkSqlite3(OpenMLDBResult sqlite3Result) throws Exception { "ResultChecker fail: row=%d column=%d sqlite3=%s fesql=%s\nsqlite3 %s\nfesql %s", i, j, sqlite3_val, fesql_val, sqlite3Result.toString(), - fesqlResult.toString())); + openMLDBResult.toString())); } else{ Assert.assertEquals(String.valueOf(fesql_val), String.valueOf(sqlite3_val), String.format( "ResultChecker fail: row=%d column=%d sqlite3=%s fesql=%s\nsqlite3 %s\nfesql %s", i, j, sqlite3_val, fesql_val, sqlite3Result.toString(), - fesqlResult.toString())); + openMLDBResult.toString())); } } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DiffVersionChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DiffVersionChecker.java index 894120bfeef..53592ca96c1 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DiffVersionChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/DiffVersionChecker.java @@ -40,7 +40,7 @@ public void check() throws Exception { resultMap.entrySet().stream().forEach(e->{ String version = e.getKey(); OpenMLDBResult result = e.getValue(); - Assert.assertTrue(fesqlResult.equals(result),"版本结果对比不一致\nmainVersion:\n"+fesqlResult+"\nversion:"+version+"\n"+result); + Assert.assertTrue(openMLDBResult.equals(result),"版本结果对比不一致\nmainVersion:\n"+ openMLDBResult +"\nversion:"+version+"\n"+result); }); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/IndexChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/IndexChecker.java index f1b7ef08b8e..c80630e5229 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/IndexChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/IndexChecker.java @@ -46,7 +46,7 @@ public IndexChecker(ExpectDesc expect, OpenMLDBResult fesqlResult){ public void check() throws Exception { logger.info("index check"); List expectIndexs = expect.getIdxs(); - List actualIndexs = fesqlResult.getSchema().getIndexs(); + List actualIndexs = openMLDBResult.getSchema().getIndexs(); Assert.assertEquals(actualIndexs.size(),expectIndexs.size(),"index count 不一致"); for(int i=0;i options = expect.getOptions(); - Assert.assertEquals(options.get("partitionNum"),partitionNum,"partitionNum不一致"); - Assert.assertEquals(options.get("replicaNum"),replicaNum,"replicaNum不一致"); + Assert.assertEquals(partitionNum,options.get("partitionNum"),"partitionNum不一致,resultData:"+resultData); + Assert.assertEquals(replicaNum,options.get("replicaNum"),"replicaNum不一致,resultData:"+resultData); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/PreAggChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/PreAggChecker.java new file mode 100644 index 00000000000..c05c91b7dc0 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/PreAggChecker.java @@ -0,0 +1,103 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com._4paradigm.openmldb.java_sdk_test.checker; + + +import com._4paradigm.openmldb.sdk.SqlExecutor; +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.model.ExpectDesc; +import com._4paradigm.openmldb.test_common.model.PreAggTable; +import com._4paradigm.openmldb.test_common.model.Table; +import com._4paradigm.openmldb.test_common.util.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.testng.Assert; +import org.testng.collections.Lists; + +import java.text.ParseException; +import java.util.Collections; +import java.util.List; + +/** + * @author zhaowei + * @date 2020/6/16 3:14 PM + */ +@Slf4j +public class PreAggChecker extends BaseChecker { + private SqlExecutor executor; + + public PreAggChecker(ExpectDesc expect, OpenMLDBResult openMLDBResult) { + super(expect, openMLDBResult); + } + + public PreAggChecker(SqlExecutor executor,ExpectDesc expect, OpenMLDBResult openMLDBResult){ + this(expect,openMLDBResult); + this.executor = executor; + } + + @Override + public void check() throws ParseException { + log.info("pre agg check"); + if (expect.getPreAgg() == null) { + throw new RuntimeException("fail check pre agg: PreAggTable is empty"); + } + String dbName = openMLDBResult.getDbName(); + String spName = openMLDBResult.getSpName(); + PreAggTable preAgg = expect.getPreAgg(); + String preAggTableName = preAgg.getName(); + String type = preAgg.getType(); + preAggTableName = SQLUtil.replaceDBNameAndSpName(dbName,spName,preAggTableName); + String sql = String.format("select key,ts_start,ts_end,num_rows,agg_val,filter_key from %s",preAggTableName); + OpenMLDBResult actualResult = SDKUtil.select(executor, "__PRE_AGG_DB", sql); + List> actualRows = actualResult.getResult(); + int count = preAgg.getCount(); + if(count>=0){ + Assert.assertEquals(actualRows.size(),count,"preAggTable count 不一致"); + } + if(count==0){ + return; + } + actualRows.stream().forEach(l->{ + Object o = DataUtil.parseBinary((String)l.get(4),type); + l.set(4,o); + }); + List expectColumns = Lists.newArrayList("string","timestamp","timestamp","int","string","string"); + List> expectRows = DataUtil.convertRows(preAgg.getRows(), expectColumns); + + int index = 1; + Collections.sort(expectRows, new RowsSort(index)); + Collections.sort(actualRows, new RowsSort(index)); + log.info("expect:{}", expectRows); + log.info("actual:{}", actualRows); + + Assert.assertEquals(actualRows.size(), expectRows.size(), String.format("ResultChecker fail: expect size %d, real size %d", expectRows.size(), actualRows.size())); + for (int i = 0; i < actualRows.size(); ++i) { + List actual_list = actualRows.get(i); + List expect_list = expectRows.get(i); + Assert.assertEquals(actual_list.size(), expect_list.size(), String.format( + "ResultChecker fail at %dth row: expect row size %d, real row size %d", i, expect_list.size(), actual_list.size())); + for (int j = 0; j < actual_list.size(); ++j) { + Object actual_val = actual_list.get(j); + Object expect_val = expect_list.get(j); + Assert.assertEquals(actual_val, expect_val, String.format( + "ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", + i, j, expect_val, actual_val, expectRows, actualRows)); + } + } + } + +} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/PreAggListChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/PreAggListChecker.java new file mode 100644 index 00000000000..7c620c2f6b6 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/PreAggListChecker.java @@ -0,0 +1,99 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com._4paradigm.openmldb.java_sdk_test.checker; + + +import com._4paradigm.openmldb.sdk.SqlExecutor; +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.model.ExpectDesc; +import com._4paradigm.openmldb.test_common.model.PreAggTable; +import com._4paradigm.openmldb.test_common.util.DataUtil; +import com._4paradigm.openmldb.test_common.util.SDKUtil; +import com._4paradigm.openmldb.test_common.util.SQLUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.testng.Assert; +import org.testng.collections.Lists; + +import java.text.ParseException; +import java.util.Collections; +import java.util.List; + +/** + * @author zhaowei + * @date 2020/6/16 3:14 PM + */ +@Slf4j +public class PreAggListChecker extends BaseChecker { + private SqlExecutor executor; + + public PreAggListChecker(ExpectDesc expect, OpenMLDBResult openMLDBResult) { + super(expect, openMLDBResult); + } + + public PreAggListChecker(SqlExecutor executor, ExpectDesc expect, OpenMLDBResult openMLDBResult){ + this(expect,openMLDBResult); + this.executor = executor; + } + + @Override + public void check() throws ParseException { + log.info("pre agg check"); +// if (CollectionUtils.isEmpty(expect.getPreAggList())) { +// throw new RuntimeException("fail check pre agg list: PreAggTable is empty"); +// } + String dbName = openMLDBResult.getDbName(); + String spName = openMLDBResult.getSpName(); + List preAggList = expect.getPreAggList(); + for(PreAggTable preAgg:preAggList) { + String preAggTableName = preAgg.getName(); + String type = preAgg.getType(); + preAggTableName = SQLUtil.replaceDBNameAndSpName(dbName, spName, preAggTableName); + String sql = String.format("select key,ts_start,ts_end,num_rows,agg_val,filter_key from %s", preAggTableName); + OpenMLDBResult actualResult = SDKUtil.select(executor, "__PRE_AGG_DB", sql); + List> actualRows = actualResult.getResult(); + actualRows.stream().forEach(l -> { + Object o = DataUtil.parseBinary((String) l.get(4), type); + l.set(4, o); + }); + List expectColumns = Lists.newArrayList("string", "timestamp", "timestamp", "int", "string", "string"); + List> expectRows = DataUtil.convertRows(preAgg.getRows(), expectColumns); + + int index = 1; + Collections.sort(expectRows, new RowsSort(index)); + Collections.sort(actualRows, new RowsSort(index)); + log.info("expect:{}", expectRows); + log.info("actual:{}", actualRows); + + Assert.assertEquals(actualRows.size(), expectRows.size(), String.format("ResultChecker fail: expect size %d, real size %d", expectRows.size(), actualRows.size())); + for (int i = 0; i < actualRows.size(); ++i) { + List actual_list = actualRows.get(i); + List expect_list = expectRows.get(i); + Assert.assertEquals(actual_list.size(), expect_list.size(), String.format( + "ResultChecker fail at %dth row: expect row size %d, real row size %d", i, expect_list.size(), actual_list.size())); + for (int j = 0; j < actual_list.size(); ++j) { + Object actual_val = actual_list.get(j); + Object expect_val = expect_list.get(j); + Assert.assertEquals(actual_val, expect_val, String.format( + "ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", + i, j, expect_val, actual_val, expectRows, actualRows)); + } + } + } + } + +} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultChecker.java index 5643a8f69c5..00e5680c98e 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultChecker.java @@ -19,7 +19,6 @@ import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; import com._4paradigm.openmldb.test_common.util.DataUtil; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.test_common.model.ExpectDesc; import com._4paradigm.openmldb.test_common.model.Table; import com._4paradigm.openmldb.test_common.util.SchemaUtil; @@ -50,11 +49,11 @@ public void check() throws ParseException { } List> expectRows = DataUtil.convertRows(expect.getRows(), expect.getColumns()); - List> actual = fesqlResult.getResult(); + List> actual = openMLDBResult.getResult(); String orderName = expect.getOrder(); if (StringUtils.isNotEmpty(orderName)) { - int index = SchemaUtil.getIndexByColumnName(fesqlResult.getColumnNames(),orderName); + int index = SchemaUtil.getIndexByColumnName(openMLDBResult.getColumnNames(),orderName); Collections.sort(expectRows, new RowsSort(index)); Collections.sort(actual, new RowsSort(index)); } @@ -79,7 +78,7 @@ public void check() throws ParseException { String.format("ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString()) + openMLDBResult.toString()) ); } else if (actual_val != null && actual_val instanceof Double) { @@ -89,7 +88,7 @@ public void check() throws ParseException { String.format("ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString()) + openMLDBResult.toString()) ); } else { @@ -97,7 +96,7 @@ public void check() throws ParseException { "ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString())); + openMLDBResult.toString())); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultCheckerByCli.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultCheckerByCli.java index 68cf423aca7..b00422a8de2 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultCheckerByCli.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultCheckerByCli.java @@ -19,7 +19,6 @@ import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; import com._4paradigm.openmldb.test_common.util.DataUtil; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.test_common.model.ExpectDesc; import com._4paradigm.openmldb.test_common.model.Table; import com._4paradigm.openmldb.test_common.util.SchemaUtil; @@ -49,11 +48,11 @@ public void check() throws ParseException { throw new RuntimeException("fail check result: columns are empty"); } List> expectRows = DataUtil.convertRows(expect.getRows(), expect.getColumns()); - List> actual = DataUtil.convertRows(fesqlResult.getResult(), expect.getColumns()); + List> actual = DataUtil.convertRows(openMLDBResult.getResult(), expect.getColumns()); String orderName = expect.getOrder(); if (StringUtils.isNotEmpty(orderName)) { - int index = SchemaUtil.getIndexByColumnName(fesqlResult.getColumnNames(),orderName); + int index = SchemaUtil.getIndexByColumnName(openMLDBResult.getColumnNames(),orderName); Collections.sort(expectRows, new RowsSort(index)); Collections.sort(actual, new RowsSort(index)); } @@ -79,7 +78,7 @@ public void check() throws ParseException { String.format("ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString()) + openMLDBResult.toString()) ); } else if (actual_val != null && actual_val instanceof Double) { @@ -89,7 +88,7 @@ public void check() throws ParseException { String.format("ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString()) + openMLDBResult.toString()) ); } else if (String.valueOf(actual_val).equalsIgnoreCase("null")){ @@ -97,14 +96,14 @@ public void check() throws ParseException { String.format("ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString()) + openMLDBResult.toString()) ); }else { Assert.assertEquals(actual_val, expect_val, String.format( "ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString())); + openMLDBResult.toString())); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultCheckerByJDBC.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultCheckerByJDBC.java index a20971c4491..db2d1bb0415 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultCheckerByJDBC.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/ResultCheckerByJDBC.java @@ -17,7 +17,6 @@ import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; import com._4paradigm.openmldb.test_common.util.DataUtil; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.test_common.model.ExpectDesc; import com._4paradigm.openmldb.test_common.model.Table; import com._4paradigm.openmldb.test_common.util.SchemaUtil; @@ -48,11 +47,11 @@ public void check() throws Exception { } List> expectRows = DataUtil.convertRows(expect.getRows(), expect.getColumns()); - List> actual = fesqlResult.getResult(); + List> actual = openMLDBResult.getResult(); String orderName = expect.getOrder(); if (StringUtils.isNotEmpty(orderName)) { - int index = SchemaUtil.getIndexByColumnName(fesqlResult.getColumnNames(),orderName); + int index = SchemaUtil.getIndexByColumnName(openMLDBResult.getColumnNames(),orderName); Collections.sort(expectRows, new RowsSort(index)); Collections.sort(actual, new RowsSort(index)); } @@ -81,7 +80,7 @@ public void check() throws Exception { "ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString())); + openMLDBResult.toString())); }else if (actual_val != null && actual_val instanceof Double) { // Assert.assertTrue(expect_val != null && expect_val instanceof Double); if(expect_val instanceof Float){ @@ -96,7 +95,7 @@ public void check() throws Exception { String.format("ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString()) + openMLDBResult.toString()) ); } else if(expect_val != null && expect_val instanceof Timestamp){ @@ -105,13 +104,13 @@ public void check() throws Exception { "ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString())); + openMLDBResult.toString())); } else{ Assert.assertEquals(String.valueOf(actual_val), String.valueOf(expect_val), String.format( "ResultChecker fail: row=%d column=%d expect=%s real=%s\nexpect %s\nreal %s", i, j, expect_val, actual_val, Table.getTableString(expect.getColumns(), expectRows), - fesqlResult.toString())); + openMLDBResult.toString())); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/SuccessChecker.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/SuccessChecker.java index 18be5712257..df3a526f6c1 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/SuccessChecker.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/checker/SuccessChecker.java @@ -35,7 +35,7 @@ public SuccessChecker(ExpectDesc expect, OpenMLDBResult fesqlResult){ public void check() throws Exception { log.info("success check"); boolean success = expect.getSuccess(); - boolean actual = fesqlResult.isOk(); + boolean actual = openMLDBResult.isOk(); Assert.assertEquals(actual,success,"success验证失败"); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/JDBCTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/JDBCTest.java index 3921cdddd7a..4b0a12a590c 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/JDBCTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/JDBCTest.java @@ -15,6 +15,8 @@ */ package com._4paradigm.openmldb.java_sdk_test.common; +import com._4paradigm.openmldb.test_common.common.BaseTest; + /** * @author zhaowei * @date 2021/3/12 7:53 AM diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/OpenMLDBConfig.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/OpenMLDBConfig.java index 7d984a35878..95ad1c81010 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/OpenMLDBConfig.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/OpenMLDBConfig.java @@ -35,43 +35,11 @@ public class OpenMLDBConfig { public static final List VERSIONS; public static boolean INIT_VERSION_ENV = true; - public static final List FESQL_CASE_LEVELS; - public static final String FESQL_CASE_PATH; - public static final String FESQL_CASE_NAME; - public static final String FESQL_CASE_ID; - public static final String FESQL_CASE_DESC; - public static final String YAML_CASE_BASE_DIR; public static final boolean ADD_REPORT_LOG; - public static final Properties CONFIG = Tool.getProperties("run_case.properties"); static { - String levelStr = System.getProperty("caseLevel"); - levelStr = StringUtils.isEmpty(levelStr) ? "0" : levelStr; - FESQL_CASE_LEVELS = Arrays.stream(levelStr.split(",")).map(Integer::parseInt).collect(Collectors.toList()); - FESQL_CASE_NAME = System.getProperty("caseName"); - FESQL_CASE_ID = System.getProperty("caseId"); - FESQL_CASE_DESC = System.getProperty("caseDesc"); - FESQL_CASE_PATH = System.getProperty("casePath"); - YAML_CASE_BASE_DIR = System.getProperty("yamlCaseBaseDir"); - log.info("FESQL_CASE_LEVELS {}", FESQL_CASE_LEVELS); - if (!StringUtils.isEmpty(FESQL_CASE_NAME)) { - log.info("FESQL_CASE_NAME {}", FESQL_CASE_NAME); - } - if (!StringUtils.isEmpty(FESQL_CASE_ID)) { - log.info("FESQL_CASE_ID {}", FESQL_CASE_ID); - } - if (!StringUtils.isEmpty(FESQL_CASE_PATH)) { - log.info("FESQL_CASE_PATH {}", FESQL_CASE_PATH); - } - if (!StringUtils.isEmpty(FESQL_CASE_DESC)) { - log.info("FESQL_CASE_DESC {}", FESQL_CASE_DESC); - } - if (!StringUtils.isEmpty(YAML_CASE_BASE_DIR)) { - log.info("YAML_CASE_BASE_DIR {}", YAML_CASE_BASE_DIR); - } - String versionStr = System.getProperty("diffVersion"); if (StringUtils.isEmpty(versionStr)) { versionStr = CONFIG.getProperty(OpenMLDBGlobalVar.env + "_versions"); @@ -92,11 +60,7 @@ public class OpenMLDBConfig { if (StringUtils.isNotEmpty(init_env)) { INIT_VERSION_ENV = Boolean.parseBoolean(init_env); } - String tableStorageMode = CONFIG.getProperty("table_storage_mode"); - if(StringUtils.isNotEmpty(tableStorageMode)){ - OpenMLDBGlobalVar.tableStorageMode = tableStorageMode; - } - log.info("test tableStorageMode: {}", OpenMLDBGlobalVar.tableStorageMode); + String version = CONFIG.getProperty("version"); if(StringUtils.isNotEmpty(version)){ OpenMLDBGlobalVar.version = version; diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/OpenMLDBTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/OpenMLDBTest.java index c502f83a7b3..1812abefd73 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/OpenMLDBTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/OpenMLDBTest.java @@ -18,8 +18,10 @@ import com._4paradigm.openmldb.sdk.SqlExecutor; +import com._4paradigm.openmldb.test_common.common.BaseTest; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBClient; +import com._4paradigm.openmldb.test_common.provider.YamlUtil; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBDeployType; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; @@ -30,6 +32,8 @@ import org.testng.annotations.Optional; import org.testng.annotations.Parameters; +import java.io.File; +import java.lang.reflect.Field; import java.sql.Statement; /** @@ -54,18 +58,41 @@ public void beforeTest(@Optional("qa") String env,@Optional("main") String versi openMLDBDeploy.setOpenMLDBPath(openMLDBPath); openMLDBDeploy.setCluster(false); OpenMLDBGlobalVar.mainInfo = openMLDBDeploy.deployCluster(2, 3); + }else if(env.equalsIgnoreCase("deploy")){ + OpenMLDBGlobalVar.mainInfo = YamlUtil.getObject("out/openmldb_info.yaml",OpenMLDBInfo.class); }else{ - OpenMLDBGlobalVar.mainInfo = OpenMLDBInfo.builder() - .deployType(OpenMLDBDeployType.CLUSTER) - .basePath("/home/zhaowei01/openmldb-auto-test/tmp") - .openMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb") - .zk_cluster("172.24.4.55:30000") - .zk_root_path("/openmldb") - .nsNum(2).tabletNum(3) - .nsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")) - .tabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")) - .apiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")) - .build(); + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); +// openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); +// openMLDBInfo.setNsNum(2); +// openMLDBInfo.setTabletNum(3); +// openMLDBInfo.setBasePath("/home/zhaowei01/openmldb-auto-test/tmp"); +// openMLDBInfo.setZk_cluster("172.24.4.55:30000"); +// openMLDBInfo.setZk_root_path("/openmldb"); +// openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")); +// openMLDBInfo.setNsNames(Lists.newArrayList()); +// openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")); +// openMLDBInfo.setTabletNames(Lists.newArrayList()); +// openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")); +// openMLDBInfo.setApiServerNames(Lists.newArrayList()); +// openMLDBInfo.setTaskManagerEndpoints(Lists.newArrayList("172.24.4.55:30007")); +// openMLDBInfo.setOpenMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb"); + + openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); + openMLDBInfo.setNsNum(2); + openMLDBInfo.setTabletNum(3); + openMLDBInfo.setBasePath("/home/zhaowei01/openmldb-auto-test/tmp"); + openMLDBInfo.setZk_cluster("172.24.4.55:30008"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30012", "172.24.4.55:30013")); + openMLDBInfo.setNsNames(Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30009", "172.24.4.55:30010", "172.24.4.55:30011")); + openMLDBInfo.setTabletNames(Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30014")); + openMLDBInfo.setApiServerNames(Lists.newArrayList()); + openMLDBInfo.setTaskManagerEndpoints(Lists.newArrayList("172.24.4.55:30015")); + openMLDBInfo.setOpenMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb"); + + OpenMLDBGlobalVar.mainInfo = openMLDBInfo; OpenMLDBGlobalVar.env = "cluster"; } @@ -73,11 +100,11 @@ public void beforeTest(@Optional("qa") String env,@Optional("main") String versi if (!StringUtils.isEmpty(caseEnv)) { OpenMLDBGlobalVar.env = caseEnv; } - log.info("fedb global var env: {}", env); + log.info("openMLDB global var env: {}", env); OpenMLDBClient fesqlClient = new OpenMLDBClient(OpenMLDBGlobalVar.mainInfo.getZk_cluster(), OpenMLDBGlobalVar.mainInfo.getZk_root_path()); executor = fesqlClient.getExecutor(); log.info("executor:{}",executor); Statement statement = executor.getStatement(); statement.execute("SET @@execute_mode='online';"); } -} +} \ No newline at end of file diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/StandaloneTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/StandaloneTest.java index c45ddb4bfab..2ea77d26adf 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/StandaloneTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/StandaloneTest.java @@ -18,6 +18,7 @@ import com._4paradigm.openmldb.sdk.SqlExecutor; +import com._4paradigm.openmldb.test_common.common.BaseTest; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBClient; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBDeployType; @@ -47,17 +48,21 @@ public void beforeTest(@Optional("qa") String env,@Optional("main") String versi openMLDBDeploy.setOpenMLDBPath(openMLDBPath); OpenMLDBGlobalVar.mainInfo = openMLDBDeploy.deployStandalone(); }else{ - OpenMLDBGlobalVar.mainInfo = OpenMLDBInfo.builder() - .deployType(OpenMLDBDeployType.STANDALONE) - .basePath("/home/wangkaidong/fedb-auto-test/standalone") - .openMLDBPath("/home/wangkaidong/fedb-auto-test/standalone/openmldb-standalone/bin/openmldb") - .nsNum(1).tabletNum(1) - .nsEndpoints(Lists.newArrayList("172.24.4.55:30013")) - .tabletEndpoints(Lists.newArrayList("172.24.4.55:30014")) - .apiServerEndpoints(Lists.newArrayList("172.24.4.55:30015")) - .host("172.24.4.55") - .port(30013) - .build(); + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.STANDALONE); + openMLDBInfo.setHost("172.24.4.55"); + openMLDBInfo.setPort(30013); + openMLDBInfo.setNsNum(1); + openMLDBInfo.setTabletNum(1); + openMLDBInfo.setBasePath("/home/wangkaidong/fedb-auto-test/standalone"); + openMLDBInfo.setZk_cluster("172.24.4.55:30000"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30013")); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30014")); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30015")); + openMLDBInfo.setOpenMLDBPath("/home/wangkaidong/fedb-auto-test/standalone/openmldb-standalone/bin/openmldb"); + + OpenMLDBGlobalVar.mainInfo = openMLDBInfo; } String caseEnv = System.getProperty("caseEnv"); if (!StringUtils.isEmpty(caseEnv)) { diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenMLDBProcedureColumn2.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenMLDBProcedureColumn2.java deleted file mode 100644 index 13e2eefff06..00000000000 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenMLDBProcedureColumn2.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2021 4Paradigm - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com._4paradigm.openmldb.java_sdk_test.entity; - -import lombok.Data; - -@Data -public class OpenMLDBProcedureColumn2 { - private int id; - private String field; - private String type; - private boolean constant; //true 可以为null -} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenmldbDeployment2.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenmldbDeployment2.java deleted file mode 100644 index 17374b4d762..00000000000 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenmldbDeployment2.java +++ /dev/null @@ -1,14 +0,0 @@ -package com._4paradigm.openmldb.java_sdk_test.entity; - -import lombok.Data; - -import java.util.List; - -@Data -public class OpenmldbDeployment2 { - private String dbName; - private String name; - private String sql; - private List inColumns; - private List outColumns; -} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseExecutor.java index a795fc5c4e4..adc918aa947 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseExecutor.java @@ -17,7 +17,6 @@ import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; -import com._4paradigm.openmldb.test_common.common.LogProxy; import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.model.SQLCaseType; import lombok.extern.slf4j.Slf4j; @@ -33,7 +32,7 @@ @Slf4j public abstract class BaseExecutor implements IExecutor{ // protected static final log log = new LogProxy(log); - protected SQLCase fesqlCase; + protected SQLCase sqlCase; protected SQLCaseType executorType; protected String dbName; protected List tableNames = Lists.newArrayList(); @@ -43,13 +42,13 @@ public abstract class BaseExecutor implements IExecutor{ public void run() { String className = Thread.currentThread().getStackTrace()[2].getClassName(); String methodName = Thread.currentThread().getStackTrace()[2].getMethodName(); - System.out.println(className+"."+methodName+":"+fesqlCase.getCaseFileName()+":"+fesqlCase.getDesc() + " Begin!"); - log.info(className+"."+methodName+":"+fesqlCase.getDesc() + " Begin!"); + System.out.println(className+"."+methodName+":"+ sqlCase.getCaseFileName()+":"+ sqlCase.getDesc() + " Begin!"); + log.info(className+"."+methodName+":"+ sqlCase.getDesc() + " Begin!"); boolean verify = false; try { verify = verify(); if(!verify) return; - if (null == fesqlCase) { + if (null == sqlCase) { Assert.fail("executor run with null case"); return; } @@ -58,13 +57,13 @@ public void run() { check(); } catch (Exception e) { e.printStackTrace(); - System.out.println(className+"."+methodName+":"+fesqlCase.getDesc() + " FAIL!"); + System.out.println(className+"."+methodName+":"+ sqlCase.getDesc() + " FAIL!"); Assert.fail("executor run with exception"); }finally { if(verify) { tearDown(); } - System.out.println(className+"."+methodName+":"+fesqlCase.getDesc() + " DONE!"); + System.out.println(className+"."+methodName+":"+ sqlCase.getDesc() + " DONE!"); } } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseSQLExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseSQLExecutor.java index c1cc044308a..b5a06c4789c 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseSQLExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BaseSQLExecutor.java @@ -45,26 +45,26 @@ public abstract class BaseSQLExecutor extends BaseExecutor{ protected SqlExecutor executor; private Map executorMap; - protected Map fedbInfoMap; + protected Map openMLDBInfoMap; private Map resultMap; - public BaseSQLExecutor(SqlExecutor executor, SQLCase fesqlCase, SQLCaseType executorType) { + public BaseSQLExecutor(SqlExecutor executor, SQLCase sqlCase, SQLCaseType executorType) { this.executor = executor; - this.fesqlCase = fesqlCase; + this.sqlCase = sqlCase; this.executorType = executorType; - dbName = Objects.isNull(fesqlCase.getDb()) ? "" : fesqlCase.getDb(); - if (!CollectionUtils.isEmpty(fesqlCase.getInputs())) { - for (InputDesc inputDesc : fesqlCase.getInputs()) { + dbName = Objects.isNull(sqlCase.getDb()) ? "" : sqlCase.getDb(); + if (!CollectionUtils.isEmpty(sqlCase.getInputs())) { + for (InputDesc inputDesc : sqlCase.getInputs()) { tableNames.add(inputDesc.getName()); } } } - public BaseSQLExecutor(SQLCase fesqlCase, SqlExecutor executor, Map executorMap, Map fedbInfoMap, SQLCaseType executorType) { - this(executor,fesqlCase,executorType); + public BaseSQLExecutor(SQLCase sqlCase, SqlExecutor executor, Map executorMap, Map openMLDBInfoMap, SQLCaseType executorType) { + this(executor,sqlCase,executorType); this.executor = executor; this.executorMap = executorMap; - this.fedbInfoMap = fedbInfoMap; + this.openMLDBInfoMap = openMLDBInfoMap; } @Override @@ -94,7 +94,7 @@ public void execute() { @Override public void check() throws Exception { - List strategyList = CheckerStrategy.build(fesqlCase, mainResult, executorType); + List strategyList = CheckerStrategy.build(executor, sqlCase, mainResult, executorType); if(MapUtils.isNotEmpty(resultMap)) { strategyList.add(new DiffVersionChecker(mainResult, resultMap)); } @@ -113,11 +113,11 @@ public void tearDown() { public void tearDown(String version,SqlExecutor executor) { log.info("version:{},begin tear down",version); - List tearDown = fesqlCase.getTearDown(); + List tearDown = sqlCase.getTearDown(); if(CollectionUtils.isNotEmpty(tearDown)){ tearDown.forEach(sql->{ - if(MapUtils.isNotEmpty(fedbInfoMap)) { - sql = SQLUtil.formatSql(sql, tableNames, fedbInfoMap.get(version)); + if(MapUtils.isNotEmpty(openMLDBInfoMap)) { + sql = SQLUtil.formatSql(sql, tableNames, openMLDBInfoMap.get(version)); }else { sql = SQLUtil.formatSql(sql, tableNames); } @@ -125,7 +125,7 @@ public void tearDown(String version,SqlExecutor executor) { }); } log.info("version:{},begin drop table",version); - List tables = fesqlCase.getInputs(); + List tables = sqlCase.getInputs(); if (CollectionUtils.isEmpty(tables)) { return; } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BatchSQLExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BatchSQLExecutor.java index 7b91b87981a..19bbc787c2f 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BatchSQLExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/BatchSQLExecutor.java @@ -16,6 +16,7 @@ package com._4paradigm.openmldb.java_sdk_test.executor; +import com._4paradigm.openmldb.java_sdk_test.common.OpenMLDBConfig; import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.openmldb.test_common.util.SDKUtil; @@ -40,34 +41,38 @@ public class BatchSQLExecutor extends BaseSQLExecutor { public BatchSQLExecutor(SqlExecutor executor, SQLCase fesqlCase, SQLCaseType executorType) { super(executor, fesqlCase, executorType); } - public BatchSQLExecutor(SQLCase fesqlCase, SqlExecutor executor, Map executorMap, Map fedbInfoMap, SQLCaseType executorType) { - super(fesqlCase, executor, executorMap, fedbInfoMap, executorType); + public BatchSQLExecutor(SQLCase sqlCase, SqlExecutor executor, Map executorMap, Map fedbInfoMap, SQLCaseType executorType) { + super(sqlCase, executor, executorMap, fedbInfoMap, executorType); } @Override public boolean verify() { - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("hybridse-only")) { - log.info("skip case in batch mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("hybridse-only")) { + log.info("skip case in batch mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("batch-unsupport")) { - log.info("skip case in batch mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("batch-unsupport")) { + log.info("skip case in batch mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("rtidb-batch-unsupport")) { - log.info("skip case in rtidb batch mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-batch-unsupport")) { + log.info("skip case in rtidb batch mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("rtidb-unsupport")) { - log.info("skip case in rtidb mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-unsupport")) { + log.info("skip case in rtidb mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("performance-sensitive-unsupport")) { - log.info("skip case in rtidb mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("performance-sensitive-unsupport")) { + log.info("skip case in rtidb mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && !OpenMLDBGlobalVar.tableStorageMode.equals("memory") && fesqlCase.getMode().contains("disk-unsupport")) { - log.info("skip case in disk mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && !OpenMLDBGlobalVar.tableStorageMode.equals("memory") && sqlCase.getMode().contains("disk-unsupport")) { + log.info("skip case in disk mode: {}", sqlCase.getDesc()); + return false; + } + if (OpenMLDBConfig.isCluster() && null != sqlCase.getMode() && sqlCase.getMode().contains("cluster-unsupport")) { + log.info("skip case in cluster mode: {}", sqlCase.getDesc()); return false; } return true; @@ -79,7 +84,7 @@ public void prepare(String version,SqlExecutor executor){ boolean dbOk = executor.createDB(dbName); log.info("version:{},create db:{},{}", version, dbName, dbOk); SDKUtil.useDB(executor,dbName); - OpenMLDBResult res = SDKUtil.createAndInsert(executor, dbName, fesqlCase.getInputs(), false); + OpenMLDBResult res = SDKUtil.createAndInsert(executor, dbName, sqlCase.getInputs(), false); if (!res.isOk()) { throw new RuntimeException("fail to run BatchSQLExecutor: prepare fail . version:"+version); } @@ -89,30 +94,30 @@ public void prepare(String version,SqlExecutor executor){ @Override public OpenMLDBResult execute(String version, SqlExecutor executor){ log.info("version:{} execute begin",version); - OpenMLDBResult fesqlResult = null; - List sqls = fesqlCase.getSqls(); + OpenMLDBResult openMLDBResult = null; + List sqls = sqlCase.getSqls(); if (sqls != null && sqls.size() > 0) { for (String sql : sqls) { // log.info("sql:{}", sql); - if(MapUtils.isNotEmpty(fedbInfoMap)) { - sql = SQLUtil.formatSql(sql, tableNames, fedbInfoMap.get(version)); + if(MapUtils.isNotEmpty(openMLDBInfoMap)) { + sql = SQLUtil.formatSql(sql, tableNames, openMLDBInfoMap.get(version)); }else { sql = SQLUtil.formatSql(sql, tableNames); } - fesqlResult = SDKUtil.sql(executor, dbName, sql); + openMLDBResult = SDKUtil.sql(executor, dbName, sql); } } - String sql = fesqlCase.getSql(); + String sql = sqlCase.getSql(); if (sql != null && sql.length() > 0) { // log.info("sql:{}", sql); - if(MapUtils.isNotEmpty(fedbInfoMap)) { - sql = SQLUtil.formatSql(sql, tableNames, fedbInfoMap.get(version)); + if(MapUtils.isNotEmpty(openMLDBInfoMap)) { + sql = SQLUtil.formatSql(sql, tableNames, openMLDBInfoMap.get(version)); }else { sql = SQLUtil.formatSql(sql, tableNames); } - fesqlResult = SDKUtil.sql(executor, dbName, sql); + openMLDBResult = SDKUtil.sql(executor, dbName, sql); } log.info("version:{} execute end",version); - return fesqlResult; + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/ClusterCliExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/ClusterCliExecutor.java index f7a281000df..bddbf14bf5f 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/ClusterCliExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/ClusterCliExecutor.java @@ -16,7 +16,6 @@ package com._4paradigm.openmldb.java_sdk_test.executor; -import com._4paradigm.openmldb.test_common.common.LogProxy; import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.model.SQLCaseType; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; @@ -36,12 +35,12 @@ public ClusterCliExecutor(SQLCase fesqlCase, Map openMLDBI @Override public boolean verify() { - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("cluster-cli-unsupport")) { - log.info("skip case in cli mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("cluster-cli-unsupport")) { + log.info("skip case in cli mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("cluster-unsupport")) { - log.info("skip case , mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("cluster-unsupport")) { + log.info("skip case , mode: {}", sqlCase.getDesc()); return false; } return super.verify(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/CommandExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/CommandExecutor.java index ad96d8265a1..6922576e0e5 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/CommandExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/CommandExecutor.java @@ -19,13 +19,11 @@ import com._4paradigm.openmldb.java_sdk_test.checker.Checker; import com._4paradigm.openmldb.java_sdk_test.checker.CheckerStrategy; import com._4paradigm.openmldb.java_sdk_test.checker.DiffVersionChecker; -import com._4paradigm.openmldb.test_common.command.OpenMLDBComamndFacade; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFacade; import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandUtil; import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFactory; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; -import com._4paradigm.openmldb.test_common.util.SDKUtil; -import com._4paradigm.openmldb.test_common.common.LogProxy; import com._4paradigm.openmldb.test_common.model.InputDesc; import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.model.SQLCaseType; @@ -47,7 +45,7 @@ public class CommandExecutor extends BaseExecutor{ private Map resultMap; public CommandExecutor(SQLCase fesqlCase, SQLCaseType executorType) { - this.fesqlCase = fesqlCase; + this.sqlCase = fesqlCase; this.executorType = executorType; dbName = fesqlCase.getDb(); if (!CollectionUtils.isEmpty(fesqlCase.getInputs())) { @@ -64,28 +62,28 @@ public CommandExecutor(SQLCase fesqlCase, Map openMLDBInfo @Override public boolean verify() { - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("hybridse-only")) { - log.info("skip case in cli mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("hybridse-only")) { + log.info("skip case in cli mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("batch-unsupport")) { - log.info("skip case in batch mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("batch-unsupport")) { + log.info("skip case in batch mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("rtidb-batch-unsupport")) { - log.info("skip case in rtidb batch mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-batch-unsupport")) { + log.info("skip case in rtidb batch mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("rtidb-unsupport")) { - log.info("skip case in rtidb mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-unsupport")) { + log.info("skip case in rtidb mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("performance-sensitive-unsupport")) { - log.info("skip case in rtidb mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("performance-sensitive-unsupport")) { + log.info("skip case in rtidb mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("cli-unsupport")) { - log.info("skip case in cli mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("cli-unsupport")) { + log.info("skip case in cli mode: {}", sqlCase.getDesc()); return false; } return true; @@ -101,9 +99,9 @@ public void prepare(){ protected void prepare(String version, OpenMLDBInfo openMLDBInfo){ log.info("version:{} prepare begin",version); - OpenMLDBResult fesqlResult = OpenMLDBCommandUtil.createDB(openMLDBInfo,dbName); - log.info("version:{},create db:{},{}", version, dbName, fesqlResult.isOk()); - OpenMLDBResult res = OpenMLDBCommandUtil.createAndInsert(openMLDBInfo, dbName, fesqlCase.getInputs()); + OpenMLDBResult openMLDBResult = OpenMLDBCommandUtil.createDB(openMLDBInfo,dbName); + log.info("version:{},create db:{},{}", version, dbName, openMLDBResult.isOk()); + OpenMLDBResult res = OpenMLDBCommandUtil.createAndInsert(openMLDBInfo, dbName, sqlCase.getInputs()); if (!res.isOk()) { throw new RuntimeException("fail to run BatchSQLExecutor: prepare fail . version:"+version); } @@ -125,8 +123,8 @@ public void execute() { protected OpenMLDBResult execute(String version, OpenMLDBInfo openMLDBInfo){ log.info("version:{} execute begin",version); - OpenMLDBResult fesqlResult = null; - List sqls = fesqlCase.getSqls(); + OpenMLDBResult openMLDBResult = null; + List sqls = sqlCase.getSqls(); if (sqls != null && sqls.size() > 0) { for (String sql : sqls) { // log.info("sql:{}", sql); @@ -135,10 +133,10 @@ protected OpenMLDBResult execute(String version, OpenMLDBInfo openMLDBInfo){ }else { sql = SQLUtil.formatSql(sql, tableNames); } - fesqlResult = OpenMLDBComamndFacade.sql(openMLDBInfo, dbName, sql); + openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo, dbName, sql); } } - String sql = fesqlCase.getSql(); + String sql = sqlCase.getSql(); if (StringUtils.isNotEmpty(sql)) { // log.info("sql:{}", sql); if(MapUtils.isNotEmpty(openMLDBInfoMap)) { @@ -146,15 +144,15 @@ protected OpenMLDBResult execute(String version, OpenMLDBInfo openMLDBInfo){ }else { sql = SQLUtil.formatSql(sql, tableNames); } - fesqlResult = OpenMLDBComamndFacade.sql(openMLDBInfo, dbName, sql); + openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo, dbName, sql); } log.info("version:{} execute end",version); - return fesqlResult; + return openMLDBResult; } @Override public void check() throws Exception { - List strategyList = CheckerStrategy.build(fesqlCase, mainResult, executorType); + List strategyList = CheckerStrategy.build(null,sqlCase, mainResult, executorType); if(MapUtils.isNotEmpty(resultMap)) { strategyList.add(new DiffVersionChecker(mainResult, resultMap)); } @@ -173,7 +171,7 @@ public void tearDown() { public void tearDown(String version,OpenMLDBInfo openMLDBInfo) { log.info("version:{},begin tear down",version); - List tearDown = fesqlCase.getTearDown(); + List tearDown = sqlCase.getTearDown(); if(CollectionUtils.isNotEmpty(tearDown)){ tearDown.forEach(sql->{ if(MapUtils.isNotEmpty(openMLDBInfoMap)) { @@ -185,7 +183,7 @@ public void tearDown(String version,OpenMLDBInfo openMLDBInfo) { }); } log.info("version:{},begin drop table",version); - List tables = fesqlCase.getInputs(); + List tables = sqlCase.getInputs(); if (CollectionUtils.isEmpty(tables)) { return; } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/DiffResultExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/DiffResultExecutor.java index 06702626378..ff5d311cdb8 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/DiffResultExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/DiffResultExecutor.java @@ -89,7 +89,7 @@ public void tearDown() { @Override public void check() throws Exception { - List strategyList = CheckerStrategy.build(fesqlCase, mainResult, executorType); + List strategyList = CheckerStrategy.build(executor,sqlCase, mainResult, executorType); strategyList.add(new DiffResultChecker(mainResult, resultMap)); for (Checker checker : strategyList) { checker.check(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/ExecutorFactory.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/ExecutorFactory.java index 084241a5a1b..b6f45de3803 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/ExecutorFactory.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/ExecutorFactory.java @@ -18,7 +18,6 @@ import com._4paradigm.openmldb.java_sdk_test.common.OpenMLDBConfig; import com._4paradigm.openmldb.sdk.SqlExecutor; -import com._4paradigm.openmldb.test_common.common.ReportLog; import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.model.SQLCaseType; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; @@ -29,116 +28,104 @@ @Slf4j public class ExecutorFactory { - private static ReportLog reportLog = ReportLog.of(); - - public static IExecutor build(SQLCase fesqlCase, SQLCaseType type) { + public static IExecutor build(SQLCase sqlCase, SQLCaseType type) { switch (type){ case kSQLITE3: - return new Sqlite3Executor(fesqlCase,type); + return new Sqlite3Executor(sqlCase,type); case kMYSQL: - return new MysqlExecutor(fesqlCase,type); + return new MysqlExecutor(sqlCase,type); case kCLI: - return new CommandExecutor(fesqlCase,type); + return new CommandExecutor(sqlCase,type); case kStandaloneCLI: - return new StandaloneCliExecutor(fesqlCase,type); + return new StandaloneCliExecutor(sqlCase,type); case kClusterCLI: - return new ClusterCliExecutor(fesqlCase,type); + return new ClusterCliExecutor(sqlCase,type); } return null; } - public static IExecutor build(SqlExecutor executor, Map executorMap, Map fedbInfoMap, SQLCase fesqlCase, SQLCaseType type) { + public static IExecutor build(SqlExecutor executor, Map executorMap, Map fedbInfoMap, SQLCase sqlCase, SQLCaseType type) { switch (type) { case kDiffBatch: { - return new BatchSQLExecutor(fesqlCase, executor, executorMap, fedbInfoMap, type); + return new BatchSQLExecutor(sqlCase, executor, executorMap, fedbInfoMap, type); } case kDiffRequest:{ - return new RequestQuerySQLExecutor(fesqlCase, executor, executorMap, fedbInfoMap, false, false, type); + return new RequestQuerySQLExecutor(sqlCase, executor, executorMap, fedbInfoMap, false, false, type); } case kDiffRequestWithSp:{ - return new StoredProcedureSQLExecutor(fesqlCase, executor, executorMap, fedbInfoMap, false, false, type); + return new StoredProcedureSQLExecutor(sqlCase, executor, executorMap, fedbInfoMap, false, false, type); } case kDiffRequestWithSpAsync:{ - return new StoredProcedureSQLExecutor(fesqlCase, executor, executorMap, fedbInfoMap, false, true, type); + return new StoredProcedureSQLExecutor(sqlCase, executor, executorMap, fedbInfoMap, false, true, type); } } return null; } - public static BaseSQLExecutor build(SqlExecutor executor, SQLCase fesqlCase, SQLCaseType type) { + public static BaseSQLExecutor build(SqlExecutor executor, SQLCase sqlCase, SQLCaseType type) { switch (type) { case kDDL: { - return getDDLExecutor(executor, fesqlCase, type); + return getDDLExecutor(executor, sqlCase, type); } case kInsertPrepared: { - return new InsertPreparedExecutor(executor,fesqlCase,type); + return new InsertPreparedExecutor(executor,sqlCase,type); } case kSelectPrepared: { - return new QueryPreparedExecutor(executor,fesqlCase,type); + return new QueryPreparedExecutor(executor,sqlCase,type); } case kBatch: { - return getFeBatchQueryExecutor(executor, fesqlCase, type); + return getFeBatchQueryExecutor(executor, sqlCase, type); } case kRequest: { - return getFeRequestQueryExecutor(executor, fesqlCase, type); + return getFeRequestQueryExecutor(executor, sqlCase, type); } case kBatchRequest: { - return getFeBatchRequestQueryExecutor(executor, fesqlCase, type); + return getFeBatchRequestQueryExecutor(executor, sqlCase, type); } case kRequestWithSp: { - return getFeRequestQueryWithSpExecutor(executor, fesqlCase, false, type); + return getFeRequestQueryWithSpExecutor(executor, sqlCase, false, type); } case kRequestWithSpAsync: { - return getFeRequestQueryWithSpExecutor(executor, fesqlCase, true, type); + return getFeRequestQueryWithSpExecutor(executor, sqlCase, true, type); } case kBatchRequestWithSp: { - return getFeBatchRequestQueryWithSpExecutor(executor, fesqlCase, false, type); + return getFeBatchRequestQueryWithSpExecutor(executor, sqlCase, false, type); } case kBatchRequestWithSpAsync: { - return getFeBatchRequestQueryWithSpExecutor(executor, fesqlCase, true, type); + return getFeBatchRequestQueryWithSpExecutor(executor, sqlCase, true, type); } case kDiffSQLResult: - return new DiffResultExecutor(executor,fesqlCase,type); + return new DiffResultExecutor(executor,sqlCase,type); + case kLongWindow: + return new LongWindowExecutor(executor,sqlCase,false,false,type); } return null; } - private static BaseSQLExecutor getDDLExecutor(SqlExecutor sqlExecutor, SQLCase fesqlCase, SQLCaseType type) { - BaseSQLExecutor executor = null; - executor = new BatchSQLExecutor(sqlExecutor, fesqlCase, type); - return executor; + private static BaseSQLExecutor getDDLExecutor(SqlExecutor sqlExecutor, SQLCase sqlCase, SQLCaseType type) { + return new BatchSQLExecutor(sqlExecutor, sqlCase, type); } - private static BaseSQLExecutor getFeBatchQueryExecutor(SqlExecutor sqlExecutor, SQLCase fesqlCase, SQLCaseType type) { + private static BaseSQLExecutor getFeBatchQueryExecutor(SqlExecutor sqlExecutor, SQLCase sqlCase, SQLCaseType type) { if (OpenMLDBConfig.isCluster()) { log.info("cluster unsupport batch query mode"); - reportLog.info("cluster unsupport batch query mode"); - return new NullExecutor(sqlExecutor, fesqlCase, type); + return new NullExecutor(sqlExecutor, sqlCase, type); } - BaseSQLExecutor executor = null; - executor = new BatchSQLExecutor(sqlExecutor, fesqlCase, type); - return executor; + return new BatchSQLExecutor(sqlExecutor, sqlCase, type); } - private static BaseSQLExecutor getFeRequestQueryExecutor(SqlExecutor sqlExecutor, SQLCase fesqlCase, SQLCaseType type) { - BaseSQLExecutor executor = null; - executor = new RequestQuerySQLExecutor(sqlExecutor, fesqlCase, false, false, type); - return executor; + private static BaseSQLExecutor getFeRequestQueryExecutor(SqlExecutor sqlExecutor, SQLCase sqlCase, SQLCaseType type) { + return new RequestQuerySQLExecutor(sqlExecutor, sqlCase, false, false, type); } private static BaseSQLExecutor getFeBatchRequestQueryExecutor(SqlExecutor sqlExecutor, - SQLCase fesqlCase, SQLCaseType type) { - RequestQuerySQLExecutor executor = new RequestQuerySQLExecutor( - sqlExecutor, fesqlCase, true, false, type); - return executor; + SQLCase sqlCase, SQLCaseType type) { + return new RequestQuerySQLExecutor( + sqlExecutor, sqlCase, true, false, type); } - private static BaseSQLExecutor getFeRequestQueryWithSpExecutor(SqlExecutor sqlExecutor, SQLCase fesqlCase, boolean isAsyn, SQLCaseType type) { - BaseSQLExecutor executor = null; - executor = new StoredProcedureSQLExecutor( - sqlExecutor, fesqlCase, false, isAsyn, type); - return executor; + private static BaseSQLExecutor getFeRequestQueryWithSpExecutor(SqlExecutor sqlExecutor, SQLCase sqlCase, boolean isAsyn, SQLCaseType type) { + return new StoredProcedureSQLExecutor( + sqlExecutor, sqlCase, false, isAsyn, type); } - private static BaseSQLExecutor getFeBatchRequestQueryWithSpExecutor(SqlExecutor sqlExecutor, SQLCase fesqlCase, boolean isAsyn, SQLCaseType type) { - BaseSQLExecutor executor = null; - executor = new StoredProcedureSQLExecutor( - sqlExecutor, fesqlCase, fesqlCase.getBatch_request() != null, isAsyn, type); - return executor; + private static BaseSQLExecutor getFeBatchRequestQueryWithSpExecutor(SqlExecutor sqlExecutor, SQLCase sqlCase, boolean isAsyn, SQLCaseType type) { + return new StoredProcedureSQLExecutor( + sqlExecutor, sqlCase, sqlCase.getBatch_request() != null, isAsyn, type); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/InsertPreparedExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/InsertPreparedExecutor.java index e12901f63f3..3f50b9cb989 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/InsertPreparedExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/InsertPreparedExecutor.java @@ -45,7 +45,7 @@ public void prepare(String version,SqlExecutor executor){ log.info("version:{} prepare begin",version); boolean dbOk = executor.createDB(dbName); log.info("version:{},create db:{},{}", version, dbName, dbOk); - OpenMLDBResult res = SDKUtil.createAndInsertWithPrepared(executor, dbName, fesqlCase.getInputs(), false); + OpenMLDBResult res = SDKUtil.createAndInsertWithPrepared(executor, dbName, sqlCase.getInputs(), false); if (!res.isOk()) { throw new RuntimeException("fail to run BatchSQLExecutor: prepare fail . version:"+version); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/JDBCExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/JDBCExecutor.java index d1b3ce96990..745324be00f 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/JDBCExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/JDBCExecutor.java @@ -34,7 +34,7 @@ public abstract class JDBCExecutor extends BaseExecutor{ public JDBCExecutor(SQLCase fesqlCase, SQLCaseType sqlCaseType) { - this.fesqlCase = fesqlCase; + this.sqlCase = fesqlCase; this.executorType = sqlCaseType; dbName = fesqlCase.getDb(); if (!CollectionUtils.isEmpty(fesqlCase.getInputs())) { @@ -46,7 +46,7 @@ public JDBCExecutor(SQLCase fesqlCase, SQLCaseType sqlCaseType) { @Override public void check() throws Exception { - List strategyList = CheckerStrategy.build(fesqlCase, mainResult,executorType); + List strategyList = CheckerStrategy.build(null,sqlCase, mainResult,executorType); for (Checker checker : strategyList) { checker.check(); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/LongWindowExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/LongWindowExecutor.java new file mode 100644 index 00000000000..41d1c0ffcfd --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/LongWindowExecutor.java @@ -0,0 +1,133 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com._4paradigm.openmldb.java_sdk_test.executor; + +import com._4paradigm.openmldb.java_sdk_test.checker.Checker; +import com._4paradigm.openmldb.java_sdk_test.checker.CheckerStrategy; +import com._4paradigm.openmldb.sdk.SqlExecutor; +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.model.InputDesc; +import com._4paradigm.openmldb.test_common.model.SQLCase; +import com._4paradigm.openmldb.test_common.model.SQLCaseType; +import com._4paradigm.openmldb.test_common.util.SDKUtil; +import com._4paradigm.openmldb.test_common.util.SQLUtil; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +public class LongWindowExecutor extends StoredProcedureSQLExecutor { + +// private List spNames; + + public LongWindowExecutor(SqlExecutor executor, SQLCase sqlCase, boolean isBatchRequest, boolean isAsyn, SQLCaseType executorType) { + super(executor, sqlCase, isBatchRequest, isAsyn, executorType); + spNames = new ArrayList<>(); + } + + public LongWindowExecutor(SQLCase sqlCase, SqlExecutor executor, Map executorMap, Map openMLDBInfoMap, boolean isBatchRequest, boolean isAsyn, SQLCaseType executorType) { + super(sqlCase, executor, executorMap, openMLDBInfoMap, isBatchRequest, isAsyn, executorType); + spNames = new ArrayList<>(); + } + + @Override + public OpenMLDBResult execute(String version, SqlExecutor executor) { + log.info("version:{} execute begin",version); + OpenMLDBResult openMLDBResult = null; + try { + List steps = sqlCase.getSteps(); + if(CollectionUtils.isNotEmpty(steps)) { + for (SQLCase step : steps) { + String sql = step.getSql(); + if (MapUtils.isNotEmpty(openMLDBInfoMap)) { + sql = SQLUtil.formatSql(sql, tableNames, openMLDBInfoMap.get(version)); + } else { + sql = SQLUtil.formatSql(sql, tableNames); + } + if(sql.toLowerCase().startsWith("select ")) { + openMLDBResult = SDKUtil.executeLongWindowDeploy(executor, sqlCase, sql, false); + openMLDBResult.setDbName(dbName); + spNames.add(sqlCase.getSpName()); + }else{ + openMLDBResult = SDKUtil.sql(executor, dbName, sql); + openMLDBResult.setDbName(dbName); + openMLDBResult.setSpName(spNames.get(0)); + } +// if (executorType == SQLCaseType.kRequest) { +// InputDesc request = sqlCase.getInputs().get(0); +// openMLDBResult = SDKUtil.sqlRequestMode(executor, dbName, true, sql, request); +// } else if (executorType == SQLCaseType.kLongWindow) { +// openMLDBResult = SDKUtil.executeLongWindowDeploy(executor, sqlCase, sql, false); +// spNames.add(sqlCase.getSpName()); +// } else { +// openMLDBResult = SDKUtil.sql(executor, dbName, sql); +// } + List strategyList = CheckerStrategy.build(executor, step, openMLDBResult, executorType); + for (Checker checker : strategyList) { + checker.check(); + } + } + }else { + if (sqlCase.getInputs().isEmpty() || + CollectionUtils.isEmpty(sqlCase.getInputs().get(0).getRows())) { + log.error("fail to execute in request query sql executor: sql case inputs is empty"); + return null; + } + String sql = sqlCase.getSql(); + log.info("sql: {}", sql); + if (sql == null || sql.length() == 0) { + return null; + } + openMLDBResult = SDKUtil.executeLongWindowDeploy(executor, sqlCase, this.isAsyn); + spNames.add(sqlCase.getSpName()); + } + }catch (Exception e){ + e.printStackTrace(); + } + log.info("version:{} execute end",version); + return openMLDBResult; + } + +// private OpenMLDBResult executeSingle(SqlExecutor executor, String sql, boolean isAsyn) throws SQLException { +// String spSql = sqlCase.getProcedure(sql); +// log.info("spSql: {}", spSql); +// return SDKUtil.sqlRequestModeWithProcedure( +// executor, dbName, sqlCase.getSpName(), null == sqlCase.getBatch_request(), +// spSql, sqlCase.getInputs().get(0), isAsyn); +// } + + +// @Override +// public void tearDown(String version,SqlExecutor executor) { +// log.info("version:{},begin tearDown",version); +// if (CollectionUtils.isEmpty(spNames)) { +// return; +// } +// for (String spName : spNames) { +// String drop = "drop procedure " + spName + ";"; +// SDKUtil.ddl(executor, dbName, drop); +// } +// super.tearDown(version,executor); +// } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/MysqlExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/MysqlExecutor.java index 1a1a56017e8..50a4a4d8b8b 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/MysqlExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/MysqlExecutor.java @@ -16,7 +16,6 @@ package com._4paradigm.openmldb.java_sdk_test.executor; import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.java_sdk_test.util.JDBCUtil; import com._4paradigm.openmldb.java_sdk_test.util.MysqlUtil; import com._4paradigm.openmldb.test_common.model.DBType; @@ -41,18 +40,18 @@ public MysqlExecutor(SQLCase fesqlCase, SQLCaseType sqlCaseType) { @Override public boolean verify() { - List sqlDialect = fesqlCase.getSqlDialect(); + List sqlDialect = sqlCase.getSqlDialect(); if(sqlDialect.contains(DBType.ANSISQL.name())|| sqlDialect.contains(DBType.MYSQL.name())){ return true; } - log.info("skip case in mysql mode: {}", fesqlCase.getDesc()); + log.info("skip case in mysql mode: {}", sqlCase.getDesc()); return false; } @Override public void prepare() { log.info("mysql prepare begin"); - for(InputDesc inputDesc:fesqlCase.getInputs()) { + for(InputDesc inputDesc: sqlCase.getInputs()) { String createSql = MysqlUtil.getCreateTableSql(inputDesc); JDBCUtil.executeUpdate(createSql, DBType.MYSQL); boolean ok = MysqlUtil.insertData(inputDesc); @@ -67,14 +66,14 @@ public void prepare() { public void execute() { log.info("mysql execute begin"); OpenMLDBResult fesqlResult = null; - List sqls = fesqlCase.getSqls(); + List sqls = sqlCase.getSqls(); if (sqls != null && sqls.size() > 0) { for (String sql : sqls) { sql = SQLUtil.formatSql(sql, tableNames); fesqlResult = JDBCUtil.executeQuery(sql,DBType.MYSQL); } } - String sql = fesqlCase.getSql(); + String sql = sqlCase.getSql(); if (sql != null && sql.length() > 0) { sql = SQLUtil.formatSql(sql, tableNames); fesqlResult = JDBCUtil.executeQuery(sql,DBType.MYSQL); @@ -86,7 +85,7 @@ public void execute() { @Override public void tearDown() { log.info("mysql,begin drop table"); - List tables = fesqlCase.getInputs(); + List tables = sqlCase.getInputs(); if (CollectionUtils.isEmpty(tables)) { return; } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/QueryPreparedExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/QueryPreparedExecutor.java index 8ef1b9332d3..c7b75bef3d9 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/QueryPreparedExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/QueryPreparedExecutor.java @@ -61,15 +61,15 @@ public OpenMLDBResult execute(String version, SqlExecutor executor){ // fesqlResult = FesqlUtil.sql(executor, dbName, sql); // } // } - String sql = fesqlCase.getSql(); + String sql = sqlCase.getSql(); if (sql != null && sql.length() > 0) { // log.info("sql:{}", sql); - if(MapUtils.isNotEmpty(fedbInfoMap)) { - sql = SQLUtil.formatSql(sql, tableNames, fedbInfoMap.get(version)); + if(MapUtils.isNotEmpty(openMLDBInfoMap)) { + sql = SQLUtil.formatSql(sql, tableNames, openMLDBInfoMap.get(version)); }else { sql = SQLUtil.formatSql(sql, tableNames); } - InputDesc parameters = fesqlCase.getParameters(); + InputDesc parameters = sqlCase.getParameters(); List types = parameters.getColumns().stream().map(s -> s.split("\\s+")[1]).collect(Collectors.toList()); List objects = parameters.getRows().get(0); fesqlResult = SDKUtil.selectWithPrepareStatement(executor, dbName,sql, types,objects); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/RequestQuerySQLExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/RequestQuerySQLExecutor.java index d3c4d3c74ab..62a3f230c30 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/RequestQuerySQLExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/RequestQuerySQLExecutor.java @@ -57,29 +57,29 @@ public OpenMLDBResult execute(String version, SqlExecutor executor) { log.info("version:{} execute begin",version); OpenMLDBResult fesqlResult = null; try { - List sqls = fesqlCase.getSqls(); + List sqls = sqlCase.getSqls(); if (sqls != null && sqls.size() > 0) { for (String sql : sqls) { // log.info("sql:{}", sql); - if(MapUtils.isNotEmpty(fedbInfoMap)) { - sql = SQLUtil.formatSql(sql, tableNames, fedbInfoMap.get(version)); + if(MapUtils.isNotEmpty(openMLDBInfoMap)) { + sql = SQLUtil.formatSql(sql, tableNames, openMLDBInfoMap.get(version)); }else { sql = SQLUtil.formatSql(sql, tableNames); } fesqlResult = SDKUtil.sql(executor, dbName, sql); } } - String sql = fesqlCase.getSql(); + String sql = sqlCase.getSql(); if (sql != null && sql.length() > 0) { // log.info("sql:{}", sql); - if(MapUtils.isNotEmpty(fedbInfoMap)) { - sql = SQLUtil.formatSql(sql, tableNames, fedbInfoMap.get(version)); + if(MapUtils.isNotEmpty(openMLDBInfoMap)) { + sql = SQLUtil.formatSql(sql, tableNames, openMLDBInfoMap.get(version)); }else { sql = SQLUtil.formatSql(sql, tableNames); } InputDesc request = null; if (isBatchRequest) { - InputDesc batchRequest = fesqlCase.getBatch_request(); + InputDesc batchRequest = sqlCase.getBatch_request(); if (batchRequest == null) { log.error("No batch request provided in case"); return null; @@ -96,16 +96,16 @@ public OpenMLDBResult execute(String version, SqlExecutor executor) { fesqlResult = SDKUtil.sqlBatchRequestMode( executor, dbName, sql, batchRequest, commonColumnIndices); } else { - if (null != fesqlCase.getBatch_request()) { - request = fesqlCase.getBatch_request(); - } else if (!fesqlCase.getInputs().isEmpty()) { - request = fesqlCase.getInputs().get(0); + if (null != sqlCase.getBatch_request()) { + request = sqlCase.getBatch_request(); + } else if (!sqlCase.getInputs().isEmpty()) { + request = sqlCase.getInputs().get(0); } if (null == request || CollectionUtils.isEmpty(request.getColumns())) { log.error("fail to execute in request query sql executor: sql case request columns is empty"); return null; } - fesqlResult = SDKUtil.sqlRequestMode(executor, dbName, null == fesqlCase.getBatch_request(), sql, request); + fesqlResult = SDKUtil.sqlRequestMode(executor, dbName, null == sqlCase.getBatch_request(), sql, request); } } }catch (Exception e){ @@ -120,43 +120,44 @@ protected void prepare(String version,SqlExecutor executor) { log.info("version:{} prepare begin",version); boolean dbOk = executor.createDB(dbName); log.info("create db:{},{}", dbName, dbOk); - boolean useFirstInputAsRequests = !isBatchRequest && null == fesqlCase.getBatch_request(); - OpenMLDBResult res = SDKUtil.createAndInsert(executor, dbName, fesqlCase.getInputs(), useFirstInputAsRequests); + SDKUtil.useDB(executor,dbName); + boolean useFirstInputAsRequests = !isBatchRequest && null == sqlCase.getBatch_request(); + OpenMLDBResult res = SDKUtil.createAndInsert(executor, dbName, sqlCase.getInputs(), useFirstInputAsRequests); if (!res.isOk()) { - throw new RuntimeException("fail to run BatchSQLExecutor: prepare fail"); + throw new RuntimeException("fail to run RequestQuerySQLExecutor: prepare fail"); } log.info("version:{} prepare end",version); } @Override public boolean verify() { - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("hybridse-only")) { - log.info("skip case in request mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("hybridse-only")) { + log.info("skip case in request mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("request-unsupport")) { - log.info("skip case in request mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("request-unsupport")) { + log.info("skip case in request mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("rtidb-unsupport")) { - log.info("skip case in rtidb mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-unsupport")) { + log.info("skip case in rtidb mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("performance-sensitive-unsupport")) { - log.info("skip case in rtidb mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("performance-sensitive-unsupport")) { + log.info("skip case in rtidb mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("rtidb-request-unsupport")) { - log.info("skip case in rtidb request mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-request-unsupport")) { + log.info("skip case in rtidb request mode: {}", sqlCase.getDesc()); return false; } - if (null != fesqlCase.getMode() && !OpenMLDBGlobalVar.tableStorageMode.equals("memory") && fesqlCase.getMode().contains("disk-unsupport")) { - log.info("skip case in disk mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && !OpenMLDBGlobalVar.tableStorageMode.equals("memory") && sqlCase.getMode().contains("disk-unsupport")) { + log.info("skip case in disk mode: {}", sqlCase.getDesc()); return false; } if (OpenMLDBConfig.isCluster() && - null != fesqlCase.getMode() && fesqlCase.getMode().contains("cluster-unsupport")) { - log.info("cluster-unsupport, skip case in cluster request mode: {}", fesqlCase.getDesc()); + null != sqlCase.getMode() && sqlCase.getMode().contains("cluster-unsupport")) { + log.info("cluster-unsupport, skip case in cluster request mode: {}", sqlCase.getDesc()); return false; } return true; diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/Sqlite3Executor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/Sqlite3Executor.java index fc3ca356c67..e1b59f86961 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/Sqlite3Executor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/Sqlite3Executor.java @@ -17,7 +17,6 @@ import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.java_sdk_test.util.JDBCUtil; import com._4paradigm.openmldb.java_sdk_test.util.Sqlite3Util; import com._4paradigm.openmldb.test_common.model.DBType; @@ -42,18 +41,18 @@ public Sqlite3Executor(SQLCase fesqlCase, SQLCaseType sqlCaseType) { @Override public boolean verify() { - List sqlDialect = fesqlCase.getSqlDialect(); + List sqlDialect = sqlCase.getSqlDialect(); if(sqlDialect.contains(DBType.ANSISQL.name())|| sqlDialect.contains(DBType.SQLITE3.name())){ return true; } - log.info("skip case in sqlite3 mode: {}", fesqlCase.getDesc()); + log.info("skip case in sqlite3 mode: {}", sqlCase.getDesc()); return false; } @Override public void prepare() { log.info("sqlite3 prepare begin"); - for(InputDesc inputDesc:fesqlCase.getInputs()) { + for(InputDesc inputDesc: sqlCase.getInputs()) { String createSql = Sqlite3Util.getCreateTableSql(inputDesc); JDBCUtil.executeUpdate(createSql,DBType.SQLITE3); boolean ok = Sqlite3Util.insertData(inputDesc); @@ -68,14 +67,14 @@ public void prepare() { public void execute() { log.info("sqlite3 execute begin"); OpenMLDBResult fesqlResult = null; - List sqls = fesqlCase.getSqls(); + List sqls = sqlCase.getSqls(); if (sqls != null && sqls.size() > 0) { for (String sql : sqls) { sql = SQLUtil.formatSql(sql, tableNames); fesqlResult = JDBCUtil.executeQuery(sql,DBType.SQLITE3); } } - String sql = fesqlCase.getSql(); + String sql = sqlCase.getSql(); if (sql != null && sql.length() > 0) { sql = SQLUtil.formatSql(sql, tableNames); fesqlResult = JDBCUtil.executeQuery(sql,DBType.SQLITE3); @@ -87,7 +86,7 @@ public void execute() { @Override public void tearDown() { log.info("sqlite3,begin drop table"); - List tables = fesqlCase.getInputs(); + List tables = sqlCase.getInputs(); if (CollectionUtils.isEmpty(tables)) { return; } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StandaloneCliExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StandaloneCliExecutor.java index 2e3b12e690b..d326bdd8cfb 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StandaloneCliExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StandaloneCliExecutor.java @@ -35,8 +35,8 @@ public StandaloneCliExecutor(SQLCase fesqlCase, Map openML @Override public boolean verify() { - if (null != fesqlCase.getMode() && fesqlCase.getMode().contains("standalone-unsupport")) { - log.info("skip case in cli mode: {}", fesqlCase.getDesc()); + if (null != sqlCase.getMode() && sqlCase.getMode().contains("standalone-unsupport")) { + log.info("skip case in cli mode: {}", sqlCase.getDesc()); return false; } return super.verify(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StepExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StepExecutor.java new file mode 100644 index 00000000000..88d109ab386 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StepExecutor.java @@ -0,0 +1,133 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com._4paradigm.openmldb.java_sdk_test.executor; + +import com._4paradigm.openmldb.java_sdk_test.checker.Checker; +import com._4paradigm.openmldb.java_sdk_test.checker.CheckerStrategy; +import com._4paradigm.openmldb.java_sdk_test.checker.DiffVersionChecker; +import com._4paradigm.openmldb.java_sdk_test.common.OpenMLDBConfig; +import com._4paradigm.openmldb.sdk.SqlExecutor; +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.model.InputDesc; +import com._4paradigm.openmldb.test_common.model.SQLCase; +import com._4paradigm.openmldb.test_common.model.SQLCaseType; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; +import com._4paradigm.openmldb.test_common.util.SDKUtil; +import com._4paradigm.openmldb.test_common.util.SQLUtil; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; + +import java.util.List; +import java.util.Map; + +/** + * @author zhaowei + * @date 2020/6/15 11:29 AM + */ +@Slf4j +public class StepExecutor extends BaseSQLExecutor { + + protected List spNames; + + public StepExecutor(SqlExecutor executor, SQLCase sqlCase, SQLCaseType executorType) { + super(executor, sqlCase, executorType); + } + public StepExecutor(SQLCase fesqlCase, SqlExecutor executor, Map executorMap, Map openMLDBInfoMap, SQLCaseType executorType) { + super(fesqlCase, executor, executorMap, openMLDBInfoMap, executorType); + } + + @Override + public boolean verify() { + if (null != sqlCase.getMode() && sqlCase.getMode().contains("hybridse-only")) { + log.info("skip case in batch mode: {}", sqlCase.getDesc()); + return false; + } + if (null != sqlCase.getMode() && sqlCase.getMode().contains("batch-unsupport")) { + log.info("skip case in batch mode: {}", sqlCase.getDesc()); + return false; + } + if (null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-batch-unsupport")) { + log.info("skip case in rtidb batch mode: {}", sqlCase.getDesc()); + return false; + } + if (null != sqlCase.getMode() && sqlCase.getMode().contains("rtidb-unsupport")) { + log.info("skip case in rtidb mode: {}", sqlCase.getDesc()); + return false; + } + if (null != sqlCase.getMode() && sqlCase.getMode().contains("performance-sensitive-unsupport")) { + log.info("skip case in rtidb mode: {}", sqlCase.getDesc()); + return false; + } + if (null != sqlCase.getMode() && !OpenMLDBGlobalVar.tableStorageMode.equals("memory") && sqlCase.getMode().contains("disk-unsupport")) { + log.info("skip case in disk mode: {}", sqlCase.getDesc()); + return false; + } + if (OpenMLDBConfig.isCluster() && null != sqlCase.getMode() && sqlCase.getMode().contains("cluster-unsupport")) { + log.info("skip case in cluster mode: {}", sqlCase.getDesc()); + return false; + } + return true; + } + + @Override + public void prepare(String version,SqlExecutor executor){ + log.info("version:{} prepare begin",version); + boolean dbOk = executor.createDB(dbName); + log.info("version:{},create db:{},{}", version, dbName, dbOk); + SDKUtil.useDB(executor,dbName); + OpenMLDBResult res = SDKUtil.createAndInsert(executor, dbName, sqlCase.getInputs(), false); + if (!res.isOk()) { + throw new RuntimeException("fail to run BatchSQLExecutor: prepare fail . version:"+version); + } + log.info("version:{} prepare end",version); + } + + @Override + public OpenMLDBResult execute(String version, SqlExecutor executor){ + log.info("version:{} execute begin",version); + OpenMLDBResult openMLDBResult = null; + try { + List steps = sqlCase.getSteps(); + for (SQLCase step : steps) { + String sql = step.getSql(); + if (MapUtils.isNotEmpty(openMLDBInfoMap)) { + sql = SQLUtil.formatSql(sql, tableNames, openMLDBInfoMap.get(version)); + } else { + sql = SQLUtil.formatSql(sql, tableNames); + } + if (executorType == SQLCaseType.kRequest) { + InputDesc request = sqlCase.getInputs().get(0); + openMLDBResult = SDKUtil.sqlRequestMode(executor, dbName, true, sql, request); + } else if (executorType == SQLCaseType.kLongWindow) { + openMLDBResult = SDKUtil.executeLongWindowDeploy(executor, sqlCase, sql, false); + spNames.add(sqlCase.getSpName()); + } else { + openMLDBResult = SDKUtil.sql(executor, dbName, sql); + } + List strategyList = CheckerStrategy.build(executor, step, openMLDBResult, executorType); + for (Checker checker : strategyList) { + checker.check(); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + log.info("version:{} execute end",version); + return openMLDBResult; + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StoredProcedureSQLExecutor.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StoredProcedureSQLExecutor.java index 2e15d9854d1..4de340711be 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StoredProcedureSQLExecutor.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/executor/StoredProcedureSQLExecutor.java @@ -25,6 +25,7 @@ import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import java.sql.SQLException; import java.util.ArrayList; @@ -34,7 +35,7 @@ @Slf4j public class StoredProcedureSQLExecutor extends RequestQuerySQLExecutor { - private List spNames; + protected List spNames; public StoredProcedureSQLExecutor(SqlExecutor executor, SQLCase fesqlCase, boolean isBatchRequest, boolean isAsyn, SQLCaseType executorType) { super(executor, fesqlCase, isBatchRequest, isAsyn, executorType); @@ -46,40 +47,25 @@ public StoredProcedureSQLExecutor(SQLCase fesqlCase, SqlExecutor executor, Map(); } - @Override - public void prepare(String version,SqlExecutor executor){ - log.info("version:{} prepare begin",version); - boolean dbOk = executor.createDB(dbName); - log.info("create db:{},{}", dbName, dbOk); - OpenMLDBResult res = SDKUtil.createAndInsert( - executor, dbName, fesqlCase.getInputs(), - !isBatchRequest && null == fesqlCase.getBatch_request()); - if (!res.isOk()) { - throw new RuntimeException("fail to run StoredProcedureSQLExecutor: prepare fail"); - } - log.info("version:{} prepare end",version); - } @Override public OpenMLDBResult execute(String version, SqlExecutor executor) { log.info("version:{} execute begin",version); OpenMLDBResult fesqlResult = null; try { - if (fesqlCase.getInputs().isEmpty() || - CollectionUtils.isEmpty(fesqlCase.getInputs().get(0).getRows())) { - log.error("fail to execute in request query sql executor: sql case inputs is empty"); - return null; + if (sqlCase.getInputs().isEmpty() || CollectionUtils.isEmpty(sqlCase.getInputs().get(0).getRows())) { + throw new IllegalArgumentException("fail to execute in request query sql executor: sql case inputs is empty"); } - String sql = fesqlCase.getSql(); + String sql = sqlCase.getSql(); log.info("sql: {}", sql); - if (sql == null || sql.length() == 0) { - return null; + if (StringUtils.isEmpty(sql)) { + throw new IllegalArgumentException("fail to execute in request query sql executor: sql is empty"); } - if (fesqlCase.getBatch_request() != null) { + if (sqlCase.getBatch_request() != null) { fesqlResult = executeBatch(executor, sql, this.isAsyn); } else { fesqlResult = executeSingle(executor, sql, this.isAsyn); } - spNames.add(fesqlCase.getSpName()); + spNames.add(sqlCase.getSpName()); }catch (Exception e){ e.printStackTrace(); } @@ -88,25 +74,25 @@ public OpenMLDBResult execute(String version, SqlExecutor executor) { } private OpenMLDBResult executeSingle(SqlExecutor executor, String sql, boolean isAsyn) throws SQLException { - String spSql = fesqlCase.getProcedure(sql); + String spSql = sqlCase.getProcedure(sql); log.info("spSql: {}", spSql); return SDKUtil.sqlRequestModeWithProcedure( - executor, dbName, fesqlCase.getSpName(), null == fesqlCase.getBatch_request(), - spSql, fesqlCase.getInputs().get(0), isAsyn); + executor, dbName, sqlCase.getSpName(), null == sqlCase.getBatch_request(), + spSql, sqlCase.getInputs().get(0), isAsyn); } private OpenMLDBResult executeBatch(SqlExecutor executor, String sql, boolean isAsyn) throws SQLException { String spName = "sp_" + tableNames.get(0) + "_" + System.currentTimeMillis(); - String spSql = SQLUtil.buildSpSQLWithConstColumns(spName, sql, fesqlCase.getBatch_request()); + String spSql = SQLUtil.buildSpSQLWithConstColumns(spName, sql, sqlCase.getBatch_request()); log.info("spSql: {}", spSql); return SDKUtil.selectBatchRequestModeWithSp( - executor, dbName, spName, spSql, fesqlCase.getBatch_request(), isAsyn); + executor, dbName, spName, spSql, sqlCase.getBatch_request(), isAsyn); } @Override public void tearDown(String version,SqlExecutor executor) { - log.info("version:{},begin drop table",version); + log.info("version:{},begin tearDown",version); if (CollectionUtils.isEmpty(spNames)) { return; } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/auto_gen_case/AutoGenCaseTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/auto_gen_case/AutoGenCaseTest.java index d056c980a84..09b551f6f59 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/auto_gen_case/AutoGenCaseTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/auto_gen_case/AutoGenCaseTest.java @@ -25,8 +25,10 @@ import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.model.SQLCaseType; import com._4paradigm.openmldb.test_common.provider.Yaml; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBDeployType; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; +import com.google.common.collect.Lists; import io.qameta.allure.Feature; import io.qameta.allure.Story; import lombok.extern.slf4j.Slf4j; @@ -62,17 +64,24 @@ public void beforeClass(){ }else{ //测试调试用 String verion = "2.2.2"; - OpenMLDBInfo fedbInfo = OpenMLDBInfo.builder() - .basePath("/home/zhaowei01/fedb-auto-test/2.2.2") - .openMLDBPath("/home/zhaowei01/fedb-auto-test/2.2.2/fedb-ns-1/bin/fedb") - .zk_cluster("172.24.4.55:10006") - .zk_root_path("/fedb") - .nsNum(2).tabletNum(3) - .nsEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:10007", "172.24.4.55:10008")) - .tabletEndpoints(com.google.common.collect.Lists.newArrayList("172.24.4.55:10009", "172.24.4.55:10010", "172.24.4.55:10011")) - .build(); - executorMap.put(verion, new OpenMLDBClient(fedbInfo.getZk_cluster(),fedbInfo.getZk_root_path()).getExecutor()); - fedbInfoMap.put(verion, fedbInfo); + OpenMLDBInfo openMLDBInfo = new OpenMLDBInfo(); + openMLDBInfo.setDeployType(OpenMLDBDeployType.CLUSTER); + openMLDBInfo.setNsNum(2); + openMLDBInfo.setTabletNum(3); + openMLDBInfo.setBasePath("/home/zhaowei01/openmldb-auto-test/tmp"); + openMLDBInfo.setZk_cluster("172.24.4.55:30000"); + openMLDBInfo.setZk_root_path("/openmldb"); + openMLDBInfo.setNsEndpoints(Lists.newArrayList("172.24.4.55:30004", "172.24.4.55:30005")); + openMLDBInfo.setNsNames(Lists.newArrayList()); + openMLDBInfo.setTabletEndpoints(Lists.newArrayList("172.24.4.55:30001", "172.24.4.55:30002", "172.24.4.55:30003")); + openMLDBInfo.setTabletNames(Lists.newArrayList()); + openMLDBInfo.setApiServerEndpoints(Lists.newArrayList("172.24.4.55:30006")); + openMLDBInfo.setApiServerNames(Lists.newArrayList()); + openMLDBInfo.setTaskManagerEndpoints(Lists.newArrayList("172.24.4.55:30007")); + openMLDBInfo.setOpenMLDBPath("/home/zhaowei01/openmldb-auto-test/tmp/openmldb-ns-1/bin/openmldb"); + + executorMap.put(verion, new OpenMLDBClient(openMLDBInfo.getZk_cluster(),openMLDBInfo.getZk_root_path()).getExecutor()); + fedbInfoMap.put(verion, openMLDBInfo); fedbInfoMap.put("mainVersion", OpenMLDBGlobalVar.mainInfo); } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/BatchRequestTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/BatchRequestTest.java index f3203c4dbdd..1c889a5f5c9 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/BatchRequestTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/BatchRequestTest.java @@ -29,19 +29,19 @@ public class BatchRequestTest extends OpenMLDBTest { @Story("BatchRequest") @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/test_batch_request.yaml") + @Yaml(filePaths = "integration_test/test_batch_request.yaml") public void testBatchRequest(SQLCase testCase) { ExecutorFactory.build(executor, testCase, SQLCaseType.kBatchRequest).run(); } @Story("SPBatchRequest") @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/test_batch_request.yaml") + @Yaml(filePaths = "integration_test/test_batch_request.yaml") public void testSPBatchRequest(SQLCase testCase) { ExecutorFactory.build(executor, testCase, SQLCaseType.kBatchRequestWithSp).run(); } @Story("SPBatchRequestAsyn") @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/test_batch_request.yaml") + @Yaml(filePaths = "integration_test/test_batch_request.yaml") public void testSPBatchRequestAsyn(SQLCase testCase) { ExecutorFactory.build(executor, testCase, SQLCaseType.kBatchRequestWithSpAsync).run(); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/DDLTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/DDLTest.java index 52ebeca22bc..3138f5629e2 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/DDLTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/DDLTest.java @@ -34,13 +34,13 @@ @Feature("DDL") public class DDLTest extends OpenMLDBTest { @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/ddl/test_create.yaml") + @Yaml(filePaths = "integration_test/ddl/test_create.yaml") @Story("create") public void testCreate(SQLCase testCase){ ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); } - @Yaml(filePaths = "function/ddl/test_create.yaml") + @Yaml(filePaths = "integration_test/ddl/test_create.yaml") @Story("create") @Test(dataProvider = "getCase",enabled = false) public void testCreateByCli(SQLCase testCase){ @@ -48,53 +48,53 @@ public void testCreateByCli(SQLCase testCase){ } @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/ddl/test_ttl.yaml") + @Yaml(filePaths = "integration_test/ddl/test_ttl.yaml") @Story("ttl") public void testTTL(SQLCase testCase){ ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); } @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = "function/ddl/test_ttl.yaml") + @Yaml(filePaths = "integration_test/ddl/test_ttl.yaml") @Story("ttl") public void testTTLByCli(SQLCase testCase){ ExecutorFactory.build(testCase, SQLCaseType.kClusterCLI).run(); } @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/ddl/test_create_index.yaml") + @Yaml(filePaths = "integration_test/ddl/test_create_index.yaml") @Story("create_index") public void testCreateIndex(SQLCase testCase){ ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); } @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = "function/ddl/test_create_index.yaml") + @Yaml(filePaths = "integration_test/ddl/test_create_index.yaml") @Story("create_index") public void testCreateIndexByCli(SQLCase testCase){ ExecutorFactory.build(testCase, SQLCaseType.kClusterCLI).run(); } @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/ddl/test_options.yaml") + @Yaml(filePaths = "integration_test/ddl/test_options.yaml") @Story("options") public void testOptions(SQLCase testCase){ ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); } @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = "function/ddl/test_options.yaml") + @Yaml(filePaths = "integration_test/ddl/test_options.yaml") @Story("options") public void testOptionsByCli(SQLCase testCase){ ExecutorFactory.build(testCase, SQLCaseType.kClusterCLI).run(); } @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/ddl/test_create_no_index.yaml") + @Yaml(filePaths = "integration_test/ddl/test_create_no_index.yaml") @Story("create_no_index") public void testCreateNoIndex(SQLCase testCase){ ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); } @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = "function/ddl/test_create_no_index.yaml") + @Yaml(filePaths = "integration_test/ddl/test_create_no_index.yaml") @Story("create_no_index") public void testCreateNoIndexByCli(SQLCase testCase){ ExecutorFactory.build(testCase, SQLCaseType.kClusterCLI).run(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/DMLTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/DMLTest.java index 9b697eb46a8..3f030154580 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/DMLTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/DMLTest.java @@ -36,38 +36,51 @@ public class DMLTest extends OpenMLDBTest { @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/dml/test_insert.yaml"}) + @Yaml(filePaths = {"integration_test/dml/test_insert.yaml"}) @Story("insert") public void testInsert(SQLCase testCase){ ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); } @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = {"function/dml/test_insert.yaml"}) + @Yaml(filePaths = {"integration_test/dml/test_insert.yaml"}) @Story("insert") public void testInsertByCli(SQLCase testCase){ ExecutorFactory.build(testCase, SQLCaseType.kClusterCLI).run(); } @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/dml/test_insert_prepared.yaml") + @Yaml(filePaths = "integration_test/dml/test_insert_prepared.yaml") @Story("insert-prepared") public void testInsertWithPrepared(SQLCase testCase){ ExecutorFactory.build(executor,testCase, SQLCaseType.kInsertPrepared).run(); } @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/dml/multi_insert.yaml") + @Yaml(filePaths = "integration_test/dml/multi_insert.yaml") @Story("multi-insert") public void testMultiInsert(SQLCase testCase){ ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); } @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = "function/dml/multi_insert.yaml") + @Yaml(filePaths = "integration_test/dml/multi_insert.yaml") @Story("multi-insert") public void testMultiInsertByCli(SQLCase testCase){ ExecutorFactory.build(testCase, SQLCaseType.kClusterCLI).run(); } + @Test(dataProvider = "getCase") + @Yaml(filePaths = {"integration_test/dml/test_delete.yaml"}) + @Story("delete") + public void testDelete(SQLCase testCase){ + ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); + } + + @Test(dataProvider = "getCase",enabled = false) + @Yaml(filePaths = {"integration_test/dml/test_delete.yaml"}) + @Story("delete") + public void testDeleteByCli(SQLCase testCase){ + ExecutorFactory.build(testCase, SQLCaseType.kClusterCLI).run(); + } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/ExpressTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/ExpressTest.java index 0b4f5a1ebf8..1326a447492 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/ExpressTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/ExpressTest.java @@ -37,7 +37,7 @@ public class ExpressTest extends OpenMLDBTest { @Story("batch") @Test(dataProvider = "getCase",enabled = false) @Yaml(filePaths = { - "function/expression/" + "integration_test/expression/" }) public void testExpress(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kBatch).run(); @@ -45,7 +45,7 @@ public void testExpress(SQLCase testCase) throws Exception { @Story("request") @Test(dataProvider = "getCase") @Yaml(filePaths = { - "function/expression/" + "integration_test/expression/" }) public void testExpressRequestMode(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequest).run(); @@ -53,7 +53,7 @@ public void testExpressRequestMode(SQLCase testCase) throws Exception { @Story("requestWithSp") @Test(dataProvider = "getCase") @Yaml(filePaths = { - "function/expression/" + "integration_test/expression/" }) public void testExpressRequestModeWithSp(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSp).run(); @@ -61,7 +61,7 @@ public void testExpressRequestModeWithSp(SQLCase testCase) throws Exception { @Story("requestWithSpAysn") @Test(dataProvider = "getCase") @Yaml(filePaths = { - "function/expression/" + "integration_test/expression/" }) public void testExpressRequestModeWithSpAysn(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSpAsync).run(); diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/FunctionTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/FunctionTest.java index 1fff9b1547a..14124a60205 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/FunctionTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/FunctionTest.java @@ -36,25 +36,25 @@ public class FunctionTest extends OpenMLDBTest { @Story("batch") @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = "function/function/") + @Yaml(filePaths = "integration_test/function/") public void testFunction(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kBatch).run(); } @Story("request") @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/function/") + @Yaml(filePaths = "integration_test/function/") public void testFunctionRequestMode(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequest).run(); } @Story("requestWithSp") @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/function/") + @Yaml(filePaths = "integration_test/function/") public void testFunctionRequestModeWithSp(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSp).run(); } @Story("requestWithSpAysn") @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/function/") + @Yaml(filePaths = "integration_test/function/") public void testFunctionRequestModeWithSpAysn(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSpAsync).run(); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/LastJoinTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/LastJoinTest.java index 128e21c2e0c..cea123ff9a6 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/LastJoinTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/LastJoinTest.java @@ -36,25 +36,25 @@ public class LastJoinTest extends OpenMLDBTest { @Story("batch") @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = {"function/join/"}) + @Yaml(filePaths = {"integration_test/join/"}) public void testLastJoin(SQLCase testCase) throws Exception { ExecutorFactory.build(executor,testCase, SQLCaseType.kBatch).run(); } @Story("request") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/join/"}) + @Yaml(filePaths = {"integration_test/join/"}) public void testLastJoinRequestMode(SQLCase testCase) throws Exception { ExecutorFactory.build(executor,testCase, SQLCaseType.kRequest).run(); } @Story("requestWithSp") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/join/"}) + @Yaml(filePaths = {"integration_test/join/"}) public void testLastJoinRequestModeWithSp(SQLCase testCase) throws Exception { ExecutorFactory.build(executor,testCase, SQLCaseType.kRequestWithSp).run(); } @Story("requestWithSpAysn") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/join/"}) + @Yaml(filePaths = {"integration_test/join/"}) public void testLastJoinRequestModeWithSpAsync(SQLCase testCase) throws Exception { ExecutorFactory.build(executor,testCase, SQLCaseType.kRequestWithSpAsync).run(); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/LongWindowTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/LongWindowTest.java new file mode 100644 index 00000000000..c7d530b96a5 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/LongWindowTest.java @@ -0,0 +1,50 @@ +package com._4paradigm.openmldb.java_sdk_test.cluster.sql_test; + +import com._4paradigm.openmldb.java_sdk_test.common.OpenMLDBTest; +import com._4paradigm.openmldb.java_sdk_test.executor.ExecutorFactory; +import com._4paradigm.openmldb.test_common.model.SQLCase; +import com._4paradigm.openmldb.test_common.model.SQLCaseType; +import com._4paradigm.openmldb.test_common.provider.Yaml; +import io.qameta.allure.Feature; +import io.qameta.allure.Story; +import lombok.extern.slf4j.Slf4j; +import org.testng.annotations.Test; + +@Slf4j +@Feature("long_window") +public class LongWindowTest extends OpenMLDBTest { + + @Test(dataProvider = "getCase") + @Yaml(filePaths = "integration_test/long_window/test_long_window.yaml") + @Story("longWindow") + public void testLongWindow(SQLCase testCase){ + ExecutorFactory.build(executor,testCase, SQLCaseType.kLongWindow).run(); + } + @Test(dataProvider = "getCase",enabled = false) + @Yaml(filePaths = "integration_test/long_window/test_long_window_batch.yaml") + @Story("longWindow-batch") + public void testLongWindowByBatch(SQLCase testCase){ + ExecutorFactory.build(executor,testCase, SQLCaseType.kBatch).run(); + } + + @Test(dataProvider = "getCase") + @Yaml(filePaths = "integration_test/long_window/test_count_where.yaml") + @Story("count_where") + public void testCountWhere(SQLCase testCase){ + ExecutorFactory.build(executor,testCase, SQLCaseType.kLongWindow).run(); + } + + @Test(dataProvider = "getCase") + @Yaml(filePaths = "integration_test/long_window/test_xxx_where.yaml") + @Story("xxx_where") + public void testXXXWhere(SQLCase testCase){ + ExecutorFactory.build(executor,testCase, SQLCaseType.kLongWindow).run(); + } + @Test(dataProvider = "getCase") + @Yaml(filePaths = "integration_test/long_window/test_udaf.yaml") + @Story("udaf") + public void testUDAF(SQLCase testCase){ + ExecutorFactory.build(executor,testCase, SQLCaseType.kLongWindow).run(); + } + +} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/MultiDBTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/MultiDBTest.java index 4dcfd0df47a..680c62832d6 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/MultiDBTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/MultiDBTest.java @@ -37,26 +37,26 @@ public class MultiDBTest extends OpenMLDBTest { @Story("batch") @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = {"function/multiple_databases/"}) + @Yaml(filePaths = {"integration_test/multiple_databases/"}) @Step("{testCase.desc}") public void testMultiDB(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kBatch).run(); } @Story("request") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/multiple_databases/"}) + @Yaml(filePaths = {"integration_test/multiple_databases/"}) public void testMultiDBRequestMode(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequest).run(); } @Story("requestWithSp") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/multiple_databases/"}) + @Yaml(filePaths = {"integration_test/multiple_databases/"}) public void testMultiDBRequestModeWithSp(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSp).run(); } @Story("requestWithSpAysn") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/multiple_databases/"}) + @Yaml(filePaths = {"integration_test/multiple_databases/"}) public void testMultiDBRequestModeWithSpAysn(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSpAsync).run(); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/SelectTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/SelectTest.java index 9930e689ad6..474e44f386f 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/SelectTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/SelectTest.java @@ -37,26 +37,26 @@ public class SelectTest extends OpenMLDBTest { @Story("batch") @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = {"function/select/","query/const_query.yaml"}) + @Yaml(filePaths = {"integration_test/select/","query/const_query.yaml"}) @Step("{testCase.desc}") public void testSelect(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kBatch).run(); } @Story("request") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/select/","query/const_query.yaml"}) + @Yaml(filePaths = {"integration_test/select/","query/const_query.yaml"}) public void testSelectRequestMode(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequest).run(); } @Story("requestWithSp") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/select/","query/const_query.yaml"}) + @Yaml(filePaths = {"integration_test/select/","query/const_query.yaml"}) public void testSelectRequestModeWithSp(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSp).run(); } @Story("requestWithSpAysn") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/select/","query/const_query.yaml"}) + @Yaml(filePaths = {"integration_test/select/","query/const_query.yaml"}) public void testSelectRequestModeWithSpAysn(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSpAsync).run(); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/WindowTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/WindowTest.java index bf3003b1248..8b98ca4972b 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/WindowTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/sql_test/WindowTest.java @@ -36,33 +36,33 @@ public class WindowTest extends OpenMLDBTest { @Story("batch") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/window/", - "function/cluster/", - "function/test_index_optimized.yaml"}) + @Yaml(filePaths = {"integration_test/window/", + "integration_test/cluster/", + "integration_test/test_index_optimized.yaml"}) public void testWindowBatch(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kBatch).run(); } @Story("requestWithSp") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/window/", - "function/cluster/", - "function/test_index_optimized.yaml"}) + @Yaml(filePaths = {"integration_test/window/", + "integration_test/cluster/", + "integration_test/test_index_optimized.yaml"}) public void testWindowRequestMode(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequest).run(); } @Story("requestWithSp") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/window/", - "function/cluster/", - "function/test_index_optimized.yaml"}) + @Yaml(filePaths = {"integration_test/window/", + "integration_test/cluster/", + "integration_test/test_index_optimized.yaml"}) public void testWindowRequestModeWithSp(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSp).run(); } @Story("requestWithSpAysn") @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/window/", - "function/cluster/", - "function/test_index_optimized.yaml"}) + @Yaml(filePaths = {"integration_test/window/", + "integration_test/cluster/", + "integration_test/test_index_optimized.yaml"}) public void testWindowRequestModeWithSpAsync(SQLCase testCase) throws Exception { ExecutorFactory.build(executor, testCase, SQLCaseType.kRequestWithSpAsync).run(); } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/v050/LongWindowTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/v050/LongWindowTest.java deleted file mode 100644 index 7f6426141cc..00000000000 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/v050/LongWindowTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com._4paradigm.openmldb.java_sdk_test.cluster.v050; - -import com._4paradigm.openmldb.java_sdk_test.common.OpenMLDBTest; -import com._4paradigm.openmldb.java_sdk_test.executor.ExecutorFactory; -import com._4paradigm.openmldb.test_common.model.SQLCase; -import com._4paradigm.openmldb.test_common.model.SQLCaseType; -import com._4paradigm.openmldb.test_common.provider.Yaml; -import io.qameta.allure.Story; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.Test; - -@Slf4j -public class LongWindowTest extends OpenMLDBTest { - - - @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/long_window/long_window.yaml") - @Story("Out-In") - public void testLongWindow1(SQLCase testCase){ - ExecutorFactory.build(executor,testCase, SQLCaseType.kBatch).run(); - } - - @Test(dataProvider = "getCase") - @Yaml(filePaths = "function/long_window/long_window.yaml") - @Story("Out-In") - public void testLongWindow2(SQLCase testCase){ - ExecutorFactory.build(executor,testCase, SQLCaseType.kRequest).run(); - } -} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/v060/DMLTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/v060/DMLTest.java deleted file mode 100644 index 9c424dc0b1f..00000000000 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/cluster/v060/DMLTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2021 4Paradigm - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com._4paradigm.openmldb.java_sdk_test.cluster.v060; - - -import com._4paradigm.openmldb.java_sdk_test.common.OpenMLDBTest; -import com._4paradigm.openmldb.java_sdk_test.executor.ExecutorFactory; -import com._4paradigm.openmldb.test_common.model.SQLCase; -import com._4paradigm.openmldb.test_common.model.SQLCaseType; -import com._4paradigm.openmldb.test_common.provider.Yaml; -import io.qameta.allure.Feature; -import io.qameta.allure.Story; -import lombok.extern.slf4j.Slf4j; -import org.testng.annotations.Test; - -/** - * @author zhaowei - * @date 2020/6/11 2:53 PM - */ -@Slf4j -@Feature("DML") -public class DMLTest extends OpenMLDBTest { - - @Test(dataProvider = "getCase") - @Yaml(filePaths = {"function/dml/test_delete.yaml"}) - @Story("delete") - public void testDelete(SQLCase testCase){ - ExecutorFactory.build(executor,testCase, SQLCaseType.kDDL).run(); - } - - @Test(dataProvider = "getCase",enabled = false) - @Yaml(filePaths = {"function/dml/test_delete.yaml"}) - @Story("delete") - public void testDeleteByCli(SQLCase testCase){ - ExecutorFactory.build(testCase, SQLCaseType.kClusterCLI).run(); - } - - - -} diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/DiffResultTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/DiffResultTest.java index 9d181d3eaba..63832b3b85e 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/DiffResultTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/DiffResultTest.java @@ -16,7 +16,7 @@ package com._4paradigm.openmldb.java_sdk_test.diff_test; import com._4paradigm.openmldb.java_sdk_test.common.OpenMLDBTest; -import com._4paradigm.openmldb.java_sdk_test.entity.OpenMLDBCaseFileList; +import com._4paradigm.openmldb.test_common.model.OpenMLDBCaseFileList; import com._4paradigm.openmldb.java_sdk_test.executor.ExecutorFactory; import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.model.SQLCaseType; diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/MysqlTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/MysqlTest.java index 3515ec78641..9efa2b3eefb 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/MysqlTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/MysqlTest.java @@ -16,7 +16,7 @@ package com._4paradigm.openmldb.java_sdk_test.diff_test; import com._4paradigm.openmldb.java_sdk_test.common.JDBCTest; -import com._4paradigm.openmldb.java_sdk_test.entity.OpenMLDBCaseFileList; +import com._4paradigm.openmldb.test_common.model.OpenMLDBCaseFileList; import com._4paradigm.openmldb.java_sdk_test.executor.ExecutorFactory; import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.model.SQLCaseType; diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/Sqlite3Test.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/Sqlite3Test.java index 06a29d9cafd..38f503d2881 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/Sqlite3Test.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/diff_test/Sqlite3Test.java @@ -17,7 +17,7 @@ import com._4paradigm.openmldb.java_sdk_test.common.JDBCTest; -import com._4paradigm.openmldb.java_sdk_test.entity.OpenMLDBCaseFileList; +import com._4paradigm.openmldb.test_common.model.OpenMLDBCaseFileList; import com._4paradigm.openmldb.java_sdk_test.executor.ExecutorFactory; import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.model.SQLCaseType; diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/standalone/v030/DMLTest.java b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/standalone/v030/DMLTest.java index cef60cde89e..553d51172fe 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/standalone/v030/DMLTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/test/java/com/_4paradigm/openmldb/java_sdk_test/standalone/v030/DMLTest.java @@ -17,7 +17,7 @@ package com._4paradigm.openmldb.java_sdk_test.standalone.v030; -import com._4paradigm.openmldb.test_common.command.OpenMLDBComamndFacade; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFacade; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.openmldb.java_sdk_test.common.StandaloneTest; import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; @@ -67,7 +67,7 @@ public void testInsertMulti1000(){ " c8 date not null,\n" + " c9 bool not null,\n" + " index(key=(c1), ts=c5));"; - OpenMLDBComamndFacade.sql(OpenMLDBGlobalVar.mainInfo, OpenMLDBGlobalVar.dbName,createSql); + OpenMLDBCommandFacade.sql(OpenMLDBGlobalVar.mainInfo, OpenMLDBGlobalVar.dbName,createSql); StringBuilder sb = new StringBuilder("insert into auto_multi_insert_1000 values "); int total = 1000; for(int i=0;i - - - - - - - - - - - - \ No newline at end of file diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/test_suite/test_tmp.xml b/test/integration-test/openmldb-test-java/openmldb-sdk-test/test_suite/test_tmp.xml index 6eba18c1912..351aa6a4152 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/test_suite/test_tmp.xml +++ b/test/integration-test/openmldb-test-java/openmldb-sdk-test/test_suite/test_tmp.xml @@ -4,15 +4,18 @@ - - - - - - - - - + + + + + + + + + + + + diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/pom.xml b/test/integration-test/openmldb-test-java/openmldb-test-common/pom.xml index 90429813d43..88a3b1460e8 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/pom.xml +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/pom.xml @@ -15,8 +15,8 @@ 8 8 - 0.5.0-SNAPSHOT - 0.5.0-macos-SNAPSHOT + 0.6.0 + 0.6.0 @@ -30,11 +30,15 @@ com.4paradigm.openmldb openmldb-jdbc ${openmldb.jdbc.version} + + com.4paradigm.openmldb openmldb-native ${openmldb.navtive.version} + + diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/bean/OpenMLDBResult.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/bean/OpenMLDBResult.java index 022a1b80a80..533f1bdf1f0 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/bean/OpenMLDBResult.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/bean/OpenMLDBResult.java @@ -31,6 +31,7 @@ public class OpenMLDBResult { private String dbName; private List tableNames; + private String spName; private String sql; private boolean haveResult; private boolean ok; diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/CommandUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/CommandUtil.java index 708c64c8f8a..37ab3479935 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/CommandUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/CommandUtil.java @@ -19,7 +19,7 @@ public static List run(String command, int time, int count){ List result; do{ result = ExecutorUtil.run(command); - if((result.size()==0)||(result.size()==1&&result.get(0).equals("zk client init failed"))){ + if((result.size()==0)||(result.contains("zk client init failed"))){ num++; Tool.sleep(time); logger.info("command retry:"+num); diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBComamndFacade.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandFacade.java similarity index 75% rename from test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBComamndFacade.java rename to test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandFacade.java index 8bf190d2220..64988386add 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBComamndFacade.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandFacade.java @@ -26,21 +26,21 @@ import java.util.List; @Slf4j -public class OpenMLDBComamndFacade { - private static final Logger logger = new LogProxy(log); +public class OpenMLDBCommandFacade { +// private static final Logger logger = new LogProxy(log); public static OpenMLDBResult sql(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { - logger.info("sql:"+sql); + log.info("sql:"+sql); sql = StringUtils.replace(sql,"\n"," "); sql = sql.trim(); - OpenMLDBResult fesqlResult = SqlChainManager.of().sql(openMLDBInfo, dbName, sql); - logger.info("fesqlResult:"+fesqlResult); - return fesqlResult; + OpenMLDBResult openMLDBResult = SqlChainManager.of().sql(openMLDBInfo, dbName, sql); + log.info("openMLDBResult:"+openMLDBResult); + return openMLDBResult; } public static OpenMLDBResult sqls(OpenMLDBInfo openMLDBInfo, String dbName, List sqls) { - OpenMLDBResult fesqlResult = null; + OpenMLDBResult openMLDBResult = null; for(String sql:sqls){ - fesqlResult = sql(openMLDBInfo,dbName,sql); + openMLDBResult = sql(openMLDBInfo,dbName,sql); } - return fesqlResult; + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandUtil.java index 2282876cfc4..affcfd98c19 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/OpenMLDBCommandUtil.java @@ -19,7 +19,6 @@ import com._4paradigm.openmldb.test_common.common.LogProxy; import com._4paradigm.openmldb.test_common.model.InputDesc; import com._4paradigm.openmldb.test_common.model.SQLCase; -import com._4paradigm.openmldb.test_common.util.SDKUtil; import com._4paradigm.openmldb.test_common.util.SQLUtil; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; import lombok.extern.slf4j.Slf4j; @@ -36,14 +35,14 @@ public class OpenMLDBCommandUtil { public static OpenMLDBResult createDB(OpenMLDBInfo openMLDBInfo, String dbName) { String sql = String.format("create database %s ;",dbName); - OpenMLDBResult fesqlResult = OpenMLDBComamndFacade.sql(openMLDBInfo,dbName,sql); - return fesqlResult; + OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,sql); + return openMLDBResult; } public static OpenMLDBResult desc(OpenMLDBInfo openMLDBInfo, String dbName, String tableName) { String sql = String.format("desc %s ;",tableName); - OpenMLDBResult fesqlResult = OpenMLDBComamndFacade.sql(openMLDBInfo,dbName,sql); - return fesqlResult; + OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,sql); + return openMLDBResult; } public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String defaultDBName, List inputs) { @@ -61,7 +60,7 @@ public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String d } } } - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); if (inputs != null && inputs.size() > 0) { for (int i = 0; i < inputs.size(); i++) { InputDesc inputDesc = inputs.get(i); @@ -72,7 +71,7 @@ public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String d createSql = SQLCase.formatSql(createSql, i, tableName); createSql = SQLUtil.formatSql(createSql, openMLDBInfo); if (!createSql.isEmpty()) { - OpenMLDBResult res = OpenMLDBComamndFacade.sql(openMLDBInfo,dbName,createSql); + OpenMLDBResult res = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,createSql); if (!res.isOk()) { logger.error("fail to create table"); // reportLog.error("fail to create table"); @@ -84,7 +83,7 @@ public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String d for (String insertSql : inserts) { insertSql = SQLCase.formatSql(insertSql, i, input.getName()); if (!insertSql.isEmpty()) { - OpenMLDBResult res = OpenMLDBComamndFacade.sql(openMLDBInfo,dbName,insertSql); + OpenMLDBResult res = OpenMLDBCommandFacade.sql(openMLDBInfo,dbName,insertSql); if (!res.isOk()) { logger.error("fail to insert table"); // reportLog.error("fail to insert table"); @@ -94,7 +93,7 @@ public static OpenMLDBResult createAndInsert(OpenMLDBInfo openMLDBInfo, String d } } } - fesqlResult.setOk(true); - return fesqlResult; + openMLDBResult.setOk(true); + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DDLHandler.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DDLHandler.java index ad0c446e0e1..ca4956ba492 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DDLHandler.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DDLHandler.java @@ -34,16 +34,16 @@ public boolean preHandle(String sql) { @Override public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); List result = OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo,dbName,sql); - fesqlResult.setMsg(Joiner.on("\n").join(result)); - fesqlResult.setOk(CommandResultUtil.success(result)); - fesqlResult.setDbName(dbName); + openMLDBResult.setMsg(Joiner.on("\n").join(result)); + openMLDBResult.setOk(CommandResultUtil.success(result)); + openMLDBResult.setDbName(dbName); if(sql.toLowerCase().startsWith("create index")){ // TODO 希望有更好的解决方案 Tool.sleep(10000); } - return fesqlResult; + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DMLHandler.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DMLHandler.java index 5f402063d1f..6cff029319c 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DMLHandler.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DMLHandler.java @@ -32,12 +32,12 @@ public boolean preHandle(String sql) { @Override public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); List result = OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo,dbName,sql); - fesqlResult.setMsg(Joiner.on("\n").join(result)); - fesqlResult.setOk(CommandResultUtil.success(result)); - fesqlResult.setDbName(dbName); - return fesqlResult; + openMLDBResult.setMsg(Joiner.on("\n").join(result)); + openMLDBResult.setOk(CommandResultUtil.success(result)); + openMLDBResult.setDbName(dbName); + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DefaultHandler.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DefaultHandler.java new file mode 100644 index 00000000000..688bdab10fd --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DefaultHandler.java @@ -0,0 +1,51 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com._4paradigm.openmldb.test_common.command.chain; + + + +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFactory; +import com._4paradigm.openmldb.test_common.util.CommandResultUtil; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import com.google.common.base.Joiner; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class DefaultHandler extends AbstractSQLHandler{ + @Override + public boolean preHandle(String sql) { + return StringUtils.isNotEmpty(sql); + } + + @Override + public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); + List result = OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo,dbName,sql); + boolean ok = CommandResultUtil.success(result); + openMLDBResult.setMsg(Joiner.on("\n").join(result)); + openMLDBResult.setOk(ok); + openMLDBResult.setDbName(dbName); + if (ok) { + CommandResultUtil.parseResult(result,openMLDBResult); + } + return openMLDBResult; + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DescHandler.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DescHandler.java index 080579f79d2..b3a1c438d04 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DescHandler.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/DescHandler.java @@ -33,15 +33,15 @@ public boolean preHandle(String sql) { @Override public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); List result = OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo,dbName,sql); boolean ok = CommandResultUtil.success(result); - fesqlResult.setMsg(Joiner.on("\n").join(result)); - fesqlResult.setOk(ok); - fesqlResult.setDbName(dbName); + openMLDBResult.setMsg(Joiner.on("\n").join(result)); + openMLDBResult.setOk(ok); + openMLDBResult.setDbName(dbName); if (ok) { - fesqlResult.setSchema(CommandResultUtil.parseSchema(result)); + openMLDBResult.setSchema(CommandResultUtil.parseSchema(result)); } - return fesqlResult; + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/QueryHandler.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/QueryHandler.java index 6496e1621e9..cc6b4bf50f4 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/QueryHandler.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/QueryHandler.java @@ -36,12 +36,12 @@ public boolean preHandle(String sql) { @Override public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); List result = OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo,dbName,sql); boolean ok = CommandResultUtil.success(result); - fesqlResult.setMsg(Joiner.on("\n").join(result)); - fesqlResult.setOk(ok); - fesqlResult.setDbName(dbName); + openMLDBResult.setMsg(Joiner.on("\n").join(result)); + openMLDBResult.setOk(ok); + openMLDBResult.setDbName(dbName); if (ok) { int count = 0; List> rows = new ArrayList<>(); @@ -52,11 +52,11 @@ public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String List row = Arrays.asList(result.get(i).split("\\s+")); rows.add(row); } - fesqlResult.setColumnNames(columnNames); + openMLDBResult.setColumnNames(columnNames); } - fesqlResult.setCount(count); - fesqlResult.setResult(rows); + openMLDBResult.setCount(count); + openMLDBResult.setResult(rows); } - return fesqlResult; + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowDeploymentHandler.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowDeploymentHandler.java index 7740138a2df..090715c8e89 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowDeploymentHandler.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowDeploymentHandler.java @@ -34,15 +34,15 @@ public boolean preHandle(String sql) { @Override public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); List result = OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo,dbName,sql); boolean ok = CommandResultUtil.success(result); - fesqlResult.setMsg(Joiner.on("\n").join(result)); - fesqlResult.setOk(ok); - fesqlResult.setDbName(dbName); + openMLDBResult.setMsg(Joiner.on("\n").join(result)); + openMLDBResult.setOk(ok); + openMLDBResult.setDbName(dbName); if (ok && result.size()>9) { - fesqlResult.setDeployment(CommandResultUtil.parseDeployment(result)); + openMLDBResult.setDeployment(CommandResultUtil.parseDeployment(result)); } - return fesqlResult; + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowDeploymentsHandler.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowDeploymentsHandler.java index 1c6c481fe40..d2b589ffb46 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowDeploymentsHandler.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowDeploymentsHandler.java @@ -35,17 +35,17 @@ public boolean preHandle(String sql) { @Override public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); List result = OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo,dbName,sql); boolean ok = CommandResultUtil.success(result); - fesqlResult.setMsg(Joiner.on("\n").join(result)); - fesqlResult.setOk(ok); - fesqlResult.setDbName(dbName); + openMLDBResult.setMsg(Joiner.on("\n").join(result)); + openMLDBResult.setOk(ok); + openMLDBResult.setDbName(dbName); if (ok && result.size()>3) { - fesqlResult.setDeployments(CommandResultUtil.parseDeployments(result)); + openMLDBResult.setDeployments(CommandResultUtil.parseDeployments(result)); }else if(result.get(0).equals("Empty set")){ - fesqlResult.setDeployments(Lists.newArrayList()); + openMLDBResult.setDeployments(Lists.newArrayList()); } - return fesqlResult; + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowTableStatusHandler.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowTableStatusHandler.java new file mode 100644 index 00000000000..f09844af096 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/ShowTableStatusHandler.java @@ -0,0 +1,47 @@ +/* + * Copyright 2021 4Paradigm + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com._4paradigm.openmldb.test_common.command.chain; + + + +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFactory; +import com._4paradigm.openmldb.test_common.util.CommandResultUtil; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import com.google.common.base.Joiner; + +import java.util.List; + +public class ShowTableStatusHandler extends AbstractSQLHandler{ + @Override + public boolean preHandle(String sql) { + return sql.toLowerCase().startsWith("show table status"); + } + + @Override + public OpenMLDBResult onHandle(OpenMLDBInfo openMLDBInfo, String dbName, String sql) { + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); + List result = OpenMLDBCommandFactory.runNoInteractive(openMLDBInfo,dbName,sql); + boolean ok = CommandResultUtil.success(result); + openMLDBResult.setMsg(Joiner.on("\n").join(result)); + openMLDBResult.setOk(ok); + openMLDBResult.setDbName(dbName); + if (ok) { + CommandResultUtil.parseResult(result,openMLDBResult); + } + return openMLDBResult; + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/SqlChainManager.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/SqlChainManager.java index 50aa40d8ebe..a0599069d86 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/SqlChainManager.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/command/chain/SqlChainManager.java @@ -32,11 +32,15 @@ private AbstractSQLHandler initHandler(){ DescHandler descHandler = new DescHandler(); ShowDeploymentHandler showDeploymentHandler = new ShowDeploymentHandler(); ShowDeploymentsHandler showDeploymentsHandler = new ShowDeploymentsHandler(); + ShowTableStatusHandler showTableStatusHandler = new ShowTableStatusHandler(); + DefaultHandler defaultHandler = new DefaultHandler(); queryHandler.setNextHandler(dmlHandler); dmlHandler.setNextHandler(ddlHandler); ddlHandler.setNextHandler(descHandler); descHandler.setNextHandler(showDeploymentHandler); showDeploymentHandler.setNextHandler(showDeploymentsHandler); + showDeploymentsHandler.setNextHandler(showTableStatusHandler); + showTableStatusHandler.setNextHandler(defaultHandler); return queryHandler; } @@ -48,7 +52,7 @@ public static SqlChainManager of() { return ClassHolder.holder; } public OpenMLDBResult sql(OpenMLDBInfo openMLDBInfo, String dbName, String sql){ - OpenMLDBResult fesqlResult = sqlHandler.doHandle(openMLDBInfo, dbName, sql); - return fesqlResult; + OpenMLDBResult openMLDBResult = sqlHandler.doHandle(openMLDBInfo, dbName, sql); + return openMLDBResult; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/BaseTest.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseTest.java similarity index 82% rename from test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/BaseTest.java rename to test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseTest.java index da0050fb919..bbf084faebb 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/common/BaseTest.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/BaseTest.java @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com._4paradigm.openmldb.java_sdk_test.common; +package com._4paradigm.openmldb.test_common.common; -import com._4paradigm.openmldb.java_sdk_test.entity.OpenMLDBCaseFileList; -import com._4paradigm.openmldb.test_common.common.LogProxy; -import com._4paradigm.openmldb.test_common.common.ReportLog; import com._4paradigm.openmldb.test_common.model.CaseFile; +import com._4paradigm.openmldb.test_common.model.OpenMLDBCaseFileList; import com._4paradigm.openmldb.test_common.model.SQLCase; import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.openmldb.test_common.provider.Yaml; @@ -39,7 +37,7 @@ */ @Slf4j public class BaseTest implements ITest { - protected static final Logger logger = new LogProxy(log); +// protected static final Logger logger = new LogProxy(log); private ThreadLocal testName = new ThreadLocal<>(); private int testNum = 0; @@ -56,7 +54,7 @@ public Object[] getCaseByYaml(Method method) throws FileNotFoundException { } OpenMLDBCaseFileList dp = OpenMLDBCaseFileList.dataProviderGenerator(casePaths); Object[] caseArray = dp.getCases().toArray(); - logger.info("caseArray.length:{}",caseArray.length); + log.info("caseArray.length:{}",caseArray.length); return caseArray; } @@ -65,11 +63,14 @@ public void BeforeMethod(Method method, Object[] testData) { ReportLog.of().clean(); if(testData==null || testData.length==0) return; Assert.assertNotNull( - testData[0], "fail to run fesql test with null SQLCase: check yaml case"); + testData[0], "fail to run openmldb test with null SQLCase: check yaml case"); if (testData[0] instanceof SQLCase) { SQLCase sqlCase = (SQLCase) testData[0]; + System.out.println("AAAAAA"); + log.info(sqlCase.getDesc()); + System.out.println(sqlCase.getDesc()); Assert.assertNotEquals(CaseFile.FAIL_SQL_CASE, - sqlCase.getDesc(), "fail to run fesql test with FAIL DATA PROVIDER SQLCase: check yaml case"); + sqlCase.getDesc(), "fail to run openmldb test with FAIL DATA PROVIDER SQLCase: check yaml case"); testName.set(String.format("[%d]%s.%s", testNum, method.getName(), CaseNameFormat(sqlCase))); } else { testName.set(String.format("[%d]%s.%s", testNum, method.getName(), null == testData[0] ? "null" : testData[0].toString())); diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/Condition.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/Condition.java index a755976d457..356330ae85c 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/Condition.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/Condition.java @@ -3,6 +3,7 @@ /** * Created by zhangguanglin on 2020/1/16. */ +@FunctionalInterface public interface Condition { Boolean execute(); } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/ConditionResult.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/ConditionResult.java new file mode 100644 index 00000000000..811840b6a1a --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/common/ConditionResult.java @@ -0,0 +1,11 @@ +package com._4paradigm.openmldb.test_common.common; + +import org.apache.commons.lang3.tuple.Pair; + +/** + * Created by zhangguanglin on 2020/1/16. + */ +@FunctionalInterface +public interface ConditionResult { + Pair execute(); +} diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/CaseFile.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/CaseFile.java index c79a5e1f767..d327211b0da 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/CaseFile.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/CaseFile.java @@ -224,12 +224,14 @@ private List generateCaseByDataProvider(SQLCase sqlCase, List d String order = expectDesc.getOrder(); List columns = expectDesc.getColumns(); List> rows = expectDesc.getRows(); + PreAggTable preAgg = expectDesc.getPreAgg(); int count = expectDesc.getCount(); if (success == false) newExpectDesc.setSuccess(success); if (count > 0) newExpectDesc.setCount(count); if (CollectionUtils.isNotEmpty(columns)) newExpectDesc.setColumns(columns); if (StringUtils.isNotEmpty(order)) newExpectDesc.setOrder(order); if (CollectionUtils.isNotEmpty(rows)) newExpectDesc.setRows(rows); + if(preAgg != null) newExpectDesc.setPreAgg(preAgg); } } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/ExpectDesc.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/ExpectDesc.java index bb6a0e08b3c..83f873d2d97 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/ExpectDesc.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/ExpectDesc.java @@ -35,4 +35,6 @@ public class ExpectDesc extends Table { private List diffTables; private CatFile cat; private String msg; + private PreAggTable preAgg; + private List preAggList; } diff --git a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenMLDBCaseFileList.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/OpenMLDBCaseFileList.java similarity index 57% rename from test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenMLDBCaseFileList.java rename to test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/OpenMLDBCaseFileList.java index 4707852dd60..6e52621cbdc 100644 --- a/test/integration-test/openmldb-test-java/openmldb-sdk-test/src/main/java/com/_4paradigm/openmldb/java_sdk_test/entity/OpenMLDBCaseFileList.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/OpenMLDBCaseFileList.java @@ -14,13 +14,11 @@ * limitations under the License. */ -package com._4paradigm.openmldb.java_sdk_test.entity; +package com._4paradigm.openmldb.test_common.model; -import com._4paradigm.openmldb.java_sdk_test.common.BaseTest; -import com._4paradigm.openmldb.java_sdk_test.common.OpenMLDBConfig; -import com._4paradigm.openmldb.test_common.model.CaseFile; -import com._4paradigm.openmldb.test_common.model.SQLCase; +import com._4paradigm.openmldb.test_common.common.BaseTest; +import com._4paradigm.openmldb.test_common.openmldb.OpenMLDBGlobalVar; import com._4paradigm.openmldb.test_common.util.Tool; import org.apache.commons.lang3.StringUtils; @@ -36,17 +34,17 @@ public List getCases() { List cases = new ArrayList(); for (CaseFile dataProvider : dataProviderList) { - for (SQLCase sqlCase : dataProvider.getCases(OpenMLDBConfig.FESQL_CASE_LEVELS)) { - if (!StringUtils.isEmpty(OpenMLDBConfig.FESQL_CASE_NAME) && - !OpenMLDBConfig.FESQL_CASE_NAME.equals(BaseTest.CaseNameFormat(sqlCase))) { + for (SQLCase sqlCase : dataProvider.getCases(OpenMLDBGlobalVar.CASE_LEVELS)) { + if (!StringUtils.isEmpty(OpenMLDBGlobalVar.CASE_NAME) && + !OpenMLDBGlobalVar.CASE_NAME.equals(BaseTest.CaseNameFormat(sqlCase))) { continue; } - if (!StringUtils.isEmpty(OpenMLDBConfig.FESQL_CASE_ID) - && !OpenMLDBConfig.FESQL_CASE_ID.equals(sqlCase.getId())) { + if (!StringUtils.isEmpty(OpenMLDBGlobalVar.CASE_ID) + && !OpenMLDBGlobalVar.CASE_ID.equals(sqlCase.getId())) { continue; } - if (!StringUtils.isEmpty(OpenMLDBConfig.FESQL_CASE_DESC) - && !OpenMLDBConfig.FESQL_CASE_DESC.equals(sqlCase.getDesc())) { + if (!StringUtils.isEmpty(OpenMLDBGlobalVar.CASE_DESC) + && !OpenMLDBGlobalVar.CASE_DESC.equals(sqlCase.getDesc())) { continue; } cases.add(sqlCase); @@ -57,27 +55,27 @@ public List getCases() { public static OpenMLDBCaseFileList dataProviderGenerator(String[] caseFiles) throws FileNotFoundException { - OpenMLDBCaseFileList fesqlDataProviderList = new OpenMLDBCaseFileList(); + OpenMLDBCaseFileList openMLDBCaseFileList = new OpenMLDBCaseFileList(); for (String caseFile : caseFiles) { - if (!StringUtils.isEmpty(OpenMLDBConfig.FESQL_CASE_PATH) - && !OpenMLDBConfig.FESQL_CASE_PATH.equals(caseFile)) { + if (!StringUtils.isEmpty(OpenMLDBGlobalVar.CASE_PATH) + && !OpenMLDBGlobalVar.CASE_PATH.equals(caseFile)) { continue; } - String casePath = Tool.getCasePath(OpenMLDBConfig.YAML_CASE_BASE_DIR, caseFile); + String casePath = Tool.getCasePath(OpenMLDBGlobalVar.YAML_CASE_BASE_DIR, caseFile); File file = new File(casePath); if (!file.exists()) { continue; } if (file.isFile()) { - fesqlDataProviderList.dataProviderList.add(CaseFile.parseCaseFile(casePath)); + openMLDBCaseFileList.dataProviderList.add(CaseFile.parseCaseFile(casePath)); } else { File[] files = file.listFiles(f -> f.getName().endsWith(".yaml")); for (File f : files) { - fesqlDataProviderList.dataProviderList.add(CaseFile.parseCaseFile(f.getAbsolutePath())); + openMLDBCaseFileList.dataProviderList.add(CaseFile.parseCaseFile(f.getAbsolutePath())); } } } - return fesqlDataProviderList; + return openMLDBCaseFileList; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/PreAggTable.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/PreAggTable.java new file mode 100644 index 00000000000..0f896f391d9 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/PreAggTable.java @@ -0,0 +1,14 @@ +package com._4paradigm.openmldb.test_common.model; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class PreAggTable implements Serializable { + private String name; + private String type; + private int count = -1; + private List> rows; +} diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/SQLCase.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/SQLCase.java index 1761e289210..6957a284074 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/SQLCase.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/SQLCase.java @@ -33,8 +33,10 @@ public class SQLCase implements Serializable{ private String id; private String desc; private String mode; + private String json; private String db; private String version; + private String longWindow; private String sql; private List> dataProvider; private List sqls; @@ -58,6 +60,7 @@ public class SQLCase implements Serializable{ private List tearDown; private List excludes; private String only; + private List steps; public static String formatSql(String sql, int idx, String name) { return sql.replaceAll("\\{" + idx + "\\}", name); @@ -93,7 +96,7 @@ public boolean isSupportDiskTable(){ return false; } for(InputDesc input:inputs){ - if (CollectionUtils.isNotEmpty(input.getColumns())&& StringUtils.isEmpty(input.getCreate())) { + if (CollectionUtils.isNotEmpty(input.getColumns())&& StringUtils.isEmpty(input.getCreate())&&StringUtils.isEmpty(input.getStorage())) { return true; } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/SQLCaseType.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/SQLCaseType.java index e5828e35169..3b2193f5177 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/SQLCaseType.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/model/SQLCaseType.java @@ -43,7 +43,8 @@ public enum SQLCaseType { kStandaloneCLI("StandaloneCLI"), kClusterCLI("ClusterCLI"), kInsertPrepared("INSERT_PREPARED"), - kSelectPrepared("SELECT_PREPARED") + kSelectPrepared("SELECT_PREPARED"), + kLongWindow("LONG_WINDOW_DEPLOY") ; @Getter private String typeName; diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/CliClient.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/CliClient.java new file mode 100644 index 00000000000..f1590b7ca30 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/CliClient.java @@ -0,0 +1,79 @@ +package com._4paradigm.openmldb.test_common.openmldb; + +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; +import com._4paradigm.openmldb.test_common.command.OpenMLDBCommandFacade; +import com._4paradigm.openmldb.test_common.util.*; +import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import lombok.extern.slf4j.Slf4j; +import org.testng.collections.Lists; + +import java.util.*; + +@Slf4j +public class CliClient { + private OpenMLDBInfo openMLDBInfo; + private String dbName; + + private CliClient(OpenMLDBInfo openMLDBInfo,String dbName){ + this.openMLDBInfo = openMLDBInfo; + this.dbName = dbName; + } + public static CliClient of(OpenMLDBInfo openMLDBInfo,String dbName){ + return new CliClient(openMLDBInfo,dbName); + } + public void create(String dbName){ + List sqlList = new ArrayList<>(); + if (!dbIsExist(dbName)) { + sqlList.add(String.format("create database %s;", dbName)); + } + OpenMLDBCommandFacade.sqls(openMLDBInfo, dbName, sqlList); + } + + public boolean dbIsExist(String dbName){ + String sql = "show databases;"; + try { + OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo, dbName, sql); + List> rows = openMLDBResult.getResult(); + for(List row:rows){ + if(row.get(0).equals(dbName)){ + return true; + } + } + return false; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + public OpenMLDBResult execute(String sql) { + OpenMLDBResult openMLDBResult = OpenMLDBCommandFacade.sql(openMLDBInfo, dbName, sql); + openMLDBResult.setSql(sql);; + return openMLDBResult; + } + public OpenMLDBResult execute(List sqlList) { + OpenMLDBResult openMLDBResult = null; + for(String sql:sqlList){ + openMLDBResult = execute(sql); + } + return openMLDBResult; + } + public void insert(String tableName,List list){ + List> dataList = new ArrayList<>(); + dataList.add(list); + insertList(tableName,dataList); + } + public void insertList(String tableName,List> dataList){ + String sql = SQLUtil.genInsertSQL(tableName,dataList); + execute(sql); + } + public void setGlobalOnline(){ + String sql = "set @@global.execute_mode='online';"; + execute(sql); + } + public Map> showTableStatus(){ + OpenMLDBResult openMLDBResult = execute("show table status;"); + List> result = openMLDBResult.getResult(); + Map> map = new HashMap<>(); + result.forEach(l->map.put(String.valueOf(l.get(1)), Lists.newArrayList(Long.parseLong(String.valueOf(l.get(4)))))); + return map; + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/NsClient.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/NsClient.java index 8b492c3db09..4b2b8db60e1 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/NsClient.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/NsClient.java @@ -7,6 +7,7 @@ import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; import org.testng.Assert; import java.util.*; @@ -57,11 +58,41 @@ public void checkOPStatusDone(String dbName,String tableName){ }); Assert.assertTrue(b,"check op done failed."); } + public List showTableHaveTable(String dbName,String tableName){ + String command = StringUtils.isNotEmpty(tableName) ?"showtable "+tableName:"showtable"; + String nsCommand = genNsCommand(dbName,command); + Tool.sleep(10*1000); + List result = WaitUtil.waitCondition(() -> { + List lines = CommandUtil.run(nsCommand); + if (lines.size() <= 2) { + return Pair.of(false, lines); + } + return Pair.of(true, lines); + }); + return result; + } public List showTable(String dbName,String tableName){ String command = StringUtils.isNotEmpty(tableName) ?"showtable "+tableName:"showtable"; List lines = runNs(dbName,command); return lines; } + public long getTableCount(String dbName, String tableName){ + List lines = showTableHaveTable(dbName,tableName); + long count = 0; + for(int i=2;i lines = showTable(dbName,tableName); @@ -174,4 +205,30 @@ public Map> getTableEndPoint(String dbName,String tableName return map; } + public Map> getTableOffset(String dbName){ + List lines = showTableHaveTable(dbName,null); + Map> offsets = new HashMap<>(); + for(int i=2;i value = offsets.get(key); + String role = infos[4]; + long offset = 0; + String offsetStr = infos[7].trim(); + if(!offsetStr.equals("-")&&!offsetStr.equals("")){ + offset = Long.parseLong(offsetStr); + } + if(value==null){ + value = new ArrayList<>(); + offsets.put(key,value); + } + if(role.equals("leader")){ + value.add(0,offset); + }else { + value.add(offset); + } + } + return offsets; + } + } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/OpenMLDBDevops.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/OpenMLDBDevops.java index a9034d576db..1c58bc3b0ce 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/OpenMLDBDevops.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/OpenMLDBDevops.java @@ -1,14 +1,15 @@ package com._4paradigm.openmldb.test_common.openmldb; -import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import com._4paradigm.qa.openmldb_deploy.common.OpenMLDBDeploy; import com._4paradigm.qa.openmldb_deploy.util.Tool; import com._4paradigm.test_tool.command_tool.common.ExecutorUtil; +import lombok.extern.slf4j.Slf4j; import org.testng.Assert; import java.util.List; -import java.util.stream.Collectors; +@Slf4j public class OpenMLDBDevops { private OpenMLDBInfo openMLDBInfo; private String dbName; @@ -37,6 +38,20 @@ public void operateTablet(int tabletIndex,String operator){ nsClient.checkTableIsAlive(dbName, null); } } + public void operateStandalone(String operator){ + String command = ""; + switch (operator){ + case "start": + command = String.format("sh %s/openmldb-standalone/bin/start-standalone.sh",basePath); + break; + case "stop": + command = String.format("sh %s/openmldb-standalone/bin/stop-standalone.sh",basePath); + break; + } + ExecutorUtil.run(command); + Tool.sleep(5*1000); + + } public void operateTablet(String operator){ int size = openMLDBInfo.getTabletEndpoints().size(); for(int i=0;i result = ExecutorUtil.run(command); + Assert.assertEquals(result.get(0),"conf-back"); + command = "cp -rf "+path +"/bin "+path+"/bin-back"; + ExecutorUtil.run(command); + command = "ls "+path+" | grep bin-back"; + result = ExecutorUtil.run(command); + Assert.assertEquals(result.get(0),"bin-back"); + } + public static void backDirectory(String path){ + if(path.endsWith("/")){ + path = path.substring(0,path.length()-1); + } + String directoryName = path.substring(path.lastIndexOf("/")+1); + String parentName = path.substring(0,path.lastIndexOf("/")); + String command = "cp -rf "+path +" "+path+"-back"; + ExecutorUtil.run(command); + command = "ls "+parentName+" | grep "+directoryName+"-back"; + List result = ExecutorUtil.run(command); + Assert.assertEquals(result.get(0),directoryName+"-back"); + } + public static void cpBin(String path, String binPath){ + String command = "rm -rf "+path+"/bin/"; + List result = ExecutorUtil.run(command); + Assert.assertEquals(result.size(),0); + command = "cp -rf "+binPath+" "+path; + result = ExecutorUtil.run(command); + Assert.assertEquals(result.size(),0); + } + public static void cpConf(String path,String confPath){ + String command = "rm -rf "+path+"/conf"; + List result = ExecutorUtil.run(command); + Assert.assertEquals(result.size(),0); + command = "cp -rf "+confPath+" "+path; + result = ExecutorUtil.run(command); + Assert.assertEquals(result.size(),0); + } + public static void modifyNsConf(String nsPath,String ip_port,String zk_endpoint){ + String[] commands = { + "sed -i 's#--endpoint=.*#--endpoint="+ip_port+"#' "+nsPath+"/conf/nameserver.flags", + "sed -i 's#--zk_cluster=.*#--zk_cluster=" + zk_endpoint + "#' " + nsPath + "/conf/nameserver.flags", + "sed -i 's@--zk_root_path=.*@--zk_root_path=/openmldb@' "+nsPath+"/conf/nameserver.flags", + "sed -i 's@#--zk_cluster=.*@--zk_cluster=" + zk_endpoint + "@' " + nsPath + "/conf/nameserver.flags", + "sed -i 's@#--zk_root_path=.*@--zk_root_path=/openmldb@' "+nsPath+"/conf/nameserver.flags", + "sed -i 's@--tablet=.*@#--tablet=127.0.0.1:9921@' "+nsPath+"/conf/nameserver.flags" + }; + for(String command:commands){ + ExecutorUtil.run(command); + } + } + public static void modifyTabletConf(String tabletPath,String ip_port,String zk_endpoint){ + String[] commands = { + "sed -i 's#--endpoint=.*#--endpoint="+ip_port+"#' "+tabletPath+"/conf/tablet.flags", + "sed -i 's/--zk_cluster=.*/--zk_cluster="+zk_endpoint+"/' "+tabletPath+"/conf/tablet.flags", + "sed -i 's@--zk_root_path=.*@--zk_root_path=/openmldb@' "+tabletPath+"/conf/tablet.flags", + "sed -i 's@#--zk_cluster=.*@--zk_cluster="+zk_endpoint+"@' "+tabletPath+"/conf/tablet.flags", + "sed -i 's@#--zk_root_path=.*@--zk_root_path=/openmldb@' "+tabletPath+"/conf/tablet.flags", + "sed -i 's@#--make_snapshot_threshold_offset=100000@--make_snapshot_threshold_offset=10@' "+tabletPath+"/conf/tablet.flags", + "sed -i 's@--gc_interval=60@--gc_interval=1@' "+tabletPath+"/conf/tablet.flags", + "echo '--hdd_root_path=./db_hdd' >> "+tabletPath+"/conf/tablet.flags", + "echo '--recycle_bin_hdd_root_path=./recycle_hdd' >> "+tabletPath+"/conf/tablet.flags", + "echo '--ssd_root_path=./db_ssd' >> "+tabletPath+"/conf/tablet.flags", + "echo '--recycle_bin_ssd_root_path=./recycle_ssd' >> "+tabletPath+"/conf/tablet.flags" + }; + for(String command:commands){ + ExecutorUtil.run(command); + } + } + public static void modifyApiServerConf(String apiServerPath,String ip_port,String zk_endpoint){ + String[] commands = { + "sed -i 's#--endpoint=.*#--endpoint="+ip_port+"#' "+apiServerPath+"/conf/apiserver.flags", + "sed -i 's/--zk_cluster=.*/--zk_cluster="+zk_endpoint+"/' "+apiServerPath+"/conf/apiserver.flags", + "sed -i 's@--zk_root_path=.*@--zk_root_path=/openmldb@' "+apiServerPath+"/conf/apiserver.flags", + "sed -i 's@#--zk_cluster=.*@--zk_cluster="+zk_endpoint+"@' "+apiServerPath+"/conf/apiserver.flags", + "sed -i 's@#--zk_root_path=.*@--zk_root_path=/openmldb@' "+apiServerPath+"/conf/apiserver.flags", + "sed -i 's@--nameserver=.*@#--nameserver=127.0.0.1:6527@' "+apiServerPath+"/conf/apiserver.flags" + }; + for(String command:commands){ + ExecutorUtil.run(command); + } + } + public static void modifyTaskManagerConf(String taskManagerPath,String ip_port,String zk_endpoint,String sparkHome){ + String[] ss = ip_port.split(":"); + String ip = ss[0]; + String port = ss[1]; + String sparkMaster = "local"; + String batchJobName = ExecutorUtil.run("ls " + taskManagerPath + "/taskmanager/lib | grep openmldb-batchjob").get(0); + String batchJobJarPath = taskManagerPath + "/taskmanager/lib/" + batchJobName; + String[] commands = { + "sed -i 's#server.host=.*#server.host=" + ip + "#' " + taskManagerPath + "/conf/taskmanager.properties", + "sed -i 's#server.port=.*#server.port=" + port + "#' " + taskManagerPath+ "/conf/taskmanager.properties", + "sed -i 's#zookeeper.cluster=.*#zookeeper.cluster=" + zk_endpoint + "#' " + taskManagerPath + "/conf/taskmanager.properties", + "sed -i 's@zookeeper.root_path=.*@zookeeper.root_path=/openmldb@' "+taskManagerPath+ "/conf/taskmanager.properties", + "sed -i 's@spark.master=.*@spark.master=" + sparkMaster + "@' "+taskManagerPath+ "/conf/taskmanager.properties", + "sed -i 's@spark.home=.*@spark.home=" + sparkHome + "@' "+taskManagerPath+ "/conf/taskmanager.properties", + "sed -i 's@batchjob.jar.path=.*@batchjob.jar.path=" + batchJobJarPath + "@' "+taskManagerPath+ "/conf/taskmanager.properties", +// "sed -i 's@spark.yarn.jars=.*@spark.yarn.jars=" + sparkYarnJars + "@' "+taskManagerPath+ "/conf/taskmanager.properties", +// "sed -i 's@offline.data.prefix=.*@offline.data.prefix=" + offlineDataPrefix + "@' "+taskManagerPath+ "/conf/taskmanager.properties", +// "sed -i 's@namenode.uri=.*@namenode.uri=" + nameNodeUri + "@' "+taskManagerPath+ "/conf/taskmanager.properties" + }; + for(String command:commands){ + ExecutorUtil.run(command); + } + } + public static void modifyStandaloneConf(String standalonePath,String nsEndpoint,String tabletEndpoint,String apiServerEndpoint){ + String[] commands = { + "sed -i 's@--zk_cluster=.*@#--zk_cluster=127.0.0.1:2181@' " + standalonePath + "/conf/standalone_nameserver.flags", + "sed -i 's@--zk_root_path=.*@#--zk_root_path=/openmldb@' "+standalonePath+"/conf/standalone_nameserver.flags", + "sed -i 's#--endpoint=.*#--endpoint=" + nsEndpoint + "#' " + standalonePath + "/conf/standalone_nameserver.flags", + "sed -i 's@#--tablet=.*@--tablet=" + tabletEndpoint + "@' " + standalonePath + "/conf/standalone_nameserver.flags", + "sed -i 's@--tablet=.*@--tablet=" + tabletEndpoint + "@' " + standalonePath + "/conf/standalone_nameserver.flags", + "sed -i 's@--zk_cluster=.*@#--zk_cluster=127.0.0.1:2181@' " + standalonePath + "/conf/standalone_tablet.flags", + "sed -i 's@--zk_root_path=.*@#--zk_root_path=/openmldb@' "+standalonePath+"/conf/standalone_tablet.flags", + "sed -i 's#--endpoint=.*#--endpoint=" + tabletEndpoint + "#' " + standalonePath + "/conf/standalone_tablet.flags", + "echo -e '\n--hdd_root_path=./db_hdd' >> "+standalonePath+"/conf/standalone_tablet.flags", + "echo '--recycle_bin_hdd_root_path=./recycle_hdd' >> "+standalonePath+"/conf/standalone_tablet.flags", + "echo '--ssd_root_path=./db_ssd' >> "+standalonePath+"/conf/standalone_tablet.flags", + "echo '--recycle_bin_ssd_root_path=./recycle_ssd' >> "+standalonePath+"/conf/standalone_tablet.flags", + "sed -i 's@--zk_cluster=.*@#--zk_cluster=127.0.0.1:2181@' "+standalonePath+"/conf/standalone_apiserver.flags", + "sed -i 's@--zk_root_path=.*@#--zk_root_path=/openmldb@' "+standalonePath+"/conf/standalone_apiserver.flags", + "sed -i 's#--endpoint=.*#--endpoint="+apiServerEndpoint+"#' "+standalonePath+"/conf/standalone_apiserver.flags", + "sed -i 's#--nameserver=.*#--nameserver="+nsEndpoint+"#' "+standalonePath+"/conf/standalone_apiserver.flags" + }; + for(String command:commands){ + ExecutorUtil.run(command); + } + } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/OpenMLDBGlobalVar.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/OpenMLDBGlobalVar.java index 767f6009b45..a285b3750c1 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/OpenMLDBGlobalVar.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/OpenMLDBGlobalVar.java @@ -17,12 +17,22 @@ package com._4paradigm.openmldb.test_common.openmldb; +import com._4paradigm.openmldb.test_common.util.Tool; import com._4paradigm.qa.openmldb_deploy.bean.OpenMLDBInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.testng.collections.Lists; + +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.stream.Collectors; /** * @author zhaowei * @date 2020/6/11 11:45 AM */ +@Slf4j public class OpenMLDBGlobalVar { public static String env; public static String level; @@ -31,4 +41,44 @@ public class OpenMLDBGlobalVar { public static OpenMLDBInfo mainInfo; public static String dbName = "test_zw"; public static String tableStorageMode = "memory"; + public static final List CASE_LEVELS; + public static final String CASE_NAME; + public static final String CASE_ID; + public static final String CASE_DESC; + public static final String CASE_PATH; + public static final String YAML_CASE_BASE_DIR; + + public static final Properties CONFIG = Tool.getProperties("run_case.properties"); + + static { + String levelStr = System.getProperty("caseLevel"); + levelStr = StringUtils.isEmpty(levelStr) ? "0" : levelStr; + CASE_LEVELS = Arrays.stream(levelStr.split(",")).map(Integer::parseInt).collect(Collectors.toList()); + CASE_NAME = System.getProperty("caseName"); + CASE_ID = System.getProperty("caseId"); + CASE_DESC = System.getProperty("caseDesc"); + CASE_PATH = System.getProperty("casePath"); + YAML_CASE_BASE_DIR = System.getProperty("yamlCaseBaseDir"); + log.info("CASE_LEVELS {}", CASE_LEVELS); + if (!StringUtils.isEmpty(CASE_NAME)) { + log.info("CASE_NAME {}", CASE_NAME); + } + if (!StringUtils.isEmpty(CASE_ID)) { + log.info("CASE_ID {}", CASE_ID); + } + if (!StringUtils.isEmpty(CASE_PATH)) { + log.info("CASE_PATH {}", CASE_PATH); + } + if (!StringUtils.isEmpty(CASE_DESC)) { + log.info("CASE_DESC {}", CASE_DESC); + } + if (!StringUtils.isEmpty(YAML_CASE_BASE_DIR)) { + log.info("YAML_CASE_BASE_DIR {}", YAML_CASE_BASE_DIR); + } + String tableStorageMode = CONFIG.getProperty("table_storage_mode"); + if(StringUtils.isNotEmpty(tableStorageMode)){ + OpenMLDBGlobalVar.tableStorageMode = tableStorageMode; + } + log.info("test tableStorageMode: {}", OpenMLDBGlobalVar.tableStorageMode); + } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/SDKClient.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/SDKClient.java index 22e6f6cd44f..7bb7d644880 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/SDKClient.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/openmldb/SDKClient.java @@ -104,6 +104,7 @@ public void createAndUseDB(String dbName){ } public void insert(String tableName,List list){ List> dataList = new ArrayList<>(); + dataList.add(list); insertList(tableName,dataList); } public void insertList(String tableName,List> dataList){ diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/provider/YamlUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/provider/YamlUtil.java index 3fd2be4fca2..76ed8d366d6 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/provider/YamlUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/provider/YamlUtil.java @@ -22,6 +22,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.PrintWriter; /** * @author zhaowei @@ -33,7 +34,7 @@ public class YamlUtil { public static final String FAIL_CASE= "FailCase"; - public static T getObject(String caseFile, Class clazz) throws FileNotFoundException { + public static T getObject(String caseFile, Class clazz) { try { Yaml yaml = new Yaml(); FileInputStream testDataStream = new FileInputStream(caseFile); @@ -43,14 +44,18 @@ public static T getObject(String caseFile, Class clazz) throws FileNotFou log.error("fail to load yaml: ", e); e.printStackTrace(); return null; -// FesqlDataProvider nullDataProvider = new FesqlDataProvider(); -// SQLCase failCase = new SQLCase(); -// failCase.setDesc(FAIL_SQL_CASE); -// nullDataProvider.setCases(Lists.newArrayList(failCase)); -// return nullDataProvider; } } - + public static void writeYamlFile(Object obj,String yamlPath) { + try { + Yaml yaml = new Yaml(); + PrintWriter out = new PrintWriter(yamlPath); + yaml.dump(obj,out); + } catch (Exception e) { + log.error("fail to write yaml: ", e); + e.printStackTrace(); + } + } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/BinaryUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/BinaryUtil.java new file mode 100644 index 00000000000..b3669c01c5a --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/BinaryUtil.java @@ -0,0 +1,148 @@ +package com._4paradigm.openmldb.test_common.util; + +import org.apache.commons.lang3.StringUtils; + +public class BinaryUtil { + // 将Unicode字符串转换成bool型数组 + public static boolean[] StrToBool(String input) { + boolean[] output = Binstr16ToBool(binaryStrToBinaryStr16(strToBinaryStr(input))); + return output; + } + + // 将bool型数组转换成Unicode字符串 + public static String BoolToStr(boolean[] input) { + String output = binaryStrToStr(Binstr16ToBinstr(BoolToBinstr16(input))); + return output; + } + + // 将字符串转换成二进制字符串 + public static String strToBinaryStr(String str) { + char[] strChar = str.toCharArray(); + String result = ""; + for (int i = 0; i < strChar.length; i++) { + String s = Integer.toBinaryString(strChar[i]); + result += s; + } + return result; + } + public static String strToBinaryStr16(String str) { + char[] strChar = str.toCharArray(); + String result = ""; + for (int i = 0; i < strChar.length; i++) { + String s = Integer.toBinaryString(strChar[i]); + s = StringUtils.leftPad(s,16,'0'); + result += s; + } + return result; + } + public static String strToBinaryStr(String str,String separator) { + char[] strChar = str.toCharArray(); + String result = ""; + for (int i = 0; i < strChar.length; i++) { + int x = (int)strChar[i]; + String s = Integer.toBinaryString(strChar[i]) + separator; + result += s; + } + return result; + } + + public static String strToStr(String str) { + String binaryStr = strToBinaryStr(str); + String result = binaryStrToStr(binaryStr); + return result; + } + + // 将二进制字符串转换成Unicode字符串 + private static String binaryStrToStr(String binStr) { + String[] tempStr = strToStrArray(binStr); + char[] tempChar = new char[tempStr.length]; + for (int i = 0; i < tempStr.length; i++) { + tempChar[i] = binaryStrToChar(tempStr[i]); + } + return String.valueOf(tempChar); + } + + // 将二进制字符串格式化成全16位带空格的Binstr + public static String binaryStrToBinaryStr16(String input) { + StringBuffer output = new StringBuffer(); + String[] tempStr = strToStrArray(input); + for (int i = 0; i < tempStr.length; i++) { + for (int j = 16 - tempStr[i].length(); j > 0; j--) { + output.append('0'); + } + output.append(tempStr[i] + " "); + } + return output.toString(); + } + + // 将全16位带空格的Binstr转化成去0前缀的带空格Binstr + private static String Binstr16ToBinstr(String input) { + StringBuffer output = new StringBuffer(); + String[] tempStr = strToStrArray(input); + for (int i = 0; i < tempStr.length; i++) { + for (int j = 0; j < 16; j++) { + if (tempStr[i].charAt(j) == '1') { + output.append(tempStr[i].substring(j) + " "); + break; + } + if (j == 15 && tempStr[i].charAt(j) == '0') + output.append("0" + " "); + } + } + return output.toString(); + } + + // 二进制字串转化为boolean型数组 输入16位有空格的Binstr + private static boolean[] Binstr16ToBool(String input) { + String[] tempStr = strToStrArray(input); + boolean[] output = new boolean[tempStr.length * 16]; + for (int i = 0, j = 0; i < input.length(); i++, j++) + if (input.charAt(i) == '1') + output[j] = true; + else if (input.charAt(i) == '0') + output[j] = false; + else + j--; + return output; + } + + // boolean型数组转化为二进制字串 返回带0前缀16位有空格的Binstr + private static String BoolToBinstr16(boolean[] input) { + StringBuffer output = new StringBuffer(); + for (int i = 0; i < input.length; i++) { + if (input[i]) + output.append('1'); + else + output.append('0'); + if ((i + 1) % 16 == 0) + output.append(' '); + } + output.append(' '); + return output.toString(); + } + + // 将二进制字符串转换为char + private static char binaryStrToChar(String binStr) { + int[] temp = binaryStrToIntArray(binStr); + int sum = 0; + for (int i = 0; i < temp.length; i++) { + sum += temp[temp.length - 1 - i] << i; + } + return (char) sum; + } + + // 将初始二进制字符串转换成字符串数组,以空格相隔 + private static String[] strToStrArray(String str) { + return str.split(" "); + } + + // 将二进制字符串转换成int数组 + private static int[] binaryStrToIntArray(String binStr) { + char[] temp = binStr.toCharArray(); + int[] result = new int[temp.length]; + for (int i = 0; i < temp.length; i++) { + result[i] = temp[i] - 48; + } + return result; + } +} diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/CommandResultUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/CommandResultUtil.java index 66c51c3e5e0..7d00df85773 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/CommandResultUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/CommandResultUtil.java @@ -2,6 +2,7 @@ import com._4paradigm.openmldb.test_common.bean.OpenMLDBColumn; import com._4paradigm.openmldb.test_common.bean.OpenMLDBIndex; +import com._4paradigm.openmldb.test_common.bean.OpenMLDBResult; import com._4paradigm.openmldb.test_common.bean.OpenMLDBTable; import com._4paradigm.openmldb.test_common.model.OpenmldbDeployment; import com.google.common.base.Joiner; @@ -123,4 +124,24 @@ public static List parseDeployments(List lines){ } return deployments; } + // ---------- ---------------- --------------- -------------- ------ ------------------ ---------------- ----------- ------------------- --------- --------------------------------------------------------------- ---------------- ------------------- + // Table_id Table_name Database_name Storage_type Rows Memory_data_size Disk_data_size Partition Partition_unalive Replica Offline_path Offline_format Offline_deep_copy + // ---------- ---------------- --------------- -------------- ------ ------------------ ---------------- ----------- ------------------- --------- --------------------------------------------------------------- ---------------- ------------------- + // 27 auto_AITzyByZ default_db ssd 1 0 473414 2 0 3 NULL NULL NULL + // 19 auto_GlcndMiH default_db hdd 1 0 515239 2 0 3 NULL + public static void parseResult(List lines, OpenMLDBResult openMLDBResult){ + if(CollectionUtils.isNotEmpty(lines)&&lines.size()>=2) { + int count = 0; + List> rows = new ArrayList<>(); + List columnNames = Arrays.asList(lines.get(1).split("\\s+")); + for (int i = 3; i < lines.size() - 2; i++) { + count++; + List row = Arrays.asList(lines.get(i).split("\\s+")); + rows.add(row); + } + openMLDBResult.setColumnNames(columnNames); + openMLDBResult.setCount(count); + openMLDBResult.setResult(rows); + } + } } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/DataUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/DataUtil.java index 734b577c5d0..9ab444499bf 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/DataUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/DataUtil.java @@ -2,7 +2,9 @@ import com._4paradigm.openmldb.jdbc.SQLResultSet; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import java.math.BigInteger; import java.sql.*; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -11,6 +13,46 @@ @Slf4j public class DataUtil { + public static String parseBinary(String str,String type){ + int length = str.length(); +// System.out.println("length = " + length); + String binaryStr = BinaryUtil.strToBinaryStr(str); + switch (type){ + case "smallint": + return String.valueOf(Short.parseShort(binaryStr, 2)); + case "int": + return String.valueOf(Integer.parseInt(binaryStr, 2)); + case "bigint": + return String.valueOf(Long.parseLong(binaryStr, 2)); + case "timestamp": + String binary = ""; + for (int i = 0; i < length; i++) { + String s = Integer.toBinaryString(str.charAt(i)); + System.out.println("s = " + s); + s = StringUtils.leftPad(s, 16, "0"); + System.out.println("AAAAA s = " + s); + binary += s; + } + System.out.println("binary = " + binary); + return String.valueOf(Long.parseLong(binary, 2)); + case "float": +// return String.valueOf(Float.intBitsToFloat(new BigInteger(binaryStr, 2).intValue())); + return BinaryUtil.strToStr(str); + case "double": + return String.valueOf(Double.longBitsToDouble(new BigInteger(binaryStr, 2).longValue())); + case "date": + int year = (int)(str.charAt(2))+1900; + int month = (int)(str.charAt(1))+1; + int day = str.charAt(0); + return year+"-"+(month<10?"0"+month:month)+"-"+(day<10?"0"+day:day); + case "string": + return str; + default: + throw new IllegalArgumentException("parse binary not support type:"+type); + } + + } + public static Object parseTime(Object data){ String dataStr = String.valueOf(data); if(dataStr.equals("{currentTime}")){ diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/ResultUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/ResultUtil.java index 76295d1b77e..04b5dddcc68 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/ResultUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/ResultUtil.java @@ -163,7 +163,7 @@ public static Object getColumnData(SQLResultSet rs, int index) throws SQLExcepti obj = rs.getLong(index + 1); } else if (columnType == Types.VARCHAR) { obj = rs.getString(index + 1); - log.info("conver string data {}", obj); +// log.info("convert string data {}", obj); } else if (columnType == Types.TIMESTAMP) { obj = rs.getTimestamp(index + 1); } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/SDKUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/SDKUtil.java index a3d4e181b63..10600ac4e7b 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/SDKUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/SDKUtil.java @@ -22,7 +22,6 @@ import com._4paradigm.openmldb.sdk.QueryFuture; import com._4paradigm.openmldb.sdk.SqlExecutor; import com._4paradigm.openmldb.test_common.chain.result.ResultParserManager; -import com._4paradigm.openmldb.test_common.common.LogProxy; import com._4paradigm.openmldb.test_common.model.InputDesc; import com._4paradigm.openmldb.test_common.model.OpenmldbDeployment; import com._4paradigm.openmldb.test_common.model.SQLCase; @@ -54,8 +53,37 @@ public static OpenMLDBResult sqlList(SqlExecutor executor, String dbName, List commonColumnIndices) throws SQLException { + List commonColumnIndices) { OpenMLDBResult fesqlResult = null; if (sql.toLowerCase().startsWith("select")) { fesqlResult = selectBatchRequestModeWithPreparedStatement( @@ -81,38 +109,44 @@ public static OpenMLDBResult sqlBatchRequestMode(SqlExecutor executor, String db public static OpenMLDBResult sqlRequestModeWithProcedure(SqlExecutor executor, String dbName, String spName, Boolean needInsertRequestRow, String sql, InputDesc rows, boolean isAsyn) throws SQLException { - OpenMLDBResult fesqlResult = null; - if (sql.toLowerCase().startsWith("create procedure")) { - fesqlResult = selectRequestModeWithSp(executor, dbName, spName, needInsertRequestRow, sql, rows, isAsyn); + OpenMLDBResult openMLDBResult = null; + if (sql.toLowerCase().startsWith("create procedure") || sql.toLowerCase().startsWith("deploy ")) { + openMLDBResult = selectRequestModeWithSp(executor, dbName, spName, needInsertRequestRow, sql, rows, isAsyn); } else { - log.error("unsupport sql: {}", sql); + throw new IllegalArgumentException("not support sql: "+ sql); } - return fesqlResult; + return openMLDBResult; } public static OpenMLDBResult sql(SqlExecutor executor, String dbName, String sql) { useDB(executor,dbName); - OpenMLDBResult fesqlResult = null; + OpenMLDBResult openMLDBResult = null; if (sql.startsWith("create database") || sql.startsWith("drop database")) { - fesqlResult = db(executor, sql); + openMLDBResult = db(executor, sql); }else if(sql.startsWith("CREATE INDEX")||sql.startsWith("create index")){ - fesqlResult = createIndex(executor, sql); + openMLDBResult = createIndex(executor, sql); }else if (sql.startsWith("create") || sql.startsWith("CREATE") || sql.startsWith("DROP")|| sql.startsWith("drop")) { - fesqlResult = ddl(executor, dbName, sql); - } else if (sql.startsWith("insert")||sql.startsWith("INSERT")) { - fesqlResult = insert(executor, dbName, sql); + openMLDBResult = ddl(executor, dbName, sql); + }else if (sql.startsWith("insert")||sql.startsWith("INSERT")) { + openMLDBResult = insert(executor, dbName, sql); + }else if (sql.startsWith("delete from")) { + openMLDBResult = delete(executor, dbName, sql); }else if(sql.startsWith("show deployments;")){ - fesqlResult = showDeploys(executor,dbName,sql); + openMLDBResult = showDeploys(executor,dbName,sql); }else if(sql.startsWith("show deployment")){ - fesqlResult = deploy(executor, dbName, sql); + openMLDBResult = showDeploy(executor, dbName, sql); }else if(sql.startsWith("desc ")){ - fesqlResult = desc(executor,dbName,sql); + openMLDBResult = desc(executor,dbName,sql); }else if(sql.contains("outfile")){ - fesqlResult = selectInto(executor, dbName, sql); + openMLDBResult = selectInto(executor, dbName, sql); + }else if(sql.contains("deploy ")){ + openMLDBResult = deploy(executor, sql); }else { - fesqlResult = select(executor, dbName, sql); + openMLDBResult = select(executor, dbName, sql); } - return fesqlResult; + openMLDBResult.setSql(sql); + log.info("openMLDBResult:{}",openMLDBResult); + return openMLDBResult; } public static OpenMLDBResult selectInto(SqlExecutor executor, String dbName, String outSql){ @@ -120,31 +154,31 @@ public static OpenMLDBResult selectInto(SqlExecutor executor, String dbName, Str return null; } log.info("select into:{}",outSql); - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); ResultSet rawRs = executor.executeSQL(dbName, outSql); if (rawRs == null) { - fesqlResult.setOk(false); - fesqlResult.setMsg("executeSQL fail, result is null"); + openMLDBResult.setOk(false); + openMLDBResult.setMsg("executeSQL fail, result is null"); } else if (rawRs instanceof SQLResultSet){ try { SQLResultSet rs = (SQLResultSet)rawRs; - fesqlResult.setOk(true); + openMLDBResult.setOk(true); } catch (Exception e) { - fesqlResult.setOk(false); - fesqlResult.setMsg(e.getMessage()); + openMLDBResult.setOk(false); + openMLDBResult.setMsg(e.getMessage()); } } - log.info("select result:{} \n", fesqlResult); - return fesqlResult; + log.info("select result:{} \n", openMLDBResult); + return openMLDBResult; } - public static OpenMLDBResult deploy(SqlExecutor executor, String dbName, String showdeploySql){ - if (showdeploySql.isEmpty()){ + public static OpenMLDBResult showDeploy(SqlExecutor executor, String dbName, String showDeploySql){ + if (showDeploySql.isEmpty()){ return null; } - log.info("show deployment:{}",showdeploySql); + log.info("show deployment:{}",showDeploySql); OpenMLDBResult fesqlResult = new OpenMLDBResult(); - ResultSet rawRs = executor.executeSQL(dbName, showdeploySql); + ResultSet rawRs = executor.executeSQL(dbName, showDeploySql); if (rawRs == null) { fesqlResult.setOk(false); fesqlResult.setMsg("executeSQL fail, result is null"); @@ -242,7 +276,7 @@ public static OpenMLDBResult createIndex(SqlExecutor executor, String sql) { try { createOk = executor.getStatement().execute(sql); openMLDBResult.setOk(true); - Thread.sleep(10000); + Tool.sleep(20*1000); } catch (Exception e) { e.printStackTrace(); openMLDBResult.setOk(false); @@ -264,6 +298,27 @@ public static OpenMLDBResult insert(SqlExecutor executor, String dbName, String log.info("insert result:{}" + fesqlResult); return fesqlResult; } + public static OpenMLDBResult delete(SqlExecutor executor, String dbName, String deleteSql) { + useDB(executor,dbName); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); + Statement statement = executor.getStatement(); + try { + statement.execute(deleteSql); + openMLDBResult.setOk(true); + openMLDBResult.setMsg("success"); + } catch (Exception e) { + e.printStackTrace(); + openMLDBResult.setOk(false); + openMLDBResult.setMsg(e.getMessage()); + }finally { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return openMLDBResult; + } public static OpenMLDBResult selectWithPrepareStatement(SqlExecutor executor, String dbName, String sql, List paramterTypes, List params) { OpenMLDBResult fesqlResult = new OpenMLDBResult(); @@ -540,12 +595,18 @@ private static OpenMLDBResult selectRequestModeWithSp(SqlExecutor executor, Stri log.info("procedure sql:{}", sql); String insertDbName = input.getDb().isEmpty() ? dbName : input.getDb(); - OpenMLDBResult fesqlResult = new OpenMLDBResult(); - if (!executor.executeDDL(dbName, sql)) { + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); + openMLDBResult.setSpName(spName); + if(sql.startsWith("deploy ")){ + OpenMLDBResult deployResult = deploy(executor, sql); + if(!deployResult.isOk()){ + return deployResult; + } + }else if (!executor.executeDDL(dbName, sql)) { log.error("execute ddl failed! sql: {}", sql); - fesqlResult.setOk(false); - fesqlResult.setMsg("execute ddl failed"); - return fesqlResult; + openMLDBResult.setOk(false); + openMLDBResult.setMsg("execute ddl failed"); + return openMLDBResult; } List> result = Lists.newArrayList(); for (int i = 0; i < rows.size(); i++) { @@ -558,9 +619,9 @@ private static OpenMLDBResult selectRequestModeWithSp(SqlExecutor executor, Stri try { rps = executor.getCallablePreparedStmt(dbName, spName); if (rps == null) { - fesqlResult.setOk(false); - fesqlResult.setMsg("Fail to getCallablePreparedStmt"); - return fesqlResult; + openMLDBResult.setOk(false); + openMLDBResult.setMsg("Fail to getCallablePreparedStmt"); + return openMLDBResult; } if (!isAsyn) { resultSet = buildRequestPreparedStatement(rps, rows.get(i)); @@ -568,33 +629,33 @@ private static OpenMLDBResult selectRequestModeWithSp(SqlExecutor executor, Stri resultSet = buildRequestPreparedStatementAsync(rps, rows.get(i)); } if (resultSet == null) { - fesqlResult.setOk(false); - fesqlResult.setMsg("result set is null"); - log.error("select result:{}", fesqlResult); - return fesqlResult; + openMLDBResult.setOk(false); + openMLDBResult.setMsg("result set is null"); + log.error("select result:{}", openMLDBResult); + return openMLDBResult; } result.addAll(ResultUtil.toList((SQLResultSet) resultSet)); if (needInsertRequestRow && !executor.executeInsert(insertDbName, inserts.get(i))) { - fesqlResult.setOk(false); - fesqlResult.setMsg("fail to execute sql in request mode: fail to insert request row after query"); - log.error(fesqlResult.getMsg()); - return fesqlResult; + openMLDBResult.setOk(false); + openMLDBResult.setMsg("fail to execute sql in request mode: fail to insert request row after query"); + log.error(openMLDBResult.getMsg()); + return openMLDBResult; } if (i == 0) { try { - ResultUtil.setSchema(resultSet.getMetaData(),fesqlResult); + ResultUtil.setSchema(resultSet.getMetaData(),openMLDBResult); } catch (SQLException throwables) { - fesqlResult.setOk(false); - fesqlResult.setMsg("fail to get/set meta data"); - return fesqlResult; + openMLDBResult.setOk(false); + openMLDBResult.setMsg("fail to get/set meta data"); + return openMLDBResult; } } } catch (SQLException throwables) { throwables.printStackTrace(); log.error("has exception. sql: {}", sql); - fesqlResult.setOk(false); - fesqlResult.setMsg("fail to execute sql"); - return fesqlResult; + openMLDBResult.setOk(false); + openMLDBResult.setMsg("fail to execute sql"); + return openMLDBResult; } finally { try { if (resultSet != null) resultSet.close(); @@ -604,11 +665,11 @@ private static OpenMLDBResult selectRequestModeWithSp(SqlExecutor executor, Stri } } } - fesqlResult.setResult(result); - fesqlResult.setCount(result.size()); - fesqlResult.setOk(true); - log.info("select result:{}", fesqlResult); - return fesqlResult; + openMLDBResult.setResult(result); + openMLDBResult.setCount(result.size()); + openMLDBResult.setOk(true); + log.info("select result:{}", openMLDBResult); + return openMLDBResult; } public static OpenMLDBResult selectBatchRequestModeWithSp(SqlExecutor executor, String dbName, String spName, @@ -783,26 +844,26 @@ public static OpenMLDBResult select(SqlExecutor executor, String dbName, String return null; } log.info("select sql:{}", selectSql); - OpenMLDBResult fesqlResult = new OpenMLDBResult(); + OpenMLDBResult openMLDBResult = new OpenMLDBResult(); ResultSet rawRs = executor.executeSQL(dbName, selectSql); if (rawRs == null) { - fesqlResult.setOk(false); - fesqlResult.setMsg("executeSQL fail, result is null"); + openMLDBResult.setOk(false); + openMLDBResult.setMsg("executeSQL fail, result is null"); } else if (rawRs instanceof SQLResultSet){ try { SQLResultSet rs = (SQLResultSet)rawRs; - ResultUtil.setSchema(rs.getMetaData(),fesqlResult); - fesqlResult.setOk(true); + ResultUtil.setSchema(rs.getMetaData(),openMLDBResult); + openMLDBResult.setOk(true); List> result = ResultUtil.toList(rs); - fesqlResult.setCount(result.size()); - fesqlResult.setResult(result); + openMLDBResult.setCount(result.size()); + openMLDBResult.setResult(result); } catch (Exception e) { - fesqlResult.setOk(false); - fesqlResult.setMsg(e.getMessage()); + openMLDBResult.setOk(false); + openMLDBResult.setMsg(e.getMessage()); } } - log.info("select result:{} \n", fesqlResult); - return fesqlResult; + log.info("select result:{} \n", openMLDBResult); + return openMLDBResult; } // public static Object getColumnData(com._4paradigm.openmldb.ResultSet rs, Schema schema, int index) { diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/SQLUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/SQLUtil.java index 2b105f0f9a5..bdc5da51683 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/SQLUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/SQLUtil.java @@ -15,6 +15,26 @@ public class SQLUtil { private static String reg = "\\{(\\d+)\\}"; private static Pattern pattern = Pattern.compile(reg); + public static String replaceDBNameAndTableName(String dbName,List tableNames,String str){ + Matcher matcher = pattern.matcher(str); + while (matcher.find()) { + int index = Integer.parseInt(matcher.group(1)); + str = str.replace("{" + index + "}", tableNames.get(index)); + } + str = str.replace("{db_name}",dbName); + return str; + } + public static String replaceDBNameAndSpName(String dbName,String spName,String str){ + str = str.replace("{sp_name}",spName); + str = str.replace("{db_name}",dbName); + return str; + } + + public static String getLongWindowDeploySQL(String name,String longWindow,String sql){ + String deploySql = String.format("deploy %s options(long_windows='%s') %s",name,longWindow,sql); + return deploySql; + } + public static String genInsertSQL(String tableName, List> dataList) { if (CollectionUtils.isEmpty(dataList)) { return ""; @@ -65,13 +85,13 @@ public static String buildInsertSQLWithPrepared(String name, List column return builder.toString(); } - public static String formatSql(String sql, List tableNames, OpenMLDBInfo fedbInfo) { + public static String formatSql(String sql, List tableNames, OpenMLDBInfo openMLDBInfo) { Matcher matcher = pattern.matcher(sql); while (matcher.find()) { int index = Integer.parseInt(matcher.group(1)); sql = sql.replace("{" + index + "}", tableNames.get(index)); } - sql = formatSql(sql,fedbInfo); + sql = formatSql(sql,openMLDBInfo); return sql; } diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/WaitUtil.java b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/WaitUtil.java index a8c97406356..134e1794411 100644 --- a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/WaitUtil.java +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/java/com/_4paradigm/openmldb/test_common/util/WaitUtil.java @@ -2,8 +2,10 @@ import com._4paradigm.openmldb.test_common.common.Condition; +import com._4paradigm.openmldb.test_common.common.ConditionResult; import lombok.extern.log4j.Log4j; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.tuple.Pair; @Slf4j @@ -11,6 +13,9 @@ public class WaitUtil { public static boolean waitCondition(Condition condition) { return waitCondition(condition,10,1200); } + public static T waitCondition(ConditionResult condition) { + return waitCondition(condition,10,1200); + } public static boolean waitCondition(Condition condition,Condition fail) { return waitCondition(condition,fail,10,1200); } @@ -38,6 +43,21 @@ private static boolean waitCondition(Condition condition, int interval, int time log.info("wait timeout!"); return false; } + private static T waitCondition(ConditionResult condition, int interval, int timeout) { + int count = 1; + while (timeout > 0){ + log.info("retry count:{}",count); + Pair execute = condition.execute(); + if (execute.getLeft()){ + return execute.getRight(); + }else { + timeout -= interval; + Tool.sleep(interval*1000); + } + count++; + } + throw new IllegalStateException("wait result timeout!"); + } /** * * @param condition 等待的条件 diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/resources/log4j.properties b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/resources/log4j.properties new file mode 100755 index 00000000000..8aa7e8e77dc --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/resources/log4j.properties @@ -0,0 +1,51 @@ +### set log levels ### +log4j.rootLogger=debug,info,stdout,warn,error + +# console log +log4j.appender.stdout = org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target = System.out +log4j.appender.stdout.Threshold = INFO +log4j.appender.stdout.layout = org.apache.log4j.PatternLayout +log4j.appender.stdout.Encoding=UTF-8 +log4j.appender.stdout.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n + +#info log +log4j.logger.info=info +log4j.appender.info=org.apache.log4j.DailyRollingFileAppender +log4j.appender.info.DatePattern='_'yyyy-MM-dd'.log' +log4j.appender.info.File=logs/info.log +log4j.appender.info.Append=true +log4j.appender.info.Threshold=INFO +log4j.appender.info.Encoding=UTF-8 +log4j.appender.info.layout=org.apache.log4j.PatternLayout +log4j.appender.info.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n +#debugs log +log4j.logger.debug=debug +log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender +log4j.appender.debug.DatePattern='_'yyyy-MM-dd'.log' +log4j.appender.debug.File=logs/debug.log +log4j.appender.debug.Append=true +log4j.appender.debug.Threshold=DEBUG +log4j.appender.debug.Encoding=UTF-8 +log4j.appender.debug.layout=org.apache.log4j.PatternLayout +log4j.appender.debug.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n +#warn log +log4j.logger.warn=warn +log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender +log4j.appender.warn.DatePattern='_'yyyy-MM-dd'.log' +log4j.appender.warn.File=logs/warn.log +log4j.appender.warn.Append=true +log4j.appender.warn.Threshold=WARN +log4j.appender.warn.Encoding=UTF-8 +log4j.appender.warn.layout=org.apache.log4j.PatternLayout +log4j.appender.warn.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n +#error +log4j.logger.error=error +log4j.appender.error = org.apache.log4j.DailyRollingFileAppender +log4j.appender.error.DatePattern='_'yyyy-MM-dd'.log' +log4j.appender.error.File = logs/error.log +log4j.appender.error.Append = true +log4j.appender.error.Threshold = ERROR +log4j.appender.error.Encoding=UTF-8 +log4j.appender.error.layout = org.apache.log4j.PatternLayout +log4j.appender.error.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [ %c.%M(%F:%L) ] - [ %p ] %m%n diff --git a/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/resources/run_case.properties b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/resources/run_case.properties new file mode 100644 index 00000000000..d361f7ddc73 --- /dev/null +++ b/test/integration-test/openmldb-test-java/openmldb-test-common/src/main/resources/run_case.properties @@ -0,0 +1,4 @@ +# memory/ssd/hdd +table_storage_mode=memory +#version=0.5.0 + diff --git a/test/integration-test/openmldb-test-java/pom.xml b/test/integration-test/openmldb-test-java/pom.xml index 568e3f8b0f5..231e8a03304 100644 --- a/test/integration-test/openmldb-test-java/pom.xml +++ b/test/integration-test/openmldb-test-java/pom.xml @@ -15,6 +15,7 @@ openmldb-tool-test openmldb-deploy openmldb-devops-test + openmldb-ecosystem diff --git a/test/steps/build-java-sdk.sh b/test/steps/build-java-sdk.sh index 2fff60f3e67..7195ee4b2f1 100755 --- a/test/steps/build-java-sdk.sh +++ b/test/steps/build-java-sdk.sh @@ -17,4 +17,5 @@ ROOT_DIR=$(pwd) cd java || exit mvn clean install -Dmaven.test.skip=true -Dgpg.skip +#mvn clean install -DskipTests=true -Dscalatest.skip=true -Dwagon.skip=true -Dmaven.test.skip=true -Dgpg.skip cd "${ROOT_DIR}" || exit diff --git a/test/steps/modify_devops_config.sh b/test/steps/modify_devops_config.sh new file mode 100755 index 00000000000..015246143c7 --- /dev/null +++ b/test/steps/modify_devops_config.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +CASE_XML=$1 +PRE_UPGRADE_VERSION=$2 +OPENMLDB_SDK_VERSION=$3 +TEST_CASE_VERSION=$4 +OPENMLDB_SERVER_VERSION=$5 +JAVA_NATIVE_VERSION=$6 +TABLE_STORAGE_MODE=$7 +echo "deploy_mode:${DEPLOY_MODE}" +ROOT_DIR=$(pwd) +echo "test_sdk_version:$OPENMLDB_SDK_VERSION" +cd test/integration-test/openmldb-test-java/openmldb-devops-test || exit +# modify suite_xml +if [[ "${PRE_UPGRADE_VERSION}" == "" ]]; then + sed -i "s###" test_suite/"${CASE_XML}" +else + sed -i "s###" test_suite/"${CASE_XML}" + sed -i "s###" test_suite/"${CASE_XML}" +fi + +echo "devops test suite xml:" +cat test_suite/"${CASE_XML}" + +cd test/integration-test/openmldb-test-java/openmldb-sdk-test || exit +# modify suite_xml +sed -i "s###" test_suite/test_cluster.xml +sed -i "s###" test_suite/test_cluster.xml + +echo "test suite xml:" +cat test_suite/test_cluster.xml + +if [ -n "${TEST_CASE_VERSION}" ]; then + echo -e "\nversion=${TEST_CASE_VERSION}" >> src/main/resources/run_case.properties +fi +if [ -n "${TABLE_STORAGE_MODE}" ]; then + sed -i "s#table_storage_mode=.*#table_storage_mode=${TABLE_STORAGE_MODE}#" src/main/resources/run_case.properties +fi +echo "run_case config:" +cat src/main/resources/run_case.properties +# modify pom +cd "${ROOT_DIR}" || exit +cd test/integration-test/openmldb-test-java/openmldb-test-common || exit +sed -i "s#.*#${OPENMLDB_SDK_VERSION}#" pom.xml +sed -i "s#.*#${JAVA_NATIVE_VERSION}#" pom.xml +echo "pom xml:" +cat pom.xml +cd "${ROOT_DIR}" || exit diff --git a/test/steps/openmldb-devops-test.sh b/test/steps/openmldb-devops-test.sh new file mode 100755 index 00000000000..b1c52093919 --- /dev/null +++ b/test/steps/openmldb-devops-test.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +#bash openmldb-sdk-test-java.sh -b SRC -c test_all.xml -d cluster -l 0 +#-b SRC表示从源码进行编译,会从github上下载代码然后进行编译,PKG表示直接从github上下载压缩包部署 +#-c 执行的suite_xml,决定了跑哪些case +#-d 部署模式,有cluster和standalone两种,默认cluster +#-l 测试的case级别,有0,1,2,3,4,5六个级别,默认为0,也可以同时跑多个级别的case,例如:1,2,3,4,5 + +while getopts ":c:t:s:v:" opt +do + case $opt in + c) + echo "参数c的值:$OPTARG" + CASE_XML=$OPTARG + ;; + t) + echo "参数t的值:$OPTARG" + TEST_TYPE=$OPTARG + ;; + s) + echo "参数s的值:$OPTARG" + TABLE_STORAGE_MODE=$OPTARG + ;; + v) + echo "参数v的值:$OPTARG" + PRE_UPGRADE_VERSION=$OPTARG + ;; + ?) echo "未知参数" + exit 1 + ;; + esac +done +if [[ "${CASE_XML}" == "" ]]; then + CASE_XML="test_all.xml" +fi +if [[ "${TEST_TYPE}" == "" ]]; then + TEST_TYPE="upgrade" +fi + +echo "CASE_XML:${CASE_XML}" +echo "TEST_TYPE:${TEST_TYPE}" +echo "TABLE_STORAGE_MODE:${TABLE_STORAGE_MODE}" + +ROOT_DIR=$(pwd) +# 安装wget +yum install -y wget +yum install -y net-tools +ulimit -c unlimited +echo "ROOT_DIR:${ROOT_DIR}" + +# 从源码编译 +deployConfigPath="test/integration-test/openmldb-test-java/openmldb-deploy/src/main/resources/deploy.properties" +OPENMLDB_SERVER_VERSION="SRC" +SERVER_URL=$(more ${deployConfigPath} | grep "${OPENMLDB_SERVER_VERSION}") +echo "SERVER_URL:${SERVER_URL}" +if [[ "${SERVER_URL}" == "" ]]; then + echo -e "\n${OPENMLDB_SERVER_VERSION}=${ROOT_DIR}/openmldb-linux.tar.gz\n" >> ${deployConfigPath} +else + sed -i "s#${OPENMLDB_SERVER_VERSION}=.*#${OPENMLDB_SERVER_VERSION}=${ROOT_DIR}/openmldb-linux.tar.gz#" ${deployConfigPath} +fi + +JAVA_SDK_VERSION=$(more java/pom.xml | grep ".*" | head -1 | sed 's#.*\(.*\).*#\1#') +JAVA_NATIVE_VERSION=$(more java/pom.xml | grep ".*" | head -1 | sed 's#.*\(.*\).*#\1#') +sh test/steps/build-java-sdk.sh + +echo "JAVA_SDK_VERSION:${JAVA_SDK_VERSION}" +echo "JAVA_NATIVE_VERSION:${JAVA_NATIVE_VERSION}" +echo "deploy config:" +cat ${deployConfigPath} +# install command tool +cd test/test-tool/command-tool || exit +mvn clean install -Dmaven.test.skip=true +cd "${ROOT_DIR}" || exit +# modify config +sh test/steps/modify_devops_config.sh "${CASE_XML}" "${PRE_UPGRADE_VERSION}" "${JAVA_SDK_VERSION}" "" "${OPENMLDB_SERVER_VERSION}" "${JAVA_NATIVE_VERSION}" "${TABLE_STORAGE_MODE}" + +# install jar +cd test/integration-test/openmldb-test-java || exit +mvn clean install -Dmaven.test.skip=true +cd "${ROOT_DIR}" || exit +# run case +cd "${ROOT_DIR}"/test/integration-test/openmldb-test-java/openmldb-devops-test || exit +mvn clean test -e -U -Dsuite=test_suite/"${CASE_XML}" + +if [[ "${TEST_TYPE}" == "upgrade" ]]; then + if [[ "${TABLE_STORAGE_MODE}" == "memory" ]]; then + SDK_CASE_XML="test_cluster.xml" + else + SDK_CASE_XML="test_cluster_disk.xml" + fi + echo "SDK_CASE_XML:${SDK_CASE_XML}" + # run case + cd "${ROOT_DIR}"/test/integration-test/openmldb-test-java/openmldb-sdk-test || exit + mvn clean test -e -U -DsuiteXmlFile=test_suite/"${SDK_CASE_XML}" -DcaseLevel="0" +fi diff --git a/test/test-tool/command-tool/src/main/java/com/_4paradigm/test_tool/command_tool/common/LocalExecutor.java b/test/test-tool/command-tool/src/main/java/com/_4paradigm/test_tool/command_tool/common/LocalExecutor.java index 03a2bbfcdd6..062a5f62118 100644 --- a/test/test-tool/command-tool/src/main/java/com/_4paradigm/test_tool/command_tool/common/LocalExecutor.java +++ b/test/test-tool/command-tool/src/main/java/com/_4paradigm/test_tool/command_tool/common/LocalExecutor.java @@ -14,7 +14,7 @@ public class LocalExecutor implements CommandExecutor { public LocalExecutor(){ starts.add("wget"); starts.add("tar"); - contains.add("--role=ns_client"); +// contains.add("--role=ns_client"); } public boolean isUseExec(String command){ for(String start:starts){