diff --git a/coral-trino/src/test/resources/product_test_cases_expected/aggregateOverFunction_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/aggregateOverFunction_expected.sql new file mode 100644 index 000000000..d6440db16 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/aggregateOverFunction_expected.sql @@ -0,0 +1,2 @@ +select max(upper(`c_string`)), min(upper(`c_string`)) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/arrayCreationAccessible_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/arrayCreationAccessible_expected.sql new file mode 100644 index 000000000..05864677a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/arrayCreationAccessible_expected.sql @@ -0,0 +1 @@ +select `timezone_hour`(`at_timezone`(timestamp '2001-08-22 03:04:05.3', 'asia/oral')), `timezone_minute`(`at_timezone`(timestamp '2001-08-22 03:04:05.3', 'asia/oral')) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/atTimeZoneAccessible_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/atTimeZoneAccessible_expected.sql new file mode 100644 index 000000000..05864677a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/atTimeZoneAccessible_expected.sql @@ -0,0 +1 @@ +select `timezone_hour`(`at_timezone`(timestamp '2001-08-22 03:04:05.3', 'asia/oral')), `timezone_minute`(`at_timezone`(timestamp '2001-08-22 03:04:05.3', 'asia/oral')) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/averageDistinct_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/averageDistinct_expected.sql new file mode 100644 index 000000000..64c93fdfe --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/averageDistinct_expected.sql @@ -0,0 +1,2 @@ +select avg(distinct `c_bigint`), avg(distinct `c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/average_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/average_expected.sql new file mode 100644 index 000000000..251c8bbbc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/average_expected.sql @@ -0,0 +1,2 @@ +select avg(`c_bigint`), avg(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/bar_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/bar_expected.sql new file mode 100644 index 000000000..d3f01a0ff --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/bar_expected.sql @@ -0,0 +1 @@ +select `bar`(1, 10), `bar`(1, 10, `rgb`(255, 0, 0), `color`('#0f0')) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/castAccessible_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/castAccessible_expected.sql new file mode 100644 index 000000000..ea14a09a1 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/castAccessible_expected.sql @@ -0,0 +1 @@ +select cast(10 as varchar(65535) character set `iso-8859-1`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countCustomerTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countCustomerTiny_expected.sql new file mode 100644 index 000000000..4c1d82571 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countCustomerTiny_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `tpch`.`tiny`.`customer` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countDistinctOnNonPartitioningKey_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countDistinctOnNonPartitioningKey_expected.sql new file mode 100644 index 000000000..dc42e7d61 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countDistinctOnNonPartitioningKey_expected.sql @@ -0,0 +1,2 @@ +select count(distinct `c2`) as `cnt` +from `empty` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countDistinctOnPartitioningKey_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countDistinctOnPartitioningKey_expected.sql new file mode 100644 index 000000000..adf9ced97 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countDistinctOnPartitioningKey_expected.sql @@ -0,0 +1,2 @@ +select count(distinct `c1`) as `cnt` +from `empty` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countDistinct_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countDistinct_expected.sql new file mode 100644 index 000000000..e4c905806 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countDistinct_expected.sql @@ -0,0 +1,2 @@ +select count(distinct `c_bigint`), count(distinct `c_double`), count(distinct `c_string`), count(distinct `c_date`), count(distinct `c_timestamp`), count(distinct `c_boolean`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countLineitemTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countLineitemTiny_expected.sql new file mode 100644 index 000000000..9917eb9e8 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countLineitemTiny_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `tpch`.`tiny`.`lineitem` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countNationTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countNationTiny_expected.sql new file mode 100644 index 000000000..55799298b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countNationTiny_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `tpch`.`tiny`.`nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countOrdersTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countOrdersTiny_expected.sql new file mode 100644 index 000000000..4f26e70d5 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countOrdersTiny_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `tpch`.`tiny`.`orders` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countPartTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countPartTiny_expected.sql new file mode 100644 index 000000000..9173f95eb --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countPartTiny_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `tpch`.`tiny`.`part` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countPartsuppTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countPartsuppTiny_expected.sql new file mode 100644 index 000000000..375ae33ac --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countPartsuppTiny_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `tpch`.`tiny`.`partsupp` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countRegionTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countRegionTiny_expected.sql new file mode 100644 index 000000000..0b0a14051 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countRegionTiny_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `tpch`.`tiny`.`region` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/countSupplierTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/countSupplierTiny_expected.sql new file mode 100644 index 000000000..76c1ac1e1 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/countSupplierTiny_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `tpch`.`tiny`.`supplier` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/count_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/count_expected.sql new file mode 100644 index 000000000..197f73024 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/count_expected.sql @@ -0,0 +1,2 @@ +select count(`c_bigint`), count(`c_double`), count(`c_string`), count(`c_date`), count(`c_timestamp`), count(`c_boolean`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/cross_join_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/cross_join_expected.sql new file mode 100644 index 000000000..3056b6c3a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/cross_join_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `r_name` +from `nation` +cross join `region` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/dateTimeOperatorsAccessible_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/dateTimeOperatorsAccessible_expected.sql new file mode 100644 index 000000000..742731a21 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/dateTimeOperatorsAccessible_expected.sql @@ -0,0 +1 @@ +select date '2012-08-08' + interval '2' day, time '01:00:00.0' + interval '3' hour, timestamp '2012-08-08 01:00:00.0' + interval '29' hour, timestamp '2012-10-31 01:00:00.0' + interval '1' month, interval '2' day + interval '3' hour, interval '3' year + interval '5' month, date '2012-08-08' - interval '2' day, time '01:00:00.0' - interval '3' hour, timestamp '2012-08-08 01:00:00.0' - interval '29' hour, timestamp '2012-10-31 01:00:00.0' - interval '1' month, interval '2' day - interval '3' hour, interval '3' year - interval '5' month \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/except_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/except_expected.sql new file mode 100644 index 000000000..1ccac2604 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/except_expected.sql @@ -0,0 +1,15 @@ +select `n_name` +from `nation` +where `n_nationkey` = 17 +except +select `n_name` +from `nation` +where `n_regionkey` = 2 +union +select `n_name` +from `nation` +where `n_regionkey` = 2 +intersect +select `n_name` +from `nation` +where `n_nationkey` > 15 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_implicit_same_tables_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_implicit_same_tables_expected.sql new file mode 100644 index 000000000..c1df3c20d --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_implicit_same_tables_expected.sql @@ -0,0 +1,4 @@ +select `p_partkey`, `n_name` +from `nation` +inner join `part` on `n_nationkey` = `p_partkey` +where `n_name` < `p_name` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_columns_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_columns_expected.sql new file mode 100644 index 000000000..c2726d00a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_columns_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `r_name` +from `nation` +inner join `region` on `nation`.`n_regionkey` = `region`.`r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_count_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_count_expected.sql new file mode 100644 index 000000000..753ced8bb --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_count_expected.sql @@ -0,0 +1,3 @@ +select count(*) +from `nation` +inner join `region` on `nation`.`n_regionkey` = `region`.`r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_star_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_star_expected.sql new file mode 100644 index 000000000..87f3d2652 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_star_expected.sql @@ -0,0 +1,3 @@ +select * +from `nation` +inner join `region` on `nation`.`n_regionkey` = `region`.`r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_where_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_where_expected.sql new file mode 100644 index 000000000..ccc155049 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/explicit_inner_join_select_where_expected.sql @@ -0,0 +1,4 @@ +select `n_name`, `r_name` +from `nation` +inner join `region` on `nation`.`n_regionkey` = `region`.`r_regionkey` +where `n_name` > 'e' \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/explicit_left_implicit_same_tables_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/explicit_left_implicit_same_tables_expected.sql new file mode 100644 index 000000000..b07974c91 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/explicit_left_implicit_same_tables_expected.sql @@ -0,0 +1,4 @@ +select `p_partkey`, `n_name` +from `nation` +left join `part` on `n_nationkey` = `p_partkey` +where `n_name` < `p_name` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/extractAccessible_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/extractAccessible_expected.sql new file mode 100644 index 000000000..0e9d73ff3 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/extractAccessible_expected.sql @@ -0,0 +1 @@ +select extract(day from timestamp '2001-08-22 03:04:05.3') \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/implicit_explicit_inner_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/implicit_explicit_inner_expected.sql new file mode 100644 index 000000000..51f0bf7aa --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/implicit_explicit_inner_expected.sql @@ -0,0 +1,4 @@ +select `p_partkey`, `n_name`, `r_name` +from `nation` +inner join `part` on `r_regionkey` = `p_partkey` +where `n_nationkey` = `r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/implicit_explicit_left_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/implicit_explicit_left_expected.sql new file mode 100644 index 000000000..3e3aaea3c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/implicit_explicit_left_expected.sql @@ -0,0 +1,4 @@ +select `p_partkey`, `n_name`, `r_name` +from `nation` +left join `part` on `r_regionkey` = `p_partkey` +where `n_nationkey` = `r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/implicit_inner_join_table_alias_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/implicit_inner_join_table_alias_expected.sql new file mode 100644 index 000000000..1f6d5bb64 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/implicit_inner_join_table_alias_expected.sql @@ -0,0 +1,3 @@ +select `n`.`n_name`, `r`.`r_name` +from `nation` as `n` +where `n`.`n_regionkey` = `r`.`r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/implicit_less_then_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/implicit_less_then_expected.sql new file mode 100644 index 000000000..0ef26ab69 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/implicit_less_then_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `r_name` +from `nation` +where `r_regionkey` > `n_nationkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/implicit_not_equal_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/implicit_not_equal_expected.sql new file mode 100644 index 000000000..0b7b9280d --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/implicit_not_equal_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `r_name` +from `nation` +where `r_regionkey` <> `n_nationkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/inner_join_null_data_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/inner_join_null_data_expected.sql new file mode 100644 index 000000000..59445d589 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/inner_join_null_data_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `department`, `name`, `salary` +from `workers` +where `n_nationkey` = `department` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/inner_join_right_outer_join_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/inner_join_right_outer_join_expected.sql new file mode 100644 index 000000000..a53838974 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/inner_join_right_outer_join_expected.sql @@ -0,0 +1,4 @@ +select `p_partkey`, `n_name`, `r_name` +from `part` +inner join `nation` on `n_regionkey` = `p_partkey` +right join `region` on `n_nationkey` = `r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/intersect_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/intersect_expected.sql new file mode 100644 index 000000000..d1de0942a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/intersect_expected.sql @@ -0,0 +1,11 @@ +select `n_name` +from `nation` +where `n_nationkey` = 17 +intersect +select `n_name` +from `nation` +where `n_regionkey` = 1 +union +select `n_name` +from `nation` +where `n_regionkey` = 2 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/kurtosis_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/kurtosis_expected.sql new file mode 100644 index 000000000..d36224d03 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/kurtosis_expected.sql @@ -0,0 +1,2 @@ +select `kurtosis`(`c_bigint`), `kurtosis`(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/left_join_on_multiple_predicates_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/left_join_on_multiple_predicates_expected.sql new file mode 100644 index 000000000..3738059fe --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/left_join_on_multiple_predicates_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `p_name` +from `nation` +left join `part` on `n_regionkey` = `p_partkey` and `n_name` = `p_name` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_constant_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_constant_expected.sql new file mode 100644 index 000000000..e5678fdf1 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_constant_expected.sql @@ -0,0 +1,4 @@ +select `n_name`, `r_name` +from `nation` +left join `region` on `n_nationkey` = `r_regionkey` +where `r_name` > 'g' \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_is_not_null_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_is_not_null_expected.sql new file mode 100644 index 000000000..ce69e4427 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_is_not_null_expected.sql @@ -0,0 +1,4 @@ +select `n_name` +from `nation` +left join `region` on `n_nationkey` = `r_regionkey` +where `r_name` is not null \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_is_null_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_is_null_expected.sql new file mode 100644 index 000000000..b56cc275c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/left_join_where_is_null_expected.sql @@ -0,0 +1,4 @@ +select `n_name` +from `nation` +left join `region` on `n_nationkey` = `r_regionkey` +where `r_name` is null \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/left_outer_join_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/left_outer_join_expected.sql new file mode 100644 index 000000000..195aa69c3 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/left_outer_join_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `r_name` +from `nation` +left join `region` on `n_nationkey` = `r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/left_outer_join_inner_join_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/left_outer_join_inner_join_expected.sql new file mode 100644 index 000000000..a08579cbf --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/left_outer_join_inner_join_expected.sql @@ -0,0 +1,4 @@ +select `p_partkey`, `n_name`, `r_name` +from `nation` +left join `region` on `n_nationkey` = `r_regionkey` +inner join `part` on `n_regionkey` = `p_partkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/likeOperatorWorks_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/likeOperatorWorks_expected.sql new file mode 100644 index 000000000..078a0ea9a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/likeOperatorWorks_expected.sql @@ -0,0 +1,3 @@ +select `name` +from `tpch`.`tiny`.`nation` +where `name` like '%an' \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/mapRetrieveOperatorWorks_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/mapRetrieveOperatorWorks_expected.sql new file mode 100644 index 000000000..d8f657329 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/mapRetrieveOperatorWorks_expected.sql @@ -0,0 +1 @@ +select `map`(array['ala', 'kot'], array[3, 4])['kot'] \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/max_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/max_expected.sql new file mode 100644 index 000000000..b966f1d27 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/max_expected.sql @@ -0,0 +1,2 @@ +select max(`c_bigint`), max(`c_double`), max(`c_string`), max(`c_date`), max(`c_timestamp`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/minMaxHasRows_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/minMaxHasRows_expected.sql new file mode 100644 index 000000000..5e4d17a2a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/minMaxHasRows_expected.sql @@ -0,0 +1,2 @@ +select min(`c1`), max(`c1`) +from `empty` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/min_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/min_expected.sql new file mode 100644 index 000000000..3903b6603 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/min_expected.sql @@ -0,0 +1,2 @@ +select min(`c_bigint`), min(`c_double`), min(`c_string`), min(`c_date`), min(`c_timestamp`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/mixAggregate_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/mixAggregate_expected.sql new file mode 100644 index 000000000..0cdc5289f --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/mixAggregate_expected.sql @@ -0,0 +1,2 @@ +select count(`c_string`), max(`c_double`), avg(`c_bigint`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/multipleDistinctAgg_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/multipleDistinctAgg_expected.sql new file mode 100644 index 000000000..5d0b1069c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/multipleDistinctAgg_expected.sql @@ -0,0 +1,2 @@ +select count(distinct `n_regionkey`), count(distinct `n_name`), min(distinct `n_nationkey`) +from `nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/multipleWithExprsReferencedFromParent_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/multipleWithExprsReferencedFromParent_expected.sql new file mode 100644 index 000000000..7c100314a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/multipleWithExprsReferencedFromParent_expected.sql @@ -0,0 +1,6 @@ +with `wnation` as (select `n_nationkey`, `n_regionkey` +from `nation`), `wregion` as (select `r_regionkey`, `r_name` +from `region`) (select `n`.`n_nationkey`, `r`.`r_regionkey` +from `wnation` as `n` +inner join `wregion` as `r` on `n`.`n_regionkey` = `r`.`r_regionkey` +where `r`.`r_name` = 'africa') \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/multiplyOperator_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/multiplyOperator_expected.sql new file mode 100644 index 000000000..1531a31fe --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/multiplyOperator_expected.sql @@ -0,0 +1,2 @@ +select `c1` * `c1` +from `empty` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/noOrderAllRowsPeers_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/noOrderAllRowsPeers_expected.sql new file mode 100644 index 000000000..c04d090c1 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/noOrderAllRowsPeers_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `discount`, rank() over (partition by `suppkey`) +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByAggregate_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByAggregate_expected.sql new file mode 100644 index 000000000..80c3157f2 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByAggregate_expected.sql @@ -0,0 +1,4 @@ +select `regionkey` as `nationkey`, `nationkey` as `regionkey`, `name` +from `tpch`.`tiny`.`nation` +where `nationkey` < 20 +order by `nationkey` desc, `regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByAliasSameAsColumn_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByAliasSameAsColumn_expected.sql new file mode 100644 index 000000000..80c3157f2 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByAliasSameAsColumn_expected.sql @@ -0,0 +1,4 @@ +select `regionkey` as `nationkey`, `nationkey` as `regionkey`, `name` +from `tpch`.`tiny`.`nation` +where `nationkey` < 20 +order by `nationkey` desc, `regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsDefault_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsDefault_expected.sql new file mode 100644 index 000000000..5de443617 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsDefault_expected.sql @@ -0,0 +1,5 @@ +select * +from (select cast(null as bigint) +union all +select 1) as `t` +order by 1 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsFirst_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsFirst_expected.sql new file mode 100644 index 000000000..34ade5557 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsFirst_expected.sql @@ -0,0 +1,5 @@ +select * +from (select cast(null as bigint) +union all +select 1) as `t` +order by 1 nulls first \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsLast_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsLast_expected.sql new file mode 100644 index 000000000..cb08d3728 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByAscNullsLast_expected.sql @@ -0,0 +1,5 @@ +select * +from (select cast(null as bigint) +union all +select 1) as `t` +order by 1 nulls last \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsDefault_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsDefault_expected.sql new file mode 100644 index 000000000..5de443617 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsDefault_expected.sql @@ -0,0 +1,5 @@ +select * +from (select cast(null as bigint) +union all +select 1) as `t` +order by 1 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsFirst_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsFirst_expected.sql new file mode 100644 index 000000000..34ade5557 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsFirst_expected.sql @@ -0,0 +1,5 @@ +select * +from (select cast(null as bigint) +union all +select 1) as `t` +order by 1 nulls first \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsLast_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsLast_expected.sql new file mode 100644 index 000000000..cb08d3728 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByDefaultNullsLast_expected.sql @@ -0,0 +1,5 @@ +select * +from (select cast(null as bigint) +union all +select 1) as `t` +order by 1 nulls last \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByDescNullsFirst_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByDescNullsFirst_expected.sql new file mode 100644 index 000000000..456073547 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByDescNullsFirst_expected.sql @@ -0,0 +1,5 @@ +select * +from (select cast(null as bigint) +union all +select 1) as `t` +order by 1 desc nulls first \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByDescNullsLast_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByDescNullsLast_expected.sql new file mode 100644 index 000000000..20558f3cb --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByDescNullsLast_expected.sql @@ -0,0 +1,5 @@ +select * +from (select cast(null as bigint) +union all +select 1) as `t` +order by 1 desc nulls last \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByDistinctColumnDesc_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByDistinctColumnDesc_expected.sql new file mode 100644 index 000000000..0d2d1cda4 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByDistinctColumnDesc_expected.sql @@ -0,0 +1,4 @@ +select distinct `brand` +from `tpch`.`tiny`.`part` +where `partkey` < 15 +order by 1 desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByExpression_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByExpression_expected.sql new file mode 100644 index 000000000..7dd71f1e3 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByExpression_expected.sql @@ -0,0 +1,4 @@ +select `totalprice` * 1.0625, `custkey` +from `tpch`.`tiny`.`orders` +order by 1 +fetch next 20 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByMixOfColumnsAscDesc_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByMixOfColumnsAscDesc_expected.sql new file mode 100644 index 000000000..8d1fb9e6c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByMixOfColumnsAscDesc_expected.sql @@ -0,0 +1,4 @@ +select `orderdate`, `orderpriority`, `custkey` +from `tpch`.`tiny`.`orders` +order by 1 desc, 2, 3 desc +fetch next 20 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedAggregate_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedAggregate_expected.sql new file mode 100644 index 000000000..ae50fb11d --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedAggregate_expected.sql @@ -0,0 +1,5 @@ +select avg(`retailprice`), `mfgr` +from `tpch`.`tiny`.`part` +group by 2 +order by count(*) +fetch next 20 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedColumns_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedColumns_expected.sql new file mode 100644 index 000000000..7d1b4ab28 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedColumns_expected.sql @@ -0,0 +1,3 @@ +select `nationkey`, `name` +from `tpch`.`tiny`.`nation` +order by `regionkey`, `nationkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedExpression_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedExpression_expected.sql new file mode 100644 index 000000000..d30a9c417 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByNonProjectedExpression_expected.sql @@ -0,0 +1,4 @@ +select `custkey`, `orderstatus` +from `tpch`.`tiny`.`orders` +order by `totalprice` * 1.0625 +fetch next 20 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/orderByOrdinals_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/orderByOrdinals_expected.sql new file mode 100644 index 000000000..1d90e8248 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/orderByOrdinals_expected.sql @@ -0,0 +1,3 @@ +select `regionkey`, `nationkey` +from `tpch`.`tiny`.`nation` +order by 1, 2 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/predicateNotProjected_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/predicateNotProjected_expected.sql new file mode 100644 index 000000000..ddd8e1208 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/predicateNotProjected_expected.sql @@ -0,0 +1,5 @@ +select `n_nationkey` +from `nation` +where `n_name` < 'india' +order by `n_nationkey` +fetch next 3 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/prediction_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/prediction_expected.sql new file mode 100644 index 000000000..91c064e2c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/prediction_expected.sql @@ -0,0 +1,3 @@ +select `classify`(`features`(1, 2 + `random`(1)), `model`) +from (select `learn_classifier`(`labels`, `features`) as `model` +from (values row(1, `features`(1, 2))) as `t` (`labels`, `features`)) as `t2` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/projectAggFuncs_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/projectAggFuncs_expected.sql new file mode 100644 index 000000000..77c5cb631 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/projectAggFuncs_expected.sql @@ -0,0 +1 @@ +select count(10), max(50), min(90.0) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/projectConstants_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/projectConstants_expected.sql new file mode 100644 index 000000000..1d70a0d14 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/projectConstants_expected.sql @@ -0,0 +1 @@ +select 1, 1.1, 100 * 5.1, 'a', 'dummy values', true, false \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/projectFunctions_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/projectFunctions_expected.sql new file mode 100644 index 000000000..3c594821d --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/projectFunctions_expected.sql @@ -0,0 +1 @@ +select abs(-10.0), `log2`(4), true and false, true or false \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q01_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q01_expected.sql new file mode 100644 index 000000000..b3983cae5 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q01_expected.sql @@ -0,0 +1,5 @@ +select `l_returnflag`, `l_linestatus`, sum(`l_quantity`) as `sum_qty`, sum(`l_extendedprice`) as `sum_base_price`, sum(`l_extendedprice` * (1 - `l_discount`)) as `sum_disc_price`, sum(`l_extendedprice` * (1 - `l_discount`) * (1 + `l_tax`)) as `sum_charge`, avg(`l_quantity`) as `avg_qty`, avg(`l_extendedprice`) as `avg_price`, avg(`l_discount`) as `avg_disc`, count(*) as `count_order` +from `lineitem` +where `l_shipdate` <= date '1998-12-01' - interval '90' day +group by `l_returnflag`, `l_linestatus` +order by `l_returnflag`, `l_linestatus` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q02_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q02_expected.sql new file mode 100644 index 000000000..61488aead --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q02_expected.sql @@ -0,0 +1,7 @@ +select `s_acctbal`, `s_name`, `n_name`, `p_partkey`, `p_mfgr`, `s_address`, `s_phone`, `s_comment` +from `part` +where `p_partkey` = `ps_partkey` and `s_suppkey` = `ps_suppkey` and `p_size` = 15 and `p_type` like '%brass' and `s_nationkey` = `n_nationkey` and `n_regionkey` = `r_regionkey` and `r_name` = 'europe' and `ps_supplycost` = (select min(`ps_supplycost`) +from `region` +where `p_partkey` = `ps_partkey` and `s_suppkey` = `ps_suppkey` and `s_nationkey` = `n_nationkey` and `n_regionkey` = `r_regionkey` and `r_name` = 'europe') +order by `s_acctbal` desc, `n_name`, `s_name`, `p_partkey` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q03_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q03_expected.sql new file mode 100644 index 000000000..49b35bb91 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q03_expected.sql @@ -0,0 +1,6 @@ +select `l_orderkey`, sum(`l_extendedprice` * (1 - `l_discount`)) as `revenue`, `o_orderdate`, `o_shippriority` +from `lineitem` +where `c_mktsegment` = 'building' and `c_custkey` = `o_custkey` and `l_orderkey` = `o_orderkey` and `o_orderdate` < date '1995-03-15' and `l_shipdate` > date '1995-03-15' +group by `l_orderkey`, `o_orderdate`, `o_shippriority` +order by `revenue` desc, `o_orderdate` +fetch next 10 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q04_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q04_expected.sql new file mode 100644 index 000000000..7d2e5588a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q04_expected.sql @@ -0,0 +1,7 @@ +select `o_orderpriority`, count(*) as `order_count` +from `orders` +where `o_orderdate` >= date '1993-07-01' and `o_orderdate` < date '1993-07-01' + interval '3' month and exists (select * +from `lineitem` +where `l_orderkey` = `o_orderkey` and `l_commitdate` < `l_receiptdate`) +group by `o_orderpriority` +order by `o_orderpriority` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q05_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q05_expected.sql new file mode 100644 index 000000000..426ffac61 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q05_expected.sql @@ -0,0 +1,5 @@ +select `n_name`, sum(`l_extendedprice` * (1 - `l_discount`)) as `revenue` +from `region` +where `c_custkey` = `o_custkey` and `l_orderkey` = `o_orderkey` and `l_suppkey` = `s_suppkey` and `c_nationkey` = `s_nationkey` and `s_nationkey` = `n_nationkey` and `n_regionkey` = `r_regionkey` and `r_name` = 'asia' and `o_orderdate` >= date '1994-01-01' and `o_orderdate` < date '1994-01-01' + interval '1' year +group by `n_name` +order by `revenue` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q06_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q06_expected.sql new file mode 100644 index 000000000..937b114d8 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q06_expected.sql @@ -0,0 +1,3 @@ +select sum(`l_extendedprice` * `l_discount`) as `revenue` +from `lineitem` +where `l_shipdate` >= date '1994-01-01' and `l_shipdate` < date '1994-01-01' + interval '1' year and `l_discount` between asymmetric 0.06 - 0.01 and 0.06 + 0.01 and `l_quantity` < 24 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q07_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q07_expected.sql new file mode 100644 index 000000000..018530fe8 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q07_expected.sql @@ -0,0 +1,6 @@ +select `supp_nation`, `cust_nation`, `l_year`, sum(`volume`) as `revenue` +from (select `n1`.`n_name` as `supp_nation`, `n2`.`n_name` as `cust_nation`, extract(year from `l_shipdate`) as `l_year`, `l_extendedprice` * (1 - `l_discount`) as `volume` +from `nation` as `n2` +where `s_suppkey` = `l_suppkey` and `o_orderkey` = `l_orderkey` and `c_custkey` = `o_custkey` and `s_nationkey` = `n1`.`n_nationkey` and `c_nationkey` = `n2`.`n_nationkey` and (`n1`.`n_name` = 'france' and `n2`.`n_name` = 'germany' or `n1`.`n_name` = 'germany' and `n2`.`n_name` = 'france') and `l_shipdate` between asymmetric date '1995-01-01' and date '1996-12-31') as `shipping` +group by `supp_nation`, `cust_nation`, `l_year` +order by `supp_nation`, `cust_nation`, `l_year` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q08_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q08_expected.sql new file mode 100644 index 000000000..ca3ef33be --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q08_expected.sql @@ -0,0 +1,6 @@ +select `o_year`, sum(case when `nation` = 'brazil' then `volume` else 0 end) / sum(`volume`) as `mkt_share` +from (select extract(year from `o_orderdate`) as `o_year`, `l_extendedprice` * (1 - `l_discount`) as `volume`, `n2`.`n_name` as `nation` +from `region` +where `p_partkey` = `l_partkey` and `s_suppkey` = `l_suppkey` and `l_orderkey` = `o_orderkey` and `o_custkey` = `c_custkey` and `c_nationkey` = `n1`.`n_nationkey` and `n1`.`n_regionkey` = `r_regionkey` and `r_name` = 'america' and `s_nationkey` = `n2`.`n_nationkey` and `o_orderdate` between asymmetric date '1995-01-01' and date '1996-12-31' and `p_type` = 'economy anodized steel') as `all_nations` +group by `o_year` +order by `o_year` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q09_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q09_expected.sql new file mode 100644 index 000000000..2dfc62b72 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q09_expected.sql @@ -0,0 +1,6 @@ +select `nation`, `o_year`, sum(`amount`) as `sum_profit` +from (select `n_name` as `nation`, extract(year from `o_orderdate`) as `o_year`, `l_extendedprice` * (1 - `l_discount`) - `ps_supplycost` * `l_quantity` as `amount` +from `nation` +where `s_suppkey` = `l_suppkey` and `ps_suppkey` = `l_suppkey` and `ps_partkey` = `l_partkey` and `p_partkey` = `l_partkey` and `o_orderkey` = `l_orderkey` and `s_nationkey` = `n_nationkey` and `p_name` like '%green%') as `profit` +group by `nation`, `o_year` +order by `nation`, `o_year` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q10_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q10_expected.sql new file mode 100644 index 000000000..f67d1fd3f --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q10_expected.sql @@ -0,0 +1,6 @@ +select `c_custkey`, `c_name`, sum(`l_extendedprice` * (1 - `l_discount`)) as `revenue`, `c_acctbal`, `n_name`, `c_address`, `c_phone`, `c_comment` +from `nation` +where `c_custkey` = `o_custkey` and `l_orderkey` = `o_orderkey` and `o_orderdate` >= date '1993-10-01' and `o_orderdate` < date '1993-10-01' + interval '3' month and `l_returnflag` = 'r' and `c_nationkey` = `n_nationkey` +group by `c_custkey`, `c_name`, `c_acctbal`, `c_phone`, `n_name`, `c_address`, `c_comment` +order by `revenue` desc +fetch next 20 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q11_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q11_expected.sql new file mode 100644 index 000000000..dd8b7d37a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q11_expected.sql @@ -0,0 +1,8 @@ +select `ps_partkey`, sum(`ps_supplycost` * `ps_availqty`) as `value` +from `nation` +where `ps_suppkey` = `s_suppkey` and `s_nationkey` = `n_nationkey` and `n_name` = 'germany' +group by `ps_partkey` +having sum(`ps_supplycost` * `ps_availqty`) > (select sum(`ps_supplycost` * `ps_availqty`) * 0.0001 +from `nation` +where `ps_suppkey` = `s_suppkey` and `s_nationkey` = `n_nationkey` and `n_name` = 'germany') +order by `value` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q12_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q12_expected.sql new file mode 100644 index 000000000..d04a7badc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q12_expected.sql @@ -0,0 +1,5 @@ +select `l_shipmode`, sum(case when `o_orderpriority` = '1-urgent' or `o_orderpriority` = '2-high' then 1 else 0 end) as `high_line_count`, sum(case when `o_orderpriority` <> '1-urgent' and `o_orderpriority` <> '2-high' then 1 else 0 end) as `low_line_count` +from `lineitem` +where `o_orderkey` = `l_orderkey` and `l_shipmode` in ('mail', 'ship') and `l_commitdate` < `l_receiptdate` and `l_shipdate` < `l_commitdate` and `l_receiptdate` >= date '1994-01-01' and `l_receiptdate` < date '1994-01-01' + interval '1' year +group by `l_shipmode` +order by `l_shipmode` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q13_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q13_expected.sql new file mode 100644 index 000000000..9b34736fc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q13_expected.sql @@ -0,0 +1,7 @@ +select `c_count`, count(*) as `custdist` +from (select `c_custkey`, count(`o_orderkey`) +from `customer` +left join `orders` on `c_custkey` = `o_custkey` and not `o_comment` like '%special%requests%' +group by `c_custkey`) as `c_orders` (`c_custkey`, `c_count`) +group by `c_count` +order by `custdist` desc, `c_count` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q14_1_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q14_1_expected.sql new file mode 100644 index 000000000..dcab95f8e --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q14_1_expected.sql @@ -0,0 +1,50 @@ +with `cross_items` as (select `i_item_sk` as `ss_item_sk` +from select `iss`.`i_brand_id` as `brand_id`, `iss`.`i_class_id` as `class_id`, `iss`.`i_category_id` as `category_id` +from `store_sales` +where `ss_item_sk` = `iss`.`i_item_sk` and `ss_sold_date_sk` = `d1`.`d_date_sk` and `d1`.`d_year` between asymmetric 1999 and 1999 + 2 +intersect +select `ics`.`i_brand_id`, `ics`.`i_class_id`, `ics`.`i_category_id` +from `catalog_sales` +where `cs_item_sk` = `ics`.`i_item_sk` and `cs_sold_date_sk` = `d2`.`d_date_sk` and `d2`.`d_year` between asymmetric 1999 and 1999 + 2 +intersect +select `iws`.`i_brand_id`, `iws`.`i_class_id`, `iws`.`i_category_id` +from `web_sales` +where `ws_item_sk` = `iws`.`i_item_sk` and `ws_sold_date_sk` = `d3`.`d_date_sk` and `d3`.`d_year` between asymmetric 1999 and 1999 + 2 +where `i_brand_id` = `brand_id` and `i_class_id` = `class_id` and `i_category_id` = `category_id`), `avg_sales` as (select avg(`quantity` * `list_price`) as `average_sales` +from (select `ss_quantity` as `quantity`, `ss_list_price` as `list_price` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `d_year` between asymmetric 1999 and 1999 + 2 +union all +select `cs_quantity` as `quantity`, `cs_list_price` as `list_price` +from `catalog_sales` +where `cs_sold_date_sk` = `d_date_sk` and `d_year` between asymmetric 1999 and 1999 + 2 +union all +select `ws_quantity` as `quantity`, `ws_list_price` as `list_price` +from `web_sales` +where `ws_sold_date_sk` = `d_date_sk` and `d_year` between asymmetric 1999 and 1999 + 2) as `x`) (select `channel`, `i_brand_id`, `i_class_id`, `i_category_id`, sum(`sales`), sum(`number_sales`) +from (select 'store' as `channel`, `i_brand_id`, `i_class_id`, `i_category_id`, sum(`ss_quantity` * `ss_list_price`) as `sales`, count(*) as `number_sales` +from `store_sales` +where `ss_item_sk` in (select `ss_item_sk` +from `cross_items`) and `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` = 1999 + 2 and `d_moy` = 11 +group by `i_brand_id`, `i_class_id`, `i_category_id` +having sum(`ss_quantity` * `ss_list_price`) > (select `average_sales` +from `avg_sales`) +union all +select 'catalog' as `channel`, `i_brand_id`, `i_class_id`, `i_category_id`, sum(`cs_quantity` * `cs_list_price`) as `sales`, count(*) as `number_sales` +from `catalog_sales` +where `cs_item_sk` in (select `ss_item_sk` +from `cross_items`) and `cs_item_sk` = `i_item_sk` and `cs_sold_date_sk` = `d_date_sk` and `d_year` = 1999 + 2 and `d_moy` = 11 +group by `i_brand_id`, `i_class_id`, `i_category_id` +having sum(`cs_quantity` * `cs_list_price`) > (select `average_sales` +from `avg_sales`) +union all +select 'web' as `channel`, `i_brand_id`, `i_class_id`, `i_category_id`, sum(`ws_quantity` * `ws_list_price`) as `sales`, count(*) as `number_sales` +from `web_sales` +where `ws_item_sk` in (select `ss_item_sk` +from `cross_items`) and `ws_item_sk` = `i_item_sk` and `ws_sold_date_sk` = `d_date_sk` and `d_year` = 1999 + 2 and `d_moy` = 11 +group by `i_brand_id`, `i_class_id`, `i_category_id` +having sum(`ws_quantity` * `ws_list_price`) > (select `average_sales` +from `avg_sales`)) as `y` +group by rollup(`channel`, `i_brand_id`, `i_class_id`, `i_category_id`) +order by `channel`, `i_brand_id`, `i_class_id`, `i_category_id` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q14_2_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q14_2_expected.sql new file mode 100644 index 000000000..448b6b88d --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q14_2_expected.sql @@ -0,0 +1,36 @@ +with `cross_items` as (select `i_item_sk` as `ss_item_sk` +from (select `iss`.`i_brand_id` as `brand_id`, `iss`.`i_class_id` as `class_id`, `iss`.`i_category_id` as `category_id` +from `store_sales` +where `ss_item_sk` = `iss`.`i_item_sk` and `ss_sold_date_sk` = `d1`.`d_date_sk` and `d1`.`d_year` between asymmetric 1999 and 1999 + 2 +intersect +select `ics`.`i_brand_id`, `ics`.`i_class_id`, `ics`.`i_category_id` +from `catalog_sales` +where `cs_item_sk` = `ics`.`i_item_sk` and `cs_sold_date_sk` = `d2`.`d_date_sk` and `d2`.`d_year` between asymmetric 1999 and 1999 + 2 +intersect +select `iws`.`i_brand_id`, `iws`.`i_class_id`, `iws`.`i_category_id` +from `web_sales` +where `ws_item_sk` = `iws`.`i_item_sk` and `ws_sold_date_sk` = `d3`.`d_date_sk` and `d3`.`d_year` between asymmetric 1999 and 1999 + 2) as `x` +where `i_brand_id` = `brand_id` and `i_class_id` = `class_id` and `i_category_id` = `category_id`), `avg_sales` as (select avg(`quantity` * `list_price`) as `average_sales` +from (select `ss_quantity` as `quantity`, `ss_list_price` as `list_price` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `d_year` between asymmetric 1999 and 1999 + 2 +union all +select `cs_quantity` as `quantity`, `cs_list_price` as `list_price` +from `catalog_sales` +where `cs_sold_date_sk` = `d_date_sk` and `d_year` between asymmetric 1999 and 1999 + 2 +union all +select `ws_quantity` as `quantity`, `ws_list_price` as `list_price` +from `web_sales` +where `ws_sold_date_sk` = `d_date_sk` and `d_year` between asymmetric 1999 and 1999 + 2)) (select * +from (select 'store' as `channel`, `i_brand_id`, `i_class_id`, `i_category_id`, sum(`ss_quantity` * `ss_list_price`) as `sales`, count(*) as `number_sales` +from `store_sales` +where `ss_item_sk` in (select `ss_item_sk` +from `cross_items`) and `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_week_seq` = (select `d_week_seq` +from `date_dim` +where `d_year` = 1999 + 1 and `d_moy` = 12 and `d_dom` = 11) +group by `i_brand_id`, `i_class_id`, `i_category_id` +having sum(`ss_quantity` * `ss_list_price`) > (select `average_sales` +from `avg_sales`)) +where `this_year`.`i_brand_id` = `last_year`.`i_brand_id` and `this_year`.`i_class_id` = `last_year`.`i_class_id` and `this_year`.`i_category_id` = `last_year`.`i_category_id` +order by `this_year`.`channel`, `this_year`.`i_brand_id`, `this_year`.`i_class_id`, `this_year`.`i_category_id` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q14_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q14_expected.sql new file mode 100644 index 000000000..13ef5cd39 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q14_expected.sql @@ -0,0 +1,3 @@ +select 100.00 * sum(case when `p_type` like 'promo%' then `l_extendedprice` * (1 - `l_discount`) else 0 end) / sum(`l_extendedprice` * (1 - `l_discount`)) as `promo_revenue` +from `part` +where `l_partkey` = `p_partkey` and `l_shipdate` >= date '1995-09-01' and `l_shipdate` < date '1995-09-01' + interval '1' month \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q15_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q15_expected.sql new file mode 100644 index 000000000..cdbd50073 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q15_expected.sql @@ -0,0 +1,5 @@ +select `s_suppkey`, `s_name`, `s_address`, `s_phone`, `total_revenue` +from `revenue` +where `s_suppkey` = `supplier_no` and `total_revenue` = (select max(`total_revenue`) +from `revenue`) +order by `s_suppkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q16_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q16_expected.sql new file mode 100644 index 000000000..25651ecc4 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q16_expected.sql @@ -0,0 +1,7 @@ +select `p_brand`, `p_type`, `p_size`, count(distinct `ps_suppkey`) as `supplier_cnt` +from `part` +where `p_partkey` = `ps_partkey` and `p_brand` <> 'brand#45' and not `p_type` like 'medium polished%' and `p_size` in (49, 14, 23, 45, 19, 3, 36, 9) and `ps_suppkey` not in (select `s_suppkey` +from `supplier` +where `s_comment` like '%customer%complaints%') +group by `p_brand`, `p_type`, `p_size` +order by `supplier_cnt` desc, `p_brand`, `p_type`, `p_size` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q17_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q17_expected.sql new file mode 100644 index 000000000..f8e9d64f5 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q17_expected.sql @@ -0,0 +1,5 @@ +select sum(`l_extendedprice`) / 7.0 as `avg_yearly` +from `part` +where `p_partkey` = `l_partkey` and `p_brand` = 'brand#23' and `p_container` = 'med box' and `l_quantity` < (select 0.2 * avg(`l_quantity`) +from `lineitem` +where `l_partkey` = `p_partkey`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q18_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q18_expected.sql new file mode 100644 index 000000000..fcef35ddc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q18_expected.sql @@ -0,0 +1,9 @@ +select `c_name`, `c_custkey`, `o_orderkey`, `o_orderdate`, `o_totalprice`, sum(`l_quantity`) +from `lineitem` +where `o_orderkey` in (select `l_orderkey` +from `lineitem` +group by `l_orderkey` +having sum(`l_quantity`) > 300) and `c_custkey` = `o_custkey` and `o_orderkey` = `l_orderkey` +group by `c_name`, `c_custkey`, `o_orderkey`, `o_orderdate`, `o_totalprice` +order by `o_totalprice` desc, `o_orderdate` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q19_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q19_expected.sql new file mode 100644 index 000000000..696c831b7 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q19_expected.sql @@ -0,0 +1,3 @@ +select sum(`l_extendedprice` * (1 - `l_discount`)) as `revenue` +from `part` +where `p_partkey` = `l_partkey` and `p_brand` = 'brand#12' and `p_container` in ('sm case', 'sm box', 'sm pack', 'sm pkg') and `l_quantity` >= 1 and `l_quantity` <= 1 + 10 and `p_size` between asymmetric 1 and 5 and `l_shipmode` in ('air', 'air reg') and `l_shipinstruct` = 'deliver in person' or `p_partkey` = `l_partkey` and `p_brand` = 'brand#23' and `p_container` in ('med bag', 'med box', 'med pkg', 'med pack') and `l_quantity` >= 10 and `l_quantity` <= 10 + 10 and `p_size` between asymmetric 1 and 10 and `l_shipmode` in ('air', 'air reg') and `l_shipinstruct` = 'deliver in person' or `p_partkey` = `l_partkey` and `p_brand` = 'brand#34' and `p_container` in ('lg case', 'lg box', 'lg pack', 'lg pkg') and `l_quantity` >= 20 and `l_quantity` <= 20 + 10 and `p_size` between asymmetric 1 and 15 and `l_shipmode` in ('air', 'air reg') and `l_shipinstruct` = 'deliver in person' \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q20_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q20_expected.sql new file mode 100644 index 000000000..afe0f4894 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q20_expected.sql @@ -0,0 +1,10 @@ +select `s_name`, `s_address` +from `supplier` +where `s_suppkey` in (select `ps_suppkey` +from `partsupp` +where `ps_partkey` in (select `p_partkey` +from `part` +where `p_name` like 'forest%') and `ps_availqty` > (select 0.5 * sum(`l_quantity`) +from `lineitem` +where `l_partkey` = `ps_partkey` and `l_suppkey` = `ps_suppkey` and `l_shipdate` >= `date`('1994-01-01') and `l_shipdate` < `date`('1994-01-01') + interval '1' year)) and `s_nationkey` = `n_nationkey` and `n_name` = 'canada' +order by `s_name` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q21_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q21_expected.sql new file mode 100644 index 000000000..14f941b01 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q21_expected.sql @@ -0,0 +1,10 @@ +select `s_name`, count(*) as `numwait` +from `nation` +where `s_suppkey` = `l1`.`l_suppkey` and `o_orderkey` = `l1`.`l_orderkey` and `o_orderstatus` = 'f' and `l1`.`l_receiptdate` > `l1`.`l_commitdate` and exists (select * +from `lineitem` as `l2` +where `l2`.`l_orderkey` = `l1`.`l_orderkey` and `l2`.`l_suppkey` <> `l1`.`l_suppkey`) and not exists (select * +from `lineitem` as `l3` +where `l3`.`l_orderkey` = `l1`.`l_orderkey` and `l3`.`l_suppkey` <> `l1`.`l_suppkey` and `l3`.`l_receiptdate` > `l3`.`l_commitdate`) and `s_nationkey` = `n_nationkey` and `n_name` = 'saudi arabia' +group by `s_name` +order by `numwait` desc, `s_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q22_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q22_expected.sql new file mode 100644 index 000000000..96cf8dd8d --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q22_expected.sql @@ -0,0 +1,10 @@ +select `cntrycode`, count(*) as `numcust`, sum(`c_acctbal`) as `totacctbal` +from (select `substr`(`c_phone`, 1, 2) as `cntrycode`, `c_acctbal` +from `customer` +where `substr`(`c_phone`, 1, 2) in ('13', '31', '23', '29', '30', '18', '17') and `c_acctbal` > (select avg(`c_acctbal`) +from `customer` +where `c_acctbal` > 0.00 and `substr`(`c_phone`, 1, 2) in ('13', '31', '23', '29', '30', '18', '17')) and not exists (select * +from `orders` +where `o_custkey` = `c_custkey`)) as `custsale` +group by `cntrycode` +order by `cntrycode` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q23_1_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q23_1_expected.sql new file mode 100644 index 000000000..0b085b774 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q23_1_expected.sql @@ -0,0 +1,27 @@ +with `frequent_ss_items` as (select `substr`(`i_item_desc`, 1, 30) as `itemdesc`, `i_item_sk` as `item_sk`, `d_date` as `solddate`, count(*) as `cnt` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `ss_item_sk` = `i_item_sk` and `d_year` in (2000, 2000 + 1, 2000 + 2, 2000 + 3) +group by `substr`(`i_item_desc`, 1, 30), `i_item_sk`, `d_date` +having count(*) > 4), `max_store_sales` as (select max(`csales`) as `tpcds_cmax` +from (select `c_customer_sk`, sum(`ss_quantity` * `ss_sales_price`) as `csales` +from `store_sales` +where `ss_customer_sk` = `c_customer_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` in (2000, 2000 + 1, 2000 + 2, 2000 + 3) +group by `c_customer_sk`)), `best_ss_customer` as (select `c_customer_sk`, sum(`ss_quantity` * `ss_sales_price`) as `ssales` +from `store_sales` +where `ss_customer_sk` = `c_customer_sk` +group by `c_customer_sk` +having sum(`ss_quantity` * `ss_sales_price`) > 50 / 100.0 * (select * +from `max_store_sales`)) (select sum(`sales`) +from (select `cs_quantity` * `cs_list_price` as `sales` +from `catalog_sales` +where `d_year` = 2000 and `d_moy` = 2 and `cs_sold_date_sk` = `d_date_sk` and `cs_item_sk` in (select `item_sk` +from `frequent_ss_items`) and `cs_bill_customer_sk` in (select `c_customer_sk` +from `best_ss_customer`) +union all +select `ws_quantity` * `ws_list_price` as `sales` +from `web_sales` +where `d_year` = 2000 and `d_moy` = 2 and `ws_sold_date_sk` = `d_date_sk` and `ws_item_sk` in (select `item_sk` +from `frequent_ss_items`) and `ws_bill_customer_sk` in (select `c_customer_sk` +from `best_ss_customer`)) +order by +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q23_2_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q23_2_expected.sql new file mode 100644 index 000000000..19f2a5d35 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q23_2_expected.sql @@ -0,0 +1,29 @@ +with `frequent_ss_items` as (select `substr`(`i_item_desc`, 1, 30) as `itemdesc`, `i_item_sk` as `item_sk`, `d_date` as `solddate`, count(*) as `cnt` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `ss_item_sk` = `i_item_sk` and `d_year` in (2000, 2000 + 1, 2000 + 2, 2000 + 3) +group by `substr`(`i_item_desc`, 1, 30), `i_item_sk`, `d_date` +having count(*) > 4), `max_store_sales` as (select max(`csales`) as `tpcds_cmax` +from (select `c_customer_sk`, sum(`ss_quantity` * `ss_sales_price`) as `csales` +from `store_sales` +where `ss_customer_sk` = `c_customer_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` in (2000, 2000 + 1, 2000 + 2, 2000 + 3) +group by `c_customer_sk`)), `best_ss_customer` as (select `c_customer_sk`, sum(`ss_quantity` * `ss_sales_price`) as `ssales` +from `store_sales` +where `ss_customer_sk` = `c_customer_sk` +group by `c_customer_sk` +having sum(`ss_quantity` * `ss_sales_price`) > 50 / 100.0 * (select * +from `max_store_sales`)) (select `c_last_name`, `c_first_name`, `sales` +from (select `c_last_name`, `c_first_name`, sum(`cs_quantity` * `cs_list_price`) as `sales` +from `catalog_sales` +where `d_year` = 2000 and `d_moy` = 2 and `cs_sold_date_sk` = `d_date_sk` and `cs_item_sk` in (select `item_sk` +from `frequent_ss_items`) and `cs_bill_customer_sk` in (select `c_customer_sk` +from `best_ss_customer`) and `cs_bill_customer_sk` = `c_customer_sk` +group by `c_last_name`, `c_first_name` +union all +select `c_last_name`, `c_first_name`, sum(`ws_quantity` * `ws_list_price`) as `sales` +from `web_sales` +where `d_year` = 2000 and `d_moy` = 2 and `ws_sold_date_sk` = `d_date_sk` and `ws_item_sk` in (select `item_sk` +from `frequent_ss_items`) and `ws_bill_customer_sk` in (select `c_customer_sk` +from `best_ss_customer`) and `ws_bill_customer_sk` = `c_customer_sk` +group by `c_last_name`, `c_first_name`) +order by `c_last_name`, `c_first_name`, `sales` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q24_1_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q24_1_expected.sql new file mode 100644 index 000000000..a8c21a430 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q24_1_expected.sql @@ -0,0 +1,9 @@ +with `ssales` as (select `c_last_name`, `c_first_name`, `s_store_name`, `ca_state`, `s_state`, `i_color`, `i_current_price`, `i_manager_id`, `i_units`, `i_size`, sum(`ss_net_paid`) as `netpaid` +from `store_sales` +where `ss_ticket_number` = `sr_ticket_number` and `ss_item_sk` = `sr_item_sk` and `ss_customer_sk` = `c_customer_sk` and `ss_item_sk` = `i_item_sk` and `ss_store_sk` = `s_store_sk` and `c_birth_country` = upper(`ca_country`) and `s_zip` = `ca_zip` and `s_market_id` = 8 +group by `c_last_name`, `c_first_name`, `s_store_name`, `ca_state`, `s_state`, `i_color`, `i_current_price`, `i_manager_id`, `i_units`, `i_size`) (select `c_last_name`, `c_first_name`, `s_store_name`, sum(`netpaid`) as `paid` +from `ssales` +where `i_color` = 'pale' +group by `c_last_name`, `c_first_name`, `s_store_name` +having sum(`netpaid`) > (select 0.05 * avg(`netpaid`) +from `ssales`)) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q24_2_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q24_2_expected.sql new file mode 100644 index 000000000..ea3b2e042 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q24_2_expected.sql @@ -0,0 +1,9 @@ +with `ssales` as (select `c_last_name`, `c_first_name`, `s_store_name`, `ca_state`, `s_state`, `i_color`, `i_current_price`, `i_manager_id`, `i_units`, `i_size`, sum(`ss_net_paid`) as `netpaid` +from `customer_address` +where `ss_ticket_number` = `sr_ticket_number` and `ss_item_sk` = `sr_item_sk` and `ss_customer_sk` = `c_customer_sk` and `ss_item_sk` = `i_item_sk` and `ss_store_sk` = `s_store_sk` and `c_birth_country` = upper(`ca_country`) and `s_zip` = `ca_zip` and `s_market_id` = 8 +group by `c_last_name`, `c_first_name`, `s_store_name`, `ca_state`, `s_state`, `i_color`, `i_current_price`, `i_manager_id`, `i_units`, `i_size`) (select `c_last_name`, `c_first_name`, `s_store_name`, sum(`netpaid`) as `paid` +from `ssales` +where `i_color` = 'chiffon' +group by `c_last_name`, `c_first_name`, `s_store_name` +having sum(`netpaid`) > (select 0.05 * avg(`netpaid`) +from `ssales`)) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q25_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q25_expected.sql new file mode 100644 index 000000000..08dbc523b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q25_expected.sql @@ -0,0 +1,6 @@ +select `i_item_id`, `i_item_desc`, `s_store_id`, `s_store_name`, sum(`ss_net_profit`) as `store_sales_profit`, sum(`sr_net_loss`) as `store_returns_loss`, sum(`cs_net_profit`) as `catalog_sales_profit` +from `store_sales` +where `d1`.`d_moy` = 4 and `d1`.`d_year` = 2001 and `d1`.`d_date_sk` = `ss_sold_date_sk` and `i_item_sk` = `ss_item_sk` and `s_store_sk` = `ss_store_sk` and `ss_customer_sk` = `sr_customer_sk` and `ss_item_sk` = `sr_item_sk` and `ss_ticket_number` = `sr_ticket_number` and `sr_returned_date_sk` = `d2`.`d_date_sk` and `d2`.`d_moy` between asymmetric 4 and 10 and `d2`.`d_year` = 2001 and `sr_customer_sk` = `cs_bill_customer_sk` and `sr_item_sk` = `cs_item_sk` and `cs_sold_date_sk` = `d3`.`d_date_sk` and `d3`.`d_moy` between asymmetric 4 and 10 and `d3`.`d_year` = 2001 +group by `i_item_id`, `i_item_desc`, `s_store_id`, `s_store_name` +order by `i_item_id`, `i_item_desc`, `s_store_id`, `s_store_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q26_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q26_expected.sql new file mode 100644 index 000000000..62faa0848 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q26_expected.sql @@ -0,0 +1,6 @@ +select `i_item_id`, avg(`cs_quantity`) as `agg1`, avg(`cs_list_price`) as `agg2`, avg(`cs_coupon_amt`) as `agg3`, avg(`cs_sales_price`) as `agg4` +from `catalog_sales` +where `cs_sold_date_sk` = `d_date_sk` and `cs_item_sk` = `i_item_sk` and `cs_bill_cdemo_sk` = `cd_demo_sk` and `cs_promo_sk` = `p_promo_sk` and `cd_gender` = 'm' and `cd_marital_status` = 's' and `cd_education_status` = 'college' and (`p_channel_email` = 'n' or `p_channel_event` = 'n') and `d_year` = 2000 +group by `i_item_id` +order by `i_item_id` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q27_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q27_expected.sql new file mode 100644 index 000000000..ed3d5c37a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q27_expected.sql @@ -0,0 +1,6 @@ +select `i_item_id`, `s_state`, grouping(`s_state`) as `g_state`, avg(`ss_quantity`) as `agg1`, avg(`ss_list_price`) as `agg2`, avg(`ss_coupon_amt`) as `agg3`, avg(`ss_sales_price`) as `agg4` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `ss_item_sk` = `i_item_sk` and `ss_store_sk` = `s_store_sk` and `ss_cdemo_sk` = `cd_demo_sk` and `cd_gender` = 'm' and `cd_marital_status` = 's' and `cd_education_status` = 'college' and `d_year` = 2002 and `s_state` in ('tn', 'tn', 'tn', 'tn', 'tn', 'tn') +group by rollup(`i_item_id`, `s_state`) +order by `i_item_id`, `s_state` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q28_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q28_expected.sql new file mode 100644 index 000000000..991e59c76 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q28_expected.sql @@ -0,0 +1,16 @@ +with `b0` as (select avg(`ss_list_price`) as `b1_lp`, count(`ss_list_price`) as `b1_cnt`, count(distinct `ss_list_price`) as `b1_cntd` +from `store_sales` +where `ss_quantity` between asymmetric 0 and 5 and (`ss_list_price` between asymmetric 8 and 8 + 10 or `ss_coupon_amt` between asymmetric 459 and 459 + 1000 or `ss_wholesale_cost` between asymmetric 57 and 57 + 20)), `b1` as (select avg(`ss_list_price`) as `b2_lp`, count(`ss_list_price`) as `b2_cnt`, count(distinct `ss_list_price`) as `b2_cntd` +from `store_sales` +where `ss_quantity` between asymmetric 6 and 10 and (`ss_list_price` between asymmetric 90 and 90 + 10 or `ss_coupon_amt` between asymmetric 2323 and 2323 + 1000 or `ss_wholesale_cost` between asymmetric 31 and 31 + 20)), `b2` as (select avg(`ss_list_price`) as `b3_lp`, count(`ss_list_price`) as `b3_cnt`, count(distinct `ss_list_price`) as `b3_cntd` +from `store_sales` +where `ss_quantity` between asymmetric 11 and 15 and (`ss_list_price` between asymmetric 142 and 142 + 10 or `ss_coupon_amt` between asymmetric 12214 and 12214 + 1000 or `ss_wholesale_cost` between asymmetric 79 and 79 + 20)), `b3` as (select avg(`ss_list_price`) as `b4_lp`, count(`ss_list_price`) as `b4_cnt`, count(distinct `ss_list_price`) as `b4_cntd` +from `store_sales` +where `ss_quantity` between asymmetric 16 and 20 and (`ss_list_price` between asymmetric 135 and 135 + 10 or `ss_coupon_amt` between asymmetric 6071 and 6071 + 1000 or `ss_wholesale_cost` between asymmetric 38 and 38 + 20)), `b4` as (select avg(`ss_list_price`) as `b5_lp`, count(`ss_list_price`) as `b5_cnt`, count(distinct `ss_list_price`) as `b5_cntd` +from `store_sales` +where `ss_quantity` between asymmetric 21 and 25 and (`ss_list_price` between asymmetric 122 and 122 + 10 or `ss_coupon_amt` between asymmetric 836 and 836 + 1000 or `ss_wholesale_cost` between asymmetric 17 and 17 + 20)), `b5` as (select avg(`ss_list_price`) as `b6_lp`, count(`ss_list_price`) as `b6_cnt`, count(distinct `ss_list_price`) as `b6_cntd` +from `store_sales` +where `ss_quantity` between asymmetric 26 and 30 and (`ss_list_price` between asymmetric 154 and 154 + 10 or `ss_coupon_amt` between asymmetric 7326 and 7326 + 1000 or `ss_wholesale_cost` between asymmetric 7 and 7 + 20)) (select * +from `b5` +order by +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q29_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q29_expected.sql new file mode 100644 index 000000000..b492f5496 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q29_expected.sql @@ -0,0 +1,6 @@ +select `i_item_id`, `i_item_desc`, `s_store_id`, `s_store_name`, sum(`ss_quantity`) as `store_sales_quantity`, sum(`sr_return_quantity`) as `store_returns_quantity`, sum(`cs_quantity`) as `catalog_sales_quantity` +from `store_sales` +where `d1`.`d_moy` = 9 and `d1`.`d_year` = 1999 and `d1`.`d_date_sk` = `ss_sold_date_sk` and `i_item_sk` = `ss_item_sk` and `s_store_sk` = `ss_store_sk` and `ss_customer_sk` = `sr_customer_sk` and `ss_item_sk` = `sr_item_sk` and `ss_ticket_number` = `sr_ticket_number` and `sr_returned_date_sk` = `d2`.`d_date_sk` and `d2`.`d_moy` between asymmetric 9 and 9 + 3 and `d2`.`d_year` = 1999 and `sr_customer_sk` = `cs_bill_customer_sk` and `sr_item_sk` = `cs_item_sk` and `cs_sold_date_sk` = `d3`.`d_date_sk` and `d3`.`d_year` in (1999, 1999 + 1, 1999 + 2) +group by `i_item_id`, `i_item_desc`, `s_store_id`, `s_store_name` +order by `i_item_id`, `i_item_desc`, `s_store_id`, `s_store_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q30_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q30_expected.sql new file mode 100644 index 000000000..82bae8efd --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q30_expected.sql @@ -0,0 +1,10 @@ +with `customer_total_return` as (select `wr_returning_customer_sk` as `ctr_customer_sk`, `ca_state` as `ctr_state`, sum(`wr_return_amt`) as `ctr_total_return` +from `web_returns` +where `wr_returned_date_sk` = `d_date_sk` and `d_year` = 2002 and `wr_returning_addr_sk` = `ca_address_sk` +group by `wr_returning_customer_sk`, `ca_state`) (select `c_customer_id`, `c_salutation`, `c_first_name`, `c_last_name`, `c_preferred_cust_flag`, `c_birth_day`, `c_birth_month`, `c_birth_year`, `c_birth_country`, `c_login`, `c_email_address`, `c_last_review_date_sk`, `ctr_total_return` +from `customer_total_return` as `ctr1` +where `ctr1`.`ctr_total_return` > (select avg(`ctr_total_return`) * 1.2 +from `customer_total_return` as `ctr2` +where `ctr1`.`ctr_state` = `ctr2`.`ctr_state`) and `ca_address_sk` = `c_current_addr_sk` and `ca_state` = 'ga' and `ctr1`.`ctr_customer_sk` = `c_customer_sk` +order by `c_customer_id`, `c_salutation`, `c_first_name`, `c_last_name`, `c_preferred_cust_flag`, `c_birth_day`, `c_birth_month`, `c_birth_year`, `c_birth_country`, `c_login`, `c_email_address`, `c_last_review_date_sk`, `ctr_total_return` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q31_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q31_expected.sql new file mode 100644 index 000000000..1c7c0c51c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q31_expected.sql @@ -0,0 +1,10 @@ +with `ss` as (select `ca_county`, `d_qoy`, `d_year`, sum(`ss_ext_sales_price`) as `store_sales` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `ss_addr_sk` = `ca_address_sk` +group by `ca_county`, `d_qoy`, `d_year`), `ws` as (select `ca_county`, `d_qoy`, `d_year`, sum(`ws_ext_sales_price`) as `web_sales` +from `web_sales` +where `ws_sold_date_sk` = `d_date_sk` and `ws_bill_addr_sk` = `ca_address_sk` +group by `ca_county`, `d_qoy`, `d_year`) (select `ss1`.`ca_county`, `ss1`.`d_year`, `ws2`.`web_sales` / `ws1`.`web_sales` as `web_q1_q2_increase`, `ss2`.`store_sales` / `ss1`.`store_sales` as `store_q1_q2_increase`, `ws3`.`web_sales` / `ws2`.`web_sales` as `web_q2_q3_increase`, `ss3`.`store_sales` / `ss2`.`store_sales` as `store_q2_q3_increase` +from `ss` as `ss1` +where `ss1`.`d_qoy` = 1 and `ss1`.`d_year` = 2000 and `ss1`.`ca_county` = `ss2`.`ca_county` and `ss2`.`d_qoy` = 2 and `ss2`.`d_year` = 2000 and `ss2`.`ca_county` = `ss3`.`ca_county` and `ss3`.`d_qoy` = 3 and `ss3`.`d_year` = 2000 and `ss1`.`ca_county` = `ws1`.`ca_county` and `ws1`.`d_qoy` = 1 and `ws1`.`d_year` = 2000 and `ws1`.`ca_county` = `ws2`.`ca_county` and `ws2`.`d_qoy` = 2 and `ws2`.`d_year` = 2000 and `ws1`.`ca_county` = `ws3`.`ca_county` and `ws3`.`d_qoy` = 3 and `ws3`.`d_year` = 2000 and case when `ws1`.`web_sales` > 0 then cast(`ws2`.`web_sales` as decimal(38, 38)) / `ws1`.`web_sales` else null end > case when `ss1`.`store_sales` > 0 then cast(`ss2`.`store_sales` as decimal(38, 38)) / `ss1`.`store_sales` else null end and case when `ws2`.`web_sales` > 0 then cast(`ws3`.`web_sales` as decimal(38, 38)) / `ws2`.`web_sales` else null end > case when `ss2`.`store_sales` > 0 then cast(`ss3`.`store_sales` as decimal(38, 38)) / `ss2`.`store_sales` else null end +order by `ss1`.`ca_county`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q32_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q32_expected.sql new file mode 100644 index 000000000..d0e2602c9 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q32_expected.sql @@ -0,0 +1,7 @@ +select sum(`cs_ext_discount_amt`) as `excess discount amount` +from `catalog_sales` +where `i_manufact_id` = 977 and `i_item_sk` = `cs_item_sk` and `d_date` between asymmetric cast('2000-01-27' as date) and cast('2000-01-27' as date) + interval '90' day and `d_date_sk` = `cs_sold_date_sk` and `cs_ext_discount_amt` > (select 1.3 * avg(`cs_ext_discount_amt`) +from `catalog_sales` +where `cs_item_sk` = `i_item_sk` and `d_date` between asymmetric cast('2000-01-27' as date) and cast('2000-01-27' as date) + interval '90' day and `d_date_sk` = `cs_sold_date_sk`) +order by +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q33_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q33_expected.sql new file mode 100644 index 000000000..770752665 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q33_expected.sql @@ -0,0 +1,27 @@ +with `ss` as (select `i_manufact_id`, sum(`ss_ext_sales_price`) as `total_sales` +from `store_sales` +where `i_manufact_id` in (select `i_manufact_id` +from `item` +where `i_category` in ('electronics')) and `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` = 1998 and `d_moy` = 5 and `ss_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_manufact_id`), `cs` as (select `i_manufact_id`, sum(`cs_ext_sales_price`) as `total_sales` +from `catalog_sales` +where `i_manufact_id` in (select `i_manufact_id` +from `item` +where `i_category` in ('electronics')) and `cs_item_sk` = `i_item_sk` and `cs_sold_date_sk` = `d_date_sk` and `d_year` = 1998 and `d_moy` = 5 and `cs_bill_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_manufact_id`), `ws` as (select `i_manufact_id`, sum(`ws_ext_sales_price`) as `total_sales` +from `web_sales` +where `i_manufact_id` in (select `i_manufact_id` +from `item` +where `i_category` in ('electronics')) and `ws_item_sk` = `i_item_sk` and `ws_sold_date_sk` = `d_date_sk` and `d_year` = 1998 and `d_moy` = 5 and `ws_bill_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_manufact_id`) (select `i_manufact_id`, sum(`total_sales`) as `total_sales` +from (select * +from `ss` +union all +select * +from `cs` +union all +select * +from `ws`) as `tmp1` +group by `i_manufact_id` +order by `total_sales` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q34_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q34_expected.sql new file mode 100644 index 000000000..5959011be --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q34_expected.sql @@ -0,0 +1,7 @@ +select `c_last_name`, `c_first_name`, `c_salutation`, `c_preferred_cust_flag`, `ss_ticket_number`, `cnt` +from (select `ss_ticket_number`, `ss_customer_sk`, count(*) as `cnt` +from `store_sales` +where `store_sales`.`ss_sold_date_sk` = `date_dim`.`d_date_sk` and `store_sales`.`ss_store_sk` = `store`.`s_store_sk` and `store_sales`.`ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and (`date_dim`.`d_dom` between asymmetric 1 and 3 or `date_dim`.`d_dom` between asymmetric 25 and 28) and (`household_demographics`.`hd_buy_potential` = '>10000' or `household_demographics`.`hd_buy_potential` = 'unknown') and `household_demographics`.`hd_vehicle_count` > 0 and case when `household_demographics`.`hd_vehicle_count` > 0 then cast(`household_demographics`.`hd_dep_count` as decimal(7, 7)) / `household_demographics`.`hd_vehicle_count` else null end > 1.2 and `date_dim`.`d_year` in (1999, 1999 + 1, 1999 + 2) and `store`.`s_county` in ('williamson county', 'williamson county', 'williamson county', 'williamson county', 'williamson county', 'williamson county', 'williamson county', 'williamson county') +group by `ss_ticket_number`, `ss_customer_sk`) as `dn` +where `ss_customer_sk` = `c_customer_sk` and `cnt` between asymmetric 15 and 20 +order by `c_last_name`, `c_first_name`, `c_salutation`, `c_preferred_cust_flag` desc, `ss_ticket_number` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q35_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q35_expected.sql new file mode 100644 index 000000000..89ea11d1c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q35_expected.sql @@ -0,0 +1,12 @@ +select `ca_state`, `cd_gender`, `cd_marital_status`, `cd_dep_count`, count(*) as `cnt1`, min(`cd_dep_count`), max(`cd_dep_count`), avg(`cd_dep_count`), `cd_dep_employed_count`, count(*) as `cnt2`, min(`cd_dep_employed_count`), max(`cd_dep_employed_count`), avg(`cd_dep_employed_count`), `cd_dep_college_count`, count(*) as `cnt3`, min(`cd_dep_college_count`), max(`cd_dep_college_count`), avg(`cd_dep_college_count`) +from `customer` as `c` +where `c`.`c_current_addr_sk` = `ca`.`ca_address_sk` and `cd_demo_sk` = `c`.`c_current_cdemo_sk` and exists (select * +from `store_sales` +where `c`.`c_customer_sk` = `ss_customer_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` = 2002 and `d_qoy` < 4) and (exists (select * +from `web_sales` +where `c`.`c_customer_sk` = `ws_bill_customer_sk` and `ws_sold_date_sk` = `d_date_sk` and `d_year` = 2002 and `d_qoy` < 4) or exists (select * +from `catalog_sales` +where `c`.`c_customer_sk` = `cs_ship_customer_sk` and `cs_sold_date_sk` = `d_date_sk` and `d_year` = 2002 and `d_qoy` < 4)) +group by `ca_state`, `cd_gender`, `cd_marital_status`, `cd_dep_count`, `cd_dep_employed_count`, `cd_dep_college_count` +order by `ca_state`, `cd_gender`, `cd_marital_status`, `cd_dep_count`, `cd_dep_employed_count`, `cd_dep_college_count` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q36_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q36_expected.sql new file mode 100644 index 000000000..ce5e07154 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q36_expected.sql @@ -0,0 +1,6 @@ +select sum(`ss_net_profit`) / sum(`ss_ext_sales_price`) as `gross_margin`, `i_category`, `i_class`, grouping(`i_category`) + grouping(`i_class`) as `lochierarchy`, rank() over (partition by grouping(`i_category`) + grouping(`i_class`), case when grouping(`i_class`) = 0 then `i_category` else null end order by sum(`ss_net_profit`) / sum(`ss_ext_sales_price`)) as `rank_within_parent` +from `store_sales` +where `d1`.`d_year` = 2001 and `d1`.`d_date_sk` = `ss_sold_date_sk` and `i_item_sk` = `ss_item_sk` and `s_store_sk` = `ss_store_sk` and `s_state` in ('tn', 'tn', 'tn', 'tn', 'tn', 'tn', 'tn', 'tn') +group by rollup(`i_category`, `i_class`) +order by `lochierarchy` desc, case when `lochierarchy` = 0 then `i_category` else null end, `rank_within_parent`, `i_category`, `i_class` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q37_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q37_expected.sql new file mode 100644 index 000000000..8193fcdc2 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q37_expected.sql @@ -0,0 +1,6 @@ +select `i_item_id`, `i_item_desc`, `i_current_price` +from `item` +where `i_current_price` between asymmetric 68 and 68 + 30 and `inv_item_sk` = `i_item_sk` and `d_date_sk` = `inv_date_sk` and cast(`d_date` as date) between asymmetric cast('2000-02-01' as date) and cast('2000-02-01' as date) + interval '60' day and `i_manufact_id` in (677, 940, 694, 808) and `inv_quantity_on_hand` between asymmetric 100 and 500 and `cs_item_sk` = `i_item_sk` +group by `i_item_id`, `i_item_desc`, `i_current_price` +order by `i_item_id` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q38_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q38_expected.sql new file mode 100644 index 000000000..6d3e79925 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q38_expected.sql @@ -0,0 +1,14 @@ +select count(*) +from (select distinct `c_last_name`, `c_first_name`, `d_date` +from `store_sales` +where `store_sales`.`ss_sold_date_sk` = `date_dim`.`d_date_sk` and `store_sales`.`ss_customer_sk` = `customer`.`c_customer_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 +intersect +select distinct `c_last_name`, `c_first_name`, `d_date` +from `catalog_sales` +where `catalog_sales`.`cs_sold_date_sk` = `date_dim`.`d_date_sk` and `catalog_sales`.`cs_bill_customer_sk` = `customer`.`c_customer_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 +intersect +select distinct `c_last_name`, `c_first_name`, `d_date` +from `web_sales` +where `web_sales`.`ws_sold_date_sk` = `date_dim`.`d_date_sk` and `web_sales`.`ws_bill_customer_sk` = `customer`.`c_customer_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11) as `hot_cust` +order by +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q39_1_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q39_1_expected.sql new file mode 100644 index 000000000..39219d5d2 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q39_1_expected.sql @@ -0,0 +1,9 @@ +with `inv` as (select `w_warehouse_name`, `w_warehouse_sk`, `i_item_sk`, `d_moy`, `stdev`, `mean`, case `mean` when 0 then null else `stdev` / `mean` end as `cov` +from (select `w_warehouse_name`, `w_warehouse_sk`, `i_item_sk`, `d_moy`, stddev_samp(`inv_quantity_on_hand`) as `stdev`, avg(`inv_quantity_on_hand`) as `mean` +from `inventory` +where `inv_item_sk` = `i_item_sk` and `inv_warehouse_sk` = `w_warehouse_sk` and `inv_date_sk` = `d_date_sk` and `d_year` = 2001 +group by `w_warehouse_name`, `w_warehouse_sk`, `i_item_sk`, `d_moy`) as `foo` +where case `mean` when 0 then 0 else `stdev` / `mean` end > 1) (select `inv1`.`w_warehouse_sk`, `inv1`.`i_item_sk`, `inv1`.`d_moy`, `inv1`.`mean`, `inv1`.`cov`, `inv2`.`w_warehouse_sk`, `inv2`.`i_item_sk`, `inv2`.`d_moy`, `inv2`.`mean`, `inv2`.`cov` +from `inv` as `inv1` +where `inv1`.`i_item_sk` = `inv2`.`i_item_sk` and `inv1`.`w_warehouse_sk` = `inv2`.`w_warehouse_sk` and `inv1`.`d_moy` = 1 and `inv2`.`d_moy` = 1 + 1 +order by `inv1`.`w_warehouse_sk`, `inv1`.`i_item_sk`, `inv1`.`d_moy`, `inv1`.`mean`, `inv1`.`cov`, `inv2`.`d_moy`, `inv2`.`mean`, `inv2`.`cov`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q39_2_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q39_2_expected.sql new file mode 100644 index 000000000..cd085094f --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q39_2_expected.sql @@ -0,0 +1,9 @@ +with `inv` as (select `w_warehouse_name`, `w_warehouse_sk`, `i_item_sk`, `d_moy`, `stdev`, `mean`, case `mean` when 0 then null else `stdev` / `mean` end as `cov` +from (select `w_warehouse_name`, `w_warehouse_sk`, `i_item_sk`, `d_moy`, stddev_samp(`inv_quantity_on_hand`) as `stdev`, avg(`inv_quantity_on_hand`) as `mean` +from `inventory` +where `inv_item_sk` = `i_item_sk` and `inv_warehouse_sk` = `w_warehouse_sk` and `inv_date_sk` = `d_date_sk` and `d_year` = 2001 +group by `w_warehouse_name`, `w_warehouse_sk`, `i_item_sk`, `d_moy`) as `foo` +where case `mean` when 0 then 0 else `stdev` / `mean` end > 1) (select `inv1`.`w_warehouse_sk`, `inv1`.`i_item_sk`, `inv1`.`d_moy`, `inv1`.`mean`, `inv1`.`cov`, `inv2`.`w_warehouse_sk`, `inv2`.`i_item_sk`, `inv2`.`d_moy`, `inv2`.`mean`, `inv2`.`cov` +from `inv` as `inv1` +where `inv1`.`i_item_sk` = `inv2`.`i_item_sk` and `inv1`.`w_warehouse_sk` = `inv2`.`w_warehouse_sk` and `inv1`.`d_moy` = 1 and `inv2`.`d_moy` = 1 + 1 and `inv1`.`cov` > 1.5 +order by `inv1`.`w_warehouse_sk`, `inv1`.`i_item_sk`, `inv1`.`d_moy`, `inv1`.`mean`, `inv1`.`cov`, `inv2`.`d_moy`, `inv2`.`mean`, `inv2`.`cov`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q40_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q40_expected.sql new file mode 100644 index 000000000..b0323e82c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q40_expected.sql @@ -0,0 +1,7 @@ +select `w_state`, `i_item_id`, sum(case when cast(`d_date` as date) < cast('2000-03-11' as date) then `cs_sales_price` - coalesce(`cr_refunded_cash`, 0) else 0 end) as `sales_before`, sum(case when cast(`d_date` as date) >= cast('2000-03-11' as date) then `cs_sales_price` - coalesce(`cr_refunded_cash`, 0) else 0 end) as `sales_after` +from `catalog_sales` +left join `catalog_returns` on `cs_order_number` = `cr_order_number` and `cs_item_sk` = `cr_item_sk` +where `i_current_price` between asymmetric 0.99 and 1.49 and `i_item_sk` = `cs_item_sk` and `cs_warehouse_sk` = `w_warehouse_sk` and `cs_sold_date_sk` = `d_date_sk` and cast(`d_date` as date) between asymmetric cast('2000-03-11' as date) - interval '30' day and cast('2000-03-11' as date) + interval '30' day +group by `w_state`, `i_item_id` +order by `w_state`, `i_item_id` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q41_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q41_expected.sql new file mode 100644 index 000000000..bacbace4b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q41_expected.sql @@ -0,0 +1,7 @@ +select distinct `i_product_name` +from `item` as `i1` +where `i_manufact_id` between asymmetric 738 and 738 + 40 and (select count(*) as `item_cnt` +from `item` +where `i_manufact` = `i1`.`i_manufact` and (`i_category` = 'women' and (`i_color` = 'powder' or `i_color` = 'khaki') and (`i_units` = 'ounce' or `i_units` = 'oz') and (`i_size` = 'medium' or `i_size` = 'extra large') or `i_category` = 'women' and (`i_color` = 'brown' or `i_color` = 'honeydew') and (`i_units` = 'bunch' or `i_units` = 'ton') and (`i_size` = 'n/a' or `i_size` = 'small') or `i_category` = 'men' and (`i_color` = 'floral' or `i_color` = 'deep') and (`i_units` = 'n/a' or `i_units` = 'dozen') and (`i_size` = 'petite' or `i_size` = 'large') or `i_category` = 'men' and (`i_color` = 'light' or `i_color` = 'cornflower') and (`i_units` = 'box' or `i_units` = 'pound') and (`i_size` = 'medium' or `i_size` = 'extra large')) or `i_manufact` = `i1`.`i_manufact` and (`i_category` = 'women' and (`i_color` = 'midnight' or `i_color` = 'snow') and (`i_units` = 'pallet' or `i_units` = 'gross') and (`i_size` = 'medium' or `i_size` = 'extra large') or `i_category` = 'women' and (`i_color` = 'cyan' or `i_color` = 'papaya') and (`i_units` = 'cup' or `i_units` = 'dram') and (`i_size` = 'n/a' or `i_size` = 'small') or `i_category` = 'men' and (`i_color` = 'orange' or `i_color` = 'frosted') and (`i_units` = 'each' or `i_units` = 'tbl') and (`i_size` = 'petite' or `i_size` = 'large') or `i_category` = 'men' and (`i_color` = 'forest' or `i_color` = 'ghost') and (`i_units` = 'lb' or `i_units` = 'bundle') and (`i_size` = 'medium' or `i_size` = 'extra large'))) > 0 +order by `i_product_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q42_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q42_expected.sql new file mode 100644 index 000000000..7bdef5a21 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q42_expected.sql @@ -0,0 +1,6 @@ +select `dt`.`d_year`, `item`.`i_category_id`, `item`.`i_category`, sum(`ss_ext_sales_price`) +from `date_dim` as `dt` +where `dt`.`d_date_sk` = `store_sales`.`ss_sold_date_sk` and `store_sales`.`ss_item_sk` = `item`.`i_item_sk` and `item`.`i_manager_id` = 1 and `dt`.`d_moy` = 11 and `dt`.`d_year` = 2000 +group by `dt`.`d_year`, `item`.`i_category_id`, `item`.`i_category` +order by sum(`ss_ext_sales_price`) desc, `dt`.`d_year`, `item`.`i_category_id`, `item`.`i_category` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q43_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q43_expected.sql new file mode 100644 index 000000000..16ba71e04 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q43_expected.sql @@ -0,0 +1,6 @@ +select `s_store_name`, `s_store_id`, sum(case when `d_day_name` = 'sunday' then `ss_sales_price` else null end) as `sun_sales`, sum(case when `d_day_name` = 'monday' then `ss_sales_price` else null end) as `mon_sales`, sum(case when `d_day_name` = 'tuesday' then `ss_sales_price` else null end) as `tue_sales`, sum(case when `d_day_name` = 'wednesday' then `ss_sales_price` else null end) as `wed_sales`, sum(case when `d_day_name` = 'thursday' then `ss_sales_price` else null end) as `thu_sales`, sum(case when `d_day_name` = 'friday' then `ss_sales_price` else null end) as `fri_sales`, sum(case when `d_day_name` = 'saturday' then `ss_sales_price` else null end) as `sat_sales` +from `date_dim` +where `d_date_sk` = `ss_sold_date_sk` and `s_store_sk` = `ss_store_sk` and `s_gmt_offset` = -5 and `d_year` = 2000 +group by `s_store_name`, `s_store_id` +order by `s_store_name`, `s_store_id`, `sun_sales`, `mon_sales`, `tue_sales`, `wed_sales`, `thu_sales`, `fri_sales`, `sat_sales` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q44_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q44_expected.sql new file mode 100644 index 000000000..af2b0a608 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q44_expected.sql @@ -0,0 +1,15 @@ +select `asceding`.`rnk`, `i1`.`i_product_name` as `best_performing`, `i2`.`i_product_name` as `worst_performing` +from (select * +from (select `item_sk`, rank() over (order by `rank_col`) as `rnk` +from (select `ss_item_sk` as `item_sk`, avg(`ss_net_profit`) as `rank_col` +from `store_sales` as `ss1` +where `ss_store_sk` = 4 +group by `ss_item_sk` +having avg(`ss_net_profit`) > 0.9 * (select avg(`ss_net_profit`) as `rank_col` +from `store_sales` +where `ss_store_sk` = 4 and `ss_addr_sk` is null +group by `ss_store_sk`)) as `v1`) as `v11` +where `rnk` < 11) as `asceding` +where `asceding`.`rnk` = `descending`.`rnk` and `i1`.`i_item_sk` = `asceding`.`item_sk` and `i2`.`i_item_sk` = `descending`.`item_sk` +order by `asceding`.`rnk` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q45_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q45_expected.sql new file mode 100644 index 000000000..a89524406 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q45_expected.sql @@ -0,0 +1,8 @@ +select `ca_zip`, `ca_city`, sum(`ws_sales_price`) +from `web_sales` +where `ws_bill_customer_sk` = `c_customer_sk` and `c_current_addr_sk` = `ca_address_sk` and `ws_item_sk` = `i_item_sk` and (`substr`(`ca_zip`, 1, 5) in ('85669', '86197', '88274', '83405', '86475', '85392', '85460', '80348', '81792') or `i_item_id` in (select `i_item_id` +from `item` +where `i_item_sk` in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29))) and `ws_sold_date_sk` = `d_date_sk` and `d_qoy` = 2 and `d_year` = 2001 +group by `ca_zip`, `ca_city` +order by `ca_zip`, `ca_city` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q46_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q46_expected.sql new file mode 100644 index 000000000..259a26f74 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q46_expected.sql @@ -0,0 +1,8 @@ +select `c_last_name`, `c_first_name`, `ca_city`, `bought_city`, `ss_ticket_number`, `amt`, `profit` +from (select `ss_ticket_number`, `ss_customer_sk`, `ca_city` as `bought_city`, sum(`ss_coupon_amt`) as `amt`, sum(`ss_net_profit`) as `profit` +from `store_sales` +where `store_sales`.`ss_sold_date_sk` = `date_dim`.`d_date_sk` and `store_sales`.`ss_store_sk` = `store`.`s_store_sk` and `store_sales`.`ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `store_sales`.`ss_addr_sk` = `customer_address`.`ca_address_sk` and (`household_demographics`.`hd_dep_count` = 4 or `household_demographics`.`hd_vehicle_count` = 3) and `date_dim`.`d_dow` in (6, 0) and `date_dim`.`d_year` in (1999, 1999 + 1, 1999 + 2) and `store`.`s_city` in ('fairview', 'midway', 'fairview', 'fairview', 'fairview') +group by `ss_ticket_number`, `ss_customer_sk`, `ss_addr_sk`, `ca_city`) as `dn` +where `ss_customer_sk` = `c_customer_sk` and `customer`.`c_current_addr_sk` = `current_addr`.`ca_address_sk` and `current_addr`.`ca_city` <> `bought_city` +order by `c_last_name`, `c_first_name`, `ca_city`, `bought_city`, `ss_ticket_number` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q47_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q47_expected.sql new file mode 100644 index 000000000..e78e8f995 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q47_expected.sql @@ -0,0 +1,10 @@ +with `v1` as (select `i_category`, `i_brand`, `s_store_name`, `s_company_name`, `d_year`, `d_moy`, sum(`ss_sales_price`) as `sum_sales`, avg(sum(`ss_sales_price`)) over (partition by `i_category`, `i_brand`, `s_store_name`, `s_company_name`, `d_year`) as `avg_monthly_sales`, rank() over (partition by `i_category`, `i_brand`, `s_store_name`, `s_company_name` order by `d_year`, `d_moy`) as `rn` +from `item` +where `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `ss_store_sk` = `s_store_sk` and (`d_year` = 1999 or `d_year` = 1999 - 1 and `d_moy` = 12 or `d_year` = 1999 + 1 and `d_moy` = 1) +group by `i_category`, `i_brand`, `s_store_name`, `s_company_name`, `d_year`, `d_moy`), `v2` as (select `v1`.`i_category`, `v1`.`i_brand`, `v1`.`s_store_name`, `v1`.`s_company_name`, `v1`.`d_year`, `v1`.`d_moy`, `v1`.`avg_monthly_sales`, `v1`.`sum_sales`, `v1_lag`.`sum_sales` as `psum`, `v1_lead`.`sum_sales` as `nsum` +from `v1` +where `v1`.`i_category` = `v1_lag`.`i_category` and `v1`.`i_category` = `v1_lead`.`i_category` and `v1`.`i_brand` = `v1_lag`.`i_brand` and `v1`.`i_brand` = `v1_lead`.`i_brand` and `v1`.`s_store_name` = `v1_lag`.`s_store_name` and `v1`.`s_store_name` = `v1_lead`.`s_store_name` and `v1`.`s_company_name` = `v1_lag`.`s_company_name` and `v1`.`s_company_name` = `v1_lead`.`s_company_name` and `v1`.`rn` = `v1_lag`.`rn` + 1 and `v1`.`rn` = `v1_lead`.`rn` - 1) (select * +from `v2` +where `d_year` = 1999 and `avg_monthly_sales` > 0 and case when `avg_monthly_sales` > 0 then abs(`sum_sales` - `avg_monthly_sales`) / `avg_monthly_sales` else null end > 0.1 +order by `sum_sales` - `avg_monthly_sales`, 3 +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q48_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q48_expected.sql new file mode 100644 index 000000000..595b3f5af --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q48_expected.sql @@ -0,0 +1,3 @@ +select sum(`ss_quantity`) +from `store_sales` +where `s_store_sk` = `ss_store_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` = 2000 and (`cd_demo_sk` = `ss_cdemo_sk` and `cd_marital_status` = 'm' and `cd_education_status` = '4 yr degree' and `ss_sales_price` between asymmetric 100.00 and 150.00 or `cd_demo_sk` = `ss_cdemo_sk` and `cd_marital_status` = 'd' and `cd_education_status` = '2 yr degree' and `ss_sales_price` between asymmetric 50.00 and 100.00 or `cd_demo_sk` = `ss_cdemo_sk` and `cd_marital_status` = 's' and `cd_education_status` = 'college' and `ss_sales_price` between asymmetric 150.00 and 200.00) and (`ss_addr_sk` = `ca_address_sk` and `ca_country` = 'united states' and `ca_state` in ('co', 'oh', 'tx') and `ss_net_profit` between asymmetric 0 and 2000 or `ss_addr_sk` = `ca_address_sk` and `ca_country` = 'united states' and `ca_state` in ('or', 'mn', 'ky') and `ss_net_profit` between asymmetric 150 and 3000 or `ss_addr_sk` = `ca_address_sk` and `ca_country` = 'united states' and `ca_state` in ('va', 'ca', 'ms') and `ss_net_profit` between asymmetric 50 and 25000) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q49_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q49_expected.sql new file mode 100644 index 000000000..565386b34 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q49_expected.sql @@ -0,0 +1,28 @@ +select 'web' as `channel`, `web`.`item`, `web`.`return_ratio`, `web`.`return_rank`, `web`.`currency_rank` +from (select `item`, `return_ratio`, `currency_ratio`, rank() over (order by `return_ratio`) as `return_rank`, rank() over (order by `currency_ratio`) as `currency_rank` +from (select `ws`.`ws_item_sk` as `item`, cast(sum(coalesce(`wr`.`wr_return_quantity`, 0)) as decimal(15, 15)) / cast(sum(coalesce(`ws`.`ws_quantity`, 0)) as decimal(15, 15)) as `return_ratio`, cast(sum(coalesce(`wr`.`wr_return_amt`, 0)) as decimal(15, 15)) / cast(sum(coalesce(`ws`.`ws_net_paid`, 0)) as decimal(15, 15)) as `currency_ratio` +from `web_sales` as `ws` +left join `web_returns` as `wr` on `ws`.`ws_order_number` = `wr`.`wr_order_number` and `ws`.`ws_item_sk` = `wr`.`wr_item_sk` +where `wr`.`wr_return_amt` > 10000 and `ws`.`ws_net_profit` > 1 and `ws`.`ws_net_paid` > 0 and `ws`.`ws_quantity` > 0 and `ws_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` = 12 +group by `ws`.`ws_item_sk`) as `in_web`) as `web` +where `web`.`return_rank` <= 10 or `web`.`currency_rank` <= 10 +union +select 'catalog' as `channel`, `catalog`.`item`, `catalog`.`return_ratio`, `catalog`.`return_rank`, `catalog`.`currency_rank` +from (select `item`, `return_ratio`, `currency_ratio`, rank() over (order by `return_ratio`) as `return_rank`, rank() over (order by `currency_ratio`) as `currency_rank` +from (select `cs`.`cs_item_sk` as `item`, cast(sum(coalesce(`cr`.`cr_return_quantity`, 0)) as decimal(15, 15)) / cast(sum(coalesce(`cs`.`cs_quantity`, 0)) as decimal(15, 15)) as `return_ratio`, cast(sum(coalesce(`cr`.`cr_return_amount`, 0)) as decimal(15, 15)) / cast(sum(coalesce(`cs`.`cs_net_paid`, 0)) as decimal(15, 15)) as `currency_ratio` +from `catalog_sales` as `cs` +left join `catalog_returns` as `cr` on `cs`.`cs_order_number` = `cr`.`cr_order_number` and `cs`.`cs_item_sk` = `cr`.`cr_item_sk` +where `cr`.`cr_return_amount` > 10000 and `cs`.`cs_net_profit` > 1 and `cs`.`cs_net_paid` > 0 and `cs`.`cs_quantity` > 0 and `cs_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` = 12 +group by `cs`.`cs_item_sk`) as `in_cat`) as `catalog` +where `catalog`.`return_rank` <= 10 or `catalog`.`currency_rank` <= 10 +union +select 'store' as `channel`, `store`.`item`, `store`.`return_ratio`, `store`.`return_rank`, `store`.`currency_rank` +from (select `item`, `return_ratio`, `currency_ratio`, rank() over (order by `return_ratio`) as `return_rank`, rank() over (order by `currency_ratio`) as `currency_rank` +from (select `sts`.`ss_item_sk` as `item`, cast(sum(coalesce(`sr`.`sr_return_quantity`, 0)) as decimal(15, 15)) / cast(sum(coalesce(`sts`.`ss_quantity`, 0)) as decimal(15, 15)) as `return_ratio`, cast(sum(coalesce(`sr`.`sr_return_amt`, 0)) as decimal(15, 15)) / cast(sum(coalesce(`sts`.`ss_net_paid`, 0)) as decimal(15, 15)) as `currency_ratio` +from `store_sales` as `sts` +left join `store_returns` as `sr` on `sts`.`ss_ticket_number` = `sr`.`sr_ticket_number` and `sts`.`ss_item_sk` = `sr`.`sr_item_sk` +where `sr`.`sr_return_amt` > 10000 and `sts`.`ss_net_profit` > 1 and `sts`.`ss_net_paid` > 0 and `sts`.`ss_quantity` > 0 and `ss_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` = 12 +group by `sts`.`ss_item_sk`) as `in_store`) as `store` +where `store`.`return_rank` <= 10 or `store`.`currency_rank` <= 10 +order by 1, 4, 5, 2 +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q50_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q50_expected.sql new file mode 100644 index 000000000..2191063b6 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q50_expected.sql @@ -0,0 +1,6 @@ +select `s_store_name`, `s_company_id`, `s_street_number`, `s_street_name`, `s_street_type`, `s_suite_number`, `s_city`, `s_county`, `s_state`, `s_zip`, sum(case when `sr_returned_date_sk` - `ss_sold_date_sk` <= 30 then 1 else 0 end) as `30 days`, sum(case when `sr_returned_date_sk` - `ss_sold_date_sk` > 30 and `sr_returned_date_sk` - `ss_sold_date_sk` <= 60 then 1 else 0 end) as `31-60 days`, sum(case when `sr_returned_date_sk` - `ss_sold_date_sk` > 60 and `sr_returned_date_sk` - `ss_sold_date_sk` <= 90 then 1 else 0 end) as `61-90 days`, sum(case when `sr_returned_date_sk` - `ss_sold_date_sk` > 90 and `sr_returned_date_sk` - `ss_sold_date_sk` <= 120 then 1 else 0 end) as `91-120 days`, sum(case when `sr_returned_date_sk` - `ss_sold_date_sk` > 120 then 1 else 0 end) as `>120 days` +from `store_sales` +where `d2`.`d_year` = 2001 and `d2`.`d_moy` = 8 and `ss_ticket_number` = `sr_ticket_number` and `ss_item_sk` = `sr_item_sk` and `ss_sold_date_sk` = `d1`.`d_date_sk` and `sr_returned_date_sk` = `d2`.`d_date_sk` and `ss_customer_sk` = `sr_customer_sk` and `ss_store_sk` = `s_store_sk` +group by `s_store_name`, `s_company_id`, `s_street_number`, `s_street_name`, `s_street_type`, `s_suite_number`, `s_city`, `s_county`, `s_state`, `s_zip` +order by `s_store_name`, `s_company_id`, `s_street_number`, `s_street_name`, `s_street_type`, `s_suite_number`, `s_city`, `s_county`, `s_state`, `s_zip` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q51_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q51_expected.sql new file mode 100644 index 000000000..71382e165 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q51_expected.sql @@ -0,0 +1,14 @@ +with `web_v1` as (select `ws_item_sk` as `item_sk`, `d_date`, sum(sum(`ws_sales_price`)) over (partition by `ws_item_sk` order by `d_date` rows between unbounded_preceding and current_row) as `cume_sales` +from `web_sales` +where `ws_sold_date_sk` = `d_date_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 and `ws_item_sk` is not null +group by `ws_item_sk`, `d_date`), `store_v1` as (select `ss_item_sk` as `item_sk`, `d_date`, sum(sum(`ss_sales_price`)) over (partition by `ss_item_sk` order by `d_date` rows between unbounded_preceding and current_row) as `cume_sales` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 and `ss_item_sk` is not null +group by `ss_item_sk`, `d_date`) (select * +from (select `item_sk`, `d_date`, `web_sales`, `store_sales`, max(`web_sales`) over (partition by `item_sk` order by `d_date` rows between unbounded_preceding and current_row) as `web_cumulative`, max(`store_sales`) over (partition by `item_sk` order by `d_date` rows between unbounded_preceding and current_row) as `store_cumulative` +from (select case when `web`.`item_sk` is not null then `web`.`item_sk` else `store`.`item_sk` end as `item_sk`, case when `web`.`d_date` is not null then `web`.`d_date` else `store`.`d_date` end as `d_date`, `web`.`cume_sales` as `web_sales`, `store`.`cume_sales` as `store_sales` +from `web_v1` as `web` +full join `store_v1` as `store` on `web`.`item_sk` = `store`.`item_sk` and `web`.`d_date` = `store`.`d_date`) as `x`) as `y` +where `web_cumulative` > `store_cumulative` +order by `item_sk`, `d_date` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q52_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q52_expected.sql new file mode 100644 index 000000000..34aab3251 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q52_expected.sql @@ -0,0 +1,6 @@ +select `dt`.`d_year`, `item`.`i_brand_id` as `brand_id`, `item`.`i_brand` as `brand`, sum(`ss_ext_sales_price`) as `ext_price` +from `date_dim` as `dt` +where `dt`.`d_date_sk` = `store_sales`.`ss_sold_date_sk` and `store_sales`.`ss_item_sk` = `item`.`i_item_sk` and `item`.`i_manager_id` = 1 and `dt`.`d_moy` = 11 and `dt`.`d_year` = 2000 +group by `dt`.`d_year`, `item`.`i_brand`, `item`.`i_brand_id` +order by `dt`.`d_year`, `ext_price` desc, `brand_id` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q53_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q53_expected.sql new file mode 100644 index 000000000..41d680064 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q53_expected.sql @@ -0,0 +1,8 @@ +select * +from (select `i_manufact_id`, sum(`ss_sales_price`) as `sum_sales`, avg(sum(`ss_sales_price`)) over (partition by `i_manufact_id`) as `avg_quarterly_sales` +from `item` +where `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `ss_store_sk` = `s_store_sk` and `d_month_seq` in (1200, 1200 + 1, 1200 + 2, 1200 + 3, 1200 + 4, 1200 + 5, 1200 + 6, 1200 + 7, 1200 + 8, 1200 + 9, 1200 + 10, 1200 + 11) and (`i_category` in ('books', 'children', 'electronics') and `i_class` in ('personal', 'portable', 'reference', 'self-help') and `i_brand` in ('scholaramalgamalg #14', 'scholaramalgamalg #7', 'exportiunivamalg #9', 'scholaramalgamalg #9') or `i_category` in ('women', 'music', 'men') and `i_class` in ('accessories', 'classical', 'fragrances', 'pants') and `i_brand` in ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'importoamalg #1')) +group by `i_manufact_id`, `d_qoy`) as `tmp1` +where case when `avg_quarterly_sales` > 0 then abs(cast(`sum_sales` as decimal(38, 38)) - `avg_quarterly_sales`) / `avg_quarterly_sales` else null end > 0.1 +order by `avg_quarterly_sales`, `sum_sales`, `i_manufact_id` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q54_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q54_expected.sql new file mode 100644 index 000000000..13843aa1c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q54_expected.sql @@ -0,0 +1,19 @@ +with `my_customers` as (select distinct `c_customer_sk`, `c_current_addr_sk` +from (select `cs_sold_date_sk` as `sold_date_sk`, `cs_bill_customer_sk` as `customer_sk`, `cs_item_sk` as `item_sk` +from `catalog_sales` +union all +select `ws_sold_date_sk` as `sold_date_sk`, `ws_bill_customer_sk` as `customer_sk`, `ws_item_sk` as `item_sk` +from `web_sales`) as `cs_or_ws_sales` +where `sold_date_sk` = `d_date_sk` and `item_sk` = `i_item_sk` and `i_category` = 'women' and `i_class` = 'maternity' and `c_customer_sk` = `cs_or_ws_sales`.`customer_sk` and `d_moy` = 12 and `d_year` = 1998), `my_revenue` as (select `c_customer_sk`, sum(`ss_ext_sales_price`) as `revenue` +from `my_customers` +where `c_current_addr_sk` = `ca_address_sk` and `ca_county` = `s_county` and `ca_state` = `s_state` and `ss_sold_date_sk` = `d_date_sk` and `c_customer_sk` = `ss_customer_sk` and `d_month_seq` between asymmetric (select distinct `d_month_seq` + 1 +from `date_dim` +where `d_year` = 1998 and `d_moy` = 12) and (select distinct `d_month_seq` + 3 +from `date_dim` +where `d_year` = 1998 and `d_moy` = 12) +group by `c_customer_sk`), `segments` as (select cast(`revenue` / 50 as integer) as `segment` +from `my_revenue`) (select `segment`, count(*) as `num_customers`, `segment` * 50 as `segment_base` +from `segments` +group by `segment` +order by `segment`, `num_customers` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q55_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q55_expected.sql new file mode 100644 index 000000000..e7c74eaf0 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q55_expected.sql @@ -0,0 +1,6 @@ +select `i_brand_id` as `brand_id`, `i_brand` as `brand`, sum(`ss_ext_sales_price`) as `ext_price` +from `date_dim` +where `d_date_sk` = `ss_sold_date_sk` and `ss_item_sk` = `i_item_sk` and `i_manager_id` = 28 and `d_moy` = 11 and `d_year` = 1999 +group by `i_brand`, `i_brand_id` +order by `ext_price` desc, `i_brand_id` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q56_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q56_expected.sql new file mode 100644 index 000000000..abf955fe9 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q56_expected.sql @@ -0,0 +1,27 @@ +with `ss` as (select `i_item_id`, sum(`ss_ext_sales_price`) as `total_sales` +from `store_sales` +where `i_item_id` in (select `i_item_id` +from `item` +where `i_color` in ('slate', 'blanched', 'burnished')) and `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` = 2 and `ss_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_item_id`), `cs` as (select `i_item_id`, sum(`cs_ext_sales_price`) as `total_sales` +from `catalog_sales` +where `i_item_id` in (select `i_item_id` +from `item` +where `i_color` in ('slate', 'blanched', 'burnished')) and `cs_item_sk` = `i_item_sk` and `cs_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` = 2 and `cs_bill_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_item_id`), `ws` as (select `i_item_id`, sum(`ws_ext_sales_price`) as `total_sales` +from `web_sales` +where `i_item_id` in (select `i_item_id` +from `item` +where `i_color` in ('slate', 'blanched', 'burnished')) and `ws_item_sk` = `i_item_sk` and `ws_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` = 2 and `ws_bill_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_item_id`) (select `i_item_id`, sum(`total_sales`) as `total_sales` +from (select * +from `ss` +union all +select * +from `cs` +union all +select * +from `ws`) as `tmp1` +group by `i_item_id` +order by `total_sales`, `i_item_id` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q57_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q57_expected.sql new file mode 100644 index 000000000..a6a989fd2 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q57_expected.sql @@ -0,0 +1,10 @@ +with `v1` as (select `i_category`, `i_brand`, `cc_name`, `d_year`, `d_moy`, sum(`cs_sales_price`) as `sum_sales`, avg(sum(`cs_sales_price`)) over (partition by `i_category`, `i_brand`, `cc_name`, `d_year`) as `avg_monthly_sales`, rank() over (partition by `i_category`, `i_brand`, `cc_name` order by `d_year`, `d_moy`) as `rn` +from `item` +where `cs_item_sk` = `i_item_sk` and `cs_sold_date_sk` = `d_date_sk` and `cc_call_center_sk` = `cs_call_center_sk` and (`d_year` = 1999 or `d_year` = 1999 - 1 and `d_moy` = 12 or `d_year` = 1999 + 1 and `d_moy` = 1) +group by `i_category`, `i_brand`, `cc_name`, `d_year`, `d_moy`), `v2` as (select `v1`.`i_category`, `v1`.`i_brand`, `v1`.`cc_name`, `v1`.`d_year`, `v1`.`d_moy`, `v1`.`avg_monthly_sales`, `v1`.`sum_sales`, `v1_lag`.`sum_sales` as `psum`, `v1_lead`.`sum_sales` as `nsum` +from `v1` +where `v1`.`i_category` = `v1_lag`.`i_category` and `v1`.`i_category` = `v1_lead`.`i_category` and `v1`.`i_brand` = `v1_lag`.`i_brand` and `v1`.`i_brand` = `v1_lead`.`i_brand` and `v1`.`cc_name` = `v1_lag`.`cc_name` and `v1`.`cc_name` = `v1_lead`.`cc_name` and `v1`.`rn` = `v1_lag`.`rn` + 1 and `v1`.`rn` = `v1_lead`.`rn` - 1) (select * +from `v2` +where `d_year` = 1999 and `avg_monthly_sales` > 0 and case when `avg_monthly_sales` > 0 then abs(`sum_sales` - `avg_monthly_sales`) / `avg_monthly_sales` else null end > 0.1 +order by `sum_sales` - `avg_monthly_sales`, 3 +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q58_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q58_expected.sql new file mode 100644 index 000000000..049f0ce87 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q58_expected.sql @@ -0,0 +1,26 @@ +with `ss_items` as (select `i_item_id` as `item_id`, sum(`ss_ext_sales_price`) as `ss_item_rev` +from `store_sales` +where `ss_item_sk` = `i_item_sk` and `d_date` in (select `d_date` +from `date_dim` +where `d_week_seq` = (select `d_week_seq` +from `date_dim` +where `d_date` = cast('2000-01-03' as date))) and `ss_sold_date_sk` = `d_date_sk` +group by `i_item_id`), `cs_items` as (select `i_item_id` as `item_id`, sum(`cs_ext_sales_price`) as `cs_item_rev` +from `catalog_sales` +where `cs_item_sk` = `i_item_sk` and `d_date` in (select `d_date` +from `date_dim` +where `d_week_seq` = (select `d_week_seq` +from `date_dim` +where `d_date` = cast('2000-01-03' as date))) and `cs_sold_date_sk` = `d_date_sk` +group by `i_item_id`), `ws_items` as (select `i_item_id` as `item_id`, sum(`ws_ext_sales_price`) as `ws_item_rev` +from `web_sales` +where `ws_item_sk` = `i_item_sk` and `d_date` in (select `d_date` +from `date_dim` +where `d_week_seq` = (select `d_week_seq` +from `date_dim` +where `d_date` = cast('2000-01-03' as date))) and `ws_sold_date_sk` = `d_date_sk` +group by `i_item_id`) (select `ss_items`.`item_id`, `ss_item_rev`, cast(`ss_item_rev` / (cast(`ss_item_rev` as decimal(16, 16)) + `cs_item_rev` + `ws_item_rev`) / 3 * 100 as decimal(7, 7)) as `ss_dev`, `cs_item_rev`, cast(`cs_item_rev` / (cast(`ss_item_rev` as decimal(16, 16)) + `cs_item_rev` + `ws_item_rev`) / 3 * 100 as decimal(7, 7)) as `cs_dev`, `ws_item_rev`, cast(`ws_item_rev` / (cast(`ss_item_rev` as decimal(16, 16)) + `cs_item_rev` + `ws_item_rev`) / 3 * 100 as decimal(7, 7)) as `ws_dev`, (`ss_item_rev` + `cs_item_rev` + `ws_item_rev`) / 3 as `average` +from `ss_items` +where `ss_items`.`item_id` = `cs_items`.`item_id` and `ss_items`.`item_id` = `ws_items`.`item_id` and `ss_item_rev` between asymmetric 0.9 * `cs_item_rev` and 1.1 * `cs_item_rev` and `ss_item_rev` between asymmetric 0.9 * `ws_item_rev` and 1.1 * `ws_item_rev` and `cs_item_rev` between asymmetric 0.9 * `ss_item_rev` and 1.1 * `ss_item_rev` and `cs_item_rev` between asymmetric 0.9 * `ws_item_rev` and 1.1 * `ws_item_rev` and `ws_item_rev` between asymmetric 0.9 * `ss_item_rev` and 1.1 * `ss_item_rev` and `ws_item_rev` between asymmetric 0.9 * `cs_item_rev` and 1.1 * `cs_item_rev` +order by `ss_items`.`item_id`, `ss_item_rev` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q59_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q59_expected.sql new file mode 100644 index 000000000..0541e317c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q59_expected.sql @@ -0,0 +1,10 @@ +with `wss` as (select `d_week_seq`, `ss_store_sk`, sum(case when `d_day_name` = 'sunday' then `ss_sales_price` else null end) as `sun_sales`, sum(case when `d_day_name` = 'monday' then `ss_sales_price` else null end) as `mon_sales`, sum(case when `d_day_name` = 'tuesday' then `ss_sales_price` else null end) as `tue_sales`, sum(case when `d_day_name` = 'wednesday' then `ss_sales_price` else null end) as `wed_sales`, sum(case when `d_day_name` = 'thursday ' then `ss_sales_price` else null end) as `thu_sales`, sum(case when `d_day_name` = 'friday' then `ss_sales_price` else null end) as `fri_sales`, sum(case when `d_day_name` = 'saturday' then `ss_sales_price` else null end) as `sat_sales` +from `store_sales` +where `d_date_sk` = `ss_sold_date_sk` +group by `d_week_seq`, `ss_store_sk`) (select `s_store_name1`, `s_store_id1`, `d_week_seq1`, `sun_sales1` / `sun_sales2`, `mon_sales1` / `mon_sales2`, `tue_sales1` / `tue_sales2`, `wed_sales1` / `wed_sales2`, `thu_sales1` / `thu_sales2`, `fri_sales1` / `fri_sales2`, `sat_sales1` / `sat_sales2` +from (select `s_store_name` as `s_store_name1`, `wss`.`d_week_seq` as `d_week_seq1`, `s_store_id` as `s_store_id1`, `sun_sales` as `sun_sales1`, `mon_sales` as `mon_sales1`, `tue_sales` as `tue_sales1`, `wed_sales` as `wed_sales1`, `thu_sales` as `thu_sales1`, `fri_sales` as `fri_sales1`, `sat_sales` as `sat_sales1` +from `wss` +where `d`.`d_week_seq` = `wss`.`d_week_seq` and `ss_store_sk` = `s_store_sk` and `d_month_seq` between asymmetric 1212 and 1212 + 11) as `y` +where `s_store_id1` = `s_store_id2` and `d_week_seq1` = `d_week_seq2` - 52 +order by `s_store_name1`, `s_store_id1`, `d_week_seq1` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q60_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q60_expected.sql new file mode 100644 index 000000000..0e1c68eec --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q60_expected.sql @@ -0,0 +1,27 @@ +with `ss` as (select `i_item_id`, sum(`ss_ext_sales_price`) as `total_sales` +from `store_sales` +where `i_item_id` in (select `i_item_id` +from `item` +where `i_category` in ('music')) and `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` = 1998 and `d_moy` = 9 and `ss_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_item_id`), `cs` as (select `i_item_id`, sum(`cs_ext_sales_price`) as `total_sales` +from `catalog_sales` +where `i_item_id` in (select `i_item_id` +from `item` +where `i_category` in ('music')) and `cs_item_sk` = `i_item_sk` and `cs_sold_date_sk` = `d_date_sk` and `d_year` = 1998 and `d_moy` = 9 and `cs_bill_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_item_id`), `ws` as (select `i_item_id`, sum(`ws_ext_sales_price`) as `total_sales` +from `web_sales` +where `i_item_id` in (select `i_item_id` +from `item` +where `i_category` in ('music')) and `ws_item_sk` = `i_item_sk` and `ws_sold_date_sk` = `d_date_sk` and `d_year` = 1998 and `d_moy` = 9 and `ws_bill_addr_sk` = `ca_address_sk` and `ca_gmt_offset` = -5 +group by `i_item_id`) (select `i_item_id`, sum(`total_sales`) as `total_sales` +from (select * +from `ss` +union all +select * +from `cs` +union all +select * +from `ws`) as `tmp1` +group by `i_item_id` +order by `i_item_id`, `total_sales` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q61_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q61_expected.sql new file mode 100644 index 000000000..d45b71579 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q61_expected.sql @@ -0,0 +1,6 @@ +select `promotions`, `total`, cast(`promotions` as decimal(15, 15)) / cast(`total` as decimal(15, 15)) * 100 +from (select sum(`ss_ext_sales_price`) as `promotions` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `ss_store_sk` = `s_store_sk` and `ss_promo_sk` = `p_promo_sk` and `ss_customer_sk` = `c_customer_sk` and `ca_address_sk` = `c_current_addr_sk` and `ss_item_sk` = `i_item_sk` and `ca_gmt_offset` = -5 and `i_category` = 'jewelry' and (`p_channel_dmail` = 'y' or `p_channel_email` = 'y' or `p_channel_tv` = 'y') and `s_gmt_offset` = -5 and `d_year` = 1998 and `d_moy` = 11) as `promotional_sales` +order by `promotions`, `total` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q62_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q62_expected.sql new file mode 100644 index 000000000..da6c91f84 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q62_expected.sql @@ -0,0 +1,6 @@ +select `substr`(`w_warehouse_name`, 1, 20), `sm_type`, `web_name`, sum(case when `ws_ship_date_sk` - `ws_sold_date_sk` <= 30 then 1 else 0 end) as `30 days`, sum(case when `ws_ship_date_sk` - `ws_sold_date_sk` > 30 and `ws_ship_date_sk` - `ws_sold_date_sk` <= 60 then 1 else 0 end) as `31-60 days`, sum(case when `ws_ship_date_sk` - `ws_sold_date_sk` > 60 and `ws_ship_date_sk` - `ws_sold_date_sk` <= 90 then 1 else 0 end) as `61-90 days`, sum(case when `ws_ship_date_sk` - `ws_sold_date_sk` > 90 and `ws_ship_date_sk` - `ws_sold_date_sk` <= 120 then 1 else 0 end) as `91-120 days`, sum(case when `ws_ship_date_sk` - `ws_sold_date_sk` > 120 then 1 else 0 end) as `>120 days` +from `web_sales` +where `d_month_seq` between asymmetric 1200 and 1200 + 11 and `ws_ship_date_sk` = `d_date_sk` and `ws_warehouse_sk` = `w_warehouse_sk` and `ws_ship_mode_sk` = `sm_ship_mode_sk` and `ws_web_site_sk` = `web_site_sk` +group by `substr`(`w_warehouse_name`, 1, 20), `sm_type`, `web_name` +order by `substr`(`w_warehouse_name`, 1, 20), `sm_type`, `web_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q63_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q63_expected.sql new file mode 100644 index 000000000..8ec012edc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q63_expected.sql @@ -0,0 +1,8 @@ +select * +from (select `i_manager_id`, sum(`ss_sales_price`) as `sum_sales`, avg(sum(`ss_sales_price`)) over (partition by `i_manager_id`) as `avg_monthly_sales` +from `item` +where `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `ss_store_sk` = `s_store_sk` and `d_month_seq` in (1200, 1200 + 1, 1200 + 2, 1200 + 3, 1200 + 4, 1200 + 5, 1200 + 6, 1200 + 7, 1200 + 8, 1200 + 9, 1200 + 10, 1200 + 11) and (`i_category` in ('books', 'children', 'electronics') and `i_class` in ('personal', 'portable', 'refernece', 'self-help') and `i_brand` in ('scholaramalgamalg #14', 'scholaramalgamalg #7', 'exportiunivamalg #9', 'scholaramalgamalg #9') or `i_category` in ('women', 'music', 'men') and `i_class` in ('accessories', 'classical', 'fragrances', 'pants') and `i_brand` in ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1', 'importoamalg #1')) +group by `i_manager_id`, `d_moy`) as `tmp1` +where case when `avg_monthly_sales` > 0 then abs(`sum_sales` - `avg_monthly_sales`) / `avg_monthly_sales` else null end > 0.1 +order by `i_manager_id`, `avg_monthly_sales`, `sum_sales` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q64_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q64_expected.sql new file mode 100644 index 000000000..009b340d2 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q64_expected.sql @@ -0,0 +1,11 @@ +with `cs_ui` as (select `cs_item_sk`, sum(`cs_ext_list_price`) as `sale`, sum(`cr_refunded_cash` + `cr_reversed_charge` + `cr_store_credit`) as `refund` +from `catalog_sales` +where `cs_item_sk` = `cr_item_sk` and `cs_order_number` = `cr_order_number` +group by `cs_item_sk` +having sum(`cs_ext_list_price`) > 2 * sum(`cr_refunded_cash` + `cr_reversed_charge` + `cr_store_credit`)), `cross_sales` as (select `i_product_name` as `product_name`, `i_item_sk` as `item_sk`, `s_store_name` as `store_name`, `s_zip` as `store_zip`, `ad1`.`ca_street_number` as `b_street_number`, `ad1`.`ca_street_name` as `b_street_name`, `ad1`.`ca_city` as `b_city`, `ad1`.`ca_zip` as `b_zip`, `ad2`.`ca_street_number` as `c_street_number`, `ad2`.`ca_street_name` as `c_street_name`, `ad2`.`ca_city` as `c_city`, `ad2`.`ca_zip` as `c_zip`, `d1`.`d_year` as `syear`, `d2`.`d_year` as `fsyear`, `d3`.`d_year` as `s2year`, count(*) as `cnt`, sum(`ss_wholesale_cost`) as `s1`, sum(`ss_list_price`) as `s2`, sum(`ss_coupon_amt`) as `s3` +from `store_sales` +where `ss_store_sk` = `s_store_sk` and `ss_sold_date_sk` = `d1`.`d_date_sk` and `ss_customer_sk` = `c_customer_sk` and `ss_cdemo_sk` = `cd1`.`cd_demo_sk` and `ss_hdemo_sk` = `hd1`.`hd_demo_sk` and `ss_addr_sk` = `ad1`.`ca_address_sk` and `ss_item_sk` = `i_item_sk` and `ss_item_sk` = `sr_item_sk` and `ss_ticket_number` = `sr_ticket_number` and `ss_item_sk` = `cs_ui`.`cs_item_sk` and `c_current_cdemo_sk` = `cd2`.`cd_demo_sk` and `c_current_hdemo_sk` = `hd2`.`hd_demo_sk` and `c_current_addr_sk` = `ad2`.`ca_address_sk` and `c_first_sales_date_sk` = `d2`.`d_date_sk` and `c_first_shipto_date_sk` = `d3`.`d_date_sk` and `ss_promo_sk` = `p_promo_sk` and `hd1`.`hd_income_band_sk` = `ib1`.`ib_income_band_sk` and `hd2`.`hd_income_band_sk` = `ib2`.`ib_income_band_sk` and `cd1`.`cd_marital_status` <> `cd2`.`cd_marital_status` and `i_color` in ('purple', 'burlywood', 'indian', 'spring', 'floral', 'medium') and `i_current_price` between asymmetric 64 and 64 + 10 and `i_current_price` between asymmetric 64 + 1 and 64 + 15 +group by `i_product_name`, `i_item_sk`, `s_store_name`, `s_zip`, `ad1`.`ca_street_number`, `ad1`.`ca_street_name`, `ad1`.`ca_city`, `ad1`.`ca_zip`, `ad2`.`ca_street_number`, `ad2`.`ca_street_name`, `ad2`.`ca_city`, `ad2`.`ca_zip`, `d1`.`d_year`, `d2`.`d_year`, `d3`.`d_year`) (select `cs1`.`product_name`, `cs1`.`store_name`, `cs1`.`store_zip`, `cs1`.`b_street_number`, `cs1`.`b_street_name`, `cs1`.`b_city`, `cs1`.`b_zip`, `cs1`.`c_street_number`, `cs1`.`c_street_name`, `cs1`.`c_city`, `cs1`.`c_zip`, `cs1`.`syear`, `cs1`.`cnt`, `cs1`.`s1` as `s11`, `cs1`.`s2` as `s21`, `cs1`.`s3` as `s31`, `cs2`.`s1` as `s12`, `cs2`.`s2` as `s22`, `cs2`.`s3` as `s32`, `cs2`.`syear`, `cs2`.`cnt` +from `cross_sales` as `cs1` +where `cs1`.`item_sk` = `cs2`.`item_sk` and `cs1`.`syear` = 1999 and `cs2`.`syear` = 1999 + 1 and `cs2`.`cnt` <= `cs1`.`cnt` and `cs1`.`store_name` = `cs2`.`store_name` and `cs1`.`store_zip` = `cs2`.`store_zip` +order by `cs1`.`product_name`, `cs1`.`store_name`, `cs2`.`cnt`, 14, 15, 16, 17, 18) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q65_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q65_expected.sql new file mode 100644 index 000000000..cdd333f26 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q65_expected.sql @@ -0,0 +1,10 @@ +select `s_store_name`, `i_item_desc`, `sc`.`revenue`, `i_current_price`, `i_wholesale_cost`, `i_brand` +from (select `ss_store_sk`, avg(`revenue`) as `ave` +from (select `ss_store_sk`, `ss_item_sk`, sum(`ss_sales_price`) as `revenue` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `d_month_seq` between asymmetric 1176 and 1176 + 11 +group by `ss_store_sk`, `ss_item_sk`) as `sa` +group by `ss_store_sk`) as `sb` +where `sb`.`ss_store_sk` = `sc`.`ss_store_sk` and `sc`.`revenue` <= 0.1 * `sb`.`ave` and `s_store_sk` = `sc`.`ss_store_sk` and `i_item_sk` = `sc`.`ss_item_sk` +order by `s_store_name`, `i_item_desc` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q66_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q66_expected.sql new file mode 100644 index 000000000..e153da353 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q66_expected.sql @@ -0,0 +1,13 @@ +select `w_warehouse_name`, `w_warehouse_sq_ft`, `w_city`, `w_county`, `w_state`, `w_country`, `ship_carriers`, `year`, sum(`jan_sales`) as `jan_sales`, sum(`feb_sales`) as `feb_sales`, sum(`mar_sales`) as `mar_sales`, sum(`apr_sales`) as `apr_sales`, sum(`may_sales`) as `may_sales`, sum(`jun_sales`) as `jun_sales`, sum(`jul_sales`) as `jul_sales`, sum(`aug_sales`) as `aug_sales`, sum(`sep_sales`) as `sep_sales`, sum(`oct_sales`) as `oct_sales`, sum(`nov_sales`) as `nov_sales`, sum(`dec_sales`) as `dec_sales`, sum(`jan_sales` / `w_warehouse_sq_ft`) as `jan_sales_per_sq_foot`, sum(`feb_sales` / `w_warehouse_sq_ft`) as `feb_sales_per_sq_foot`, sum(`mar_sales` / `w_warehouse_sq_ft`) as `mar_sales_per_sq_foot`, sum(`apr_sales` / `w_warehouse_sq_ft`) as `apr_sales_per_sq_foot`, sum(`may_sales` / `w_warehouse_sq_ft`) as `may_sales_per_sq_foot`, sum(`jun_sales` / `w_warehouse_sq_ft`) as `jun_sales_per_sq_foot`, sum(`jul_sales` / `w_warehouse_sq_ft`) as `jul_sales_per_sq_foot`, sum(`aug_sales` / `w_warehouse_sq_ft`) as `aug_sales_per_sq_foot`, sum(`sep_sales` / `w_warehouse_sq_ft`) as `sep_sales_per_sq_foot`, sum(`oct_sales` / `w_warehouse_sq_ft`) as `oct_sales_per_sq_foot`, sum(`nov_sales` / `w_warehouse_sq_ft`) as `nov_sales_per_sq_foot`, sum(`dec_sales` / `w_warehouse_sq_ft`) as `dec_sales_per_sq_foot`, sum(`jan_net`) as `jan_net`, sum(`feb_net`) as `feb_net`, sum(`mar_net`) as `mar_net`, sum(`apr_net`) as `apr_net`, sum(`may_net`) as `may_net`, sum(`jun_net`) as `jun_net`, sum(`jul_net`) as `jul_net`, sum(`aug_net`) as `aug_net`, sum(`sep_net`) as `sep_net`, sum(`oct_net`) as `oct_net`, sum(`nov_net`) as `nov_net`, sum(`dec_net`) as `dec_net` +from (select `w_warehouse_name`, `w_warehouse_sq_ft`, `w_city`, `w_county`, `w_state`, `w_country`, `concat`(`concat`('dhl', ','), 'barian') as `ship_carriers`, `d_year` as `year`, sum(case when `d_moy` = 1 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `jan_sales`, sum(case when `d_moy` = 2 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `feb_sales`, sum(case when `d_moy` = 3 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `mar_sales`, sum(case when `d_moy` = 4 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `apr_sales`, sum(case when `d_moy` = 5 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `may_sales`, sum(case when `d_moy` = 6 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `jun_sales`, sum(case when `d_moy` = 7 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `jul_sales`, sum(case when `d_moy` = 8 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `aug_sales`, sum(case when `d_moy` = 9 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `sep_sales`, sum(case when `d_moy` = 10 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `oct_sales`, sum(case when `d_moy` = 11 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `nov_sales`, sum(case when `d_moy` = 12 then `ws_ext_sales_price` * `ws_quantity` else 0 end) as `dec_sales`, sum(case when `d_moy` = 1 then `ws_net_paid` * `ws_quantity` else 0 end) as `jan_net`, sum(case when `d_moy` = 2 then `ws_net_paid` * `ws_quantity` else 0 end) as `feb_net`, sum(case when `d_moy` = 3 then `ws_net_paid` * `ws_quantity` else 0 end) as `mar_net`, sum(case when `d_moy` = 4 then `ws_net_paid` * `ws_quantity` else 0 end) as `apr_net`, sum(case when `d_moy` = 5 then `ws_net_paid` * `ws_quantity` else 0 end) as `may_net`, sum(case when `d_moy` = 6 then `ws_net_paid` * `ws_quantity` else 0 end) as `jun_net`, sum(case when `d_moy` = 7 then `ws_net_paid` * `ws_quantity` else 0 end) as `jul_net`, sum(case when `d_moy` = 8 then `ws_net_paid` * `ws_quantity` else 0 end) as `aug_net`, sum(case when `d_moy` = 9 then `ws_net_paid` * `ws_quantity` else 0 end) as `sep_net`, sum(case when `d_moy` = 10 then `ws_net_paid` * `ws_quantity` else 0 end) as `oct_net`, sum(case when `d_moy` = 11 then `ws_net_paid` * `ws_quantity` else 0 end) as `nov_net`, sum(case when `d_moy` = 12 then `ws_net_paid` * `ws_quantity` else 0 end) as `dec_net` +from `web_sales` +where `ws_warehouse_sk` = `w_warehouse_sk` and `ws_sold_date_sk` = `d_date_sk` and `ws_sold_time_sk` = `t_time_sk` and `ws_ship_mode_sk` = `sm_ship_mode_sk` and `d_year` = 2001 and `t_time` between asymmetric 30838 and 30838 + 28800 and `sm_carrier` in ('dhl', 'barian') +group by `w_warehouse_name`, `w_warehouse_sq_ft`, `w_city`, `w_county`, `w_state`, `w_country`, `d_year` +union all +select `w_warehouse_name`, `w_warehouse_sq_ft`, `w_city`, `w_county`, `w_state`, `w_country`, `concat`(`concat`('dhl', ','), 'barian') as `ship_carriers`, `d_year` as `year`, sum(case when `d_moy` = 1 then `cs_sales_price` * `cs_quantity` else 0 end) as `jan_sales`, sum(case when `d_moy` = 2 then `cs_sales_price` * `cs_quantity` else 0 end) as `feb_sales`, sum(case when `d_moy` = 3 then `cs_sales_price` * `cs_quantity` else 0 end) as `mar_sales`, sum(case when `d_moy` = 4 then `cs_sales_price` * `cs_quantity` else 0 end) as `apr_sales`, sum(case when `d_moy` = 5 then `cs_sales_price` * `cs_quantity` else 0 end) as `may_sales`, sum(case when `d_moy` = 6 then `cs_sales_price` * `cs_quantity` else 0 end) as `jun_sales`, sum(case when `d_moy` = 7 then `cs_sales_price` * `cs_quantity` else 0 end) as `jul_sales`, sum(case when `d_moy` = 8 then `cs_sales_price` * `cs_quantity` else 0 end) as `aug_sales`, sum(case when `d_moy` = 9 then `cs_sales_price` * `cs_quantity` else 0 end) as `sep_sales`, sum(case when `d_moy` = 10 then `cs_sales_price` * `cs_quantity` else 0 end) as `oct_sales`, sum(case when `d_moy` = 11 then `cs_sales_price` * `cs_quantity` else 0 end) as `nov_sales`, sum(case when `d_moy` = 12 then `cs_sales_price` * `cs_quantity` else 0 end) as `dec_sales`, sum(case when `d_moy` = 1 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `jan_net`, sum(case when `d_moy` = 2 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `feb_net`, sum(case when `d_moy` = 3 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `mar_net`, sum(case when `d_moy` = 4 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `apr_net`, sum(case when `d_moy` = 5 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `may_net`, sum(case when `d_moy` = 6 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `jun_net`, sum(case when `d_moy` = 7 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `jul_net`, sum(case when `d_moy` = 8 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `aug_net`, sum(case when `d_moy` = 9 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `sep_net`, sum(case when `d_moy` = 10 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `oct_net`, sum(case when `d_moy` = 11 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `nov_net`, sum(case when `d_moy` = 12 then `cs_net_paid_inc_tax` * `cs_quantity` else 0 end) as `dec_net` +from `catalog_sales` +where `cs_warehouse_sk` = `w_warehouse_sk` and `cs_sold_date_sk` = `d_date_sk` and `cs_sold_time_sk` = `t_time_sk` and `cs_ship_mode_sk` = `sm_ship_mode_sk` and `d_year` = 2001 and `t_time` between asymmetric 30838 and 30838 + 28800 and `sm_carrier` in ('dhl', 'barian') +group by `w_warehouse_name`, `w_warehouse_sq_ft`, `w_city`, `w_county`, `w_state`, `w_country`, `d_year`) as `x` +group by `w_warehouse_name`, `w_warehouse_sq_ft`, `w_city`, `w_county`, `w_state`, `w_country`, `ship_carriers`, `year` +order by `w_warehouse_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q67_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q67_expected.sql new file mode 100644 index 000000000..7475a0a2f --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q67_expected.sql @@ -0,0 +1,9 @@ +select * +from (select `i_category`, `i_class`, `i_brand`, `i_product_name`, `d_year`, `d_qoy`, `d_moy`, `s_store_id`, `sumsales`, rank() over (partition by `i_category` order by `sumsales` desc) as `rk` +from (select `i_category`, `i_class`, `i_brand`, `i_product_name`, `d_year`, `d_qoy`, `d_moy`, `s_store_id`, sum(coalesce(`ss_sales_price` * `ss_quantity`, 0)) as `sumsales` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `ss_item_sk` = `i_item_sk` and `ss_store_sk` = `s_store_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 +group by rollup(`i_category`, `i_class`, `i_brand`, `i_product_name`, `d_year`, `d_qoy`, `d_moy`, `s_store_id`)) as `dw1`) as `dw2` +where `rk` <= 100 +order by `i_category`, `i_class`, `i_brand`, `i_product_name`, `d_year`, `d_qoy`, `d_moy`, `s_store_id`, `sumsales`, `rk` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q68_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q68_expected.sql new file mode 100644 index 000000000..0188e10f6 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q68_expected.sql @@ -0,0 +1,8 @@ +select `c_last_name`, `c_first_name`, `ca_city`, `bought_city`, `ss_ticket_number`, `extended_price`, `extended_tax`, `list_price` +from (select `ss_ticket_number`, `ss_customer_sk`, `ca_city` as `bought_city`, sum(`ss_ext_sales_price`) as `extended_price`, sum(`ss_ext_list_price`) as `list_price`, sum(`ss_ext_tax`) as `extended_tax` +from `store_sales` +where `store_sales`.`ss_sold_date_sk` = `date_dim`.`d_date_sk` and `store_sales`.`ss_store_sk` = `store`.`s_store_sk` and `store_sales`.`ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `store_sales`.`ss_addr_sk` = `customer_address`.`ca_address_sk` and `date_dim`.`d_dom` between asymmetric 1 and 2 and (`household_demographics`.`hd_dep_count` = 4 or `household_demographics`.`hd_vehicle_count` = 3) and `date_dim`.`d_year` in (1999, 1999 + 1, 1999 + 2) and `store`.`s_city` in ('midway', 'fairview') +group by `ss_ticket_number`, `ss_customer_sk`, `ss_addr_sk`, `ca_city`) as `dn` +where `ss_customer_sk` = `c_customer_sk` and `customer`.`c_current_addr_sk` = `current_addr`.`ca_address_sk` and `current_addr`.`ca_city` <> `bought_city` +order by `c_last_name`, `ss_ticket_number` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q69_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q69_expected.sql new file mode 100644 index 000000000..6022d7900 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q69_expected.sql @@ -0,0 +1,12 @@ +select `cd_gender`, `cd_marital_status`, `cd_education_status`, count(*) as `cnt1`, `cd_purchase_estimate`, count(*) as `cnt2`, `cd_credit_rating`, count(*) as `cnt3` +from `customer` as `c` +where `c`.`c_current_addr_sk` = `ca`.`ca_address_sk` and `ca_state` in ('ky', 'ga', 'nm') and `cd_demo_sk` = `c`.`c_current_cdemo_sk` and exists (select * +from `store_sales` +where `c`.`c_customer_sk` = `ss_customer_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` between asymmetric 4 and 4 + 2) and not exists (select * +from `web_sales` +where `c`.`c_customer_sk` = `ws_bill_customer_sk` and `ws_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` between asymmetric 4 and 4 + 2) and not exists (select * +from `catalog_sales` +where `c`.`c_customer_sk` = `cs_ship_customer_sk` and `cs_sold_date_sk` = `d_date_sk` and `d_year` = 2001 and `d_moy` between asymmetric 4 and 4 + 2) +group by `cd_gender`, `cd_marital_status`, `cd_education_status`, `cd_purchase_estimate`, `cd_credit_rating` +order by `cd_gender`, `cd_marital_status`, `cd_education_status`, `cd_purchase_estimate`, `cd_credit_rating` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q70_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q70_expected.sql new file mode 100644 index 000000000..446d0a8c8 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q70_expected.sql @@ -0,0 +1,11 @@ +select sum(`ss_net_profit`) as `total_sum`, `s_state`, `s_county`, grouping(`s_state`) + grouping(`s_county`) as `lochierarchy`, rank() over (partition by grouping(`s_state`) + grouping(`s_county`), case when grouping(`s_county`) = 0 then `s_state` else null end order by sum(`ss_net_profit`) desc) as `rank_within_parent` +from `store_sales` +where `d1`.`d_month_seq` between asymmetric 1200 and 1200 + 11 and `d1`.`d_date_sk` = `ss_sold_date_sk` and `s_store_sk` = `ss_store_sk` and `s_state` in (select `s_state` +from (select `s_state` as `s_state`, rank() over (partition by `s_state` order by sum(`ss_net_profit`) desc) as `ranking` +from `store_sales` +where `d_month_seq` between asymmetric 1200 and 1200 + 11 and `d_date_sk` = `ss_sold_date_sk` and `s_store_sk` = `ss_store_sk` +group by `s_state`) as `tmp1` +where `ranking` <= 5) +group by rollup(`s_state`, `s_county`) +order by `lochierarchy` desc, case when `lochierarchy` = 0 then `s_state` else null end, `rank_within_parent` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q71_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q71_expected.sql new file mode 100644 index 000000000..37dc1d598 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q71_expected.sql @@ -0,0 +1,15 @@ +select `i_brand_id` as `brand_id`, `i_brand` as `brand`, `t_hour`, `t_minute`, sum(`ext_price`) as `ext_price` +from (select `ws_ext_sales_price` as `ext_price`, `ws_sold_date_sk` as `sold_date_sk`, `ws_item_sk` as `sold_item_sk`, `ws_sold_time_sk` as `time_sk` +from `web_sales` +where `d_date_sk` = `ws_sold_date_sk` and `d_moy` = 11 and `d_year` = 1999 +union all +select `cs_ext_sales_price` as `ext_price`, `cs_sold_date_sk` as `sold_date_sk`, `cs_item_sk` as `sold_item_sk`, `cs_sold_time_sk` as `time_sk` +from `catalog_sales` +where `d_date_sk` = `cs_sold_date_sk` and `d_moy` = 11 and `d_year` = 1999 +union all +select `ss_ext_sales_price` as `ext_price`, `ss_sold_date_sk` as `sold_date_sk`, `ss_item_sk` as `sold_item_sk`, `ss_sold_time_sk` as `time_sk` +from `store_sales` +where `d_date_sk` = `ss_sold_date_sk` and `d_moy` = 11 and `d_year` = 1999) as `tmp` +where `sold_item_sk` = `i_item_sk` and `i_manager_id` = 1 and `time_sk` = `t_time_sk` and (`t_meal_time` = 'breakfast' or `t_meal_time` = 'dinner') +group by `i_brand`, `i_brand_id`, `t_hour`, `t_minute` +order by `ext_price` desc, `i_brand_id` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q72_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q72_expected.sql new file mode 100644 index 000000000..072c9b804 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q72_expected.sql @@ -0,0 +1,16 @@ +select `i_item_desc`, `w_warehouse_name`, `d1`.`d_week_seq`, sum(case when `p_promo_sk` is null then 1 else 0 end) as `no_promo`, sum(case when `p_promo_sk` is not null then 1 else 0 end) as `promo`, count(*) as `total_cnt` +from `catalog_sales` +inner join `inventory` on `cs_item_sk` = `inv_item_sk` +inner join `warehouse` on `w_warehouse_sk` = `inv_warehouse_sk` +inner join `item` on `i_item_sk` = `cs_item_sk` +inner join `customer_demographics` on `cs_bill_cdemo_sk` = `cd_demo_sk` +inner join `household_demographics` on `cs_bill_hdemo_sk` = `hd_demo_sk` +inner join `date_dim` as `d1` on `cs_sold_date_sk` = `d1`.`d_date_sk` +inner join `date_dim` as `d2` on `inv_date_sk` = `d2`.`d_date_sk` +inner join `date_dim` as `d3` on `cs_ship_date_sk` = `d3`.`d_date_sk` +left join `promotion` on `cs_promo_sk` = `p_promo_sk` +left join `catalog_returns` on `cr_item_sk` = `cs_item_sk` and `cr_order_number` = `cs_order_number` +where `d1`.`d_week_seq` = `d2`.`d_week_seq` and `inv_quantity_on_hand` < `cs_quantity` and `d3`.`d_date` > `d1`.`d_date` + interval '5' day and `hd_buy_potential` = '>10000' and `d1`.`d_year` = 1999 and `cd_marital_status` = 'd' +group by `i_item_desc`, `w_warehouse_name`, `d1`.`d_week_seq` +order by `total_cnt` desc, `i_item_desc`, `w_warehouse_name`, `d1`.`d_week_seq` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q73_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q73_expected.sql new file mode 100644 index 000000000..18461ef3b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q73_expected.sql @@ -0,0 +1,7 @@ +select `c_last_name`, `c_first_name`, `c_salutation`, `c_preferred_cust_flag`, `ss_ticket_number`, `cnt` +from (select `ss_ticket_number`, `ss_customer_sk`, count(*) as `cnt` +from `store_sales` +where `store_sales`.`ss_sold_date_sk` = `date_dim`.`d_date_sk` and `store_sales`.`ss_store_sk` = `store`.`s_store_sk` and `store_sales`.`ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `date_dim`.`d_dom` between asymmetric 1 and 2 and (`household_demographics`.`hd_buy_potential` = '>10000' or `household_demographics`.`hd_buy_potential` = 'unknown') and `household_demographics`.`hd_vehicle_count` > 0 and case when `household_demographics`.`hd_vehicle_count` > 0 then cast(`household_demographics`.`hd_dep_count` as decimal(7, 7)) / `household_demographics`.`hd_vehicle_count` else null end > 1 and `date_dim`.`d_year` in (1999, 1999 + 1, 1999 + 2) and `store`.`s_county` in ('williamson county', 'franklin parish', 'bronx county', 'orange county') +group by `ss_ticket_number`, `ss_customer_sk`) as `dj` +where `ss_customer_sk` = `c_customer_sk` and `cnt` between asymmetric 1 and 5 +order by `cnt` desc, `c_last_name` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q74_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q74_expected.sql new file mode 100644 index 000000000..4b8a3fc2a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q74_expected.sql @@ -0,0 +1,13 @@ +with `year_total` as select `c_customer_id` as `customer_id`, `c_first_name` as `customer_first_name`, `c_last_name` as `customer_last_name`, `d_year` as `year`, sum(`ss_net_paid`) as `year_total`, 's' as `sale_type` +from `customer` +where `c_customer_sk` = `ss_customer_sk` and `ss_sold_date_sk` = `d_date_sk` and `d_year` in (2001, 2001 + 1) +group by `c_customer_id`, `c_first_name`, `c_last_name`, `d_year` +union all +select `c_customer_id` as `customer_id`, `c_first_name` as `customer_first_name`, `c_last_name` as `customer_last_name`, `d_year` as `year`, sum(`ws_net_paid`) as `year_total`, 'w' as `sale_type` +from `customer` +where `c_customer_sk` = `ws_bill_customer_sk` and `ws_sold_date_sk` = `d_date_sk` and `d_year` in (2001, 2001 + 1) +group by `c_customer_id`, `c_first_name`, `c_last_name`, `d_year` (select `t_s_secyear`.`customer_id`, `t_s_secyear`.`customer_first_name`, `t_s_secyear`.`customer_last_name` +from `year_total` as `t_s_firstyear` +where `t_s_secyear`.`customer_id` = `t_s_firstyear`.`customer_id` and `t_s_firstyear`.`customer_id` = `t_w_secyear`.`customer_id` and `t_s_firstyear`.`customer_id` = `t_w_firstyear`.`customer_id` and `t_s_firstyear`.`sale_type` = 's' and `t_w_firstyear`.`sale_type` = 'w' and `t_s_secyear`.`sale_type` = 's' and `t_w_secyear`.`sale_type` = 'w' and `t_s_firstyear`.`year` = 2001 and `t_s_secyear`.`year` = 2001 + 1 and `t_w_firstyear`.`year` = 2001 and `t_w_secyear`.`year` = 2001 + 1 and `t_s_firstyear`.`year_total` > 0 and `t_w_firstyear`.`year_total` > 0 and case when `t_w_firstyear`.`year_total` > 0 then `t_w_secyear`.`year_total` / `t_w_firstyear`.`year_total` else null end > case when `t_s_firstyear`.`year_total` > 0 then `t_s_secyear`.`year_total` / `t_s_firstyear`.`year_total` else null end +order by 1, 1, 1 +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q75_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q75_expected.sql new file mode 100644 index 000000000..3b868cc84 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q75_expected.sql @@ -0,0 +1,26 @@ +with `all_sales` as (select `d_year`, `i_brand_id`, `i_class_id`, `i_category_id`, `i_manufact_id`, sum(`sales_cnt`) as `sales_cnt`, sum(`sales_amt`) as `sales_amt` +from (select `d_year`, `i_brand_id`, `i_class_id`, `i_category_id`, `i_manufact_id`, `cs_quantity` - coalesce(`cr_return_quantity`, 0) as `sales_cnt`, `cs_ext_sales_price` - coalesce(`cr_return_amount`, 0.0) as `sales_amt` +from `catalog_sales` +inner join `item` on `i_item_sk` = `cs_item_sk` +inner join `date_dim` on `d_date_sk` = `cs_sold_date_sk` +left join `catalog_returns` on `cs_order_number` = `cr_order_number` and `cs_item_sk` = `cr_item_sk` +where `i_category` = 'books' +union +select `d_year`, `i_brand_id`, `i_class_id`, `i_category_id`, `i_manufact_id`, `ss_quantity` - coalesce(`sr_return_quantity`, 0) as `sales_cnt`, `ss_ext_sales_price` - coalesce(`sr_return_amt`, 0.0) as `sales_amt` +from `store_sales` +inner join `item` on `i_item_sk` = `ss_item_sk` +inner join `date_dim` on `d_date_sk` = `ss_sold_date_sk` +left join `store_returns` on `ss_ticket_number` = `sr_ticket_number` and `ss_item_sk` = `sr_item_sk` +where `i_category` = 'books' +union +select `d_year`, `i_brand_id`, `i_class_id`, `i_category_id`, `i_manufact_id`, `ws_quantity` - coalesce(`wr_return_quantity`, 0) as `sales_cnt`, `ws_ext_sales_price` - coalesce(`wr_return_amt`, 0.0) as `sales_amt` +from `web_sales` +inner join `item` on `i_item_sk` = `ws_item_sk` +inner join `date_dim` on `d_date_sk` = `ws_sold_date_sk` +left join `web_returns` on `ws_order_number` = `wr_order_number` and `ws_item_sk` = `wr_item_sk` +where `i_category` = 'books') as `sales_detail` +group by `d_year`, `i_brand_id`, `i_class_id`, `i_category_id`, `i_manufact_id`) (select `prev_yr`.`d_year` as `prev_year`, `curr_yr`.`d_year` as `year`, `curr_yr`.`i_brand_id`, `curr_yr`.`i_class_id`, `curr_yr`.`i_category_id`, `curr_yr`.`i_manufact_id`, `prev_yr`.`sales_cnt` as `prev_yr_cnt`, `curr_yr`.`sales_cnt` as `curr_yr_cnt`, `curr_yr`.`sales_cnt` - `prev_yr`.`sales_cnt` as `sales_cnt_diff`, `curr_yr`.`sales_amt` - `prev_yr`.`sales_amt` as `sales_amt_diff` +from `all_sales` as `curr_yr` +where `curr_yr`.`i_brand_id` = `prev_yr`.`i_brand_id` and `curr_yr`.`i_class_id` = `prev_yr`.`i_class_id` and `curr_yr`.`i_category_id` = `prev_yr`.`i_category_id` and `curr_yr`.`i_manufact_id` = `prev_yr`.`i_manufact_id` and `curr_yr`.`d_year` = 2002 and `prev_yr`.`d_year` = 2002 - 1 and cast(`curr_yr`.`sales_cnt` as decimal(17, 17)) / cast(`prev_yr`.`sales_cnt` as decimal(17, 17)) < 0.9 +order by `sales_cnt_diff`, `sales_amt_diff` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q76_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q76_expected.sql new file mode 100644 index 000000000..2d85766d4 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q76_expected.sql @@ -0,0 +1,15 @@ +select `channel`, `col_name`, `d_year`, `d_qoy`, `i_category`, count(*) as `sales_cnt`, sum(`ext_sales_price`) as `sales_amt` +from (select 'store' as `channel`, 'ss_store_sk' as `col_name`, `d_year`, `d_qoy`, `i_category`, `ss_ext_sales_price` as `ext_sales_price` +from `store_sales` +where `ss_store_sk` is null and `ss_sold_date_sk` = `d_date_sk` and `ss_item_sk` = `i_item_sk` +union all +select 'web' as `channel`, 'ws_ship_customer_sk' as `col_name`, `d_year`, `d_qoy`, `i_category`, `ws_ext_sales_price` as `ext_sales_price` +from `web_sales` +where `ws_ship_customer_sk` is null and `ws_sold_date_sk` = `d_date_sk` and `ws_item_sk` = `i_item_sk` +union all +select 'catalog' as `channel`, 'cs_ship_addr_sk' as `col_name`, `d_year`, `d_qoy`, `i_category`, `cs_ext_sales_price` as `ext_sales_price` +from `catalog_sales` +where `cs_ship_addr_sk` is null and `cs_sold_date_sk` = `d_date_sk` and `cs_item_sk` = `i_item_sk`) as `foo` +group by `channel`, `col_name`, `d_year`, `d_qoy`, `i_category` +order by `channel`, `col_name`, `d_year`, `d_qoy`, `i_category` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q77_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q77_expected.sql new file mode 100644 index 000000000..71813e650 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q77_expected.sql @@ -0,0 +1,32 @@ +with `ss` as (select `s_store_sk`, sum(`ss_ext_sales_price`) as `sales`, sum(`ss_net_profit`) as `profit` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `d_date` between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day and `ss_store_sk` = `s_store_sk` +group by `s_store_sk`), `sr` as (select `s_store_sk`, sum(`sr_return_amt`) as `returns`, sum(`sr_net_loss`) as `profit_loss` +from `store_returns` +where `sr_returned_date_sk` = `d_date_sk` and `d_date` between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day and `sr_store_sk` = `s_store_sk` +group by `s_store_sk`), `cs` as (select `cs_call_center_sk`, sum(`cs_ext_sales_price`) as `sales`, sum(`cs_net_profit`) as `profit` +from `catalog_sales` +where `cs_sold_date_sk` = `d_date_sk` and `d_date` between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day +group by `cs_call_center_sk`), `cr` as (select `cr_call_center_sk`, sum(`cr_return_amount`) as `returns`, sum(`cr_net_loss`) as `profit_loss` +from `catalog_returns` +where `cr_returned_date_sk` = `d_date_sk` and `d_date` between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day +group by `cr_call_center_sk`), `ws` as (select `wp_web_page_sk`, sum(`ws_ext_sales_price`) as `sales`, sum(`ws_net_profit`) as `profit` +from `web_sales` +where `ws_sold_date_sk` = `d_date_sk` and `d_date` between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day and `ws_web_page_sk` = `wp_web_page_sk` +group by `wp_web_page_sk`), `wr` as (select `wp_web_page_sk`, sum(`wr_return_amt`) as `returns`, sum(`wr_net_loss`) as `profit_loss` +from `web_returns` +where `wr_returned_date_sk` = `d_date_sk` and `d_date` between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day and `wr_web_page_sk` = `wp_web_page_sk` +group by `wp_web_page_sk`) (select `channel`, `id`, sum(`sales`) as `sales`, sum(`returns`) as `returns`, sum(`profit`) as `profit` +from (select 'store channel' as `channel`, `ss`.`s_store_sk` as `id`, `sales`, coalesce(`returns`, 0) as `returns`, `profit` - coalesce(`profit_loss`, 0) as `profit` +from `ss` +left join `sr` on `ss`.`s_store_sk` = `sr`.`s_store_sk` +union all +select 'catalog channel' as `channel`, `cs_call_center_sk` as `id`, `sales`, `returns`, `profit` - `profit_loss` as `profit` +from `cs` +union all +select 'web channel' as `channel`, `ws`.`wp_web_page_sk` as `id`, `sales`, coalesce(`returns`, 0) as `returns`, `profit` - coalesce(`profit_loss`, 0) as `profit` +from `ws` +left join `wr` on `ws`.`wp_web_page_sk` = `wr`.`wp_web_page_sk`) as `x` +group by rollup(`channel`, `id`) +order by `channel`, `id`, `sales` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q78_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q78_expected.sql new file mode 100644 index 000000000..8b35cf5ee --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q78_expected.sql @@ -0,0 +1,22 @@ +with `ws` as (select `d_year` as `ws_sold_year`, `ws_item_sk`, `ws_bill_customer_sk` as `ws_customer_sk`, sum(`ws_quantity`) as `ws_qty`, sum(`ws_wholesale_cost`) as `ws_wc`, sum(`ws_sales_price`) as `ws_sp` +from `web_sales` +left join `web_returns` on `wr_order_number` = `ws_order_number` and `ws_item_sk` = `wr_item_sk` +inner join `date_dim` on `ws_sold_date_sk` = `d_date_sk` +where `wr_order_number` is null +group by `d_year`, `ws_item_sk`, `ws_bill_customer_sk`), `cs` as (select `d_year` as `cs_sold_year`, `cs_item_sk`, `cs_bill_customer_sk` as `cs_customer_sk`, sum(`cs_quantity`) as `cs_qty`, sum(`cs_wholesale_cost`) as `cs_wc`, sum(`cs_sales_price`) as `cs_sp` +from `catalog_sales` +left join `catalog_returns` on `cr_order_number` = `cs_order_number` and `cs_item_sk` = `cr_item_sk` +inner join `date_dim` on `cs_sold_date_sk` = `d_date_sk` +where `cr_order_number` is null +group by `d_year`, `cs_item_sk`, `cs_bill_customer_sk`), `ss` as (select `d_year` as `ss_sold_year`, `ss_item_sk`, `ss_customer_sk`, sum(`ss_quantity`) as `ss_qty`, sum(`ss_wholesale_cost`) as `ss_wc`, sum(`ss_sales_price`) as `ss_sp` +from `store_sales` +left join `store_returns` on `sr_ticket_number` = `ss_ticket_number` and `ss_item_sk` = `sr_item_sk` +inner join `date_dim` on `ss_sold_date_sk` = `d_date_sk` +where `sr_ticket_number` is null +group by `d_year`, `ss_item_sk`, `ss_customer_sk`) (select `ss_sold_year`, `ss_item_sk`, `ss_customer_sk`, round(cast(`ss_qty` as decimal(10, 10)) / coalesce(`ws_qty` + `cs_qty`, 1), 2) as `ratio`, `ss_qty` as `store_qty`, `ss_wc` as `store_wholesale_cost`, `ss_sp` as `store_sales_price`, coalesce(`ws_qty`, 0) + coalesce(`cs_qty`, 0) as `other_chan_qty`, coalesce(`ws_wc`, 0) + coalesce(`cs_wc`, 0) as `other_chan_wholesale_cost`, coalesce(`ws_sp`, 0) + coalesce(`cs_sp`, 0) as `other_chan_sales_price` +from `ss` +left join `ws` on `ws_sold_year` = `ss_sold_year` and `ws_item_sk` = `ss_item_sk` and `ws_customer_sk` = `ss_customer_sk` +left join `cs` on `cs_sold_year` = `ss_sold_year` and `cs_item_sk` = `cs_item_sk` and `cs_customer_sk` = `ss_customer_sk` +where coalesce(`ws_qty`, 0) > 0 and coalesce(`cs_qty`, 0) > 0 and `ss_sold_year` = 2000 +order by `ss_sold_year`, `ss_item_sk`, `ss_customer_sk`, `ss_qty` desc, `ss_wc` desc, `ss_sp` desc, `other_chan_qty`, `other_chan_wholesale_cost`, `other_chan_sales_price`, round(cast(`ss_qty` as decimal(10, 10)) / coalesce(`ws_qty` + `cs_qty`, 1), 2) +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q79_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q79_expected.sql new file mode 100644 index 000000000..63f9837d7 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q79_expected.sql @@ -0,0 +1,8 @@ +select `c_last_name`, `c_first_name`, `substr`(`s_city`, 1, 30), `ss_ticket_number`, `amt`, `profit` +from (select `ss_ticket_number`, `ss_customer_sk`, `store`.`s_city`, sum(`ss_coupon_amt`) as `amt`, sum(`ss_net_profit`) as `profit` +from `store_sales` +where `store_sales`.`ss_sold_date_sk` = `date_dim`.`d_date_sk` and `store_sales`.`ss_store_sk` = `store`.`s_store_sk` and `store_sales`.`ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and (`household_demographics`.`hd_dep_count` = 6 or `household_demographics`.`hd_vehicle_count` > 2) and `date_dim`.`d_dow` = 1 and `date_dim`.`d_year` in (1999, 1999 + 1, 1999 + 2) and `store`.`s_number_employees` between asymmetric 200 and 295 +group by `ss_ticket_number`, `ss_customer_sk`, `ss_addr_sk`, `store`.`s_city`) as `ms` +where `ss_customer_sk` = `c_customer_sk` +order by `c_last_name`, `c_first_name`, `substr`(`s_city`, 1, 30), `profit` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q80_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q80_expected.sql new file mode 100644 index 000000000..eaaaa4620 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q80_expected.sql @@ -0,0 +1,24 @@ +with `ssr` as (select `s_store_id` as `store_id`, sum(`ss_ext_sales_price`) as `sales`, sum(coalesce(`sr_return_amt`, 0)) as `returns`, sum(`ss_net_profit` - coalesce(`sr_net_loss`, 0)) as `profit` +from `store_sales` +left join `store_returns` on `ss_item_sk` = `sr_item_sk` and `ss_ticket_number` = `sr_ticket_number` +where `ss_sold_date_sk` = `d_date_sk` and cast(`d_date` as date) between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day and `ss_store_sk` = `s_store_sk` and `ss_item_sk` = `i_item_sk` and `i_current_price` > 50 and `ss_promo_sk` = `p_promo_sk` and `p_channel_tv` = 'n' +group by `s_store_id`), `csr` as (select `cp_catalog_page_id` as `catalog_page_id`, sum(`cs_ext_sales_price`) as `sales`, sum(coalesce(`cr_return_amount`, 0)) as `returns`, sum(`cs_net_profit` - coalesce(`cr_net_loss`, 0)) as `profit` +from `catalog_sales` +left join `catalog_returns` on `cs_item_sk` = `cr_item_sk` and `cs_order_number` = `cr_order_number` +where `cs_sold_date_sk` = `d_date_sk` and cast(`d_date` as date) between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day and `cs_catalog_page_sk` = `cp_catalog_page_sk` and `cs_item_sk` = `i_item_sk` and `i_current_price` > 50 and `cs_promo_sk` = `p_promo_sk` and `p_channel_tv` = 'n' +group by `cp_catalog_page_id`), `wsr` as (select `web_site_id`, sum(`ws_ext_sales_price`) as `sales`, sum(coalesce(`wr_return_amt`, 0)) as `returns`, sum(`ws_net_profit` - coalesce(`wr_net_loss`, 0)) as `profit` +from `web_sales` +left join `web_returns` on `ws_item_sk` = `wr_item_sk` and `ws_order_number` = `wr_order_number` +where `ws_sold_date_sk` = `d_date_sk` and cast(`d_date` as date) between asymmetric cast('2000-08-23' as date) and cast('2000-08-23' as date) + interval '30' day and `ws_web_site_sk` = `web_site_sk` and `ws_item_sk` = `i_item_sk` and `i_current_price` > 50 and `ws_promo_sk` = `p_promo_sk` and `p_channel_tv` = 'n' +group by `web_site_id`) (select `channel`, `id`, sum(`sales`) as `sales`, sum(`returns`) as `returns`, sum(`profit`) as `profit` +from (select 'store channel' as `channel`, `concat`('store', `store_id`) as `id`, `sales`, `returns`, `profit` +from `ssr` +union all +select 'catalog channel' as `channel`, `concat`('catalog_page', `catalog_page_id`) as `id`, `sales`, `returns`, `profit` +from `csr` +union all +select 'web channel' as `channel`, `concat`('web_site', `web_site_id`) as `id`, `sales`, `returns`, `profit` +from `wsr`) as `x` +group by rollup(`channel`, `id`) +order by `channel`, `id` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q81_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q81_expected.sql new file mode 100644 index 000000000..31d8efc60 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q81_expected.sql @@ -0,0 +1,10 @@ +with `customer_total_return` as (select `cr_returning_customer_sk` as `ctr_customer_sk`, `ca_state` as `ctr_state`, sum(`cr_return_amt_inc_tax`) as `ctr_total_return` +from `catalog_returns` +where `cr_returned_date_sk` = `d_date_sk` and `d_year` = 2000 and `cr_returning_addr_sk` = `ca_address_sk` +group by `cr_returning_customer_sk`, `ca_state`) (select `c_customer_id`, `c_salutation`, `c_first_name`, `c_last_name`, `ca_street_number`, `ca_street_name`, `ca_street_type`, `ca_suite_number`, `ca_city`, `ca_county`, `ca_state`, `ca_zip`, `ca_country`, `ca_gmt_offset`, `ca_location_type`, `ctr_total_return` +from `customer_total_return` as `ctr1` +where `ctr1`.`ctr_total_return` > (select avg(`ctr_total_return`) * 1.2 +from `customer_total_return` as `ctr2` +where `ctr1`.`ctr_state` = `ctr2`.`ctr_state`) and `ca_address_sk` = `c_current_addr_sk` and `ca_state` = 'ga' and `ctr1`.`ctr_customer_sk` = `c_customer_sk` +order by `c_customer_id`, `c_salutation`, `c_first_name`, `c_last_name`, `ca_street_number`, `ca_street_name`, `ca_street_type`, `ca_suite_number`, `ca_city`, `ca_county`, `ca_state`, `ca_zip`, `ca_country`, `ca_gmt_offset`, `ca_location_type`, `ctr_total_return` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q82_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q82_expected.sql new file mode 100644 index 000000000..cb5948b9a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q82_expected.sql @@ -0,0 +1,6 @@ +select `i_item_id`, `i_item_desc`, `i_current_price` +from `item` +where `i_current_price` between asymmetric 62 and 62 + 30 and `inv_item_sk` = `i_item_sk` and `d_date_sk` = `inv_date_sk` and cast(`d_date` as date) between asymmetric cast('2000-05-25' as date) and cast('2000-05-25' as date) + interval '60' day and `i_manufact_id` in (129, 270, 821, 423) and `inv_quantity_on_hand` between asymmetric 100 and 500 and `ss_item_sk` = `i_item_sk` +group by `i_item_id`, `i_item_desc`, `i_current_price` +order by `i_item_id` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q83_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q83_expected.sql new file mode 100644 index 000000000..8e1b8f83e --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q83_expected.sql @@ -0,0 +1,26 @@ +with `sr_items` as (select `i_item_id` as `item_id`, sum(`sr_return_quantity`) as `sr_item_qty` +from `store_returns` +where `sr_item_sk` = `i_item_sk` and `d_date` in (select `d_date` +from `date_dim` +where `d_week_seq` in (select `d_week_seq` +from `date_dim` +where `d_date` in (cast('2000-06-30' as date), cast('2000-09-27' as date), cast('2000-11-17' as date)))) and `sr_returned_date_sk` = `d_date_sk` +group by `i_item_id`), `cr_items` as (select `i_item_id` as `item_id`, sum(`cr_return_quantity`) as `cr_item_qty` +from `catalog_returns` +where `cr_item_sk` = `i_item_sk` and `d_date` in (select `d_date` +from `date_dim` +where `d_week_seq` in (select `d_week_seq` +from `date_dim` +where `d_date` in (cast('2000-06-30' as date), cast('2000-09-27' as date), cast('2000-11-17' as date)))) and `cr_returned_date_sk` = `d_date_sk` +group by `i_item_id`), `wr_items` as (select `i_item_id` as `item_id`, sum(`wr_return_quantity`) as `wr_item_qty` +from `web_returns` +where `wr_item_sk` = `i_item_sk` and `d_date` in (select `d_date` +from `date_dim` +where `d_week_seq` in (select `d_week_seq` +from `date_dim` +where `d_date` in (cast('2000-06-30' as date), cast('2000-09-27' as date), cast('2000-11-17' as date)))) and `wr_returned_date_sk` = `d_date_sk` +group by `i_item_id`) (select `sr_items`.`item_id`, `sr_item_qty`, cast(`sr_item_qty` / (cast(`sr_item_qty` as decimal(9, 9)) + `cr_item_qty` + `wr_item_qty`) / 3.0 * 100 as decimal(7, 7)) as `sr_dev`, `cr_item_qty`, cast(`cr_item_qty` / (cast(`sr_item_qty` as decimal(9, 9)) + `cr_item_qty` + `wr_item_qty`) / 3.0 * 100 as decimal(7, 7)) as `cr_dev`, `wr_item_qty`, cast(`wr_item_qty` / (cast(`sr_item_qty` as decimal(9, 9)) + `cr_item_qty` + `wr_item_qty`) / 3.0 * 100 as decimal(7, 7)) as `wr_dev`, (`sr_item_qty` + `cr_item_qty` + `wr_item_qty`) / 3.00 as `average` +from `sr_items` +where `sr_items`.`item_id` = `cr_items`.`item_id` and `sr_items`.`item_id` = `wr_items`.`item_id` +order by `sr_items`.`item_id`, `sr_item_qty` +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q84_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q84_expected.sql new file mode 100644 index 000000000..960310036 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q84_expected.sql @@ -0,0 +1,5 @@ +select `c_customer_id` as `customer_id`, `concat`(`concat`(`c_last_name`, ', '), `c_first_name`) as `customername` +from `customer` +where `ca_city` = 'edgewood' and `c_current_addr_sk` = `ca_address_sk` and `ib_lower_bound` >= 38128 and `ib_upper_bound` <= 38128 + 50000 and `ib_income_band_sk` = `hd_income_band_sk` and `cd_demo_sk` = `c_current_cdemo_sk` and `hd_demo_sk` = `c_current_hdemo_sk` and `sr_cdemo_sk` = `cd_demo_sk` +order by `c_customer_id` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q85_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q85_expected.sql new file mode 100644 index 000000000..49c968241 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q85_expected.sql @@ -0,0 +1,6 @@ +select `substr`(`r_reason_desc`, 1, 20), avg(`ws_quantity`), avg(`wr_refunded_cash`), avg(`wr_fee`) +from `web_sales` +where `ws_web_page_sk` = `wp_web_page_sk` and `ws_item_sk` = `wr_item_sk` and `ws_order_number` = `wr_order_number` and `ws_sold_date_sk` = `d_date_sk` and `d_year` = 2000 and `cd1`.`cd_demo_sk` = `wr_refunded_cdemo_sk` and `cd2`.`cd_demo_sk` = `wr_returning_cdemo_sk` and `ca_address_sk` = `wr_refunded_addr_sk` and `r_reason_sk` = `wr_reason_sk` and (`cd1`.`cd_marital_status` = 'm' and `cd1`.`cd_marital_status` = `cd2`.`cd_marital_status` and `cd1`.`cd_education_status` = 'advanced degree' and `cd1`.`cd_education_status` = `cd2`.`cd_education_status` and `ws_sales_price` between asymmetric 100.00 and 150.00 or `cd1`.`cd_marital_status` = 's' and `cd1`.`cd_marital_status` = `cd2`.`cd_marital_status` and `cd1`.`cd_education_status` = 'college' and `cd1`.`cd_education_status` = `cd2`.`cd_education_status` and `ws_sales_price` between asymmetric 50.00 and 100.00 or `cd1`.`cd_marital_status` = 'w' and `cd1`.`cd_marital_status` = `cd2`.`cd_marital_status` and `cd1`.`cd_education_status` = '2 yr degree' and `cd1`.`cd_education_status` = `cd2`.`cd_education_status` and `ws_sales_price` between asymmetric 150.00 and 200.00) and (`ca_country` = 'united states' and `ca_state` in ('in', 'oh', 'nj') and `ws_net_profit` between asymmetric 100 and 200 or `ca_country` = 'united states' and `ca_state` in ('wi', 'ct', 'ky') and `ws_net_profit` between asymmetric 150 and 300 or `ca_country` = 'united states' and `ca_state` in ('la', 'ia', 'ar') and `ws_net_profit` between asymmetric 50 and 250) +group by `r_reason_desc` +order by `substr`(`r_reason_desc`, 1, 20), avg(`ws_quantity`), avg(`wr_refunded_cash`), avg(`wr_fee`) +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q86_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q86_expected.sql new file mode 100644 index 000000000..2449dbe94 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q86_expected.sql @@ -0,0 +1,6 @@ +select sum(`ws_net_paid`) as `total_sum`, `i_category`, `i_class`, grouping(`i_category`) + grouping(`i_class`) as `lochierarchy`, rank() over (partition by grouping(`i_category`) + grouping(`i_class`), case when grouping(`i_class`) = 0 then `i_category` else null end order by sum(`ws_net_paid`) desc) as `rank_within_parent` +from `web_sales` +where `d1`.`d_month_seq` between asymmetric 1200 and 1200 + 11 and `d1`.`d_date_sk` = `ws_sold_date_sk` and `i_item_sk` = `ws_item_sk` +group by rollup(`i_category`, `i_class`) +order by `lochierarchy` desc, case when `lochierarchy` = 0 then `i_category` else null end, `rank_within_parent` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q87_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q87_expected.sql new file mode 100644 index 000000000..e6f12488d --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q87_expected.sql @@ -0,0 +1,12 @@ +select count(*) +from (select distinct `c_last_name`, `c_first_name`, `d_date` +from `store_sales` +where `store_sales`.`ss_sold_date_sk` = `date_dim`.`d_date_sk` and `store_sales`.`ss_customer_sk` = `customer`.`c_customer_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 +except +select distinct `c_last_name`, `c_first_name`, `d_date` +from `catalog_sales` +where `catalog_sales`.`cs_sold_date_sk` = `date_dim`.`d_date_sk` and `catalog_sales`.`cs_bill_customer_sk` = `customer`.`c_customer_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 +except +select distinct `c_last_name`, `c_first_name`, `d_date` +from `web_sales` +where `web_sales`.`ws_sold_date_sk` = `date_dim`.`d_date_sk` and `web_sales`.`ws_bill_customer_sk` = `customer`.`c_customer_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11) as `cool_cust` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q88_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q88_expected.sql new file mode 100644 index 000000000..8543f1520 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q88_expected.sql @@ -0,0 +1,18 @@ +with `s0` as (select count(*) as `h8_30_to_9` +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 8 and `time_dim`.`t_minute` >= 30 and (`household_demographics`.`hd_dep_count` = 4 and `household_demographics`.`hd_vehicle_count` <= 4 + 2 or `household_demographics`.`hd_dep_count` = 2 and `household_demographics`.`hd_vehicle_count` <= 2 + 2 or `household_demographics`.`hd_dep_count` = 0 and `household_demographics`.`hd_vehicle_count` <= 0 + 2) and `store`.`s_store_name` = 'ese'), `s1` as (select count(*) as `h9_to_9_30` +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 9 and `time_dim`.`t_minute` < 30 and (`household_demographics`.`hd_dep_count` = 4 and `household_demographics`.`hd_vehicle_count` <= 4 + 2 or `household_demographics`.`hd_dep_count` = 2 and `household_demographics`.`hd_vehicle_count` <= 2 + 2 or `household_demographics`.`hd_dep_count` = 0 and `household_demographics`.`hd_vehicle_count` <= 0 + 2) and `store`.`s_store_name` = 'ese'), `s2` as (select count(*) as `h9_30_to_10` +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 9 and `time_dim`.`t_minute` >= 30 and (`household_demographics`.`hd_dep_count` = 4 and `household_demographics`.`hd_vehicle_count` <= 4 + 2 or `household_demographics`.`hd_dep_count` = 2 and `household_demographics`.`hd_vehicle_count` <= 2 + 2 or `household_demographics`.`hd_dep_count` = 0 and `household_demographics`.`hd_vehicle_count` <= 0 + 2) and `store`.`s_store_name` = 'ese'), `s3` as (select count(*) as `h10_to_10_30` +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 10 and `time_dim`.`t_minute` < 30 and (`household_demographics`.`hd_dep_count` = 4 and `household_demographics`.`hd_vehicle_count` <= 4 + 2 or `household_demographics`.`hd_dep_count` = 2 and `household_demographics`.`hd_vehicle_count` <= 2 + 2 or `household_demographics`.`hd_dep_count` = 0 and `household_demographics`.`hd_vehicle_count` <= 0 + 2) and `store`.`s_store_name` = 'ese'), `s4` as (select count(*) as `h10_30_to_11` +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 10 and `time_dim`.`t_minute` >= 30 and (`household_demographics`.`hd_dep_count` = 4 and `household_demographics`.`hd_vehicle_count` <= 4 + 2 or `household_demographics`.`hd_dep_count` = 2 and `household_demographics`.`hd_vehicle_count` <= 2 + 2 or `household_demographics`.`hd_dep_count` = 0 and `household_demographics`.`hd_vehicle_count` <= 0 + 2) and `store`.`s_store_name` = 'ese'), `s5` as (select count(*) as `h11_to_11_30` +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 11 and `time_dim`.`t_minute` < 30 and (`household_demographics`.`hd_dep_count` = 4 and `household_demographics`.`hd_vehicle_count` <= 4 + 2 or `household_demographics`.`hd_dep_count` = 2 and `household_demographics`.`hd_vehicle_count` <= 2 + 2 or `household_demographics`.`hd_dep_count` = 0 and `household_demographics`.`hd_vehicle_count` <= 0 + 2) and `store`.`s_store_name` = 'ese'), `s6` as (select count(*) as `h11_30_to_12` +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 11 and `time_dim`.`t_minute` >= 30 and (`household_demographics`.`hd_dep_count` = 4 and `household_demographics`.`hd_vehicle_count` <= 4 + 2 or `household_demographics`.`hd_dep_count` = 2 and `household_demographics`.`hd_vehicle_count` <= 2 + 2 or `household_demographics`.`hd_dep_count` = 0 and `household_demographics`.`hd_vehicle_count` <= 0 + 2) and `store`.`s_store_name` = 'ese'), `s7` as (select count(*) as `h12_to_12_30` +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 12 and `time_dim`.`t_minute` < 30 and (`household_demographics`.`hd_dep_count` = 4 and `household_demographics`.`hd_vehicle_count` <= 4 + 2 or `household_demographics`.`hd_dep_count` = 2 and `household_demographics`.`hd_vehicle_count` <= 2 + 2 or `household_demographics`.`hd_dep_count` = 0 and `household_demographics`.`hd_vehicle_count` <= 0 + 2) and `store`.`s_store_name` = 'ese') (select * +from `s7`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q89_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q89_expected.sql new file mode 100644 index 000000000..6b483b9b6 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q89_expected.sql @@ -0,0 +1,8 @@ +select * +from (select `i_category`, `i_class`, `i_brand`, `s_store_name`, `s_company_name`, `d_moy`, sum(`ss_sales_price`) as `sum_sales`, avg(sum(`ss_sales_price`)) over (partition by `i_category`, `i_brand`, `s_store_name`, `s_company_name`) as `avg_monthly_sales` +from `item` +where `ss_item_sk` = `i_item_sk` and `ss_sold_date_sk` = `d_date_sk` and `ss_store_sk` = `s_store_sk` and `d_year` in (1999) and (`i_category` in ('books', 'electronics', 'sports') and `i_class` in ('computers', 'stereo', 'football') or `i_category` in ('men', 'jewelry', 'women') and `i_class` in ('shirts', 'birdal', 'dresses')) +group by `i_category`, `i_class`, `i_brand`, `s_store_name`, `s_company_name`, `d_moy`) as `tmp1` +where case when `avg_monthly_sales` <> 0 then abs(`sum_sales` - `avg_monthly_sales`) / `avg_monthly_sales` else null end > 0.1 +order by `sum_sales` - `avg_monthly_sales`, `s_store_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q90_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q90_expected.sql new file mode 100644 index 000000000..52cdb26db --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q90_expected.sql @@ -0,0 +1,6 @@ +select cast(`amc` as decimal(15, 15)) / cast(`pmc` as decimal(15, 15)) as `am_pm_ratio` +from (select count(*) as `amc` +from `web_sales` +where `ws_sold_time_sk` = `time_dim`.`t_time_sk` and `ws_ship_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ws_web_page_sk` = `web_page`.`wp_web_page_sk` and `time_dim`.`t_hour` between asymmetric 8 and 8 + 1 and `household_demographics`.`hd_dep_count` = 6 and `web_page`.`wp_char_count` between asymmetric 5000 and 5200) as `at` +order by `am_pm_ratio` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q91_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q91_expected.sql new file mode 100644 index 000000000..4524fdd51 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q91_expected.sql @@ -0,0 +1,5 @@ +select `cc_call_center_id` as `call_center`, `cc_name` as `call_center_name`, `cc_manager` as `manager`, sum(`cr_net_loss`) as `returns_loss` +from `call_center` +where `cr_call_center_sk` = `cc_call_center_sk` and `cr_returned_date_sk` = `d_date_sk` and `cr_returning_customer_sk` = `c_customer_sk` and `cd_demo_sk` = `c_current_cdemo_sk` and `hd_demo_sk` = `c_current_hdemo_sk` and `ca_address_sk` = `c_current_addr_sk` and `d_year` = 1998 and `d_moy` = 11 and (`cd_marital_status` = 'm' and `cd_education_status` = 'unknown' or `cd_marital_status` = 'w' and `cd_education_status` = 'advanced degree') and `hd_buy_potential` like 'unknown' and `ca_gmt_offset` = -7 +group by `cc_call_center_id`, `cc_name`, `cc_manager`, `cd_marital_status`, `cd_education_status` +order by sum(`cr_net_loss`) desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q92_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q92_expected.sql new file mode 100644 index 000000000..282dc1b6c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q92_expected.sql @@ -0,0 +1,7 @@ +select sum(`ws_ext_discount_amt`) as `excess discount amount` +from `web_sales` +where `i_manufact_id` = 350 and `i_item_sk` = `ws_item_sk` and `d_date` between asymmetric cast('2000-01-27' as date) and cast('2000-01-27' as date) + interval '90' day and `d_date_sk` = `ws_sold_date_sk` and `ws_ext_discount_amt` > (select 1.3 * avg(`ws_ext_discount_amt`) +from `web_sales` +where `ws_item_sk` = `i_item_sk` and `d_date` between asymmetric cast('2000-01-27' as date) and cast('2000-01-27' as date) + interval '90' day and `d_date_sk` = `ws_sold_date_sk`) +order by sum(`ws_ext_discount_amt`) +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q93_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q93_expected.sql new file mode 100644 index 000000000..beb97f087 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q93_expected.sql @@ -0,0 +1,8 @@ +select `ss_customer_sk`, sum(`act_sales`) as `sumsales` +from (select `ss_item_sk`, `ss_ticket_number`, `ss_customer_sk`, case when `sr_return_quantity` is not null then (`ss_quantity` - `sr_return_quantity`) * `ss_sales_price` else `ss_quantity` * `ss_sales_price` end as `act_sales` +from `store_sales` +left join `store_returns` on `sr_item_sk` = `ss_item_sk` and `sr_ticket_number` = `ss_ticket_number` +where `sr_reason_sk` = `r_reason_sk` and `r_reason_desc` = 'reason 28') as `t` +group by `ss_customer_sk` +order by `sumsales`, `ss_customer_sk` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q94_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q94_expected.sql new file mode 100644 index 000000000..82cb6d065 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q94_expected.sql @@ -0,0 +1,9 @@ +select count(distinct `ws_order_number`) as `order count`, sum(`ws_ext_ship_cost`) as `total shipping cost`, sum(`ws_net_profit`) as `total net profit` +from `web_sales` as `ws1` +where `d_date` between asymmetric cast('1999-2-01' as date) and cast('1999-2-01' as date) + interval '60' day and `ws1`.`ws_ship_date_sk` = `d_date_sk` and `ws1`.`ws_ship_addr_sk` = `ca_address_sk` and `ca_state` = 'il' and `ws1`.`ws_web_site_sk` = `web_site_sk` and `web_company_name` = 'pri' and exists (select * +from `web_sales` as `ws2` +where `ws1`.`ws_order_number` = `ws2`.`ws_order_number` and `ws1`.`ws_warehouse_sk` <> `ws2`.`ws_warehouse_sk`) and not exists (select * +from `web_returns` as `wr1` +where `ws1`.`ws_order_number` = `wr1`.`wr_order_number`) +order by count(distinct `ws_order_number`) +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q95_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q95_expected.sql new file mode 100644 index 000000000..a58ad641a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q95_expected.sql @@ -0,0 +1,10 @@ +with `ws_wh` as (select `ws1`.`ws_order_number`, `ws1`.`ws_warehouse_sk` as `wh1`, `ws2`.`ws_warehouse_sk` as `wh2` +from `web_sales` as `ws1` +where `ws1`.`ws_order_number` = `ws2`.`ws_order_number` and `ws1`.`ws_warehouse_sk` <> `ws2`.`ws_warehouse_sk`) (select count(distinct `ws_order_number`) as `order count`, sum(`ws_ext_ship_cost`) as `total shipping cost`, sum(`ws_net_profit`) as `total net profit` +from `web_sales` as `ws1` +where cast(`d_date` as date) between asymmetric cast('1999-2-01' as date) and cast('1999-2-01' as date) + interval '60' day and `ws1`.`ws_ship_date_sk` = `d_date_sk` and `ws1`.`ws_ship_addr_sk` = `ca_address_sk` and `ca_state` = 'il' and `ws1`.`ws_web_site_sk` = `web_site_sk` and `web_company_name` = 'pri' and `ws1`.`ws_order_number` in (select `ws_order_number` +from `ws_wh`) and `ws1`.`ws_order_number` in (select `wr_order_number` +from `web_returns` +where `wr_order_number` = `ws_wh`.`ws_order_number`) +order by count(distinct `ws_order_number`) +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q96_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q96_expected.sql new file mode 100644 index 000000000..98a473f92 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q96_expected.sql @@ -0,0 +1,5 @@ +select count(*) +from `store_sales` +where `ss_sold_time_sk` = `time_dim`.`t_time_sk` and `ss_hdemo_sk` = `household_demographics`.`hd_demo_sk` and `ss_store_sk` = `s_store_sk` and `time_dim`.`t_hour` = 20 and `time_dim`.`t_minute` >= 30 and `household_demographics`.`hd_dep_count` = 7 and `store`.`s_store_name` = 'ese' +order by count(*) +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q97_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q97_expected.sql new file mode 100644 index 000000000..299e8448f --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q97_expected.sql @@ -0,0 +1,11 @@ +with `ssci` as (select `ss_customer_sk` as `customer_sk`, `ss_item_sk` as `item_sk` +from `store_sales` +where `ss_sold_date_sk` = `d_date_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 +group by `ss_customer_sk`, `ss_item_sk`), `csci` as (select `cs_bill_customer_sk` as `customer_sk`, `cs_item_sk` as `item_sk` +from `catalog_sales` +where `cs_sold_date_sk` = `d_date_sk` and `d_month_seq` between asymmetric 1200 and 1200 + 11 +group by `cs_bill_customer_sk`, `cs_item_sk`) (select sum(case when `ssci`.`customer_sk` is not null and `csci`.`customer_sk` is null then 1 else 0 end) as `store_only`, sum(case when `ssci`.`customer_sk` is null and `csci`.`customer_sk` is not null then 1 else 0 end) as `catalog_only`, sum(case when `ssci`.`customer_sk` is not null and `csci`.`customer_sk` is not null then 1 else 0 end) as `store_and_catalog` +from `ssci` +full join `csci` on `ssci`.`customer_sk` = `csci`.`customer_sk` and `ssci`.`item_sk` = `csci`.`item_sk` +order by +fetch next 100 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q98_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q98_expected.sql new file mode 100644 index 000000000..b026ad669 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q98_expected.sql @@ -0,0 +1,5 @@ +select `i_item_id`, `i_item_desc`, `i_category`, `i_class`, `i_current_price`, sum(`ss_ext_sales_price`) as `itemrevenue`, sum(`ss_ext_sales_price`) * 100 / (sum(sum(`ss_ext_sales_price`)) over (partition by `i_class`)) as `revenueratio` +from `store_sales` +where `ss_item_sk` = `i_item_sk` and `i_category` in ('sports', 'books', 'home') and `ss_sold_date_sk` = `d_date_sk` and cast(`d_date` as date) between asymmetric cast('1999-02-22' as date) and cast('1999-02-22' as date) + interval '30' day +group by `i_item_id`, `i_item_desc`, `i_category`, `i_class`, `i_current_price` +order by `i_category`, `i_class`, `i_item_id`, `i_item_desc`, `revenueratio` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/q99_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/q99_expected.sql new file mode 100644 index 000000000..325ca80be --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/q99_expected.sql @@ -0,0 +1,6 @@ +select `substr`(`w_warehouse_name`, 1, 20), `sm_type`, `cc_name`, sum(case when `cs_ship_date_sk` - `cs_sold_date_sk` <= 30 then 1 else 0 end) as `30 days`, sum(case when `cs_ship_date_sk` - `cs_sold_date_sk` > 30 and `cs_ship_date_sk` - `cs_sold_date_sk` <= 60 then 1 else 0 end) as `31-60 days`, sum(case when `cs_ship_date_sk` - `cs_sold_date_sk` > 60 and `cs_ship_date_sk` - `cs_sold_date_sk` <= 90 then 1 else 0 end) as `61-90 days`, sum(case when `cs_ship_date_sk` - `cs_sold_date_sk` > 90 and `cs_ship_date_sk` - `cs_sold_date_sk` <= 120 then 1 else 0 end) as `91-120 days`, sum(case when `cs_ship_date_sk` - `cs_sold_date_sk` > 120 then 1 else 0 end) as `>120 days` +from `catalog_sales` +where `d_month_seq` between asymmetric 1200 and 1200 + 11 and `cs_ship_date_sk` = `d_date_sk` and `cs_warehouse_sk` = `w_warehouse_sk` and `cs_ship_mode_sk` = `sm_ship_mode_sk` and `cs_call_center_sk` = `cc_call_center_sk` +group by `substr`(`w_warehouse_name`, 1, 20), `sm_type`, `cc_name` +order by `substr`(`w_warehouse_name`, 1, 20), `sm_type`, `cc_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rangeCurrent_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rangeCurrent_expected.sql new file mode 100644 index 000000000..e995bf931 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rangeCurrent_expected.sql @@ -0,0 +1,2 @@ +select `nationkey`, min(`nationkey`) over (partition by `regionkey` order by `comment` range between unbounded_preceding and current_row) as `min` +from `tpch`.`tiny`.`nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rangeNoPartition_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rangeNoPartition_expected.sql new file mode 100644 index 000000000..15d3d4968 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rangeNoPartition_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `discount`, `extendedprice`, min(`extendedprice`) over (order by `discount` range current_row) as `min_extendedprice`, max(`extendedprice`) over (order by `discount` range current_row) as `max_extendedprice` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rangeUnbounded_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rangeUnbounded_expected.sql new file mode 100644 index 000000000..15b9b07f5 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rangeUnbounded_expected.sql @@ -0,0 +1,2 @@ +select `nationkey`, min(`nationkey`) over (partition by `regionkey` order by `comment` range between unbounded_preceding and unbounded_following) as `min` +from `tpch`.`tiny`.`nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rankFunctionsImplicitExplicitFrame_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rankFunctionsImplicitExplicitFrame_expected.sql new file mode 100644 index 000000000..86cfe7316 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rankFunctionsImplicitExplicitFrame_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `discount`, dense_rank() over (order by `discount`), rank() over (order by `discount` range between unbounded_preceding and current_row) +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/render2_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/render2_expected.sql new file mode 100644 index 000000000..c31f8c1dc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/render2_expected.sql @@ -0,0 +1 @@ +select `render`('ala', `color`(0, `rgb`(255, 0, 0), `rgb`(0, 255, 0))), `render`('ala', `color`(0, 0, 10, `rgb`(255, 0, 0), `rgb`(0, 255, 0))) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/render_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/render_expected.sql new file mode 100644 index 000000000..3ef205e6d --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/render_expected.sql @@ -0,0 +1 @@ +select `render`(true) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/repeatedDistinctAgg_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/repeatedDistinctAgg_expected.sql new file mode 100644 index 000000000..ea001d7bc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/repeatedDistinctAgg_expected.sql @@ -0,0 +1,2 @@ +select count(distinct `n_regionkey`), count(distinct `n_regionkey`) +from `nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_expected.sql new file mode 100644 index 000000000..ad675b3b0 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_expected.sql @@ -0,0 +1,4 @@ +select `p_partkey`, `n_name`, `r_name` +from `part` +right join `nation` on `n_regionkey` = `p_partkey` +left join `region` on `n_nationkey` = `r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_inner_join_parentheses_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_inner_join_parentheses_expected.sql new file mode 100644 index 000000000..52bce9b60 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_inner_join_parentheses_expected.sql @@ -0,0 +1,5 @@ +select `p_partkey`, `n2`.`n_name`, `r_name` +from `part` +right join `nation` as `n1` on `n1`.`n_regionkey` = `p_partkey` +left join `region` on `n1`.`n_nationkey` = `r_regionkey` +inner join `nation` as `n2` on `n2`.`n_nationkey` = `r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_parentheses_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_parentheses_expected.sql new file mode 100644 index 000000000..ad675b3b0 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/right_join_left_join_parentheses_expected.sql @@ -0,0 +1,4 @@ +select `p_partkey`, `n_name`, `r_name` +from `part` +right join `nation` on `n_regionkey` = `p_partkey` +left join `region` on `n_nationkey` = `r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/right_join_null_data_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/right_join_null_data_expected.sql new file mode 100644 index 000000000..6b4e5f4ad --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/right_join_null_data_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `department`, `name`, `salary` +from `nation` +right join `workers` on `n_nationkey` = `department` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/right_outer_join_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/right_outer_join_expected.sql new file mode 100644 index 000000000..a32e6000e --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/right_outer_join_expected.sql @@ -0,0 +1,3 @@ +select `n_name`, `r_name` +from `region` +right join `nation` on `n_nationkey` = `r_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsBounded_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsBounded_expected.sql new file mode 100644 index 000000000..831b5a0c8 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsBounded_expected.sql @@ -0,0 +1,2 @@ +select `nationkey`, min(`nationkey`) over (partition by `regionkey` order by `nationkey` rows between `preceding`(2) and `following`(1)) as `min` +from `tpch`.`tiny`.`nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsDifferentOrders_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsDifferentOrders_expected.sql new file mode 100644 index 000000000..bcad6e679 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsDifferentOrders_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `extendedprice`, round(sum(`extendedprice`) over (partition by `suppkey` order by `orderkey` desc rows between unbounded_preceding and current_row), 5) as `total_extendedprice`, `discount`, round(avg(`discount`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 5) as `avg_discount` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsDisjointWindows_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsDisjointWindows_expected.sql new file mode 100644 index 000000000..846dd7351 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsDisjointWindows_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `quantity`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and `preceding`(1)), 5) as `total_quantity`, `extendedprice`, round(sum(`extendedprice`) over (partition by `suppkey` order by `orderkey` rows between current_row and `following`(1)), 5) as `total_extendedprice`, `discount`, round(avg(`discount`) over (partition by `suppkey` order by `orderkey` rows between `following`(3) and unbounded_following), 5) as `avg_discount` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsFirstLast_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsFirstLast_expected.sql new file mode 100644 index 000000000..b776f9db5 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsFirstLast_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `extendedprice`, first_value(`extendedprice`) over (partition by `suppkey` order by `extendedprice` desc rows between unbounded_preceding and unbounded_following), last_value(`extendedprice`) over (partition by `suppkey` order by `extendedprice` desc rows between unbounded_preceding and unbounded_following) +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame2F3F_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame2F3F_expected.sql new file mode 100644 index 000000000..6b164a4b6 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame2F3F_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `quantity`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between `following`(2) and `following`(3)), 5) as `total_quantity` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame2FUBF_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame2FUBF_expected.sql new file mode 100644 index 000000000..aa63fe16a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame2FUBF_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `quantity`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between `following`(2) and unbounded_following), 5) as `total_quantity` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame3P2P_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame3P2P_expected.sql new file mode 100644 index 000000000..f888e768a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsFrame3P2P_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `quantity`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between `preceding`(3) and `preceding`(2)), 5) as `total_quantity` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsFrameUBP2P_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsFrameUBP2P_expected.sql new file mode 100644 index 000000000..b9eb61846 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsFrameUBP2P_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `quantity`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and `preceding`(2)), 5) as `total_quantity` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsIdenticalWindows_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsIdenticalWindows_expected.sql new file mode 100644 index 000000000..1d7e411b2 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsIdenticalWindows_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `quantity`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 5) as `total_quantity`, `extendedprice`, round(sum(`extendedprice`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 5) as `total_extendedprice`, `discount`, round(avg(`discount`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 5) as `avg_discount` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsIntersectingWindows_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsIntersectingWindows_expected.sql new file mode 100644 index 000000000..69baf1e33 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsIntersectingWindows_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `quantity`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between `preceding`(3) and `following`(1)), 5) as `total_quantity`, `extendedprice`, round(sum(`extendedprice`) over (partition by `suppkey` order by `orderkey` rows between `preceding`(1) and `following`(2)), 5) as `total_extendedprice`, `discount`, round(avg(`discount`) over (partition by `suppkey` order by `orderkey` rows between current_row and unbounded_following), 5) as `avg_discount` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsRangeLeadLag_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsRangeLeadLag_expected.sql new file mode 100644 index 000000000..f4fdf6d8e --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsRangeLeadLag_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `discount`, lead(`discount`) over (partition by `suppkey` order by `orderkey` desc) as `next_discount`, `extendedprice`, lag(`extendedprice`) over (partition by `discount` order by `extendedprice` range current_row) as `previous_extendedprice` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsUBPImplicitCR_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsUBPImplicitCR_expected.sql new file mode 100644 index 000000000..f7107121f --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsUBPImplicitCR_expected.sql @@ -0,0 +1,3 @@ +select `orderkey`, `suppkey`, `quantity`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows unbounded_preceding), 5) as `total_quantity` +from `tpch`.`tiny`.`lineitem` +where `partkey` = 272 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/rowsUnbounded_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/rowsUnbounded_expected.sql new file mode 100644 index 000000000..b3844f18e --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/rowsUnbounded_expected.sql @@ -0,0 +1,2 @@ +select `nationkey`, min(`nationkey`) over (partition by `regionkey` order by `comment` rows between unbounded_preceding and unbounded_following) as `min` +from `tpch`.`tiny`.`nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runAggrOnColumnWithGroupBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runAggrOnColumnWithGroupBy_expected.sql new file mode 100644 index 000000000..a493f5bf6 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runAggrOnColumnWithGroupBy_expected.sql @@ -0,0 +1,3 @@ +select sum(`c1`), `c2` +from `empty` +group by `c2` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runAggrOnStarWithGroupBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runAggrOnStarWithGroupBy_expected.sql new file mode 100644 index 000000000..8bad67801 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runAggrOnStarWithGroupBy_expected.sql @@ -0,0 +1,3 @@ +select count(*), `c1` +from `empty` +group by `c1` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runAggrWithoutGroupBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runAggrWithoutGroupBy_expected.sql new file mode 100644 index 000000000..a70ae62b7 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runAggrWithoutGroupBy_expected.sql @@ -0,0 +1,2 @@ +select sum(`c1`) +from `empty` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesGroupByOridnalAndHaving_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesGroupByOridnalAndHaving_expected.sql new file mode 100644 index 000000000..d7509f3fc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesGroupByOridnalAndHaving_expected.sql @@ -0,0 +1,4 @@ +select `n_regionkey`, count(*) +from `nation` +group by 1 +having sum(`n_regionkey`) > 5 and sum(`n_regionkey`) < 20 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithGroupByOrdinal_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithGroupByOrdinal_expected.sql new file mode 100644 index 000000000..8a36fc438 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithGroupByOrdinal_expected.sql @@ -0,0 +1,3 @@ +select `n_regionkey`, count(*), sum(`n_nationkey`) +from `nation` +group by 1 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithGroupByWithFalseWherePredicate_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithGroupByWithFalseWherePredicate_expected.sql new file mode 100644 index 000000000..440eb71a5 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithGroupByWithFalseWherePredicate_expected.sql @@ -0,0 +1,4 @@ +select count(*), sum(`n_nationkey`) +from `nation` +where 1 = 2 +group by `n_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithWherePredicatesAndGroupByOrdinal_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithWherePredicatesAndGroupByOrdinal_expected.sql new file mode 100644 index 000000000..9b0a73b17 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithWherePredicatesAndGroupByOrdinal_expected.sql @@ -0,0 +1,4 @@ +select `n_regionkey`, count(*), sum(`n_regionkey`) +from `nation` +where `n_regionkey` > 2 +group by 1 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithoutGroupByButWithPredicates_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithoutGroupByButWithPredicates_expected.sql new file mode 100644 index 000000000..6073e00fa --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runAggregatesWithoutGroupByButWithPredicates_expected.sql @@ -0,0 +1,3 @@ +select count(*), sum(`n_nationkey`) +from `nation` +where 1 = 2 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runConstantGroupBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runConstantGroupBy_expected.sql new file mode 100644 index 000000000..70688679b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runConstantGroupBy_expected.sql @@ -0,0 +1,3 @@ +select 2 +from `nation` +group by 1 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runCountNull_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runCountNull_expected.sql new file mode 100644 index 000000000..0f3edb185 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runCountNull_expected.sql @@ -0,0 +1,4 @@ +select `n_regionkey`, count(null) +from `nation` +where `n_nationkey` > 5 +group by `n_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingOnEmptyResult_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingOnEmptyResult_expected.sql new file mode 100644 index 000000000..3ea5f455c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingOnEmptyResult_expected.sql @@ -0,0 +1,4 @@ +select count(`n_regionkey`) +from `nation` +where 1 = 2 +having sum(`n_regionkey`) is null \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingOutsideSubq_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingOutsideSubq_expected.sql new file mode 100644 index 000000000..7b6962f57 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingOutsideSubq_expected.sql @@ -0,0 +1,6 @@ +select `n_regionkey` +from (select `n_regionkey`, count(*) as `cnt` +from `nation` +group by `n_regionkey`) as `t` +group by `n_regionkey` +having `n_regionkey` < 3 and count(`cnt`) > 0 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithAggExpr_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithAggExpr_expected.sql new file mode 100644 index 000000000..90e5461da --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithAggExpr_expected.sql @@ -0,0 +1,3 @@ +select count(*) +from `workers` +having sum(`salary` * 2) / count(*) > 0 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithExpr_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithExpr_expected.sql new file mode 100644 index 000000000..862a7bb88 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithExpr_expected.sql @@ -0,0 +1,4 @@ +select count(*) +from `workers` +group by `id_department` * 2 +having sum(log10(`salary` + 1)) > 0 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithGrpExpr_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithGrpExpr_expected.sql new file mode 100644 index 000000000..b28071387 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithGrpExpr_expected.sql @@ -0,0 +1,4 @@ +select count(*) +from `workers` +group by `salary` * `id_department` +having `salary` * `id_department` is not null \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithMultipleAggs_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithMultipleAggs_expected.sql new file mode 100644 index 000000000..01e854443 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithMultipleAggs_expected.sql @@ -0,0 +1,4 @@ +select `p_type`, count(*) +from `part` +group by `p_type` +having count(*) > 20 and avg(`p_retailprice`) > 1000 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithNullCheck_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithNullCheck_expected.sql new file mode 100644 index 000000000..c790176b7 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithNullCheck_expected.sql @@ -0,0 +1,4 @@ +select `first_name`, count(*) +from `workers` +group by `first_name` +having `first_name` is null \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithOrderBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithOrderBy_expected.sql new file mode 100644 index 000000000..c3ada23d7 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithOrderBy_expected.sql @@ -0,0 +1,5 @@ +select `id_department`, count(*) +from `workers` +group by `id_department` +having count(*) > 1 +order by `id_department` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithoutGroupBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithoutGroupBy_expected.sql new file mode 100644 index 000000000..13a6b9274 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runHavingWithoutGroupBy_expected.sql @@ -0,0 +1,3 @@ +select count(*) +from `nation` +having count(*) > 20 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runMultipleGroupBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runMultipleGroupBy_expected.sql new file mode 100644 index 000000000..b1c19bbd0 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runMultipleGroupBy_expected.sql @@ -0,0 +1,5 @@ +select count(*), `n_regionkey`, `n_nationkey` +from `nation` +where `n_regionkey` < 2 +group by `n_nationkey`, `n_regionkey` +order by `n_regionkey`, `n_nationkey` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/runOrderByWithFromSubq_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/runOrderByWithFromSubq_expected.sql new file mode 100644 index 000000000..b270a18b0 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/runOrderByWithFromSubq_expected.sql @@ -0,0 +1,7 @@ +select `nationkey`, `regionkey`, `name` +from (select `regionkey`, `nationkey`, `name` +from `tpch`.`tiny`.`nation` +where `nationkey` < 20 +order by 2 desc +fetch next 5 rows only) as `t` +order by 2, 1 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/scalarOnColumn_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/scalarOnColumn_expected.sql new file mode 100644 index 000000000..90e6aea4e --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/scalarOnColumn_expected.sql @@ -0,0 +1,2 @@ +select sqrt(`c1`) +from `empty` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/selectCountStar_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/selectCountStar_expected.sql new file mode 100644 index 000000000..09d9a3e40 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/selectCountStar_expected.sql @@ -0,0 +1,2 @@ +select count(*) +from `empty` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/selectFromNationTiny_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/selectFromNationTiny_expected.sql new file mode 100644 index 000000000..f8b445a79 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/selectFromNationTiny_expected.sql @@ -0,0 +1,2 @@ +select `nationkey`, `name`, `regionkey` +from `tpch`.`tiny`.`nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaColumns_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaColumns_expected.sql new file mode 100644 index 000000000..8ecff0458 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaColumns_expected.sql @@ -0,0 +1,4 @@ +select `table_catalog`, `table_schema`, `table_name`, `column_name`, `data_type`, `is_nullable`, `column_default`, `comment` +from `system`.`information_schema`.`columns` +where `table_schema` <> 'jdbc' +order by `table_catalog`, `table_schema`, `table_name`, `ordinal_position` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaSchemata_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaSchemata_expected.sql new file mode 100644 index 000000000..baaf39c55 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaSchemata_expected.sql @@ -0,0 +1,2 @@ +select `catalog_name`, `schema_name` +from `system`.`information_schema`.`schemata` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaTables_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaTables_expected.sql new file mode 100644 index 000000000..38763554f --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/selectInformationSchemaTables_expected.sql @@ -0,0 +1,2 @@ +select `table_catalog`, `table_schema`, `table_name`, `table_type` +from `system`.`information_schema`.`tables` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/selectStar_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/selectStar_expected.sql new file mode 100644 index 000000000..53eaa20cc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/selectStar_expected.sql @@ -0,0 +1,2 @@ +select * +from `empty` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/simple_case_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/simple_case_expected.sql new file mode 100644 index 000000000..b0d914b6a --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/simple_case_expected.sql @@ -0,0 +1 @@ +select case when true then 33 else null end \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/skewness_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/skewness_expected.sql new file mode 100644 index 000000000..885385c09 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/skewness_expected.sql @@ -0,0 +1,2 @@ +select `skewness`(`c_bigint`), `skewness`(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/stddev_popDistinct_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/stddev_popDistinct_expected.sql new file mode 100644 index 000000000..e8bf8f8f0 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/stddev_popDistinct_expected.sql @@ -0,0 +1,2 @@ +select stddev_pop(distinct `c_bigint`), stddev_pop(distinct `c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/stddev_pop_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/stddev_pop_expected.sql new file mode 100644 index 000000000..35f6db91b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/stddev_pop_expected.sql @@ -0,0 +1,2 @@ +select stddev_pop(`c_bigint`), stddev_pop(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/stddev_sampDistinct_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/stddev_sampDistinct_expected.sql new file mode 100644 index 000000000..5fea431d4 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/stddev_sampDistinct_expected.sql @@ -0,0 +1,2 @@ +select stddev_samp(distinct `c_bigint`), stddev_samp(distinct `c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/stddev_samp_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/stddev_samp_expected.sql new file mode 100644 index 000000000..763e1f9a6 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/stddev_samp_expected.sql @@ -0,0 +1,2 @@ +select stddev_samp(`c_bigint`), stddev_samp(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/sub_select_in_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/sub_select_in_expected.sql new file mode 100644 index 000000000..d06f05aba --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/sub_select_in_expected.sql @@ -0,0 +1,4 @@ +select `n_name` +from `nation` +where `n_nationkey` in (select `r_regionkey` +from `region`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/sumDistinct_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/sumDistinct_expected.sql new file mode 100644 index 000000000..5eb0b8a59 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/sumDistinct_expected.sql @@ -0,0 +1,2 @@ +select sum(distinct `c_bigint`), sum(distinct `c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/sumOnSubq_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/sumOnSubq_expected.sql new file mode 100644 index 000000000..14d1236d9 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/sumOnSubq_expected.sql @@ -0,0 +1,3 @@ +select sum(`cnt`) +from (select count(*) as `cnt` +from `empty`) as `foo` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/sum_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/sum_expected.sql new file mode 100644 index 000000000..908037fb1 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/sum_expected.sql @@ -0,0 +1,2 @@ +select sum(`c_bigint`), sum(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/tryCastAccessible_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/tryCastAccessible_expected.sql new file mode 100644 index 000000000..60d868e08 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/tryCastAccessible_expected.sql @@ -0,0 +1 @@ +select cast(10 as varchar(65535) character set `iso-8859-1`), cast('ala' as bigint) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/unionAllSameTable_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/unionAllSameTable_expected.sql new file mode 100644 index 000000000..acfbd96df --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/unionAllSameTable_expected.sql @@ -0,0 +1,5 @@ +select * +from `nation` +union all +select * +from `nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/unionDistinctSameTable_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/unionDistinctSameTable_expected.sql new file mode 100644 index 000000000..f61291c86 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/unionDistinctSameTable_expected.sql @@ -0,0 +1,5 @@ +select * +from `nation` +union +select * +from `nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/unionMoreThanTwoTables_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/unionMoreThanTwoTables_expected.sql new file mode 100644 index 000000000..6c8620ce9 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/unionMoreThanTwoTables_expected.sql @@ -0,0 +1,9 @@ +select count(*) +from `nation` +union all +select sum(`n_nationkey`) +from `nation` +group by `n_regionkey` +union all +select `n_regionkey` +from `nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/unionOrderBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/unionOrderBy_expected.sql new file mode 100644 index 000000000..7cbc1a371 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/unionOrderBy_expected.sql @@ -0,0 +1,10 @@ +select count(*) +from `nation` +union all +select sum(`n_nationkey`) +from `nation` +group by `n_regionkey` +union all +select `n_regionkey` +from `nation` +order by 1 desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/unionWithAggregation_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/unionWithAggregation_expected.sql new file mode 100644 index 000000000..fc70e3b5c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/unionWithAggregation_expected.sql @@ -0,0 +1,6 @@ +select count(*) +from `nation` +union all +select sum(`n_nationkey`) +from `nation` +group by `n_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/useRestrictiveLimitFromSubq_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/useRestrictiveLimitFromSubq_expected.sql new file mode 100644 index 000000000..688145962 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/useRestrictiveLimitFromSubq_expected.sql @@ -0,0 +1,7 @@ +select count(*) +from (select * +from `nation` +order by +fetch next 2 rows only) as `foo` +order by +fetch next 5 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/var_popDistinct_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/var_popDistinct_expected.sql new file mode 100644 index 000000000..36b617712 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/var_popDistinct_expected.sql @@ -0,0 +1,2 @@ +select var_pop(distinct `c_bigint`), var_pop(distinct `c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/var_pop_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/var_pop_expected.sql new file mode 100644 index 000000000..10f782ddc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/var_pop_expected.sql @@ -0,0 +1,2 @@ +select var_pop(`c_bigint`), var_pop(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/var_sampDistinct_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/var_sampDistinct_expected.sql new file mode 100644 index 000000000..e612c54b4 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/var_sampDistinct_expected.sql @@ -0,0 +1,2 @@ +select var_samp(distinct `c_bigint`), var_samp(distinct `c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/var_samp_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/var_samp_expected.sql new file mode 100644 index 000000000..44b57246b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/var_samp_expected.sql @@ -0,0 +1,2 @@ +select var_samp(`c_bigint`), var_samp(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/varcharPrediction_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/varcharPrediction_expected.sql new file mode 100644 index 000000000..ece096c66 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/varcharPrediction_expected.sql @@ -0,0 +1,3 @@ +select `classify`(`features`(1, 2 + `random`(1)), `model`) +from (select `learn_classifier`(`labels`, `features`) as `model` +from (values row('cat', `features`(1, 2))) as `t` (`labels`, `features`)) as `t2` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/varianceDistinct_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/varianceDistinct_expected.sql new file mode 100644 index 000000000..4d5c8bd35 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/varianceDistinct_expected.sql @@ -0,0 +1,2 @@ +select variance(distinct `c_bigint`), variance(distinct `c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/variance_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/variance_expected.sql new file mode 100644 index 000000000..a820cb944 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/variance_expected.sql @@ -0,0 +1,2 @@ +select variance(`c_bigint`), variance(`c_double`) +from `datatype` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationAABcp_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationAABcp_expected.sql new file mode 100644 index 000000000..b1d4efeb1 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationAABcp_expected.sql @@ -0,0 +1,3 @@ +select `suppkey`, `orderkey`, `partkey`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_quantity_a`, round(sum(`discount`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_discount_a`, ntile(4) over (partition by `partkey` order by `orderkey` rows between unbounded_preceding and current_row) as `ntile_quantity_b` +from `tpch`.`tiny`.`lineitem` +where (`partkey` = 272 or `partkey` = 273) and `suppkey` > 50 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationAAcpA_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationAAcpA_expected.sql new file mode 100644 index 000000000..49d9d93ec --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationAAcpA_expected.sql @@ -0,0 +1,3 @@ +select `suppkey`, `orderkey`, `partkey`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_quantity_a`, lag(`quantity`, 1, 0.0) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row) as `lag_quantity_a`, round(sum(`discount`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_discount_a` +from `tpch`.`tiny`.`lineitem` +where (`partkey` = 272 or `partkey` = 273) and `suppkey` > 50 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationABA_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationABA_expected.sql new file mode 100644 index 000000000..21bf25a43 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationABA_expected.sql @@ -0,0 +1,3 @@ +select `suppkey`, `orderkey`, `partkey`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_quantity_a`, round(sum(`quantity`) over (partition by `orderkey` order by `shipdate` rows between unbounded_preceding and current_row), 3) as `sum_quantity_b`, round(sum(`discount`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_discount_a` +from `tpch`.`tiny`.`lineitem` +where (`partkey` = 272 or `partkey` = 273) and `suppkey` > 50 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationABcpA_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationABcpA_expected.sql new file mode 100644 index 000000000..b1c03e1af --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationABcpA_expected.sql @@ -0,0 +1,3 @@ +select `suppkey`, `orderkey`, `partkey`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_quantity_a`, lag(`quantity`, 1, 0.0) over (partition by `partkey` order by `orderkey` rows between unbounded_preceding and current_row) as `lag_quantity_b`, round(sum(`discount`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_discount_a` +from `tpch`.`tiny`.`lineitem` +where (`partkey` = 272 or `partkey` = 273) and `suppkey` > 50 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationBcpAA_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationBcpAA_expected.sql new file mode 100644 index 000000000..582c2224b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/windowSpecificationBcpAA_expected.sql @@ -0,0 +1,3 @@ +select `suppkey`, `orderkey`, `partkey`, nth_value(`quantity`, 4) over (partition by `partkey` order by `orderkey` rows between unbounded_preceding and current_row) as `nth_value_quantity_b`, round(sum(`quantity`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_quantity_a`, round(sum(`discount`) over (partition by `suppkey` order by `orderkey` rows between unbounded_preceding and current_row), 3) as `sum_discount_a` +from `tpch`.`tiny`.`lineitem` +where (`partkey` = 272 or `partkey` = 273) and `suppkey` > 50 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withCount_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withCount_expected.sql new file mode 100644 index 000000000..dace59094 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withCount_expected.sql @@ -0,0 +1,2 @@ +select count(distinct `n_regionkey`), count(*) +from `nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withDuplicates_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withDuplicates_expected.sql new file mode 100644 index 000000000..61d55509b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withDuplicates_expected.sql @@ -0,0 +1,2 @@ +select distinct `n_regionkey` +from `nation` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withExprAccessingAnotherAndAlsoFromParents_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withExprAccessingAnotherAndAlsoFromParents_expected.sql new file mode 100644 index 000000000..6756c2b44 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withExprAccessingAnotherAndAlsoFromParents_expected.sql @@ -0,0 +1,4 @@ +with `w1` as (select * +from `nation`), `w2` as (select * +from `w1`) (select count(*) +from `w1`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withExprReferencedInWhereClause_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withExprReferencedInWhereClause_expected.sql new file mode 100644 index 000000000..67233ebda --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withExprReferencedInWhereClause_expected.sql @@ -0,0 +1,6 @@ +with `wregion` as (select min(`n_regionkey`) +from `nation` +where `n_name` >= 'n') (select `r_regionkey`, `r_name` +from `region` +where `r_regionkey` in (select * +from `wregion`)) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withExprRepeated_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withExprRepeated_expected.sql new file mode 100644 index 000000000..5e19f2dd1 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withExprRepeated_expected.sql @@ -0,0 +1,4 @@ +with `wnation` as (select `n_name`, `n_nationkey`, `n_regionkey` +from `nation`) (select `n1`.`n_name`, `n2`.`n_name` +from `wnation` as `n1` +inner join `wnation` as `n2` on `n1`.`n_nationkey` = `n2`.`n_regionkey`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withExprUsingAnotherWithExpr_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withExprUsingAnotherWithExpr_expected.sql new file mode 100644 index 000000000..70b6e3ba5 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withExprUsingAnotherWithExpr_expected.sql @@ -0,0 +1,9 @@ +with `w1` as (select min(`n_nationkey`) as `x`, max(`n_regionkey`) as `y` +from `nation`), `w2` as (select `x`, `y` +from `w1`) (select count(*) as `count`, `n_regionkey` +from `nation` +group by `n_regionkey` +union all +select * +from `w2`) +order by `n_regionkey`, `count` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withExprUsingOrderbyLimit_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withExprUsingOrderbyLimit_expected.sql new file mode 100644 index 000000000..f64643d33 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withExprUsingOrderbyLimit_expected.sql @@ -0,0 +1,7 @@ +with `ordered` as (select `n_nationkey` as `a`, `n_regionkey` as `b`, `n_name` as `c` +from `nation` +order by 1, 2 +fetch next 10 rows only) (select * +from `ordered` +order by 1, 2 +fetch next 5 rows only) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withExprWithNoReferenceInParent_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withExprWithNoReferenceInParent_expected.sql new file mode 100644 index 000000000..19e1c00fc --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withExprWithNoReferenceInParent_expected.sql @@ -0,0 +1,4 @@ +with `ct` as (select * +from `region`) (select `n_name` +from `nation` +where `n_nationkey` = 0) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withGroupByAndOrderByInSubq_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withGroupByAndOrderByInSubq_expected.sql new file mode 100644 index 000000000..988e44ceb --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withGroupByAndOrderByInSubq_expected.sql @@ -0,0 +1,6 @@ +select `foo`.`c`, `foo`.`n_regionkey` +from (select `n_regionkey`, count(*) as `c` +from `nation` +group by `n_regionkey` +order by `n_regionkey` +fetch next 2 rows only) as `foo` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withGroupByDistinctAgg_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withGroupByDistinctAgg_expected.sql new file mode 100644 index 000000000..2d769bf92 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withGroupByDistinctAgg_expected.sql @@ -0,0 +1,4 @@ +select `n_regionkey`, count(distinct `n_name`) +from `nation` +group by `n_regionkey` +having `n_regionkey` < 4 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withGroupByInSubq_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withGroupByInSubq_expected.sql new file mode 100644 index 000000000..7c3fe4c08 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withGroupByInSubq_expected.sql @@ -0,0 +1,6 @@ +select count(*) +from (select `ps_suppkey`, count(*) +from `partsupp` +group by `ps_suppkey` +order by +fetch next 20 rows only) as `t1` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withGroupBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withGroupBy_expected.sql new file mode 100644 index 000000000..17d70b530 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withGroupBy_expected.sql @@ -0,0 +1,4 @@ +select distinct `n_regionkey`, count(*) +from `nation` +where `n_nationkey` > 0 +group by `n_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withGroupOrderHaving_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withGroupOrderHaving_expected.sql new file mode 100644 index 000000000..6015fd558 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withGroupOrderHaving_expected.sql @@ -0,0 +1,4 @@ +select min(10), 3 as `col1` +group by 2 +having 6 > 5 +order by 1 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withJoinInSubq_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withJoinInSubq_expected.sql new file mode 100644 index 000000000..5e7a64e6c --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withJoinInSubq_expected.sql @@ -0,0 +1,6 @@ +select count(*) +from (select * +from `nation` as `n1` +inner join `nation` as `n2` on `n1`.`n_regionkey` = `n2`.`n_regionkey` +order by +fetch next 5 rows only) as `foo` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withLimitZero_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withLimitZero_expected.sql new file mode 100644 index 000000000..05114663f --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withLimitZero_expected.sql @@ -0,0 +1,5 @@ +select count(*) +from (select * +from `nation` +order by +fetch next 0 rows only) as `foo` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withNoDuplicates_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withNoDuplicates_expected.sql new file mode 100644 index 000000000..4633b6d2b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withNoDuplicates_expected.sql @@ -0,0 +1,2 @@ +select distinct `r_name` +from `region` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withOrderBy_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withOrderBy_expected.sql new file mode 100644 index 000000000..d866e7634 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withOrderBy_expected.sql @@ -0,0 +1,3 @@ +select distinct `n_regionkey` +from `nation` +order by `n_regionkey` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withSimpleExprInNestedFromClause_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withSimpleExprInNestedFromClause_expected.sql new file mode 100644 index 000000000..14fc30344 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withSimpleExprInNestedFromClause_expected.sql @@ -0,0 +1,4 @@ +with `nested` as (select * +from `nation`) (select count(*) +from (select * +from `nested`) as `a`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withSimpleLimit_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withSimpleLimit_expected.sql new file mode 100644 index 000000000..076257693 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withSimpleLimit_expected.sql @@ -0,0 +1,4 @@ +select `n_nationkey` +from `nation` +order by `n_nationkey` desc +fetch next 5 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withSubq_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withSubq_expected.sql new file mode 100644 index 000000000..35aa66b14 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withSubq_expected.sql @@ -0,0 +1,5 @@ +select count(*) +from (select * +from `nation` +order by +fetch next 10 rows only) as `t1` \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withUnionAll_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withUnionAll_expected.sql new file mode 100644 index 000000000..d7f12d305 --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withUnionAll_expected.sql @@ -0,0 +1,7 @@ +select 1 +union all +select 2 +union all +select 4 * 5 +union all +select -5 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withWhereClause_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withWhereClause_expected.sql new file mode 100644 index 000000000..09b9e1a3b --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withWhereClause_expected.sql @@ -0,0 +1,2 @@ +select 1 +where true and 2 = 2 \ No newline at end of file diff --git a/coral-trino/src/test/resources/product_test_cases_expected/withWhereFalse_expected.sql b/coral-trino/src/test/resources/product_test_cases_expected/withWhereFalse_expected.sql new file mode 100644 index 000000000..0bb7d95cd --- /dev/null +++ b/coral-trino/src/test/resources/product_test_cases_expected/withWhereFalse_expected.sql @@ -0,0 +1,2 @@ +select count(*), 1 +where false \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/10_expected.sql b/coral-trino/src/test/resources/queries/10_expected.sql new file mode 100644 index 000000000..a1652fe28 --- /dev/null +++ b/coral-trino/src/test/resources/queries/10_expected.sql @@ -0,0 +1,6 @@ +select `c_custkey`, `c_name`, sum(`l_extendedprice` * (1 - `l_discount`)) as `revenue`, `c_acctbal`, `n_name`, `c_address`, `c_phone`, `c_comment` +from `nation` +where `c_custkey` = `o_custkey` and `l_orderkey` = `o_orderkey` and `o_orderdate` >= date '2013-03-05' and `o_orderdate` < date '2013-03-05' + interval '3' month and `l_returnflag` = 'r' and `c_nationkey` = `n_nationkey` +group by `c_custkey`, `c_name`, `c_acctbal`, `c_phone`, `n_name`, `c_address`, `c_comment` +order by `revenue` desc +fetch next 20 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/11_expected.sql b/coral-trino/src/test/resources/queries/11_expected.sql new file mode 100644 index 000000000..1f1415f9c --- /dev/null +++ b/coral-trino/src/test/resources/queries/11_expected.sql @@ -0,0 +1,8 @@ +select `ps_partkey`, sum(`ps_supplycost` * `ps_availqty`) as `value` +from `nation` +where `ps_suppkey` = `s_suppkey` and `s_nationkey` = `n_nationkey` and `n_name` = 'nation name' +group by `ps_partkey` +having sum(`ps_supplycost` * `ps_availqty`) > (select sum(`ps_supplycost` * `ps_availqty`) * 33 +from `nation` +where `ps_suppkey` = `s_suppkey` and `s_nationkey` = `n_nationkey` and `n_name` = 'nation name') +order by `value` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/12_expected.sql b/coral-trino/src/test/resources/queries/12_expected.sql new file mode 100644 index 000000000..a31122275 --- /dev/null +++ b/coral-trino/src/test/resources/queries/12_expected.sql @@ -0,0 +1,5 @@ +select `l_shipmode`, sum(case when `o_orderpriority` = '1-urgent' or `o_orderpriority` = '2-high' then 1 else 0 end) as `high_line_count`, sum(case when `o_orderpriority` <> '1-urgent' and `o_orderpriority` <> '2-high' then 1 else 0 end) as `low_line_count` +from `lineitem` +where `o_orderkey` = `l_orderkey` and `l_shipmode` in ('ship mode 1', 'ship mode 2') and `l_commitdate` < `l_receiptdate` and `l_shipdate` < `l_commitdate` and `l_receiptdate` >= date '2013-03-05' and `l_receiptdate` < date '2013-03-05' + interval '1' year +group by `l_shipmode` +order by `l_shipmode` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/13_expected.sql b/coral-trino/src/test/resources/queries/13_expected.sql new file mode 100644 index 000000000..d44abe94c --- /dev/null +++ b/coral-trino/src/test/resources/queries/13_expected.sql @@ -0,0 +1,7 @@ +select `c_count`, count(*) as `custdist` +from (select `c_custkey`, count(`o_orderkey`) +from `customer` +left join `orders` on `c_custkey` = `o_custkey` and not `o_comment` like '%comment like 1%comment like 2%' +group by `c_custkey`) as `c_orders` (`c_custkey`, `c_count`) +group by `c_count` +order by `custdist` desc, `c_count` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/14_expected.sql b/coral-trino/src/test/resources/queries/14_expected.sql new file mode 100644 index 000000000..e196d74b1 --- /dev/null +++ b/coral-trino/src/test/resources/queries/14_expected.sql @@ -0,0 +1,3 @@ +select 100.00 * sum(case when `p_type` like 'promo%' then `l_extendedprice` * (1 - `l_discount`) else 0 end) / sum(`l_extendedprice` * (1 - `l_discount`)) as `promo_revenue` +from `part` +where `l_partkey` = `p_partkey` and `l_shipdate` >= date '2013-03-05' and `l_shipdate` < date '2013-03-05' + interval '1' month \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/15_expected.sql b/coral-trino/src/test/resources/queries/15_expected.sql new file mode 100644 index 000000000..039c088af --- /dev/null +++ b/coral-trino/src/test/resources/queries/15_expected.sql @@ -0,0 +1,2 @@ +select * +from `dummy` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/16_expected.sql b/coral-trino/src/test/resources/queries/16_expected.sql new file mode 100644 index 000000000..cb05d1141 --- /dev/null +++ b/coral-trino/src/test/resources/queries/16_expected.sql @@ -0,0 +1,7 @@ +select `p_brand`, `p_type`, `p_size`, count(distinct `ps_suppkey`) as `supplier_cnt` +from `part` +where `p_partkey` = `ps_partkey` and `p_brand` <> 'part brand' and not `p_type` like 'part type like%' and `p_size` in (3, 4, 5, 6, 7, 8, 9, 10) and `ps_suppkey` not in (select `s_suppkey` +from `supplier` +where `s_comment` like '%customer%complaints%') +group by `p_brand`, `p_type`, `p_size` +order by `supplier_cnt` desc, `p_brand`, `p_type`, `p_size` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/17_expected.sql b/coral-trino/src/test/resources/queries/17_expected.sql new file mode 100644 index 000000000..2a61a9d51 --- /dev/null +++ b/coral-trino/src/test/resources/queries/17_expected.sql @@ -0,0 +1,5 @@ +select sum(`l_extendedprice`) / 7.0 as `avg_yearly` +from `part` +where `p_partkey` = `l_partkey` and `p_brand` = 'part brand' and `p_container` = 'part container' and `l_quantity` < (select 0.2 * avg(`l_quantity`) +from `lineitem` +where `l_partkey` = `p_partkey`) \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/18_expected.sql b/coral-trino/src/test/resources/queries/18_expected.sql new file mode 100644 index 000000000..2fef6eda7 --- /dev/null +++ b/coral-trino/src/test/resources/queries/18_expected.sql @@ -0,0 +1,9 @@ +select `c_name`, `c_custkey`, `o_orderkey`, `o_orderdate`, `o_totalprice`, sum(`l_quantity`) +from `lineitem` +where `o_orderkey` in (select `l_orderkey` +from `lineitem` +group by `l_orderkey` +having sum(`l_quantity`) > 33) and `c_custkey` = `o_custkey` and `o_orderkey` = `l_orderkey` +group by `c_name`, `c_custkey`, `o_orderkey`, `o_orderdate`, `o_totalprice` +order by `o_totalprice` desc, `o_orderdate` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/19_expected.sql b/coral-trino/src/test/resources/queries/19_expected.sql new file mode 100644 index 000000000..94d1a9e82 --- /dev/null +++ b/coral-trino/src/test/resources/queries/19_expected.sql @@ -0,0 +1,3 @@ +select sum(`l_extendedprice` * (1 - `l_discount`)) as `revenue` +from `part` +where `p_partkey` = `l_partkey` and `p_brand` = 'part brand 1' and `p_container` in ('sm case', 'sm box', 'sm pack', 'sm pkg') and `l_quantity` >= 11 and `l_quantity` <= 11 + 10 and `p_size` between asymmetric 1 and 5 and `l_shipmode` in ('air', 'air reg') and `l_shipinstruct` = 'deliver in person' or `p_partkey` = `l_partkey` and `p_brand` = 'part brand 2' and `p_container` in ('med bag', 'med box', 'med pkg', 'med pack') and `l_quantity` >= 22 and `l_quantity` <= 22 + 10 and `p_size` between asymmetric 1 and 10 and `l_shipmode` in ('air', 'air reg') and `l_shipinstruct` = 'deliver in person' or `p_partkey` = `l_partkey` and `p_brand` = 'part brand 3' and `p_container` in ('lg case', 'lg box', 'lg pack', 'lg pkg') and `l_quantity` >= 33 and `l_quantity` <= 33 + 10 and `p_size` between asymmetric 1 and 15 and `l_shipmode` in ('air', 'air reg') and `l_shipinstruct` = 'deliver in person' \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/1_expected.sql b/coral-trino/src/test/resources/queries/1_expected.sql new file mode 100644 index 000000000..10b7020a0 --- /dev/null +++ b/coral-trino/src/test/resources/queries/1_expected.sql @@ -0,0 +1,5 @@ +select `l_returnflag`, `l_linestatus`, sum(`l_quantity`) as `sum_qty`, sum(`l_extendedprice`) as `sum_base_price`, sum(`l_extendedprice` * (1 - `l_discount`)) as `sum_disc_price`, sum(`l_extendedprice` * (1 - `l_discount`) * (1 + `l_tax`)) as `sum_charge`, avg(`l_quantity`) as `avg_qty`, avg(`l_extendedprice`) as `avg_price`, avg(`l_discount`) as `avg_disc`, count(*) as `count_order` +from `lineitem` +where `l_shipdate` <= date '1998-12-01' - interval '3' day +group by `l_returnflag`, `l_linestatus` +order by `l_returnflag`, `l_linestatus` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/20_expected.sql b/coral-trino/src/test/resources/queries/20_expected.sql new file mode 100644 index 000000000..e25a86d71 --- /dev/null +++ b/coral-trino/src/test/resources/queries/20_expected.sql @@ -0,0 +1,10 @@ +select `s_name`, `s_address` +from `nation` +where `s_suppkey` in (select `ps_suppkey` +from `partsupp` +where `ps_partkey` in (select `p_partkey` +from `part` +where `p_name` like 'part name like%') and `ps_availqty` > (select 0.5 * sum(`l_quantity`) +from `lineitem` +where `l_partkey` = `ps_partkey` and `l_suppkey` = `ps_suppkey` and `l_shipdate` >= date '2013-03-05' and `l_shipdate` < date '2013-03-05' + interval '1' year)) and `s_nationkey` = `n_nationkey` and `n_name` = 'nation name' +order by `s_name` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/21_expected.sql b/coral-trino/src/test/resources/queries/21_expected.sql new file mode 100644 index 000000000..94831fdf1 --- /dev/null +++ b/coral-trino/src/test/resources/queries/21_expected.sql @@ -0,0 +1,10 @@ +select `s_name`, count(*) as `numwait` +from `nation` +where `s_suppkey` = `l1`.`l_suppkey` and `o_orderkey` = `l1`.`l_orderkey` and `o_orderstatus` = 'f' and `l1`.`l_receiptdate` > `l1`.`l_commitdate` and exists (select * +from `lineitem` as `l2` +where `l2`.`l_orderkey` = `l1`.`l_orderkey` and `l2`.`l_suppkey` <> `l1`.`l_suppkey`) and not exists (select * +from `lineitem` as `l3` +where `l3`.`l_orderkey` = `l1`.`l_orderkey` and `l3`.`l_suppkey` <> `l1`.`l_suppkey` and `l3`.`l_receiptdate` > `l3`.`l_commitdate`) and `s_nationkey` = `n_nationkey` and `n_name` = 'nation name' +group by `s_name` +order by `numwait` desc, `s_name` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/22_expected.sql b/coral-trino/src/test/resources/queries/22_expected.sql new file mode 100644 index 000000000..a98f21fdf --- /dev/null +++ b/coral-trino/src/test/resources/queries/22_expected.sql @@ -0,0 +1,10 @@ +select `cntrycode`, count(*) as `numcust`, sum(`c_acctbal`) as `totacctbal` +from (select `substr`(`c_phone`, 1, 2) as `cntrycode`, `c_acctbal` +from `customer` +where `substr`(`c_phone`, 1, 2) in ('phone 1', 'phone 2', 'phone 3', 'phone 4', 'phone 5', 'phone 6', 'phone 7') and `c_acctbal` > (select avg(`c_acctbal`) +from `customer` +where `c_acctbal` > 0.00 and `substr`(`c_phone`, 1, 2) in ('phone 1', 'phone 2', 'phone 3', 'phone 4', 'phone 5', 'phone 6', 'phone 7')) and not exists (select * +from `orders` +where `o_custkey` = `c_custkey`)) as `custsale` +group by `cntrycode` +order by `cntrycode` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/2_expected.sql b/coral-trino/src/test/resources/queries/2_expected.sql new file mode 100644 index 000000000..7ab56f81f --- /dev/null +++ b/coral-trino/src/test/resources/queries/2_expected.sql @@ -0,0 +1,7 @@ +select `s_acctbal`, `s_name`, `n_name`, `p_partkey`, `p_mfgr`, `s_address`, `s_phone`, `s_comment` +from `part` +where `p_partkey` = `ps_partkey` and `s_suppkey` = `ps_suppkey` and `p_size` = 33 and `p_type` like '%part type like' and `s_nationkey` = `n_nationkey` and `n_regionkey` = `r_regionkey` and `r_name` = 'region name' and `ps_supplycost` = (select min(`ps_supplycost`) +from `partsupp` +where `p_partkey` = `ps_partkey` and `s_suppkey` = `ps_suppkey` and `s_nationkey` = `n_nationkey` and `n_regionkey` = `r_regionkey` and `r_name` = 'region name') +order by `s_acctbal` desc, `n_name`, `s_name`, `p_partkey` +fetch next 100 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/3_expected.sql b/coral-trino/src/test/resources/queries/3_expected.sql new file mode 100644 index 000000000..7917aa172 --- /dev/null +++ b/coral-trino/src/test/resources/queries/3_expected.sql @@ -0,0 +1,6 @@ +select `l_orderkey`, sum(`l_extendedprice` * (1 - `l_discount`)) as `revenue`, `o_orderdate`, `o_shippriority` +from `lineitem` +where `c_mktsegment` = 'market segment' and `c_custkey` = `o_custkey` and `l_orderkey` = `o_orderkey` and `o_orderdate` < date '2013-03-05' and `l_shipdate` > date '2013-03-05' +group by `l_orderkey`, `o_orderdate`, `o_shippriority` +order by `revenue` desc, `o_orderdate` +fetch next 10 rows only \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/4_expected.sql b/coral-trino/src/test/resources/queries/4_expected.sql new file mode 100644 index 000000000..fe1545704 --- /dev/null +++ b/coral-trino/src/test/resources/queries/4_expected.sql @@ -0,0 +1,7 @@ +select `o_orderpriority`, count(*) as `order_count` +from `orders` +where `o_orderdate` >= date '2013-03-05' and `o_orderdate` < date '2013-03-05' + interval '3' month and exists (select * +from `lineitem` +where `l_orderkey` = `o_orderkey` and `l_commitdate` < `l_receiptdate`) +group by `o_orderpriority` +order by `o_orderpriority` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/5_expected.sql b/coral-trino/src/test/resources/queries/5_expected.sql new file mode 100644 index 000000000..edb2cd978 --- /dev/null +++ b/coral-trino/src/test/resources/queries/5_expected.sql @@ -0,0 +1,5 @@ +select `n_name`, sum(`l_extendedprice` * (1 - `l_discount`)) as `revenue` +from `region` +where `c_custkey` = `o_custkey` and `l_orderkey` = `o_orderkey` and `l_suppkey` = `s_suppkey` and `c_nationkey` = `s_nationkey` and `s_nationkey` = `n_nationkey` and `n_regionkey` = `r_regionkey` and `r_name` = 'region name' and `o_orderdate` >= date '2013-03-05' and `o_orderdate` < date '2013-03-05' + interval '1' year +group by `n_name` +order by `revenue` desc \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/6_expected.sql b/coral-trino/src/test/resources/queries/6_expected.sql new file mode 100644 index 000000000..f2e37aa20 --- /dev/null +++ b/coral-trino/src/test/resources/queries/6_expected.sql @@ -0,0 +1,3 @@ +select sum(`l_extendedprice` * `l_discount`) as `revenue` +from `lineitem` +where `l_shipdate` >= date '2013-03-05' and `l_shipdate` < date '2013-03-05' + interval '1' year and `l_discount` between asymmetric 33 - 0.01 and 33 + 0.01 and `l_quantity` < 44 \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/7_expected.sql b/coral-trino/src/test/resources/queries/7_expected.sql new file mode 100644 index 000000000..2c6e6aa5f --- /dev/null +++ b/coral-trino/src/test/resources/queries/7_expected.sql @@ -0,0 +1,6 @@ +select `supp_nation`, `cust_nation`, `l_year`, sum(`volume`) as `revenue` +from (select `n1`.`n_name` as `supp_nation`, `n2`.`n_name` as `cust_nation`, extract(year from `l_shipdate`) as `l_year`, `l_extendedprice` * (1 - `l_discount`) as `volume` +from `nation` as `n2` +where `s_suppkey` = `l_suppkey` and `o_orderkey` = `l_orderkey` and `c_custkey` = `o_custkey` and `s_nationkey` = `n1`.`n_nationkey` and `c_nationkey` = `n2`.`n_nationkey` and (`n1`.`n_name` = 'nation name 1' and `n2`.`n_name` = 'nation name 2' or `n1`.`n_name` = 'nation name 2' and `n2`.`n_name` = 'nation name 1') and `l_shipdate` between asymmetric date '1995-01-01' and date '1996-12-31') as `shipping` +group by `supp_nation`, `cust_nation`, `l_year` +order by `supp_nation`, `cust_nation`, `l_year` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/8_expected.sql b/coral-trino/src/test/resources/queries/8_expected.sql new file mode 100644 index 000000000..e75771723 --- /dev/null +++ b/coral-trino/src/test/resources/queries/8_expected.sql @@ -0,0 +1,6 @@ +select `o_year`, sum(case when `nation` = 'nation name' then `volume` else 0 end) / sum(`volume`) as `mkt_share` +from (select extract(year from `o_orderdate`) as `o_year`, `l_extendedprice` * (1 - `l_discount`) as `volume`, `n2`.`n_name` as `nation` +from `region` +where `p_partkey` = `l_partkey` and `s_suppkey` = `l_suppkey` and `l_orderkey` = `o_orderkey` and `o_custkey` = `c_custkey` and `c_nationkey` = `n1`.`n_nationkey` and `n1`.`n_regionkey` = `r_regionkey` and `r_name` = 'region name' and `s_nationkey` = `n2`.`n_nationkey` and `o_orderdate` between asymmetric date '1995-01-01' and date '1996-12-31' and `p_type` = 'part type') as `all_nations` +group by `o_year` +order by `o_year` \ No newline at end of file diff --git a/coral-trino/src/test/resources/queries/9_expected.sql b/coral-trino/src/test/resources/queries/9_expected.sql new file mode 100644 index 000000000..d8abf186a --- /dev/null +++ b/coral-trino/src/test/resources/queries/9_expected.sql @@ -0,0 +1,6 @@ +select `nation`, `o_year`, sum(`amount`) as `sum_profit` +from (select `n_name` as `nation`, extract(year from `o_orderdate`) as `o_year`, `l_extendedprice` * (1 - `l_discount`) - `ps_supplycost` * `l_quantity` as `amount` +from `nation` +where `s_suppkey` = `l_suppkey` and `ps_suppkey` = `l_suppkey` and `ps_partkey` = `l_partkey` and `p_partkey` = `l_partkey` and `o_orderkey` = `l_orderkey` and `s_nationkey` = `n_nationkey` and `p_name` like '%part name like%') as `profit` +group by `nation`, `o_year` +order by `nation`, `o_year` desc \ No newline at end of file