// The following tests use `SELECT *` with `GROUP BY`, which is not specified by the PartiQL or SQL92 spec. Tracking // issue for partiql-spec: https://github.com/partiql/partiql-spec/issues/48. The test behavior follows what's // currently implemented in the Kotlin reference implementation. 'select-star-group-by'::[ envs::{ simple_1_col_1_group: [ { col1: 1 }, { col1: 1 } ], sales_report:[ { fiscal_year:2000T, rep:"Bob", total_sales:1.0 }, { fiscal_year:2000T, rep:"Jon", total_sales:2.0 }, { fiscal_year:2000T, rep:"Meg", total_sales:3.0 }, { fiscal_year:2001T, rep:"Bob", total_sales:10.0 }, { fiscal_year:2001T, rep:"Jon", total_sales:20.0 }, { fiscal_year:2001T, rep:"Meg", total_sales:30.0 }, { fiscal_year:2002T, rep:"Bob", total_sales:100.0 }, { fiscal_year:2002T, rep:"Jon", total_sales:200.0 }, { fiscal_year:2002T, rep:"Meg", total_sales:300.0 } ], simple_2_col_1_group: [ { col1: 1, col2: 10 }, { col1: 1, col2: 10 } ], simple_1_col_2_groups: [ { col1: 1 }, { col1: 2 }, { col1: 1 }, { col1: 2 } ], simple_2_col_2_groups: [ { col1: 1, col2: 10}, { col1: 11, col2: 110}, { col1: 1, col2: 10 }, { col1: 11, col2: 110 } ], string_groups: [ { col1: "a" }, { col1: "a" } ], string_numbers: [ { num: "1" }, { num: "2" } ], products_sparse: [ { productId: 1, categoryId: 20, regionId: 100, supplierId_nulls: 10, supplierId_missings: 10, supplierId_mixed: 10, price_nulls: 1.0, price_missings: 1.0, price_mixed: 1.0 }, { productId: 2, categoryId: 20, regionId: 100, supplierId_nulls: 10, supplierId_missings: 10, supplierId_mixed: 10, price_nulls: 2.0, price_missings: 2.0, price_mixed: 2.0 }, { productId: 3, categoryId: 20, regionId: 200, supplierId_nulls: 10, supplierId_missings: 10, supplierId_mixed: 10, price_nulls: 3.0, price_missings: 3.0, price_mixed: 3.0 }, { productId: 5, categoryId: 21, regionId: 100, supplierId_nulls: null, price_nulls: null }, { productId: 4, categoryId: 20, regionId: 100, supplierId_nulls: null, supplierId_mixed: null, price_nulls: null, price_mixed: null }, { productId: 6, categoryId: 21, regionId: 100, supplierId_nulls: 11, supplierId_missings: 11, supplierId_mixed: 11, price_nulls: 4.0, price_missings: 4.0, price_mixed: 4.0 }, { productId: 7, categoryId: 21, regionId: 200, supplierId_nulls: 11, supplierId_missings: 11, supplierId_mixed: 11, price_nulls: 5.0, price_missings: 5.0, price_mixed: 5.0 }, { productId: 8, categoryId: 21, regionId: 200, supplierId_nulls: null, supplierId_mixed: null, price_nulls: null, price_mixed: null }, { productId: 9, categoryId: 21, regionId: 200, supplierId_nulls: null, price_nulls: null, }, { productId: 10, categoryId: 21, regionId: 200, supplierId_nulls: null, supplierId_mixed: null, price_nulls: null, } ], join_me: [ { 'foo': 20 }, { 'foo': 30 } ], different_types_per_row: [ { 'a': 1001 }, 1002.0, "one-thousand and three" ] }, { name:"SELECT * with GROUP BY", statement:"SELECT * FROM simple_1_col_1_group GROUP BY col1", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1 } ] } }, { name:"SELECT * with GROUP BY and GROUP AS", statement:"SELECT * FROM simple_1_col_1_group GROUP BY col1 GROUP AS grp", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1, grp:$bag::[ { simple_1_col_1_group:{ col1:1 } }, { simple_1_col_1_group:{ col1:1 } } ] } ] } }, { name:"GROUP BY binding referenced in FROM clause", statement:"SELECT * FROM non_included_sales_report, gb_binding WHERE fiscal_year >= `2001T` GROUP BY rep AS gb_binding", assert:[ { evalMode:EvalModeError, result:EvaluationFail }, { result:EvaluationSuccess, evalMode:EvalModeCoerce, output:$bag::[] } ] }, { name:"GROUP BY binding referenced in WHERE clause", statement:"SELECT * FROM non_included_sales_report, gb_binding WHERE gb_binding = 1 GROUP BY rep AS gb_binding", assert:[ { evalMode:EvalModeError, result:EvaluationFail }, { result:EvaluationSuccess, evalMode:EvalModeCoerce, output:$bag::[] } ] }, { name:"GROUP AS binding referenced in FROM clause", statement:"SELECT * FROM non_included_sales_report, gba_binding WHERE fiscal_year >= `2001T` GROUP BY rep GROUP AS gba_binding", assert:[ { evalMode:EvalModeError, result:EvaluationFail }, { result:EvaluationSuccess, evalMode:EvalModeCoerce, output:$bag::[] } ] }, { name:"GROUP AS binding referenced in WHERE clause", statement:"SELECT * FROM non_included_sales_report, gba_binding WHERE gba_binding = 1 GROUP BY rep GROUP AS gba_binding", assert:[ { evalMode:EvalModeError, result:EvaluationFail }, { result:EvaluationSuccess, evalMode:EvalModeCoerce, output:$bag::[] } ] }, { name:"SELECT * FROM [] GROUP BY doesntMatterWontBeEvaluated", statement:"SELECT * FROM [] GROUP BY doesntMatterWontBeEvaluated", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ ] } }, { name:"SELECT * FROM simple_2_col_1_group GROUP BY col1", statement:"SELECT * FROM simple_2_col_1_group GROUP BY col1", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1 } ] } }, { name:"SELECT * FROM simple_2_col_1_group GROUP BY col2", statement:"SELECT * FROM simple_2_col_1_group GROUP BY col2", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col2:10 } ] } }, { name:"SELECT * FROM simple_1_col_2_groups GROUP BY col1", statement:"SELECT * FROM simple_1_col_2_groups GROUP BY col1", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1 }, { col1:2 } ] } }, { name:"SELECT * FROM simple_2_col_2_groups GROUP BY col1", statement:"SELECT * FROM simple_2_col_2_groups GROUP BY col1", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1 }, { col1:11 } ] } }, { name:"SELECT * FROM simple_2_col_2_groups GROUP BY col2", statement:"SELECT * FROM simple_2_col_2_groups GROUP BY col2", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col2:10 }, { col2:110 } ] } }, { name:"SELECT * FROM simple_1_col_1_group GROUP BY col1 + 1", statement:"SELECT * FROM simple_1_col_1_group GROUP BY col1 + 1", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { _1:2 } ] } }, { name:"SELECT * FROM string_groups GROUP BY col1 || 'a'", statement:"SELECT * FROM string_groups GROUP BY col1 || 'a'", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { _1:"aa" } ] } }, { name:"SELECT * FROM string_numbers GROUP BY CAST(num AS INT)", statement:"SELECT * FROM string_numbers GROUP BY CAST(num AS INT)", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { num:1 }, { num:2 } ] } }, { name:"SELECT * FROM simple_1_col_1_group GROUP BY col1 + 1 AS someGBE", statement:"SELECT * FROM simple_1_col_1_group GROUP BY col1 + 1 AS someGBE", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { someGBE:2 } ] } }, { name:"SELECT * FROM string_groups GROUP BY col1 || 'a' AS someGBE", statement:"SELECT * FROM string_groups GROUP BY col1 || 'a' AS someGBE", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { someGBE:"aa" } ] } }, { name:"SELECT * FROM string_numbers GROUP BY CAST(num AS INT) AS someGBE", statement:"SELECT * FROM string_numbers GROUP BY CAST(num AS INT) AS someGBE", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { someGBE:1 }, { someGBE:2 } ] } }, { name:"SELECT * FROM simple_1_col_1_group GROUP BY NULL AS someNull", statement:"SELECT * FROM simple_1_col_1_group GROUP BY NULL AS someNull", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { someNull:null } ] } }, { name:"SELECT * FROM simple_1_col_1_group GROUP BY MISSING AS someMissing", statement:"SELECT * FROM simple_1_col_1_group GROUP BY MISSING AS someMissing", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { } ] } }, { name:"SELECT * FROM simple_1_col_1_group GROUP BY NULL AS groupExp", statement:"SELECT * FROM simple_1_col_1_group GROUP BY NULL AS groupExp", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { groupExp:null } ] } }, { name:"SELECT * FROM simple_1_col_1_group GROUP BY MISSING AS groupExp", statement:"SELECT * FROM simple_1_col_1_group GROUP BY MISSING AS groupExp", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { } ] } }, { name:"SELECT * FROM products_sparse p GROUP BY p.supplierId_nulls", statement:"SELECT * FROM products_sparse p GROUP BY p.supplierId_nulls", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { supplierId_nulls:10 }, { supplierId_nulls:11 }, { supplierId_nulls:null } ] } }, { name:"SELECT * FROM products_sparse p GROUP BY p.supplierId_missings", statement:"SELECT * FROM products_sparse p GROUP BY p.supplierId_missings", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { supplierId_missings:10 }, { supplierId_missings:11 }, { } ] } }, { name:"SELECT * FROM products_sparse p GROUP BY p.supplierId_mixed", statement:"SELECT * FROM products_sparse p GROUP BY p.supplierId_mixed", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { supplierId_mixed:10 }, { supplierId_mixed:11 }, { } ] } }, { name:"SELECT * FROM products_sparse p GROUP BY p.regionId, p.supplierId_nulls", statement:"SELECT * FROM products_sparse p GROUP BY p.regionId, p.supplierId_nulls", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { regionId:100, supplierId_nulls:10 }, { regionId:100, supplierId_nulls:11 }, { regionId:100, supplierId_nulls:null }, { regionId:200, supplierId_nulls:10 }, { regionId:200, supplierId_nulls:11 }, { regionId:200, supplierId_nulls:null } ] } }, { name:"SELECT * FROM products_sparse p GROUP BY p.regionId, p.supplierId_missings", statement:"SELECT * FROM products_sparse p GROUP BY p.regionId, p.supplierId_missings", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { regionId:100, supplierId_missings:10 }, { regionId:100, supplierId_missings:11 }, { regionId:100 }, { regionId:200, supplierId_missings:10 }, { regionId:200, supplierId_missings:11 }, { regionId:200 } ] } }, { name:"SELECT * FROM products_sparse p GROUP BY p.regionId, p.supplierId_mixed", statement:"SELECT * FROM products_sparse p GROUP BY p.regionId, p.supplierId_mixed", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { regionId:100, supplierId_mixed:10 }, { regionId:100, supplierId_mixed:11 }, { regionId:100 }, { regionId:200, supplierId_mixed:10 }, { regionId:200, supplierId_mixed:11 }, { regionId:200, supplierId_mixed:null } ] } }, { name:"SELECT * FROM simple_2_col_1_group GROUP BY col1 GROUP AS g", statement:"SELECT * FROM simple_2_col_1_group GROUP BY col1 GROUP AS g", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1, g:$bag::[ { simple_2_col_1_group:{ col1:1, col2:10 } }, { simple_2_col_1_group:{ col1:1, col2:10 } } ] } ] } }, { name:"SELECT * FROM simple_2_col_1_group GROUP BY col2 GROUP AS g", statement:"SELECT * FROM simple_2_col_1_group GROUP BY col2 GROUP AS g", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col2:10, g:$bag::[ { simple_2_col_1_group:{ col1:1, col2:10 } }, { simple_2_col_1_group:{ col1:1, col2:10 } } ] } ] } }, { name:"SELECT * FROM simple_1_col_2_groups GROUP BY col1 GROUP AS g", statement:"SELECT * FROM simple_1_col_2_groups GROUP BY col1 GROUP AS g", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1, g:$bag::[ { simple_1_col_2_groups:{ col1:1 } }, { simple_1_col_2_groups:{ col1:1 } } ] }, { col1:2, g:$bag::[ { simple_1_col_2_groups:{ col1:2 } }, { simple_1_col_2_groups:{ col1:2 } } ] } ] } }, { name:"SELECT * FROM simple_2_col_2_groups GROUP BY col1 GROUP AS g", statement:"SELECT * FROM simple_2_col_2_groups GROUP BY col1 GROUP AS g", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1, g:$bag::[ { simple_2_col_2_groups:{ col1:1, col2:10 } }, { simple_2_col_2_groups:{ col1:1, col2:10 } } ] }, { col1:11, g:$bag::[ { simple_2_col_2_groups:{ col1:11, col2:110 } }, { simple_2_col_2_groups:{ col1:11, col2:110 } } ] } ] } }, { name:"SELECT * FROM simple_2_col_2_groups GROUP BY col2 GROUP AS g", statement:"SELECT * FROM simple_2_col_2_groups GROUP BY col2 GROUP AS g", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col2:10, g:$bag::[ { simple_2_col_2_groups:{ col1:1, col2:10 } }, { simple_2_col_2_groups:{ col1:1, col2:10 } } ] }, { col2:110, g:$bag::[ { simple_2_col_2_groups:{ col1:11, col2:110 } }, { simple_2_col_2_groups:{ col1:11, col2:110 } } ] } ] } }, { name:"SELECT * FROM simple_1_col_1_group, join_me GROUP BY col1 GROUP AS g", statement:"SELECT * FROM simple_1_col_1_group, join_me GROUP BY col1 GROUP AS g", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1, g:$bag::[ { simple_1_col_1_group:{ col1:1 }, join_me:{ foo:20 } }, { simple_1_col_1_group:{ col1:1 }, join_me:{ foo:30 } }, { simple_1_col_1_group:{ col1:1 }, join_me:{ foo:20 } }, { simple_1_col_1_group:{ col1:1 }, join_me:{ foo:30 } } ] } ] } }, { name:"SELECT * FROM simple_1_col_1_group, different_types_per_row GROUP BY col1 GROUP AS g", statement:"SELECT * FROM simple_1_col_1_group, different_types_per_row GROUP BY col1 GROUP AS g", assert:{ result:EvaluationSuccess, evalMode:[ EvalModeCoerce, EvalModeError ], output:$bag::[ { col1:1, g:$bag::[ { simple_1_col_1_group:{ col1:1 }, different_types_per_row:{ a:1001 } }, { simple_1_col_1_group:{ col1:1 }, different_types_per_row:1002.0 }, { simple_1_col_1_group:{ col1:1 }, different_types_per_row:"one-thousand and three" }, { simple_1_col_1_group:{ col1:1 }, different_types_per_row:{ a:1001 } }, { simple_1_col_1_group:{ col1:1 }, different_types_per_row:1002.0 }, { simple_1_col_1_group:{ col1:1 }, different_types_per_row:"one-thousand and three" } ] } ] } }, ]