mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 14:35:04 +00:00
SQL: [Tests] Add integ tests for selecting a literal and an aggregate (#42121)
The related issue regarding aggregation queries where some literals are also selected together with aggregate function has been fixed with #49570. Add integration tests to verify the behavior. Relates to: #41411 (cherry picked from commit 9f414a8d05c75e1a9f8250084f6dcd634d5d78d8)
This commit is contained in:
parent
7c6264b28c
commit
282e919607
@ -565,3 +565,45 @@ implicitGroupByWithLiteral
|
|||||||
SELECT 10, MAX("salary") FROM test_emp;
|
SELECT 10, MAX("salary") FROM test_emp;
|
||||||
groupByWithLiteralAndCount
|
groupByWithLiteralAndCount
|
||||||
SELECT 20, COUNT(*) from test_emp GROUP BY gender ORDER BY 2;
|
SELECT 20, COUNT(*) from test_emp GROUP BY gender ORDER BY 2;
|
||||||
|
groupByNumberWithLiteral
|
||||||
|
SELECT emp_no e, 5 FROM "test_emp" GROUP BY emp_no ORDER BY e DESC;
|
||||||
|
groupByNumberWithWhereWithLiteral
|
||||||
|
SELECT emp_no e, 5 FROM "test_emp" WHERE emp_no < 10020 GROUP BY e ORDER BY emp_no DESC;
|
||||||
|
groupByMulScalarWithLiterals
|
||||||
|
SELECT emp_no * 2 AS e , 5, TRUE FROM test_emp GROUP BY e ORDER BY e;
|
||||||
|
groupByMulScalarWithWhereWithLiterals
|
||||||
|
SELECT emp_no * 2 AS e, 5, TRUE FROM test_emp WHERE emp_no < 10020 GROUP BY e ORDER BY e;
|
||||||
|
aggMaxImplicitWithLiteral
|
||||||
|
SELECT MAX(salary) AS max, 5 FROM test_emp;
|
||||||
|
aggMaxImplicitWithCastWithLiteral
|
||||||
|
SELECT CAST(MAX(emp_no) AS SMALLINT) c, 5 FROM "test_emp";
|
||||||
|
aggMaxImplicitWithCastWithWhereWithLiteral
|
||||||
|
SELECT CAST(MAX(emp_no) AS SMALLINT) c, 5 FROM "test_emp" WHERE emp_no > 10000;
|
||||||
|
aggSumWithCastWithLiteral
|
||||||
|
SELECT gender g, CAST(SUM(emp_no) AS BIGINT) s, TRUE FROM "test_emp" GROUP BY gender ORDER BY gender;
|
||||||
|
aggSumWithCastWithAliasWithLiteral
|
||||||
|
SELECT TRUE, gender g, CAST(SUM(emp_no) AS BIGINT) s FROM "test_emp" GROUP BY g ORDER BY g DESC;
|
||||||
|
aggSumWithWhereWithLiteral
|
||||||
|
SELECT TRUE, gender g, CAST(SUM(emp_no) AS BIGINT) s FROM "test_emp" WHERE emp_no > 10000 GROUP BY gender ORDER BY gender;
|
||||||
|
|
||||||
|
// group by with aliased literal
|
||||||
|
groupByNumberWithLiteralWithAlias
|
||||||
|
SELECT emp_no e, 5 department FROM "test_emp" GROUP BY emp_no ORDER BY e DESC;
|
||||||
|
groupByNumberWithWhereWithLiteralWithAlias
|
||||||
|
SELECT emp_no e, 5 department FROM "test_emp" WHERE emp_no < 10020 GROUP BY e ORDER BY emp_no DESC;
|
||||||
|
groupByMulScalarWithLiteralsWithAliases
|
||||||
|
SELECT emp_no * 2 AS e, 5 department, TRUE as employed FROM test_emp GROUP BY e ORDER BY e;
|
||||||
|
groupByMulScalarWithWhereWithLiteralsWithAliases
|
||||||
|
SELECT emp_no * 2 AS e, 5 department, TRUE as employed FROM test_emp WHERE emp_no < 10020 GROUP BY e ORDER BY e;
|
||||||
|
aggMaxImplicitWithLiteralWithAlias
|
||||||
|
SELECT MAX(salary) AS max, 5 department FROM test_emp;
|
||||||
|
aggMaxImplicitWithCastWithLiteralWithAlias
|
||||||
|
SELECT CAST(MAX(emp_no) AS SMALLINT) c, 5 department FROM "test_emp";
|
||||||
|
aggMaxImplicitWithCastWithWhereWithLiteralWithAlias
|
||||||
|
SELECT CAST(MAX(emp_no) AS SMALLINT) c, 5 department FROM "test_emp" WHERE emp_no > 10000;
|
||||||
|
aggSumWithCastWithLiteralWithAlias
|
||||||
|
SELECT gender g, CAST(SUM(emp_no) AS BIGINT) s, TRUE as employed FROM "test_emp" GROUP BY gender ORDER BY gender;
|
||||||
|
aggSumWithCastWithAliasWithLiteralWithAlias
|
||||||
|
SELECT TRUE as employed, gender g, CAST(SUM(emp_no) AS BIGINT) s FROM "test_emp" GROUP BY g ORDER BY g DESC;
|
||||||
|
aggSumWithWhereWithLiteralWithAlias
|
||||||
|
SELECT TRUE as employed, gender g, CAST(SUM(emp_no) AS BIGINT) s FROM "test_emp" WHERE emp_no > 10000 GROUP BY gender ORDER BY gender;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user