Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve merge into performance, Update Column Only Optimization #14429

Merged

Conversation

JackTan25
Copy link
Contributor

@JackTan25 JackTan25 commented Jan 23, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

1.Update Column Only Optimization

image

in most times, we will run below:

1.  merge into t1 using t2 on xx when matched then update * when not matched then insert *;
2. merge into t1 using t2 on xx when matched then update t1.a = t2.a when not matched then insert *;

there is no condition for update and no delete,and the right side for update expr must be column ref, so we don't support:

1. merge into t1 using t2 on xx when matched and cond1 then update t1.a = t2.a when not matched then insert *;
2. merge into t1 using t2 on xx when matched then and cond1 update * when matched then delete  when not matched then insert *;
3. merge into t1 using t2 on xx when matched and cond1 then update t1.a = t2.a+2 when not matched then insert *;

2.Future Work

we can extend this Column Only Optimization to delete operation and also with condition like below:

1. merge into t1 using t2 on xx when matched and cond1 then update t1.a = t2.a when not matched then insert *;
2.merge into t1 using t2 on xx when matched then and cond1 update * when matched then delete  when not matched then insert *;

Performance Test

we test in debug mode on MacOS M1 (16c32G).

## pr14429
mysql> set enable_experimental_merge_into = 1;
Query OK, 0 rows affected (0.01 sec)

mysql> set enable_distributed_merge_into = 1;
Query OK, 0 rows affected (0.02 sec)

mysql> MERGE INTO lineitem_target_origin_400_blocks1 as t1 using lineitem_target_origin_200_blocks1 as t2 on       t1.l_orderkey = t2.l_orderkey and      t1.l_partkey = t2.l_partkey   and t1.l_suppkey = t2.l_suppkey and      t1.l_linenumber = t2.l_linenumber and       t1.l_quantity = t2.l_quantity and       t1.l_extendedprice = t2.l_extendedprice and      t1.l_discount = t2.l_discount      when matched then update *      when not matched then insert *;
+-------------------------+------------------------+
| number of rows inserted | number of rows updated |
+-------------------------+------------------------+
|                       0 |                4000000 |
+-------------------------+------------------------+
1 row in set (36.85 sec)
Read 8500000 rows, 1.37 GiB in 36.805 sec., 230.95 thousand rows/sec., 38.10 MiB/sec.
## in main branch

mysql> set enable_experimental_merge_into = 1;                                                                                                    
Query OK, 0 rows affected (0.01 sec)

mysql> set enable_distributed_merge_into = 1;                                                                                                     
Query OK, 0 rows affected (0.01 sec)

mysql> MERGE INTO lineitem_target_origin_400_blocks1 as t1 using lineitem_target_origin_200_blocks1 as t2 on       t1.l_orderkey = t2.l_orderkey and      t1.l_partkey = t2.l_partkey   and t1.l_suppkey = t2.l_suppkey and      t1.l_linenumber = t2.l_linenumber and       t1.l_quantity = t2.l_quantity and       t1.l_extendedprice = t2.l_extendedprice and      t1.l_discount = t2.l_discount      when matched then update *      when not matched then insert *;
+-------------------------+------------------------+
| number of rows inserted | number of rows updated |
+-------------------------+------------------------+
|                       0 |                4000000 |
+-------------------------+------------------------+
1 row in set (39.86 sec)
Read 8500000 rows, 1.37 GiB in 39.806 sec., 213.54 thousand rows/sec., 35.23 MiB/sec.

in release mode, we can be better. When there are too much data to be updated ,we can get better performance.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@JackTan25 JackTan25 marked this pull request as draft January 23, 2024 05:42
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Jan 23, 2024
@JackTan25 JackTan25 changed the title feat: Improve merge into performance test feat: Improve merge into performance, Update Column Only Optimization Jan 23, 2024
JackTan25 added a commit to JackTan25/databend that referenced this pull request Jan 23, 2024
BohuTANG pushed a commit that referenced this pull request Jan 24, 2024
* add non_equal_plan_forbidden

* add more random test

* move tests to #14429

* Update src/query/sql/src/planner/optimizer/optimizer.rs

Co-authored-by: xudong.w <wxd963996380@gmail.com>

---------

Co-authored-by: xudong.w <wxd963996380@gmail.com>
@JackTan25 JackTan25 added the ci-cloud Build docker image for cloud test label Jan 24, 2024
Copy link
Contributor

Docker Image for PR

  • tag: pr-14429-dccc506

note: this image tag is only available for internal use,
please check the internal doc for more details.

@JackTan25 JackTan25 added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Jan 24, 2024
Copy link
Contributor

Docker Image for PR

  • tag: pr-14429-595fe5d

note: this image tag is only available for internal use,
please check the internal doc for more details.

@BohuTANG
Copy link
Member

It's better to do the benchmark in the prod cloud, please don't do it on debug mode.

@JackTan25
Copy link
Contributor Author

It's better to do the benchmark in the prod cloud, please don't do it on debug mode.

of course, the debug mode is an initial local test. I will do cloud test for this pr, this is draft pr, I will do that.

@JackTan25 JackTan25 added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Jan 24, 2024
Copy link
Contributor

Docker Image for PR

  • tag: pr-14429-fa9af81

note: this image tag is only available for internal use,
please check the internal doc for more details.

@JackTan25 JackTan25 added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Jan 25, 2024
Copy link
Contributor

Docker Image for PR

  • tag: pr-14429-635f8f9

note: this image tag is only available for internal use,
please check the internal doc for more details.

@JackTan25
Copy link
Contributor Author

passed merge into source build in merge into performance test util.

Click me
-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks1 -D mergeinto_performance
Command executed successfully. Output:
114729502	25.50088990	104948.50	0.00

Executing command: snowsql --query -- test lineitem_target_origin_200_blocks1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks1 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
114729502	25.50088990	104948.50	0.00

OK - Unknown Query
114729502	25.50088990	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
114729502

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
114729502

OK - Unknown Query
114729502

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check

-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

Executing command: snowsql --query 

-- 4. correlated check

-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

OK - Unknown Query
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
57840341

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
57840341

OK - Unknown Query
57840341

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- =============================================================

-- test lineitem_target_origin_200_blocks2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks2 -D mergeinto_performance
Command executed successfully. Output:
114729502	25.50088990	104948.50	0.00

Executing command: snowsql --query 


-- =============================================================

-- test lineitem_target_origin_200_blocks2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks2 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
114729502	25.50088990	104948.50	0.00

OK - Unknown Query
114729502	25.50088990	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
114729502

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
114729502

OK - Unknown Query
114729502

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

OK - Unknown Query
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
57840341

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
57840341

OK - Unknown Query
57840341

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_200_blocks3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks3 -D mergeinto_performance
Command executed successfully. Output:
114729502	25.50088990	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_200_blocks3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks3 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
114729502	25.50088990	104948.50	0.00

OK - Unknown Query
114729502	25.50088990	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
114729502

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
114729502

OK - Unknown Query
114729502

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

OK - Unknown Query
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
57840341

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
57840341

OK - Unknown Query
57840341

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_200_blocks4 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks4 -D mergeinto_performance
Command executed successfully. Output:
114729502	25.50088990	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_200_blocks4 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks4 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
114729502	25.50088990	104948.50	0.00

OK - Unknown Query
114729502	25.50088990	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks4
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
114729502

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks4
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
114729502

OK - Unknown Query
114729502

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks4
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks4
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks4
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks4
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

OK - Unknown Query
A	F	28301281
N	F	739905
N	O	57381835
R	F	28306481

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks4
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks4
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks4
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
57840341

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks4
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
57840341

OK - Unknown Query
57840341

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks4
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks4
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks4
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial1 -D mergeinto_performance
Command executed successfully. Output:
103255731	25.50115337	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial1 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
103255731	25.50115337	104948.50	0.00

OK - Unknown Query
103255731	25.50115337	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
103255731

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
103255731

OK - Unknown Query
103255731

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

OK - Unknown Query
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
51393942

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
51393942

OK - Unknown Query
51393942

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial2 -D mergeinto_performance
Command executed successfully. Output:
103255731	25.50115337	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial2 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
103255731	25.50115337	104948.50	0.00

OK - Unknown Query
103255731	25.50115337	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
103255731

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
103255731

OK - Unknown Query
103255731

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

OK - Unknown Query
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
51393942

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
51393942

OK - Unknown Query
51393942

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- =======================================================
-- test lineitem_target_origin_200_blocks_partial3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial3 -D mergeinto_performance
Command executed successfully. Output:
103255731	25.50115337	104948.50	0.00

Executing command: snowsql --query 


-- =======================================================
-- test lineitem_target_origin_200_blocks_partial3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial3 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
103255731	25.50115337	104948.50	0.00

OK - Unknown Query
103255731	25.50115337	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
103255731

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
103255731

OK - Unknown Query
103255731

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

OK - Unknown Query
A	F	28301281
N	F	739905
N	O	45908064
R	F	28306481

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
51393942

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
51393942

OK - Unknown Query
51393942

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial_plus_50_blocks1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1 -D mergeinto_performance
Command executed successfully. Output:
129126690	25.50090575	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial_plus_50_blocks1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
129126690	25.50090575	104948.50	0.00

OK - Unknown Query
129126690	25.50090575	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
129126690

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
129126690

OK - Unknown Query
129126690

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

OK - Unknown Query
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
64269361

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
64269361

OK - Unknown Query
64269361

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial_plus_50_blocks2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2 -D mergeinto_performance
Command executed successfully. Output:
129126690	25.50090575	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial_plus_50_blocks2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
129126690	25.50090575	104948.50	0.00

OK - Unknown Query
129126690	25.50090575	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
129126690

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
129126690

OK - Unknown Query
129126690

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

OK - Unknown Query
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
64269361

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
64269361

OK - Unknown Query
64269361

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial_plus_50_blocks3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3 -D mergeinto_performance
Command executed successfully. Output:
129126690	25.50090575	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_200_blocks_partial_plus_50_blocks3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
129126690	25.50090575	104948.50	0.00

OK - Unknown Query
129126690	25.50090575	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
129126690

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
129126690

OK - Unknown Query
129126690

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

OK - Unknown Query
A	F	35392860
N	F	923652
N	O	57413635
R	F	35396543

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
64269361

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
64269361

OK - Unknown Query
64269361

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_200_blocks_partial_plus_50_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_400_blocks1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_400_blocks1 -D mergeinto_performance
Command executed successfully. Output:
229042196	25.49995718	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_400_blocks1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_400_blocks1 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
229042196	25.49995718	104948.50	0.00

OK - Unknown Query
229042196	25.49995718	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_400_blocks1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
229042196

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_400_blocks1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
229042196

OK - Unknown Query
229042196

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_400_blocks1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_400_blocks1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_400_blocks1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_400_blocks1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

OK - Unknown Query
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_400_blocks1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_400_blocks1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_400_blocks1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
115470212

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_400_blocks1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
115470212

OK - Unknown Query
115470212

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_400_blocks2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_400_blocks2 -D mergeinto_performance
Command executed successfully. Output:
254913155	25.49995315	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_400_blocks2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_400_blocks2 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
254913155	25.49995315	104948.50	0.00

OK - Unknown Query
254913155	25.49995315	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_400_blocks2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
254913155

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_400_blocks2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
254913155

OK - Unknown Query
254913155

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_400_blocks2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_400_blocks2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_400_blocks2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	63598486
N	F	1659105
N	O	126042296
R	F	63613268

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_400_blocks2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	63598486
N	F	1659105
N	O	126042296
R	F	63613268

OK - Unknown Query
A	F	63598486
N	F	1659105
N	O	126042296
R	F	63613268

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_400_blocks2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_400_blocks2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_400_blocks2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
128345631

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_400_blocks2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
128345631

OK - Unknown Query
128345631

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_400_blocks3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_400_blocks3 -D mergeinto_performance
Command executed successfully. Output:
229042196	25.49995718	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_400_blocks3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_400_blocks3 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
229042196	25.49995718	104948.50	0.00

OK - Unknown Query
229042196	25.49995718	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_400_blocks3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
229042196

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_400_blocks3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
229042196

OK - Unknown Query
229042196

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_400_blocks3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_400_blocks3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_400_blocks3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_400_blocks3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

OK - Unknown Query
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_400_blocks3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_400_blocks3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_400_blocks3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
115470212

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_400_blocks3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
115470212

OK - Unknown Query
115470212

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_400_blocks4 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_400_blocks4 -D mergeinto_performance
Command executed successfully. Output:
229042196	25.49995718	104948.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_400_blocks4 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_400_blocks4 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
229042196	25.49995718	104948.50	0.00

OK - Unknown Query
229042196	25.49995718	104948.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_400_blocks4
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
229042196

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_400_blocks4
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
229042196

OK - Unknown Query
229042196

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_400_blocks4
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_400_blocks4
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

OK - Unknown Query
1	1	1
1	2	1
1	3	1
1	4	1
1	5	1
1	6	1
2	1	1
3	1	1
3	2	1
3	3	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_400_blocks4
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_400_blocks4
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

OK - Unknown Query
A	F	56506907
N	F	1475358
N	O	114536725
R	F	56523206

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_400_blocks4
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_400_blocks4
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_400_blocks4
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
115470212

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_400_blocks4
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
115470212

OK - Unknown Query
115470212

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks4
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks4
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_400_blocks4
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_one_block1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_one_block1 -D mergeinto_performance
Command executed successfully. Output:
574015	25.50743796	104768.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_one_block1 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_one_block1 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
574015	25.50743796	104768.50	0.00

OK - Unknown Query
574015	25.50743796	104768.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_one_block1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
574015

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_one_block1
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
574015

OK - Unknown Query
574015

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_one_block1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_one_block1
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

OK - Unknown Query
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_one_block1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	142333
N	F	3628
N	O	286316
R	F	141738

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_one_block1
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	142333
N	F	3628
N	O	286316
R	F	141738

OK - Unknown Query
A	F	142333
N	F	3628
N	O	286316
R	F	141738

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_one_block1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_one_block1
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_one_block1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
289491

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_one_block1
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
289491

OK - Unknown Query
289491

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block1
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_one_block2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_one_block2 -D mergeinto_performance
Command executed successfully. Output:
574015	25.50743796	104768.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_one_block2 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_one_block2 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
574015	25.50743796	104768.50	0.00

OK - Unknown Query
574015	25.50743796	104768.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_one_block2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
574015

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_one_block2
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
574015

OK - Unknown Query
574015

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_one_block2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_one_block2
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

OK - Unknown Query
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_one_block2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	142333
N	F	3628
N	O	286316
R	F	141738

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_one_block2
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	142333
N	F	3628
N	O	286316
R	F	141738

OK - Unknown Query
A	F	142333
N	F	3628
N	O	286316
R	F	141738

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_one_block2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_one_block2
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_one_block2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
289491

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_one_block2
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
289491

OK - Unknown Query
289491

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block2
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- =======================================================
-- test lineitem_target_origin_one_block3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_one_block3 -D mergeinto_performance
Command executed successfully. Output:
574015	25.50743796	104768.50	0.00

Executing command: snowsql --query 

-- =======================================================
-- test lineitem_target_origin_one_block3 table

-- 1. Basic Statistics Query
SELECT 
    COUNT(*) as total_records,
    AVG(l_quantity) as avg_quantity,
    MAX(l_extendedprice) as max_price,
    MIN(l_discount) as min_discount
FROM lineitem_target_origin_one_block3 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
574015	25.50743796	104768.50	0.00

OK - Unknown Query
574015	25.50743796	104768.50	0.00

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_one_block3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' -D mergeinto_performance
Command executed successfully. Output:
574015

Executing command: snowsql --query 

-- 2. data range and valid check
SELECT 
    COUNT(*) 
FROM lineitem_target_origin_one_block3
WHERE l_shipdate < '2000-01-01' OR l_shipdate > '2024-01-01' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
574015

OK - Unknown Query
574015

Preparing to run Unknown Query...
Executing command: bendsql --query=


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_one_block3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 -D mergeinto_performance
Command executed successfully. Output:
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

Executing command: snowsql --query 


-- 3. unique composite check
SELECT 
    l_orderkey, l_linenumber, COUNT(*)
FROM lineitem_target_origin_one_block3
GROUP BY l_orderkey, l_linenumber
HAVING COUNT(*) >= 1 order by l_orderkey, l_linenumber limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

OK - Unknown Query
11983072	1	1
11983072	2	1
11983072	3	1
11983072	4	1
11983072	5	1
11983073	1	1
11983073	2	1
11983073	3	1
11983073	4	1
11983074	1	1

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_one_block3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 -D mergeinto_performance
Command executed successfully. Output:
A	F	142333
N	F	3628
N	O	286316
R	F	141738

Executing command: snowsql --query 

-- 4. correlated check


-- 5. test specific value
SELECT 
    l_returnflag, l_linestatus, COUNT(*)
FROM lineitem_target_origin_one_block3
GROUP BY l_returnflag, l_linestatus order by l_returnflag, l_linestatus limit 10 --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
A	F	142333
N	F	3628
N	O	286316
R	F	141738

OK - Unknown Query
A	F	142333
N	F	3628
N	O	286316
R	F	141738

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_one_block3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL -D mergeinto_performance
Command executed successfully. Output:
0

Executing command: snowsql --query 

-- 6 .non null check
SELECT COUNT(*) FROM lineitem_target_origin_one_block3
WHERE l_orderkey IS NULL OR l_partkey IS NULL OR l_quantity IS NULL --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0

OK - Unknown Query
0

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_one_block3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate -D mergeinto_performance
Command executed successfully. Output:
289491

Executing command: snowsql --query 

-- 7. Continuous-time
SELECT 
    COUNT(*)
FROM lineitem_target_origin_one_block3
WHERE l_shipdate > l_commitdate OR l_shipdate > l_receiptdate --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
289491

OK - Unknown Query
289491

Preparing to run Unknown Query...
Executing command: bendsql --query=

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' -D mergeinto_performance
Command executed successfully. Output:
NULL

Executing command: snowsql --query 

-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31' --dbname mergeinto_performance --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
None

DIFFERENCE FOUND

Unknown Query:


-- 8. aggregation at condition filter.
SELECT 
    SUM(l_extendedprice * (1 - l_discount)) as total_sales
FROM lineitem_target_origin_one_block3
WHERE l_shipdate BETWEEN '2023-01-01' AND '2023-12-31'
Differences:

bendsql:
NULL

snowsql:
None

@JackTan25
Copy link
Contributor Author

passed in wizard:

Click me
Setting up and executing scripts for both bendsql and snowsql...
Executing command: bendsql --query=DROP DATABASE IF EXISTS mergeinto; -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=CREATE DATABASE mergeinto; -D mergeinto
Command executed successfully. Output:

Database 'mergeinto' has been set up.
Executing SQL scripts from: sql/mergeinto/bend/setup.sql using bendsql
Executing command: bendsql --query=-- row_per_block is set to 513, 5113, 51113 to ensure that the data is distributed across multiple blocks.
DROP TABLE IF EXISTS assets -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE assets (
                        user_id       INT          NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        value         DECIMAL(18,8) NOT NULL,
                        last_updated  DATE         NOT NULL
) cluster by(user_id,asset_type) row_per_block=513 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

DROP TABLE IF EXISTS assets_10w -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE assets_10w (
                        user_id       INT          NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        value         DECIMAL(18,8) NOT NULL,
                        last_updated  DATE         NOT NULL
) cluster by(user_id,asset_type) row_per_block=513 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

DROP TABLE IF EXISTS assets_10 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE assets_10 (
                        user_id       INT          NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        value         DECIMAL(18,8) NOT NULL,
                        last_updated  DATE         NOT NULL
) cluster by(user_id,asset_type) row_per_block=513 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

DROP TABLE IF EXISTS orders -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE orders (
                        order_id      INT          NOT NULL,
                        user_id       INT          NOT NULL,
                        order_type    VARCHAR      NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        price         DECIMAL(18,8) NOT NULL,
                        status        VARCHAR      NOT NULL,
                        created_at    DATE         NOT NULL,
                        updated_at    DATE         NOT NULL
) cluster by(order_id,user_id,order_type) row_per_block=5113 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

DROP TABLE IF EXISTS orders_25w -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE orders_25w (
                        order_id      INT          NOT NULL,
                        user_id       INT          NOT NULL,
                        order_type    VARCHAR      NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        price         DECIMAL(18,8) NOT NULL,
                        status        VARCHAR      NOT NULL,
                        created_at    DATE         NOT NULL,
                        updated_at    DATE         NOT NULL
) cluster by(order_id,user_id,order_type) row_per_block=5113 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

DROP TABLE IF EXISTS orders_25 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE orders_25 (
                        order_id      INT          NOT NULL,
                        user_id       INT          NOT NULL,
                        order_type    VARCHAR      NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        price         DECIMAL(18,8) NOT NULL,
                        status        VARCHAR      NOT NULL,
                        created_at    DATE         NOT NULL,
                        updated_at    DATE         NOT NULL
) cluster by(order_id,user_id,order_type) row_per_block=5113 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

DROP TABLE IF EXISTS transactions -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE transactions (
                              transaction_id    INT          NOT NULL,
                              user_id           INT          NOT NULL,
                              transaction_type  VARCHAR      NOT NULL,
                              asset_type        VARCHAR      NOT NULL,
                              quantity          DECIMAL(18,8) NOT NULL,
                              transaction_time  DATE         NOT NULL
) cluster by(transaction_id,user_id,transaction_type) row_per_block=51113 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

DROP TABLE IF EXISTS transactions_50w -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE transactions_50w (
                              transaction_id    INT          NOT NULL,
                              user_id           INT          NOT NULL,
                              transaction_type  VARCHAR      NOT NULL,
                              asset_type        VARCHAR      NOT NULL,
                              quantity          DECIMAL(18,8) NOT NULL,
                              transaction_time  DATE         NOT NULL
) cluster by(transaction_id,user_id,transaction_type) row_per_block=51113 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

DROP TABLE IF EXISTS transactions_50 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=
CREATE TABLE transactions_50 (
                              transaction_id    INT          NOT NULL,
                              user_id           INT          NOT NULL,
                              transaction_type  VARCHAR      NOT NULL,
                              asset_type        VARCHAR      NOT NULL,
                              quantity          DECIMAL(18,8) NOT NULL,
                              transaction_time  DATE         NOT NULL
) cluster by(transaction_id,user_id,transaction_type) row_per_block=51113 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

CREATE STAGE IF NOT EXISTS wizardbend3
    URL = 's3://wizardbend/' -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

COPY INTO assets
    FROM @wizardbend3/mergeinto/assets.parquet
    FILE_FORMAT = (TYPE = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/assets.parquet	100000	0	NULL	NULL

Executing command: bendsql --query=

COPY INTO assets_10w
    FROM @wizardbend3/mergeinto/assets_10w.parquet
    FILE_FORMAT = (TYPE = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/assets_10w.parquet	100000	0	NULL	NULL

Executing command: bendsql --query=

COPY INTO assets_10
    FROM @wizardbend3/mergeinto/assets_10.parquet
    FILE_FORMAT = (TYPE = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/assets_10.parquet	10	0	NULL	NULL

Executing command: bendsql --query=

COPY INTO orders
    FROM @wizardbend3/mergeinto/orders.parquet
    FILE_FORMAT = (type = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/orders.parquet	500000	0	NULL	NULL

Executing command: bendsql --query=

COPY INTO orders_25w
    FROM @wizardbend3/mergeinto/orders_25w.parquet
    FILE_FORMAT = (type = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/orders_25w.parquet	250000	0	NULL	NULL

Executing command: bendsql --query=

COPY INTO orders_25
    FROM @wizardbend3/mergeinto/orders_25.parquet
    FILE_FORMAT = (type = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/orders_25.parquet	25	0	NULL	NULL

Executing command: bendsql --query=

COPY INTO transactions
    FROM @wizardbend3/mergeinto/transactions.parquet
    FILE_FORMAT = (type = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/transactions.parquet	1000000	0	NULL	NULL

Executing command: bendsql --query=

COPY INTO transactions_50w
    FROM @wizardbend3/mergeinto/transactions_50w.parquet
    FILE_FORMAT = (type = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/transactions_50w.parquet	500000	0	NULL	NULL

Executing command: bendsql --query=

COPY INTO transactions_50
    FROM @wizardbend3/mergeinto/transactions_50.parquet
    FILE_FORMAT = (type = parquet) -D mergeinto
Command executed successfully. Output:
mergeinto/transactions_50.parquet	50	0	NULL	NULL

Executing SQL scripts from: sql/mergeinto/action.sql using bendsql
Executing command: bendsql --query=-- MERGE-INTO-A1-1: Conditional Merge Based on Order Status
-- This query updates orders with a status of 'pending' to 'completed'.
MERGE INTO orders_25 as orders USING (
    SELECT * FROM orders WHERE status = 'pending'
) AS pending_orders ON orders.order_id = pending_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'completed' -D mergeinto
Command executed successfully. Output:
7

Executing command: bendsql --query=

-- MERGE-INTO-A1-2: Conditional Merge Based on Order Status
-- This query updates orders with a status of 'pending' to 'completed'.
MERGE INTO orders_25w as orders USING (
    SELECT * FROM orders WHERE status = 'pending'
) AS pending_orders ON orders.order_id = pending_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'completed' -D mergeinto
Command executed successfully. Output:
87208

Executing command: bendsql --query=

-- MERGE-INTO-A2-1: Merging with Aggregated Data
-- This query updates the quantity of orders based on the sum of quantities for each user and asset type.
MERGE INTO orders_25 as orders USING (
    SELECT user_id, asset_type, SUM(quantity) AS total_quantity
    FROM orders
    GROUP BY user_id, asset_type
) AS agg_orders ON orders.user_id = agg_orders.user_id AND orders.asset_type = agg_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = agg_orders.total_quantity -D mergeinto
Command executed successfully. Output:
25

Executing command: bendsql --query=

-- MERGE-INTO-A2-2: Merging with Aggregated Data
-- This query updates the quantity of orders based on the sum of quantities for each user and asset type.
MERGE INTO orders_25w as orders USING (
    SELECT user_id, asset_type, SUM(quantity) AS total_quantity
    FROM orders
    GROUP BY user_id, asset_type
) AS agg_orders ON orders.user_id = agg_orders.user_id AND orders.asset_type = agg_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = agg_orders.total_quantity -D mergeinto
Command executed successfully. Output:
250000

Executing command: bendsql --query=

-- MERGE-INTO-A3-1: Merge with Date-Based Condition
-- This query archives orders created before 2022-01-01.
MERGE INTO orders_25 as orders USING (
    SELECT * FROM orders WHERE created_at < '2022-01-01'
) AS old_orders ON orders.order_id = old_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'archived' -D mergeinto
Command executed successfully. Output:
25

Executing command: bendsql --query=

-- MERGE-INTO-A3-1: Merge with Date-Based Condition
-- This query archives orders created before 2022-01-01.
MERGE INTO orders_25w as orders USING (
    SELECT * FROM orders WHERE created_at < '2022-01-01'
) AS old_orders ON orders.order_id = old_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'archived' -D mergeinto
Command executed successfully. Output:
250000

Executing command: bendsql --query=

-- MERGE-INTO-A4-1: Random Swap of Buy and Sell Orders
-- This query randomly swaps 'buy' and 'sell' order types.
MERGE INTO orders_25 as orders USING (
    SELECT order_id,
           user_id,
           CASE WHEN order_type = 'buy' THEN 'sell' ELSE 'buy' END AS order_type,
           asset_type,
           quantity,
           price,
           status,
           created_at,
           updated_at
    FROM orders
) AS swapped_orders ON orders.order_id = swapped_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.order_type = swapped_orders.order_type -D mergeinto
Command executed successfully. Output:
25

Executing command: bendsql --query=


-- MERGE-INTO-A4-2: Random Swap of Buy and Sell Orders
-- This query randomly swaps 'buy' and 'sell' order types.
MERGE INTO orders_25w as orders USING (
    SELECT order_id,
           user_id,
           CASE WHEN order_type = 'buy' THEN 'sell' ELSE 'buy' END AS order_type,
           asset_type,
           quantity,
           price,
           status,
           created_at,
           updated_at
    FROM orders
) AS swapped_orders ON orders.order_id = swapped_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.order_type = swapped_orders.order_type -D mergeinto
Command executed successfully. Output:
250000

Executing command: bendsql --query=

-- MERGE-INTO-A5-1: Merging with a Fixed Increase in Quantity
-- This query increases the quantity of each order by 10.
MERGE INTO orders_25 as orders USING (
    SELECT * FROM orders
) AS all_orders ON orders.order_id = all_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = orders.quantity + 10 -D mergeinto
Command executed successfully. Output:
25

Executing command: bendsql --query=

-- MERGE-INTO-A5-2: Merging with a Fixed Increase in Quantity
-- This query increases the quantity of each order by 10.
MERGE INTO orders_25w as orders USING (
    SELECT * FROM orders
) AS all_orders ON orders.order_id = all_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = orders.quantity + 10 -D mergeinto
Command executed successfully. Output:
250000

Executing command: bendsql --query=

-- MERGE-INTO-A6-1: Merge for Creating Duplicate Orders with New IDs
-- This query duplicates orders with new order IDs.
MERGE INTO orders_25 as orders USING (
    SELECT
            order_id + 500000 AS new_order_id, -- Creating new order_ids
            user_id,
            order_type,
            asset_type,
            quantity,
            price,
            status,
            created_at,
            updated_at
    FROM orders
) AS duplicate_orders ON orders.order_id = duplicate_orders.new_order_id
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (duplicate_orders.new_order_id, duplicate_orders.user_id, duplicate_orders.order_type, duplicate_orders.asset_type, duplicate_orders.quantity, duplicate_orders.price, duplicate_orders.status, duplicate_orders.created_at, duplicate_orders.updated_at) -D mergeinto
Command executed successfully. Output:
500000

Executing command: bendsql --query=

-- MERGE-INTO-A6-2: Merge for Creating Duplicate Orders with New IDs
-- This query duplicates orders with new order IDs.
MERGE INTO orders_25w as orders USING (
    SELECT
            order_id + 500000 AS new_order_id, -- Creating new order_ids
            user_id,
            order_type,
            asset_type,
            quantity,
            price,
            status,
            created_at,
            updated_at
    FROM orders
) AS duplicate_orders ON orders.order_id = duplicate_orders.new_order_id
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (duplicate_orders.new_order_id, duplicate_orders.user_id, duplicate_orders.order_type, duplicate_orders.asset_type, duplicate_orders.quantity, duplicate_orders.price, duplicate_orders.status, duplicate_orders.created_at, duplicate_orders.updated_at) -D mergeinto
Command executed successfully. Output:
500000

Executing command: bendsql --query=


-- MERGE-INTO-A7-1: Merge with Subquery Join
-- This query updates orders with a new quantity based on an average quantity calculation joined from a subquery.
MERGE INTO orders_25 as orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity + a.avg_quantity AS new_quantity, o.price, o.status, o.created_at, o.updated_at
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) a ON o.user_id = a.user_id AND o.asset_type = a.asset_type
) AS joined_data ON orders.order_id = joined_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = joined_data.new_quantity -D mergeinto
Command executed successfully. Output:
25

Executing command: bendsql --query=

-- MERGE-INTO-A7-2: Merge with Subquery Join
-- This query updates orders with a new quantity based on an average quantity calculation joined from a subquery.
MERGE INTO orders_25w as orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity + a.avg_quantity AS new_quantity, o.price, o.status, o.created_at, o.updated_at
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) a ON o.user_id = a.user_id AND o.asset_type = a.asset_type
) AS joined_data ON orders.order_id = joined_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = joined_data.new_quantity -D mergeinto
Command executed successfully. Output:
250000

Executing command: bendsql --query=

-- MERGE-INTO-A8-1: Merge with Date Ranges and Status Change
-- This query updates the status of orders created between 2021-01-01 and 2021-06-30.
MERGE INTO orders_25 as orders USING (
    SELECT * FROM orders
    WHERE created_at BETWEEN '2021-01-01' AND '2021-06-30'
) AS date_filtered ON orders.order_id = date_filtered.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = CASE WHEN orders.status = 'pending' THEN 'expired' ELSE orders.status END -D mergeinto
Command executed successfully. Output:
25

Executing command: bendsql --query=

-- MERGE-INTO-A8-2: Merge with Date Ranges and Status Change
-- This query updates the status of orders created between 2021-01-01 and 2021-06-30.
MERGE INTO orders_25w as orders USING (
    SELECT * FROM orders
    WHERE created_at BETWEEN '2021-01-01' AND '2021-06-30'
) AS date_filtered ON orders.order_id = date_filtered.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = CASE WHEN orders.status = 'pending' THEN 'expired' ELSE orders.status END -D mergeinto
Command executed successfully. Output:
250000

Executing command: bendsql --query=

-- MERGE-INTO-A9-1: Complex Merge with Nested Subqueries
-- This query updates the status of orders based on their quantity in relation to the average quantity.
MERGE INTO orders_25 as orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity, o.price, o.status, o.created_at, o.updated_at,
           CASE
               WHEN o.quantity < sub.avg_quantity THEN 'below_avg'
               WHEN o.quantity > sub.avg_quantity THEN 'above_avg'
               ELSE 'avg'
               END AS quantity_status
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) sub ON o.user_id = sub.user_id AND o.asset_type = sub.asset_type
) AS complex_data ON orders.order_id = complex_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = complex_data.quantity_status -D mergeinto
Command executed successfully. Output:
25

Executing command: bendsql --query=

-- MERGE-INTO-A9-2: Complex Merge with Nested Subqueries
-- This query updates the status of orders based on their quantity in relation to the average quantity.
MERGE INTO orders_25w as orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity, o.price, o.status, o.created_at, o.updated_at,
           CASE
               WHEN o.quantity < sub.avg_quantity THEN 'below_avg'
               WHEN o.quantity > sub.avg_quantity THEN 'above_avg'
               ELSE 'avg'
               END AS quantity_status
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) sub ON o.user_id = sub.user_id AND o.asset_type = sub.asset_type
) AS complex_data ON orders.order_id = complex_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = complex_data.quantity_status -D mergeinto
Command executed successfully. Output:
250000

Executing command: bendsql --query=

-- MERGE-INTO-A10-1: Merge Based on Average Asset Value
-- This query updates the price of orders based on the average value of assets for each user and asset type.
MERGE INTO orders_25 as orders USING (
    SELECT a.user_id, a.asset_type, AVG(a.value) as avg_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
) AS asset_data ON orders.user_id = asset_data.user_id AND orders.asset_type = asset_data.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.price = orders.price + asset_data.avg_value -D mergeinto
Command executed successfully. Output:
167229

Executing command: bendsql --query=

-- MERGE-INTO-A10-2: Merge Based on Average Asset Value
-- This query updates the price of orders based on the average value of assets for each user and asset type.
MERGE INTO orders_25w as orders USING (
    SELECT a.user_id, a.asset_type, AVG(a.value) as avg_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
) AS asset_data ON orders.user_id = asset_data.user_id AND orders.asset_type = asset_data.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.price = orders.price + asset_data.avg_value -D mergeinto
Command executed successfully. Output:
250889

Executing command: bendsql --query=

-- MERGE-INTO-A11-1: asserts
MERGE INTO assets_10 as assets USING (
    SELECT a.user_id, a.asset_type,
           SUM(a.quantity) AS total_quantity,
           AVG(a.value) AS average_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
    UNION ALL
    SELECT a.user_id, 'NEW_ASSET' AS asset_type,  -- New asset type for insert
           100 AS quantity,                       -- Example quantity
           1000 AS value                          -- Example value
    FROM assets a
    WHERE a.user_id % 2 = 0  -- Condition to select subset for new data
    GROUP BY a.user_id
) AS combined_assets ON assets.user_id = combined_assets.user_id AND assets.asset_type = combined_assets.asset_type
    WHEN MATCHED THEN
        UPDATE SET assets.quantity = combined_assets.total_quantity, assets.value = combined_assets.average_value
    WHEN NOT MATCHED THEN
        INSERT (user_id, asset_type, quantity, value, last_updated)
            VALUES (combined_assets.user_id, combined_assets.asset_type, combined_assets.total_quantity, combined_assets.average_value, '2023-01-01') -D mergeinto
Command executed successfully. Output:
149990	10

Executing command: bendsql --query=

-- MERGE-INTO-A11-2: asserts
MERGE INTO assets_10w as assets USING (
    SELECT a.user_id, a.asset_type,
           SUM(a.quantity) AS total_quantity,
           AVG(a.value) AS average_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
    UNION ALL
    SELECT a.user_id, 'NEW_ASSET' AS asset_type,  -- New asset type for insert
           100 AS quantity,                       -- Example quantity
           1000 AS value                          -- Example value
    FROM assets a
    WHERE a.user_id % 2 = 0  -- Condition to select subset for new data
    GROUP BY a.user_id
) AS combined_assets ON assets.user_id = combined_assets.user_id AND assets.asset_type = combined_assets.asset_type
    WHEN MATCHED THEN
        UPDATE SET assets.quantity = combined_assets.total_quantity, assets.value = combined_assets.average_value
    WHEN NOT MATCHED THEN
        INSERT (user_id, asset_type, quantity, value, last_updated)
            VALUES (combined_assets.user_id, combined_assets.asset_type, combined_assets.total_quantity, combined_assets.average_value, '2023-01-01') -D mergeinto
Command executed successfully. Output:
50000	100000

Executing command: bendsql --query=

-- MERGE-INTO-A12-1: transactions
MERGE INTO transactions_50 as transactions
    USING (
        SELECT
            t.user_id,
            t.asset_type,
            SUM(t.quantity) AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, t.asset_type) AS next_transaction_id
        FROM transactions t
        GROUP BY t.user_id, t.asset_type
        UNION ALL
        SELECT
            t.user_id,
            'NEW_TRANSACTION' AS asset_type,
            30 AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, 'NEW_TRANSACTION') AS next_transaction_id
        FROM transactions t
        WHERE t.user_id % 2 = 0
        GROUP BY t.user_id
    ) AS combined_transactions
    ON transactions.user_id = combined_transactions.user_id
        AND transactions.asset_type = combined_transactions.asset_type
    WHEN MATCHED AND combined_transactions.user_id > 5000 THEN DELETE
    WHEN MATCHED THEN
        UPDATE SET transactions.quantity = combined_transactions.total_quantity
    WHEN NOT MATCHED THEN
        INSERT (transaction_id, user_id, transaction_type, asset_type, quantity, transaction_time)
            VALUES (combined_transactions.next_transaction_id,
                    combined_transactions.user_id,
                    'trade',
                    combined_transactions.asset_type,
                    combined_transactions.total_quantity,
                    '2023-01-01') -D mergeinto
Command executed successfully. Output:
344558	0	50

Executing command: bendsql --query=

-- MERGE-INTO-A12-2: transactions
MERGE INTO transactions_50w as transactions
    USING (
        SELECT
            t.user_id,
            t.asset_type,
            SUM(t.quantity) AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, t.asset_type) AS next_transaction_id
        FROM transactions t
        GROUP BY t.user_id, t.asset_type
        UNION ALL
        SELECT
            t.user_id,
            'NEW_TRANSACTION' AS asset_type,
            30 AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, 'NEW_TRANSACTION') AS next_transaction_id
        FROM transactions t
        WHERE t.user_id % 2 = 0
        GROUP BY t.user_id
    ) AS combined_transactions
    ON transactions.user_id = combined_transactions.user_id
        AND transactions.asset_type = combined_transactions.asset_type
    WHEN MATCHED AND combined_transactions.user_id > 5000 THEN DELETE
    WHEN MATCHED THEN
        UPDATE SET transactions.quantity = combined_transactions.total_quantity
    WHEN NOT MATCHED THEN
        INSERT (transaction_id, user_id, transaction_type, asset_type, quantity, transaction_time)
            VALUES (combined_transactions.next_transaction_id,
                    combined_transactions.user_id,
                    'trade',
                    combined_transactions.asset_type,
                    combined_transactions.total_quantity,
                    '2023-01-01') -D mergeinto
Command executed successfully. Output:
88968	25005	474995

Executing command: bendsql --query=

-- MERGE-INTO-A13-1: orders
MERGE INTO orders_25 as orders
    USING (
        SELECT
            o.user_id,
            o.asset_type,
            SUM(o.quantity) AS total_quantity,
            AVG(o.price) AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, o.asset_type) AS next_order_id
        FROM orders o
        GROUP BY o.user_id, o.asset_type
        UNION ALL
        SELECT
            o.user_id,
            'NEW_ORDER' AS asset_type,
            50 AS total_quantity,
            500 AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, 'NEW_ORDER') AS next_order_id
        FROM orders o
        WHERE o.user_id % 2 = 0
        GROUP BY o.user_id
    ) AS combined_orders
    ON orders.user_id = combined_orders.user_id AND orders.asset_type = combined_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = combined_orders.total_quantity, orders.price = combined_orders.average_price
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (combined_orders.next_order_id,
                    combined_orders.user_id,
                    'buy',
                    combined_orders.asset_type,
                    combined_orders.total_quantity,
                    combined_orders.average_price,
                    'Pending',
                    '2023-01-01',
                    '2023-01-01') -D mergeinto
Command executed successfully. Output:
50000	500025

Executing command: bendsql --query=

-- MERGE-INTO-A13-2: orders
MERGE INTO orders_25w as orders
    USING (
        SELECT
            o.user_id,
            o.asset_type,
            SUM(o.quantity) AS total_quantity,
            AVG(o.price) AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, o.asset_type) AS next_order_id
        FROM orders o
        GROUP BY o.user_id, o.asset_type
        UNION ALL
        SELECT
            o.user_id,
            'NEW_ORDER' AS asset_type,
            50 AS total_quantity,
            500 AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, 'NEW_ORDER') AS next_order_id
        FROM orders o
        WHERE o.user_id % 2 = 0
        GROUP BY o.user_id
    ) AS combined_orders
    ON orders.user_id = combined_orders.user_id AND orders.asset_type = combined_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = combined_orders.total_quantity, orders.price = combined_orders.average_price
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (combined_orders.next_order_id,
                    combined_orders.user_id,
                    'buy',
                    combined_orders.asset_type,
                    combined_orders.total_quantity,
                    combined_orders.average_price,
                    'Pending',
                    '2023-01-01',
                    '2023-01-01') -D mergeinto
Command executed successfully. Output:
50000	750000

Executing command: bendsql --query=

-- MERGE-INTO-A14: Conditional Merge Based on Order Status
-- This query updates orders with a status of 'pending' to 'completed'.
MERGE INTO orders USING (
    SELECT * FROM orders WHERE status = 'pending'
) AS pending_orders ON orders.order_id = pending_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'completed' -D mergeinto
Command executed successfully. Output:
174150

Executing command: bendsql --query=

-- MERGE-INTO-A15: Merging with Aggregated Data
-- This query updates the quantity of orders based on the sum of quantities for each user and asset type.
MERGE INTO orders USING (
    SELECT user_id, asset_type, SUM(quantity) AS total_quantity
    FROM orders
    GROUP BY user_id, asset_type
) AS agg_orders ON orders.user_id = agg_orders.user_id AND orders.asset_type = agg_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = agg_orders.total_quantity -D mergeinto
Command executed successfully. Output:
500000

Executing command: bendsql --query=

-- MERGE-INTO-A16: Merge with Date-Based Condition
-- This query archives orders created before 2022-01-01.
MERGE INTO orders USING (
    SELECT * FROM orders WHERE created_at < '2022-01-01'
) AS old_orders ON orders.order_id = old_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'archived' -D mergeinto
Command executed successfully. Output:
500000

Executing command: bendsql --query=

-- MERGE-INTO-A17: Random Swap of Buy and Sell Orders
-- This query randomly swaps 'buy' and 'sell' order types.
MERGE INTO orders USING (
    SELECT order_id,
           user_id,
           CASE WHEN order_type = 'buy' THEN 'sell' ELSE 'buy' END AS order_type,
           asset_type,
           quantity,
           price,
           status,
           created_at,
           updated_at
    FROM orders
) AS swapped_orders ON orders.order_id = swapped_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.order_type = swapped_orders.order_type -D mergeinto
Command executed successfully. Output:
500000

Executing command: bendsql --query=

-- MERGE-INTO-A18: Merging with a Fixed Increase in Quantity
-- This query increases the quantity of each order by 10.
MERGE INTO orders USING (
    SELECT * FROM orders
) AS all_orders ON orders.order_id = all_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = orders.quantity + 10 -D mergeinto
Command executed successfully. Output:
500000

Executing command: bendsql --query=

-- MERGE-INTO-A19: Merge for Creating Duplicate Orders with New IDs
-- This query duplicates orders with new order IDs.
MERGE INTO orders USING (
    SELECT
            order_id + 500000 AS new_order_id, -- Creating new order_ids
            user_id,
            order_type,
            asset_type,
            quantity,
            price,
            status,
            created_at,
            updated_at
    FROM orders
) AS duplicate_orders ON orders.order_id = duplicate_orders.new_order_id
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (duplicate_orders.new_order_id, duplicate_orders.user_id, duplicate_orders.order_type, duplicate_orders.asset_type, duplicate_orders.quantity, duplicate_orders.price, duplicate_orders.status, duplicate_orders.created_at, duplicate_orders.updated_at) -D mergeinto
Command executed successfully. Output:
500000

Executing command: bendsql --query=

-- MERGE-INTO-A20: Merge with Subquery Join
-- This query updates orders with a new quantity based on an average quantity calculation joined from a subquery.
MERGE INTO orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity + a.avg_quantity AS new_quantity, o.price, o.status, o.created_at, o.updated_at
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) a ON o.user_id = a.user_id AND o.asset_type = a.asset_type
) AS joined_data ON orders.order_id = joined_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = joined_data.new_quantity -D mergeinto
Command executed successfully. Output:
1000000

Executing command: bendsql --query=

-- MERGE-INTO-A21: Merge with Date Ranges and Status Change
-- This query updates the status of orders created between 2021-01-01 and 2021-06-30.
MERGE INTO orders USING (
    SELECT * FROM orders
    WHERE created_at BETWEEN '2021-01-01' AND '2021-06-30'
) AS date_filtered ON orders.order_id = date_filtered.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = CASE WHEN orders.status = 'pending' THEN 'expired' ELSE orders.status END -D mergeinto
Command executed successfully. Output:
1000000

Executing command: bendsql --query=

-- MERGE-INTO-A22: Complex Merge with Nested Subqueries
-- This query updates the status of orders based on their quantity in relation to the average quantity.
MERGE INTO orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity, o.price, o.status, o.created_at, o.updated_at,
           CASE
               WHEN o.quantity < sub.avg_quantity THEN 'below_avg'
               WHEN o.quantity > sub.avg_quantity THEN 'above_avg'
               ELSE 'avg'
               END AS quantity_status
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) sub ON o.user_id = sub.user_id AND o.asset_type = sub.asset_type
) AS complex_data ON orders.order_id = complex_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = complex_data.quantity_status -D mergeinto
Command executed successfully. Output:
1000000

Executing command: bendsql --query=

-- MERGE-INTO-A23: Merge Based on Average Asset Value
-- This query updates the price of orders based on the average value of assets for each user and asset type.
MERGE INTO orders USING (
    SELECT a.user_id, a.asset_type, AVG(a.value) as avg_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
) AS asset_data ON orders.user_id = asset_data.user_id AND orders.asset_type = asset_data.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.price = orders.price + asset_data.avg_value -D mergeinto
Command executed successfully. Output:
334442

Executing command: bendsql --query=

-- MERGE-INTO-A24: asserts
MERGE INTO assets USING (
    SELECT a.user_id, a.asset_type,
           SUM(a.quantity) AS total_quantity,
           AVG(a.value) AS average_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
    UNION ALL
    SELECT a.user_id, 'NEW_ASSET' AS asset_type,  -- New asset type for insert
           100 AS quantity,                       -- Example quantity
           1000 AS value                          -- Example value
    FROM assets a
    WHERE a.user_id % 2 = 0  -- Condition to select subset for new data
    GROUP BY a.user_id
) AS combined_assets ON assets.user_id = combined_assets.user_id AND assets.asset_type = combined_assets.asset_type
    WHEN MATCHED THEN
        UPDATE SET assets.quantity = combined_assets.total_quantity, assets.value = combined_assets.average_value
    WHEN NOT MATCHED THEN
        INSERT (user_id, asset_type, quantity, value, last_updated)
            VALUES (combined_assets.user_id, combined_assets.asset_type, combined_assets.total_quantity, combined_assets.average_value, '2023-01-01') -D mergeinto
Command executed successfully. Output:
50000	100000

Executing command: bendsql --query=

-- MERGE-INTO-A25: transactions
MERGE INTO transactions
    USING (
        SELECT
            t.user_id,
            t.asset_type,
            SUM(t.quantity) AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, t.asset_type) AS next_transaction_id
        FROM transactions t
        GROUP BY t.user_id, t.asset_type
        UNION ALL
        SELECT
            t.user_id,
            'NEW_TRANSACTION' AS asset_type,
            30 AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, 'NEW_TRANSACTION') AS next_transaction_id
        FROM transactions t
        WHERE t.user_id % 2 = 0
        GROUP BY t.user_id
    ) AS combined_transactions
    ON transactions.user_id = combined_transactions.user_id
        AND transactions.asset_type = combined_transactions.asset_type
    WHEN MATCHED AND combined_transactions.user_id > 5000 THEN DELETE
    WHEN MATCHED THEN
        UPDATE SET transactions.quantity = combined_transactions.total_quantity
    WHEN NOT MATCHED THEN
        INSERT (transaction_id, user_id, transaction_type, asset_type, quantity, transaction_time)
            VALUES (combined_transactions.next_transaction_id,
                    combined_transactions.user_id,
                    'trade',
                    combined_transactions.asset_type,
                    combined_transactions.total_quantity,
                    '2023-01-01') -D mergeinto
Command executed successfully. Output:
50000	50010	949990

Executing command: bendsql --query=

-- MERGE-INTO-A26: orders
MERGE INTO orders
    USING (
        SELECT
            o.user_id,
            o.asset_type,
            SUM(o.quantity) AS total_quantity,
            AVG(o.price) AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, o.asset_type) AS next_order_id
        FROM orders o
        GROUP BY o.user_id, o.asset_type
        UNION ALL
        SELECT
            o.user_id,
            'NEW_ORDER' AS asset_type,
            50 AS total_quantity,
            500 AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, 'NEW_ORDER') AS next_order_id
        FROM orders o
        WHERE o.user_id % 2 = 0
        GROUP BY o.user_id
    ) AS combined_orders
    ON orders.user_id = combined_orders.user_id AND orders.asset_type = combined_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = combined_orders.total_quantity, orders.price = combined_orders.average_price
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (combined_orders.next_order_id,
                    combined_orders.user_id,
                    'buy',
                    combined_orders.asset_type,
                    combined_orders.total_quantity,
                    combined_orders.average_price,
                    'Pending',
                    '2023-01-01',
                    '2023-01-01') -D mergeinto
Command executed successfully. Output:
50000	1000000

Executing command: bendsql --query=

-- INSERT-INTO-A27: orders
INSERT INTO orders SELECT * FROM orders_25 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

-- INSERT-INTO-A28: orders
INSERT INTO orders SELECT * FROM orders_25w -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

-- INSERT-INTO-A29: orders
INSERT INTO transactions SELECT * FROM transactions_50 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

-- INSERT-INTO-A30: orders
INSERT INTO transactions SELECT * FROM transactions_50w -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

-- INSERT-INTO-A31: orders
INSERT INTO assets SELECT * FROM assets_10 -D mergeinto
Command executed successfully. Output:

Executing command: bendsql --query=

-- INSERT-INTO-A32: orders
INSERT INTO assets SELECT * FROM assets_10w -D mergeinto
Command executed successfully. Output:

Executing command: snowsql --query DROP DATABASE IF EXISTS mergeinto; --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false
Command executed successfully. Output:
MERGEINTO successfully dropped.

Executing command: snowsql --query CREATE DATABASE mergeinto; --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false
Command executed successfully. Output:
Database MERGEINTO successfully created.

Database 'mergeinto' has been set up.
Executing SQL scripts from: sql/mergeinto/snow/setup.sql using snowsql
Executing command: snowsql --query DROP TABLE IF EXISTS assets --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (ASSETS already dropped).

Executing command: snowsql --query 
CREATE TABLE assets (
                        user_id INT NOT NULL,
                        asset_type VARCHAR NOT NULL,
                        quantity DECIMAL(18, 8) NOT NULL,
                        value DECIMAL(18, 8) NOT NULL,
                        last_updated DATE NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table ASSETS successfully created.

Executing command: snowsql --query 


DROP TABLE IF EXISTS assets_10w --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (ASSETS_10W already dropped).

Executing command: snowsql --query 
CREATE TABLE assets_10w (
                        user_id       INT          NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        value         DECIMAL(18,8) NOT NULL,
                        last_updated  DATE         NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table ASSETS_10W successfully created.

Executing command: snowsql --query 

DROP TABLE IF EXISTS assets_10 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (ASSETS_10 already dropped).

Executing command: snowsql --query 
CREATE TABLE assets_10 (
                        user_id       INT          NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        value         DECIMAL(18,8) NOT NULL,
                        last_updated  DATE         NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table ASSETS_10 successfully created.

Executing command: snowsql --query 

DROP TABLE IF EXISTS orders --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (ORDERS already dropped).

Executing command: snowsql --query 
CREATE TABLE orders (
                        order_id INT NOT NULL,
                        user_id INT NOT NULL,
                        order_type VARCHAR NOT NULL,
                        asset_type VARCHAR NOT NULL,
                        quantity DECIMAL(18, 8) NOT NULL,
                        price DECIMAL(18, 8) NOT NULL,
                        status VARCHAR NOT NULL,
                        created_at DATE NOT NULL,
                        updated_at DATE NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table ORDERS successfully created.

Executing command: snowsql --query 

DROP TABLE IF EXISTS orders_25w --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (ORDERS_25W already dropped).

Executing command: snowsql --query 
CREATE TABLE orders_25w (
                        order_id      INT          NOT NULL,
                        user_id       INT          NOT NULL,
                        order_type    VARCHAR      NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        price         DECIMAL(18,8) NOT NULL,
                        status        VARCHAR      NOT NULL,
                        created_at    DATE         NOT NULL,
                        updated_at    DATE         NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table ORDERS_25W successfully created.

Executing command: snowsql --query 

DROP TABLE IF EXISTS orders_25 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (ORDERS_25 already dropped).

Executing command: snowsql --query 
CREATE TABLE orders_25 (
                        order_id      INT          NOT NULL,
                        user_id       INT          NOT NULL,
                        order_type    VARCHAR      NOT NULL,
                        asset_type    VARCHAR      NOT NULL,
                        quantity      DECIMAL(18,8) NOT NULL,
                        price         DECIMAL(18,8) NOT NULL,
                        status        VARCHAR      NOT NULL,
                        created_at    DATE         NOT NULL,
                        updated_at    DATE         NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table ORDERS_25 successfully created.

Executing command: snowsql --query 

DROP TABLE IF EXISTS transactions --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (TRANSACTIONS already dropped).

Executing command: snowsql --query 
CREATE TABLE transactions (
                              transaction_id INT NOT NULL,
                              user_id INT NOT NULL,
                              transaction_type VARCHAR NOT NULL,
                              asset_type VARCHAR NOT NULL,
                              quantity DECIMAL(18, 8) NOT NULL,
                              transaction_time DATE NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table TRANSACTIONS successfully created.

Executing command: snowsql --query 

DROP TABLE IF EXISTS transactions_50w --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (TRANSACTIONS_50W already dropped).

Executing command: snowsql --query 
CREATE TABLE transactions_50w (
                              transaction_id    INT          NOT NULL,
                              user_id           INT          NOT NULL,
                              transaction_type  VARCHAR      NOT NULL,
                              asset_type        VARCHAR      NOT NULL,
                              quantity          DECIMAL(18,8) NOT NULL,
                              transaction_time  DATE         NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table TRANSACTIONS_50W successfully created.

Executing command: snowsql --query 
DROP TABLE IF EXISTS transactions_50 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Drop statement executed successfully (TRANSACTIONS_50 already dropped).

Executing command: snowsql --query 
CREATE TABLE transactions_50 (
                              transaction_id    INT          NOT NULL,
                              user_id           INT          NOT NULL,
                              transaction_type  VARCHAR      NOT NULL,
                              asset_type        VARCHAR      NOT NULL,
                              quantity          DECIMAL(18,8) NOT NULL,
                              transaction_time  DATE         NOT NULL
) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Table TRANSACTIONS_50 successfully created.

Executing command: snowsql --query 

CREATE OR REPLACE STAGE wizardbend URL='s3://wizardbend/' --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
Stage area WIZARDBEND successfully created.

Executing command: snowsql --query 
CREATE OR REPLACE FILE FORMAT parquet_format TYPE = 'parquet' --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
File format PARQUET_FORMAT successfully created.

Executing command: snowsql --query 

COPY INTO assets
    FROM (SELECT
    $1:user_id::INT,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:value::DECIMAL(18, 8),
    $1:last_updated::DATE
    FROM @wizardbend/mergeinto/assets.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/assets.parquet	LOADED	100000	100000	1	0	None	None	None	None

Executing command: snowsql --query 

COPY INTO assets_10w
    FROM (SELECT
    $1:user_id::INT,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:value::DECIMAL(18, 8),
    $1:last_updated::DATE
    FROM @wizardbend/mergeinto/assets_10w.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/assets_10w.parquet	LOADED	100000	100000	1	0	None	None	None	None

Executing command: snowsql --query 

COPY INTO assets_10
    FROM (SELECT
    $1:user_id::INT,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:value::DECIMAL(18, 8),
    $1:last_updated::DATE
    FROM @wizardbend/mergeinto/assets_10.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/assets_10.parquet	LOADED	10	10	1	0	None	None	None	None

Executing command: snowsql --query 

COPY INTO orders
    FROM (SELECT
    $1:order_id::INT,
    $1:user_id::INT,
    $1:order_type::VARCHAR,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:price::DECIMAL(18, 8),
    $1:status::VARCHAR,
    $1:created_at::DATE,
    $1:updated_at::DATE
    FROM @wizardbend/mergeinto/orders.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/orders.parquet	LOADED	500000	500000	1	0	None	None	None	None

Executing command: snowsql --query 

COPY INTO orders_25w
    FROM (SELECT
    $1:order_id::INT,
    $1:user_id::INT,
    $1:order_type::VARCHAR,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:price::DECIMAL(18, 8),
    $1:status::VARCHAR,
    $1:created_at::DATE,
    $1:updated_at::DATE
    FROM @wizardbend/mergeinto/orders_25w.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/orders_25w.parquet	LOADED	250000	250000	1	0	None	None	None	None

Executing command: snowsql --query 

COPY INTO orders_25
    FROM (SELECT
    $1:order_id::INT,
    $1:user_id::INT,
    $1:order_type::VARCHAR,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:price::DECIMAL(18, 8),
    $1:status::VARCHAR,
    $1:created_at::DATE,
    $1:updated_at::DATE
    FROM @wizardbend/mergeinto/orders_25.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/orders_25.parquet	LOADED	25	25	1	0	None	None	None	None

Executing command: snowsql --query 

COPY INTO transactions
    FROM (SELECT
    $1:transaction_id::INT,
    $1:user_id::INT,
    $1:transaction_type::VARCHAR,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:transaction_time::DATE
    FROM @wizardbend/mergeinto/transactions.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/transactions.parquet	LOADED	1000000	1000000	1	0	None	None	None	None

Executing command: snowsql --query 

COPY INTO transactions_50w
    FROM (SELECT
    $1:transaction_id::INT,
    $1:user_id::INT,
    $1:transaction_type::VARCHAR,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:transaction_time::DATE
    FROM @wizardbend/mergeinto/transactions_50w.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/transactions_50w.parquet	LOADED	500000	500000	1	0	None	None	None	None

Executing command: snowsql --query 

COPY INTO transactions_50
    FROM (SELECT
    $1:transaction_id::INT,
    $1:user_id::INT,
    $1:transaction_type::VARCHAR,
    $1:asset_type::VARCHAR,
    $1:quantity::DECIMAL(18, 8),
    $1:transaction_time::DATE
    FROM @wizardbend/mergeinto/transactions_50.parquet (file_format => 'parquet_format')) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
s3://wizardbend/mergeinto/transactions_50.parquet	LOADED	50	50	1	0	None	None	None	None

Executing SQL scripts from: sql/mergeinto/action.sql using snowsql
Executing command: snowsql --query -- MERGE-INTO-A1-1: Conditional Merge Based on Order Status
-- This query updates orders with a status of 'pending' to 'completed'.
MERGE INTO orders_25 as orders USING (
    SELECT * FROM orders WHERE status = 'pending'
) AS pending_orders ON orders.order_id = pending_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'completed' --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
7

Executing command: snowsql --query 

-- MERGE-INTO-A1-2: Conditional Merge Based on Order Status
-- This query updates orders with a status of 'pending' to 'completed'.
MERGE INTO orders_25w as orders USING (
    SELECT * FROM orders WHERE status = 'pending'
) AS pending_orders ON orders.order_id = pending_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'completed' --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
87208

Executing command: snowsql --query 

-- MERGE-INTO-A2-1: Merging with Aggregated Data
-- This query updates the quantity of orders based on the sum of quantities for each user and asset type.
MERGE INTO orders_25 as orders USING (
    SELECT user_id, asset_type, SUM(quantity) AS total_quantity
    FROM orders
    GROUP BY user_id, asset_type
) AS agg_orders ON orders.user_id = agg_orders.user_id AND orders.asset_type = agg_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = agg_orders.total_quantity --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
25

Executing command: snowsql --query 

-- MERGE-INTO-A2-2: Merging with Aggregated Data
-- This query updates the quantity of orders based on the sum of quantities for each user and asset type.
MERGE INTO orders_25w as orders USING (
    SELECT user_id, asset_type, SUM(quantity) AS total_quantity
    FROM orders
    GROUP BY user_id, asset_type
) AS agg_orders ON orders.user_id = agg_orders.user_id AND orders.asset_type = agg_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = agg_orders.total_quantity --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
250000

Executing command: snowsql --query 

-- MERGE-INTO-A3-1: Merge with Date-Based Condition
-- This query archives orders created before 2022-01-01.
MERGE INTO orders_25 as orders USING (
    SELECT * FROM orders WHERE created_at < '2022-01-01'
) AS old_orders ON orders.order_id = old_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'archived' --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
25

Executing command: snowsql --query 

-- MERGE-INTO-A3-1: Merge with Date-Based Condition
-- This query archives orders created before 2022-01-01.
MERGE INTO orders_25w as orders USING (
    SELECT * FROM orders WHERE created_at < '2022-01-01'
) AS old_orders ON orders.order_id = old_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'archived' --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
250000

Executing command: snowsql --query 

-- MERGE-INTO-A4-1: Random Swap of Buy and Sell Orders
-- This query randomly swaps 'buy' and 'sell' order types.
MERGE INTO orders_25 as orders USING (
    SELECT order_id,
           user_id,
           CASE WHEN order_type = 'buy' THEN 'sell' ELSE 'buy' END AS order_type,
           asset_type,
           quantity,
           price,
           status,
           created_at,
           updated_at
    FROM orders
) AS swapped_orders ON orders.order_id = swapped_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.order_type = swapped_orders.order_type --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
25

Executing command: snowsql --query 


-- MERGE-INTO-A4-2: Random Swap of Buy and Sell Orders
-- This query randomly swaps 'buy' and 'sell' order types.
MERGE INTO orders_25w as orders USING (
    SELECT order_id,
           user_id,
           CASE WHEN order_type = 'buy' THEN 'sell' ELSE 'buy' END AS order_type,
           asset_type,
           quantity,
           price,
           status,
           created_at,
           updated_at
    FROM orders
) AS swapped_orders ON orders.order_id = swapped_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.order_type = swapped_orders.order_type --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
250000

Executing command: snowsql --query 

-- MERGE-INTO-A5-1: Merging with a Fixed Increase in Quantity
-- This query increases the quantity of each order by 10.
MERGE INTO orders_25 as orders USING (
    SELECT * FROM orders
) AS all_orders ON orders.order_id = all_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = orders.quantity + 10 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
25

Executing command: snowsql --query 

-- MERGE-INTO-A5-2: Merging with a Fixed Increase in Quantity
-- This query increases the quantity of each order by 10.
MERGE INTO orders_25w as orders USING (
    SELECT * FROM orders
) AS all_orders ON orders.order_id = all_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = orders.quantity + 10 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
250000

Executing command: snowsql --query 

-- MERGE-INTO-A6-1: Merge for Creating Duplicate Orders with New IDs
-- This query duplicates orders with new order IDs.
MERGE INTO orders_25 as orders USING (
    SELECT
            order_id + 500000 AS new_order_id, -- Creating new order_ids
            user_id,
            order_type,
            asset_type,
            quantity,
            price,
            status,
            created_at,
            updated_at
    FROM orders
) AS duplicate_orders ON orders.order_id = duplicate_orders.new_order_id
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (duplicate_orders.new_order_id, duplicate_orders.user_id, duplicate_orders.order_type, duplicate_orders.asset_type, duplicate_orders.quantity, duplicate_orders.price, duplicate_orders.status, duplicate_orders.created_at, duplicate_orders.updated_at) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
500000

Executing command: snowsql --query 

-- MERGE-INTO-A6-2: Merge for Creating Duplicate Orders with New IDs
-- This query duplicates orders with new order IDs.
MERGE INTO orders_25w as orders USING (
    SELECT
            order_id + 500000 AS new_order_id, -- Creating new order_ids
            user_id,
            order_type,
            asset_type,
            quantity,
            price,
            status,
            created_at,
            updated_at
    FROM orders
) AS duplicate_orders ON orders.order_id = duplicate_orders.new_order_id
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (duplicate_orders.new_order_id, duplicate_orders.user_id, duplicate_orders.order_type, duplicate_orders.asset_type, duplicate_orders.quantity, duplicate_orders.price, duplicate_orders.status, duplicate_orders.created_at, duplicate_orders.updated_at) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
500000

Executing command: snowsql --query 


-- MERGE-INTO-A7-1: Merge with Subquery Join
-- This query updates orders with a new quantity based on an average quantity calculation joined from a subquery.
MERGE INTO orders_25 as orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity + a.avg_quantity AS new_quantity, o.price, o.status, o.created_at, o.updated_at
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) a ON o.user_id = a.user_id AND o.asset_type = a.asset_type
) AS joined_data ON orders.order_id = joined_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = joined_data.new_quantity --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
25

Executing command: snowsql --query 

-- MERGE-INTO-A7-2: Merge with Subquery Join
-- This query updates orders with a new quantity based on an average quantity calculation joined from a subquery.
MERGE INTO orders_25w as orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity + a.avg_quantity AS new_quantity, o.price, o.status, o.created_at, o.updated_at
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) a ON o.user_id = a.user_id AND o.asset_type = a.asset_type
) AS joined_data ON orders.order_id = joined_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = joined_data.new_quantity --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
250000

Executing command: snowsql --query 

-- MERGE-INTO-A8-1: Merge with Date Ranges and Status Change
-- This query updates the status of orders created between 2021-01-01 and 2021-06-30.
MERGE INTO orders_25 as orders USING (
    SELECT * FROM orders
    WHERE created_at BETWEEN '2021-01-01' AND '2021-06-30'
) AS date_filtered ON orders.order_id = date_filtered.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = CASE WHEN orders.status = 'pending' THEN 'expired' ELSE orders.status END --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
25

Executing command: snowsql --query 

-- MERGE-INTO-A8-2: Merge with Date Ranges and Status Change
-- This query updates the status of orders created between 2021-01-01 and 2021-06-30.
MERGE INTO orders_25w as orders USING (
    SELECT * FROM orders
    WHERE created_at BETWEEN '2021-01-01' AND '2021-06-30'
) AS date_filtered ON orders.order_id = date_filtered.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = CASE WHEN orders.status = 'pending' THEN 'expired' ELSE orders.status END --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
250000

Executing command: snowsql --query 

-- MERGE-INTO-A9-1: Complex Merge with Nested Subqueries
-- This query updates the status of orders based on their quantity in relation to the average quantity.
MERGE INTO orders_25 as orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity, o.price, o.status, o.created_at, o.updated_at,
           CASE
               WHEN o.quantity < sub.avg_quantity THEN 'below_avg'
               WHEN o.quantity > sub.avg_quantity THEN 'above_avg'
               ELSE 'avg'
               END AS quantity_status
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) sub ON o.user_id = sub.user_id AND o.asset_type = sub.asset_type
) AS complex_data ON orders.order_id = complex_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = complex_data.quantity_status --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
25

Executing command: snowsql --query 

-- MERGE-INTO-A9-2: Complex Merge with Nested Subqueries
-- This query updates the status of orders based on their quantity in relation to the average quantity.
MERGE INTO orders_25w as orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity, o.price, o.status, o.created_at, o.updated_at,
           CASE
               WHEN o.quantity < sub.avg_quantity THEN 'below_avg'
               WHEN o.quantity > sub.avg_quantity THEN 'above_avg'
               ELSE 'avg'
               END AS quantity_status
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) sub ON o.user_id = sub.user_id AND o.asset_type = sub.asset_type
) AS complex_data ON orders.order_id = complex_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = complex_data.quantity_status --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
250000

Executing command: snowsql --query 

-- MERGE-INTO-A10-1: Merge Based on Average Asset Value
-- This query updates the price of orders based on the average value of assets for each user and asset type.
MERGE INTO orders_25 as orders USING (
    SELECT a.user_id, a.asset_type, AVG(a.value) as avg_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
) AS asset_data ON orders.user_id = asset_data.user_id AND orders.asset_type = asset_data.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.price = orders.price + asset_data.avg_value --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
167229

Executing command: snowsql --query 

-- MERGE-INTO-A10-2: Merge Based on Average Asset Value
-- This query updates the price of orders based on the average value of assets for each user and asset type.
MERGE INTO orders_25w as orders USING (
    SELECT a.user_id, a.asset_type, AVG(a.value) as avg_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
) AS asset_data ON orders.user_id = asset_data.user_id AND orders.asset_type = asset_data.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.price = orders.price + asset_data.avg_value --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
250889

Executing command: snowsql --query 

-- MERGE-INTO-A11-1: asserts
MERGE INTO assets_10 as assets USING (
    SELECT a.user_id, a.asset_type,
           SUM(a.quantity) AS total_quantity,
           AVG(a.value) AS average_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
    UNION ALL
    SELECT a.user_id, 'NEW_ASSET' AS asset_type,  -- New asset type for insert
           100 AS quantity,                       -- Example quantity
           1000 AS value                          -- Example value
    FROM assets a
    WHERE a.user_id % 2 = 0  -- Condition to select subset for new data
    GROUP BY a.user_id
) AS combined_assets ON assets.user_id = combined_assets.user_id AND assets.asset_type = combined_assets.asset_type
    WHEN MATCHED THEN
        UPDATE SET assets.quantity = combined_assets.total_quantity, assets.value = combined_assets.average_value
    WHEN NOT MATCHED THEN
        INSERT (user_id, asset_type, quantity, value, last_updated)
            VALUES (combined_assets.user_id, combined_assets.asset_type, combined_assets.total_quantity, combined_assets.average_value, '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
149990	10

Executing command: snowsql --query 

-- MERGE-INTO-A11-2: asserts
MERGE INTO assets_10w as assets USING (
    SELECT a.user_id, a.asset_type,
           SUM(a.quantity) AS total_quantity,
           AVG(a.value) AS average_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
    UNION ALL
    SELECT a.user_id, 'NEW_ASSET' AS asset_type,  -- New asset type for insert
           100 AS quantity,                       -- Example quantity
           1000 AS value                          -- Example value
    FROM assets a
    WHERE a.user_id % 2 = 0  -- Condition to select subset for new data
    GROUP BY a.user_id
) AS combined_assets ON assets.user_id = combined_assets.user_id AND assets.asset_type = combined_assets.asset_type
    WHEN MATCHED THEN
        UPDATE SET assets.quantity = combined_assets.total_quantity, assets.value = combined_assets.average_value
    WHEN NOT MATCHED THEN
        INSERT (user_id, asset_type, quantity, value, last_updated)
            VALUES (combined_assets.user_id, combined_assets.asset_type, combined_assets.total_quantity, combined_assets.average_value, '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
50000	100000

Executing command: snowsql --query 

-- MERGE-INTO-A12-1: transactions
MERGE INTO transactions_50 as transactions
    USING (
        SELECT
            t.user_id,
            t.asset_type,
            SUM(t.quantity) AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, t.asset_type) AS next_transaction_id
        FROM transactions t
        GROUP BY t.user_id, t.asset_type
        UNION ALL
        SELECT
            t.user_id,
            'NEW_TRANSACTION' AS asset_type,
            30 AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, 'NEW_TRANSACTION') AS next_transaction_id
        FROM transactions t
        WHERE t.user_id % 2 = 0
        GROUP BY t.user_id
    ) AS combined_transactions
    ON transactions.user_id = combined_transactions.user_id
        AND transactions.asset_type = combined_transactions.asset_type
    WHEN MATCHED AND combined_transactions.user_id > 5000 THEN DELETE
    WHEN MATCHED THEN
        UPDATE SET transactions.quantity = combined_transactions.total_quantity
    WHEN NOT MATCHED THEN
        INSERT (transaction_id, user_id, transaction_type, asset_type, quantity, transaction_time)
            VALUES (combined_transactions.next_transaction_id,
                    combined_transactions.user_id,
                    'trade',
                    combined_transactions.asset_type,
                    combined_transactions.total_quantity,
                    '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
344558	0	50

Executing command: snowsql --query 

-- MERGE-INTO-A12-2: transactions
MERGE INTO transactions_50w as transactions
    USING (
        SELECT
            t.user_id,
            t.asset_type,
            SUM(t.quantity) AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, t.asset_type) AS next_transaction_id
        FROM transactions t
        GROUP BY t.user_id, t.asset_type
        UNION ALL
        SELECT
            t.user_id,
            'NEW_TRANSACTION' AS asset_type,
            30 AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, 'NEW_TRANSACTION') AS next_transaction_id
        FROM transactions t
        WHERE t.user_id % 2 = 0
        GROUP BY t.user_id
    ) AS combined_transactions
    ON transactions.user_id = combined_transactions.user_id
        AND transactions.asset_type = combined_transactions.asset_type
    WHEN MATCHED AND combined_transactions.user_id > 5000 THEN DELETE
    WHEN MATCHED THEN
        UPDATE SET transactions.quantity = combined_transactions.total_quantity
    WHEN NOT MATCHED THEN
        INSERT (transaction_id, user_id, transaction_type, asset_type, quantity, transaction_time)
            VALUES (combined_transactions.next_transaction_id,
                    combined_transactions.user_id,
                    'trade',
                    combined_transactions.asset_type,
                    combined_transactions.total_quantity,
                    '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
88968	25005	474995

Executing command: snowsql --query 

-- MERGE-INTO-A13-1: orders
MERGE INTO orders_25 as orders
    USING (
        SELECT
            o.user_id,
            o.asset_type,
            SUM(o.quantity) AS total_quantity,
            AVG(o.price) AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, o.asset_type) AS next_order_id
        FROM orders o
        GROUP BY o.user_id, o.asset_type
        UNION ALL
        SELECT
            o.user_id,
            'NEW_ORDER' AS asset_type,
            50 AS total_quantity,
            500 AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, 'NEW_ORDER') AS next_order_id
        FROM orders o
        WHERE o.user_id % 2 = 0
        GROUP BY o.user_id
    ) AS combined_orders
    ON orders.user_id = combined_orders.user_id AND orders.asset_type = combined_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = combined_orders.total_quantity, orders.price = combined_orders.average_price
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (combined_orders.next_order_id,
                    combined_orders.user_id,
                    'buy',
                    combined_orders.asset_type,
                    combined_orders.total_quantity,
                    combined_orders.average_price,
                    'Pending',
                    '2023-01-01',
                    '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
50000	500025

Executing command: snowsql --query 

-- MERGE-INTO-A13-2: orders
MERGE INTO orders_25w as orders
    USING (
        SELECT
            o.user_id,
            o.asset_type,
            SUM(o.quantity) AS total_quantity,
            AVG(o.price) AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, o.asset_type) AS next_order_id
        FROM orders o
        GROUP BY o.user_id, o.asset_type
        UNION ALL
        SELECT
            o.user_id,
            'NEW_ORDER' AS asset_type,
            50 AS total_quantity,
            500 AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, 'NEW_ORDER') AS next_order_id
        FROM orders o
        WHERE o.user_id % 2 = 0
        GROUP BY o.user_id
    ) AS combined_orders
    ON orders.user_id = combined_orders.user_id AND orders.asset_type = combined_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = combined_orders.total_quantity, orders.price = combined_orders.average_price
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (combined_orders.next_order_id,
                    combined_orders.user_id,
                    'buy',
                    combined_orders.asset_type,
                    combined_orders.total_quantity,
                    combined_orders.average_price,
                    'Pending',
                    '2023-01-01',
                    '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
50000	750000

Executing command: snowsql --query 

-- MERGE-INTO-A14: Conditional Merge Based on Order Status
-- This query updates orders with a status of 'pending' to 'completed'.
MERGE INTO orders USING (
    SELECT * FROM orders WHERE status = 'pending'
) AS pending_orders ON orders.order_id = pending_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'completed' --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
174150

Executing command: snowsql --query 

-- MERGE-INTO-A15: Merging with Aggregated Data
-- This query updates the quantity of orders based on the sum of quantities for each user and asset type.
MERGE INTO orders USING (
    SELECT user_id, asset_type, SUM(quantity) AS total_quantity
    FROM orders
    GROUP BY user_id, asset_type
) AS agg_orders ON orders.user_id = agg_orders.user_id AND orders.asset_type = agg_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = agg_orders.total_quantity --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
500000

Executing command: snowsql --query 

-- MERGE-INTO-A16: Merge with Date-Based Condition
-- This query archives orders created before 2022-01-01.
MERGE INTO orders USING (
    SELECT * FROM orders WHERE created_at < '2022-01-01'
) AS old_orders ON orders.order_id = old_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = 'archived' --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
500000

Executing command: snowsql --query 

-- MERGE-INTO-A17: Random Swap of Buy and Sell Orders
-- This query randomly swaps 'buy' and 'sell' order types.
MERGE INTO orders USING (
    SELECT order_id,
           user_id,
           CASE WHEN order_type = 'buy' THEN 'sell' ELSE 'buy' END AS order_type,
           asset_type,
           quantity,
           price,
           status,
           created_at,
           updated_at
    FROM orders
) AS swapped_orders ON orders.order_id = swapped_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.order_type = swapped_orders.order_type --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
500000

Executing command: snowsql --query 

-- MERGE-INTO-A18: Merging with a Fixed Increase in Quantity
-- This query increases the quantity of each order by 10.
MERGE INTO orders USING (
    SELECT * FROM orders
) AS all_orders ON orders.order_id = all_orders.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = orders.quantity + 10 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
500000

Executing command: snowsql --query 

-- MERGE-INTO-A19: Merge for Creating Duplicate Orders with New IDs
-- This query duplicates orders with new order IDs.
MERGE INTO orders USING (
    SELECT
            order_id + 500000 AS new_order_id, -- Creating new order_ids
            user_id,
            order_type,
            asset_type,
            quantity,
            price,
            status,
            created_at,
            updated_at
    FROM orders
) AS duplicate_orders ON orders.order_id = duplicate_orders.new_order_id
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (duplicate_orders.new_order_id, duplicate_orders.user_id, duplicate_orders.order_type, duplicate_orders.asset_type, duplicate_orders.quantity, duplicate_orders.price, duplicate_orders.status, duplicate_orders.created_at, duplicate_orders.updated_at) --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
500000

Executing command: snowsql --query 

-- MERGE-INTO-A20: Merge with Subquery Join
-- This query updates orders with a new quantity based on an average quantity calculation joined from a subquery.
MERGE INTO orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity + a.avg_quantity AS new_quantity, o.price, o.status, o.created_at, o.updated_at
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) a ON o.user_id = a.user_id AND o.asset_type = a.asset_type
) AS joined_data ON orders.order_id = joined_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = joined_data.new_quantity --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1000000

Executing command: snowsql --query 

-- MERGE-INTO-A21: Merge with Date Ranges and Status Change
-- This query updates the status of orders created between 2021-01-01 and 2021-06-30.
MERGE INTO orders USING (
    SELECT * FROM orders
    WHERE created_at BETWEEN '2021-01-01' AND '2021-06-30'
) AS date_filtered ON orders.order_id = date_filtered.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = CASE WHEN orders.status = 'pending' THEN 'expired' ELSE orders.status END --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1000000

Executing command: snowsql --query 

-- MERGE-INTO-A22: Complex Merge with Nested Subqueries
-- This query updates the status of orders based on their quantity in relation to the average quantity.
MERGE INTO orders USING (
    SELECT o.order_id, o.user_id, o.order_type, o.asset_type, o.quantity, o.price, o.status, o.created_at, o.updated_at,
           CASE
               WHEN o.quantity < sub.avg_quantity THEN 'below_avg'
               WHEN o.quantity > sub.avg_quantity THEN 'above_avg'
               ELSE 'avg'
               END AS quantity_status
    FROM orders o
             INNER JOIN (
        SELECT user_id, asset_type, AVG(quantity) AS avg_quantity
        FROM orders
        GROUP BY user_id, asset_type
    ) sub ON o.user_id = sub.user_id AND o.asset_type = sub.asset_type
) AS complex_data ON orders.order_id = complex_data.order_id
    WHEN MATCHED THEN
        UPDATE SET orders.status = complex_data.quantity_status --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1000000

Executing command: snowsql --query 

-- MERGE-INTO-A23: Merge Based on Average Asset Value
-- This query updates the price of orders based on the average value of assets for each user and asset type.
MERGE INTO orders USING (
    SELECT a.user_id, a.asset_type, AVG(a.value) as avg_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
) AS asset_data ON orders.user_id = asset_data.user_id AND orders.asset_type = asset_data.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.price = orders.price + asset_data.avg_value --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
334442

Executing command: snowsql --query 

-- MERGE-INTO-A24: asserts
MERGE INTO assets USING (
    SELECT a.user_id, a.asset_type,
           SUM(a.quantity) AS total_quantity,
           AVG(a.value) AS average_value
    FROM assets a
    GROUP BY a.user_id, a.asset_type
    UNION ALL
    SELECT a.user_id, 'NEW_ASSET' AS asset_type,  -- New asset type for insert
           100 AS quantity,                       -- Example quantity
           1000 AS value                          -- Example value
    FROM assets a
    WHERE a.user_id % 2 = 0  -- Condition to select subset for new data
    GROUP BY a.user_id
) AS combined_assets ON assets.user_id = combined_assets.user_id AND assets.asset_type = combined_assets.asset_type
    WHEN MATCHED THEN
        UPDATE SET assets.quantity = combined_assets.total_quantity, assets.value = combined_assets.average_value
    WHEN NOT MATCHED THEN
        INSERT (user_id, asset_type, quantity, value, last_updated)
            VALUES (combined_assets.user_id, combined_assets.asset_type, combined_assets.total_quantity, combined_assets.average_value, '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
50000	100000

Executing command: snowsql --query 

-- MERGE-INTO-A25: transactions
MERGE INTO transactions
    USING (
        SELECT
            t.user_id,
            t.asset_type,
            SUM(t.quantity) AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, t.asset_type) AS next_transaction_id
        FROM transactions t
        GROUP BY t.user_id, t.asset_type
        UNION ALL
        SELECT
            t.user_id,
            'NEW_TRANSACTION' AS asset_type,
            30 AS total_quantity,
            (SELECT MAX(transaction_id) FROM transactions) + ROW_NUMBER() OVER (ORDER BY t.user_id, 'NEW_TRANSACTION') AS next_transaction_id
        FROM transactions t
        WHERE t.user_id % 2 = 0
        GROUP BY t.user_id
    ) AS combined_transactions
    ON transactions.user_id = combined_transactions.user_id
        AND transactions.asset_type = combined_transactions.asset_type
    WHEN MATCHED AND combined_transactions.user_id > 5000 THEN DELETE
    WHEN MATCHED THEN
        UPDATE SET transactions.quantity = combined_transactions.total_quantity
    WHEN NOT MATCHED THEN
        INSERT (transaction_id, user_id, transaction_type, asset_type, quantity, transaction_time)
            VALUES (combined_transactions.next_transaction_id,
                    combined_transactions.user_id,
                    'trade',
                    combined_transactions.asset_type,
                    combined_transactions.total_quantity,
                    '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
50000	50010	949990

Executing command: snowsql --query 

-- MERGE-INTO-A26: orders
MERGE INTO orders
    USING (
        SELECT
            o.user_id,
            o.asset_type,
            SUM(o.quantity) AS total_quantity,
            AVG(o.price) AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, o.asset_type) AS next_order_id
        FROM orders o
        GROUP BY o.user_id, o.asset_type
        UNION ALL
        SELECT
            o.user_id,
            'NEW_ORDER' AS asset_type,
            50 AS total_quantity,
            500 AS average_price,
            (SELECT MAX(order_id) FROM orders) + ROW_NUMBER() OVER (ORDER BY o.user_id, 'NEW_ORDER') AS next_order_id
        FROM orders o
        WHERE o.user_id % 2 = 0
        GROUP BY o.user_id
    ) AS combined_orders
    ON orders.user_id = combined_orders.user_id AND orders.asset_type = combined_orders.asset_type
    WHEN MATCHED THEN
        UPDATE SET orders.quantity = combined_orders.total_quantity, orders.price = combined_orders.average_price
    WHEN NOT MATCHED THEN
        INSERT (order_id, user_id, order_type, asset_type, quantity, price, status, created_at, updated_at)
            VALUES (combined_orders.next_order_id,
                    combined_orders.user_id,
                    'buy',
                    combined_orders.asset_type,
                    combined_orders.total_quantity,
                    combined_orders.average_price,
                    'Pending',
                    '2023-01-01',
                    '2023-01-01') --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
50000	1000000

Executing command: snowsql --query 

-- INSERT-INTO-A27: orders
INSERT INTO orders SELECT * FROM orders_25 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
550025

Executing command: snowsql --query 

-- INSERT-INTO-A28: orders
INSERT INTO orders SELECT * FROM orders_25w --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
800000

Executing command: snowsql --query 

-- INSERT-INTO-A29: orders
INSERT INTO transactions SELECT * FROM transactions_50 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
344558

Executing command: snowsql --query 

-- INSERT-INTO-A30: orders
INSERT INTO transactions SELECT * FROM transactions_50w --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
113973

Executing command: snowsql --query 

-- INSERT-INTO-A31: orders
INSERT INTO assets SELECT * FROM assets_10 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
150000

Executing command: snowsql --query 

-- INSERT-INTO-A32: orders
INSERT INTO assets SELECT * FROM assets_10w --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
150000

Preparing to run MERGE-INTO-C1...
Executing command: bendsql --query=-- MERGE-INTO-C1: Asset Types Distribution
SELECT asset_type, COUNT(*) AS count
FROM assets
GROUP BY asset_type
ORDER BY count DESC, asset_type
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
NEW_ASSET	150000
BTC	104817
ETH	104808
XRP	90375

Executing command: snowsql --query -- MERGE-INTO-C1: Asset Types Distribution
SELECT asset_type, COUNT(*) AS count
FROM assets
GROUP BY asset_type
ORDER BY count DESC, asset_type
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
NEW_ASSET	150000
BTC	104817
ETH	104808
XRP	90375

OK - MERGE-INTO-C1
NEW_ASSET	150000
BTC	104817
ETH	104808
XRP	90375

Preparing to run MERGE-INTO-C2...
Executing command: bendsql --query=

-- MERGE-INTO-C2: Aggregated Quantity and Value Statistics
SELECT SUM(quantity) AS total_quantity,
       AVG(quantity) AS average_quantity,
       SUM(value) AS total_value,
       AVG(value) AS average_value
FROM assets -D mergeinto
Command executed successfully. Output:
165342725.20941540	367.428278243145	1653427252.09414242	3674.282782431428

Executing command: snowsql --query 

-- MERGE-INTO-C2: Aggregated Quantity and Value Statistics
SELECT SUM(quantity) AS total_quantity,
       AVG(quantity) AS average_quantity,
       SUM(value) AS total_value,
       AVG(value) AS average_value
FROM assets --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
165342725.20941540	367.428278243145	1653427252.09414242	3674.282782431428

OK - MERGE-INTO-C2
165342725.20941540	367.428278243145	1653427252.09414242	3674.282782431428

Preparing to run MERGE-INTO-C3...
Executing command: bendsql --query=

-- MERGE-INTO-C3: Assets Counts by User
SELECT user_id, COUNT(*) AS count
FROM assets
GROUP BY user_id
ORDER BY count DESC, user_id
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
0	6
2	6
4	6
6	6
8	6
10	6
12	6
14	6
16	6
18	6
20	6
22	6
24	6

Executing command: snowsql --query 

-- MERGE-INTO-C3: Assets Counts by User
SELECT user_id, COUNT(*) AS count
FROM assets
GROUP BY user_id
ORDER BY count DESC, user_id
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
0	6
2	6
4	6
6	6
8	6
10	6
12	6
14	6
16	6
18	6
20	6
22	6
24	6

OK - MERGE-INTO-C3
0	6
2	6
4	6
6	6
8	6
10	6
12	6
14	6
16	6
18	6
20	6
22	6
24	6

Preparing to run MERGE-INTO-C4...
Executing command: bendsql --query=

-- MERGE-INTO-C4: Date Range Analysis of Last Update
SELECT CASE
           WHEN last_updated < '2022-01-01' THEN 'Before 2022'
           ELSE 'After 2021-12-31'
           END AS date_range,
       COUNT(*) AS count
FROM assets
GROUP BY date_range
ORDER BY date_range
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
After 2021-12-31	410014
Before 2022	39986

Executing command: snowsql --query 

-- MERGE-INTO-C4: Date Range Analysis of Last Update
SELECT CASE
           WHEN last_updated < '2022-01-01' THEN 'Before 2022'
           ELSE 'After 2021-12-31'
           END AS date_range,
       COUNT(*) AS count
FROM assets
GROUP BY date_range
ORDER BY date_range
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
After 2021-12-31	410014
Before 2022	39986

OK - MERGE-INTO-C4
After 2021-12-31	410014
Before 2022	39986

Preparing to run MERGE-INTO-C5...
Executing command: bendsql --query=

-- MERGE-INTO-C5: General Status Distribution
SELECT status, COUNT(*) AS count
FROM orders
GROUP BY status
ORDER BY count DESC, status
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
avg	1049532
completed	350986
pending	348300
cancelled	300714
Pending	150000
above_avg	100418
below_avg	100075

Executing command: snowsql --query 

-- MERGE-INTO-C5: General Status Distribution
SELECT status, COUNT(*) AS count
FROM orders
GROUP BY status
ORDER BY count DESC, status
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
avg	1049532
completed	350986
pending	348300
cancelled	300714
Pending	150000
above_avg	100418
below_avg	100075

OK - MERGE-INTO-C5
avg	1049532
completed	350986
pending	348300
cancelled	300714
Pending	150000
above_avg	100418
below_avg	100075

Preparing to run MERGE-INTO-C6...
Executing command: bendsql --query=

-- MERGE-INTO-C6: General Quantity Statistics
SELECT SUM(quantity) AS total_quantity,
       AVG(quantity) AS average_quantity,
       MIN(quantity) AS min_quantity,
       MAX(quantity) AS max_quantity
FROM orders -D mergeinto
Command executed successfully. Output:
1526855542.46298600	636.183182451427	0.00005807	8910.78518320

Executing command: snowsql --query 

-- MERGE-INTO-C6: General Quantity Statistics
SELECT SUM(quantity) AS total_quantity,
       AVG(quantity) AS average_quantity,
       MIN(quantity) AS min_quantity,
       MAX(quantity) AS max_quantity
FROM orders --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
1526855542.46298600	636.183182451427	0.00005807	8910.78518320

OK - MERGE-INTO-C6
1526855542.46298600	636.183182451427	0.00005807	8910.78518320

Preparing to run MERGE-INTO-C7...
Executing command: bendsql --query=

-- MERGE-INTO-C7: New Orders vs Existing Orders Count
SELECT CASE
           WHEN order_id > 500000 THEN 'New Order'
           ELSE 'Existing Order'
           END AS order_category,
       COUNT(*) AS count
FROM orders
GROUP BY order_category
ORDER BY count DESC
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
New Order	1649995
Existing Order	750030

Executing command: snowsql --query 

-- MERGE-INTO-C7: New Orders vs Existing Orders Count
SELECT CASE
           WHEN order_id > 500000 THEN 'New Order'
           ELSE 'Existing Order'
           END AS order_category,
       COUNT(*) AS count
FROM orders
GROUP BY order_category
ORDER BY count DESC
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
New Order	1649995
Existing Order	750030

OK - MERGE-INTO-C7
New Order	1649995
Existing Order	750030

Preparing to run MERGE-INTO-C8...
Executing command: bendsql --query=

-- MERGE-INTO-C8: Order Type Distribution
SELECT order_type, COUNT(*) AS count
FROM orders
GROUP BY order_type
ORDER BY count DESC, order_type
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
buy	1274986
sell	1125039

Executing command: snowsql --query 

-- MERGE-INTO-C8: Order Type Distribution
SELECT order_type, COUNT(*) AS count
FROM orders
GROUP BY order_type
ORDER BY count DESC, order_type
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
buy	1274986
sell	1125039

OK - MERGE-INTO-C8
buy	1274986
sell	1125039

Preparing to run MERGE-INTO-C9...
Executing command: bendsql --query=

-- MERGE-INTO-C9: Date Range Analysis
SELECT CASE
           WHEN created_at < '2022-01-01' THEN 'Before 2022'
           WHEN created_at BETWEEN '2021-01-01' AND '2021-06-30' THEN 'First Half 2021'
           ELSE 'After 2021-06-30'
           END AS date_range,
       COUNT(*) AS count
FROM orders
GROUP BY date_range
ORDER BY date_range
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
After 2021-06-30	150000
Before 2022	2250025

Executing command: snowsql --query 

-- MERGE-INTO-C9: Date Range Analysis
SELECT CASE
           WHEN created_at < '2022-01-01' THEN 'Before 2022'
           WHEN created_at BETWEEN '2021-01-01' AND '2021-06-30' THEN 'First Half 2021'
           ELSE 'After 2021-06-30'
           END AS date_range,
       COUNT(*) AS count
FROM orders
GROUP BY date_range
ORDER BY date_range
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
After 2021-06-30	150000
Before 2022	2250025

OK - MERGE-INTO-C9
After 2021-06-30	150000
Before 2022	2250025

Preparing to run MERGE-INTO-C10...
Executing command: bendsql --query=

-- MERGE-INTO-C10: Price Analysis After Adjustments
SELECT SUM(price) AS total_price,
       AVG(price) AS average_price,
       MIN(price) AS min_price,
       MAX(price) AS max_price
FROM orders -D mergeinto
Command executed successfully. Output:
2874615680.22030825	1197.744056924535	0.00058074	10990.07262787

Executing command: snowsql --query 

-- MERGE-INTO-C10: Price Analysis After Adjustments
SELECT SUM(price) AS total_price,
       AVG(price) AS average_price,
       MIN(price) AS min_price,
       MAX(price) AS max_price
FROM orders --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
2874615680.22030825	1197.744056924535	0.00058074	10990.07262787

OK - MERGE-INTO-C10
2874615680.22030825	1197.744056924535	0.00058074	10990.07262787

Preparing to run MERGE-INTO-C11...
Executing command: bendsql --query=

-- MERGE-INTO-C11: Transaction Types Distribution
SELECT transaction_type, COUNT(*) AS count
FROM transactions
GROUP BY transaction_type
ORDER BY count DESC, transaction_type
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
trade	505920
deposit	26492
withdrawal	26129

Executing command: snowsql --query 

-- MERGE-INTO-C11: Transaction Types Distribution
SELECT transaction_type, COUNT(*) AS count
FROM transactions
GROUP BY transaction_type
ORDER BY count DESC, transaction_type
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
trade	505920
deposit	26492
withdrawal	26129

OK - MERGE-INTO-C11
trade	505920
deposit	26492
withdrawal	26129

Preparing to run MERGE-INTO-C12...
Executing command: bendsql --query=

-- MERGE-INTO-C12: Aggregated Quantity Statistics
SELECT SUM(quantity) AS total_quantity,
       AVG(quantity) AS average_quantity,
       MIN(quantity) AS min_quantity,
       MAX(quantity) AS max_quantity
FROM transactions -D mergeinto
Command executed successfully. Output:
73627261.57298446	131.820692792444	0.00106899	664.06985910

Executing command: snowsql --query 

-- MERGE-INTO-C12: Aggregated Quantity Statistics
SELECT SUM(quantity) AS total_quantity,
       AVG(quantity) AS average_quantity,
       MIN(quantity) AS min_quantity,
       MAX(quantity) AS max_quantity
FROM transactions --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
73627261.57298446	131.820692792444	0.00106899	664.06985910

OK - MERGE-INTO-C12
73627261.57298446	131.820692792444	0.00106899	664.06985910

Preparing to run MERGE-INTO-C13...
Executing command: bendsql --query=

-- MERGE-INTO-C13: Transaction Counts by User and Asset Type
SELECT user_id, asset_type, COUNT(*) AS count
FROM transactions
GROUP BY user_id, asset_type
ORDER BY count DESC, user_id, asset_type
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
804	ETH	15
1216	ETH	15
216	BTC	14
425	ETH	14
844	BTC	14
1231	ETH	14
1539	ETH	14
1603	ETH	14
1926	ETH	14
2609	BTC	14
2704	ETH	14
2827	ETH	14
2841	BTC	14

Executing command: snowsql --query 

-- MERGE-INTO-C13: Transaction Counts by User and Asset Type
SELECT user_id, asset_type, COUNT(*) AS count
FROM transactions
GROUP BY user_id, asset_type
ORDER BY count DESC, user_id, asset_type
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
804	ETH	15
1216	ETH	15
216	BTC	14
425	ETH	14
844	BTC	14
1231	ETH	14
1539	ETH	14
1603	ETH	14
1926	ETH	14
2609	BTC	14
2704	ETH	14
2827	ETH	14
2841	BTC	14

OK - MERGE-INTO-C13
804	ETH	15
1216	ETH	15
216	BTC	14
425	ETH	14
844	BTC	14
1231	ETH	14
1539	ETH	14
1603	ETH	14
1926	ETH	14
2609	BTC	14
2704	ETH	14
2827	ETH	14
2841	BTC	14

Preparing to run MERGE-INTO-C14...
Executing command: bendsql --query=

-- MERGE-INTO-C14: Date Range Analysis of Transactions
SELECT CASE
           WHEN transaction_time < '2022-01-01' THEN 'Before 2022'
           ELSE 'After 2021-12-31'
           END AS date_range,
       COUNT(*) AS count
FROM transactions
GROUP BY date_range
ORDER BY date_range
    LIMIT 13 -D mergeinto
Command executed successfully. Output:
After 2021-12-31	483526
Before 2022	75015

Executing command: snowsql --query 

-- MERGE-INTO-C14: Date Range Analysis of Transactions
SELECT CASE
           WHEN transaction_time < '2022-01-01' THEN 'Before 2022'
           ELSE 'After 2021-12-31'
           END AS date_range,
       COUNT(*) AS count
FROM transactions
GROUP BY date_range
ORDER BY date_range
    LIMIT 13 --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
After 2021-12-31	483526
Before 2022	75015

OK - MERGE-INTO-C14
After 2021-12-31	483526
Before 2022	75015

Preparing to run MERGE-INTO-C15...
Executing command: bendsql --query=

-- MERGE-INTO-C15: asserts
SELECT asset_type, SUM(quantity) AS total_quantity, SUM(value) AS total_value
FROM assets
GROUP BY asset_type ORDER BY asset_type ASC -D mergeinto
Command executed successfully. Output:
BTC	54537998.34092175	545379983.40921303
ETH	50387362.73309448	503873627.33094612
NEW_ASSET	15000000.00000000	150000000.00000000
XRP	45417364.13539917	454173641.35398327

Executing command: snowsql --query 

-- MERGE-INTO-C15: asserts
SELECT asset_type, SUM(quantity) AS total_quantity, SUM(value) AS total_value
FROM assets
GROUP BY asset_type ORDER BY asset_type ASC --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
BTC	54537998.34092175	545379983.40921303
ETH	50387362.73309448	503873627.33094612
NEW_ASSET	15000000.00000000	150000000.00000000
XRP	45417364.13539917	454173641.35398327

OK - MERGE-INTO-C15
BTC	54537998.34092175	545379983.40921303
ETH	50387362.73309448	503873627.33094612
NEW_ASSET	15000000.00000000	150000000.00000000
XRP	45417364.13539917	454173641.35398327

Preparing to run MERGE-INTO-C16...
Executing command: bendsql --query=

-- MERGE-INTO-C16: orders
SELECT asset_type, SUM(quantity) AS total_quantity, AVG(price) AS average_price
FROM orders
GROUP BY asset_type ORDER BY asset_type ASC -D mergeinto
Command executed successfully. Output:
BTC	577143846.60937705	1321.552983291813
ETH	532400471.20223598	1228.552050777431
NEW_ORDER	7500000.00000000	500.000000000000
XRP	409811224.65137297	1172.281276438386

Executing command: snowsql --query 

-- MERGE-INTO-C16: orders
SELECT asset_type, SUM(quantity) AS total_quantity, AVG(price) AS average_price
FROM orders
GROUP BY asset_type ORDER BY asset_type ASC --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
BTC	577143846.60937705	1321.552983291813
ETH	532400471.20223598	1228.552050777431
NEW_ORDER	7500000.00000000	500.000000000000
XRP	409811224.65137297	1172.281276438386

OK - MERGE-INTO-C16
BTC	577143846.60937705	1321.552983291813
ETH	532400471.20223598	1228.552050777431
NEW_ORDER	7500000.00000000	500.000000000000
XRP	409811224.65137297	1172.281276438386

Preparing to run MERGE-INTO-C17...
Executing command: bendsql --query=

-- MERGE-INTO-C17: transactions
SELECT transaction_type, SUM(quantity) AS total_quantity
FROM transactions
GROUP BY transaction_type ORDER BY transaction_type ASC -D mergeinto
Command executed successfully. Output:
deposit	5712183.27889012
trade	62705473.53457811
withdrawal	5209604.75951623

Executing command: snowsql --query 

-- MERGE-INTO-C17: transactions
SELECT transaction_type, SUM(quantity) AS total_quantity
FROM transactions
GROUP BY transaction_type ORDER BY transaction_type ASC --dbname mergeinto --schemaname PUBLIC -o output_format=tsv -o header=false -o timing=false -o friendly=false --warehouse COMPUTE_WH
Command executed successfully. Output:
deposit	5712183.27889012
trade	62705473.53457811
withdrawal	5209604.75951623

OK - MERGE-INTO-C17
deposit	5712183.27889012
trade	62705473.53457811
withdrawal	5209604.75951623

@JackTan25
Copy link
Contributor Author

JackTan25 commented Jan 25, 2024

## v1.2.309-nightly
MERGE INTO lineitem_target_origin_400_blocks1 as t1 using lineitem_target_origin_200_blocks1 as t2 on 
    t1.l_orderkey = t2.l_orderkey and
    t1.l_partkey = t2.l_partkey  and t1.l_suppkey = t2.l_suppkey and
    t1.l_linenumber = t2.l_linenumber and 
    t1.l_quantity = t2.l_quantity and 
    t1.l_extendedprice = t2.l_extendedprice and
    t1.l_discount = t2.l_discount
    when matched then update *
    when not matched then insert *;
 cost time: 1m 53.2s

@JackTan25
Copy link
Contributor Author

JackTan25 commented Jan 25, 2024

 ## pr 14429
MERGE INTO lineitem_target_origin_400_blocks1 as t1 using lineitem_target_origin_200_blocks1 as t2 on 
    t1.l_orderkey = t2.l_orderkey and
    t1.l_partkey = t2.l_partkey  and t1.l_suppkey = t2.l_suppkey and
    t1.l_linenumber = t2.l_linenumber and 
    t1.l_quantity = t2.l_quantity and 
    t1.l_extendedprice = t2.l_extendedprice and
    t1.l_discount = t2.l_discount
    when matched then update *
    when not matched then insert *;
time cost: 1m 19.5s

@JackTan25
Copy link
Contributor Author

JackTan25 commented Jan 25, 2024

performace test result:
matched update 0.1billion rows, from 1m 53.2s to 1m 19.5s, improve 34s. cc @dantengsky

@JackTan25 JackTan25 marked this pull request as ready for review January 25, 2024 12:42
@BohuTANG BohuTANG merged commit 5feb282 into databendlabs:main Jan 26, 2024
71 checks passed
@JackTan25 JackTan25 mentioned this pull request Jan 30, 2024
11 tasks
yufan022 pushed a commit to yufan022/databend that referenced this pull request Apr 25, 2024
* add non_equal_plan_forbidden

* add more random test

* move tests to databendlabs#14429

* Update src/query/sql/src/planner/optimizer/optimizer.rs

Co-authored-by: xudong.w <wxd963996380@gmail.com>

---------

Co-authored-by: xudong.w <wxd963996380@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-cloud Build docker image for cloud test pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants