Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[CBRD-25746] added a sql javasp test case for If the SP of GROUP BY of WITH ROLLUP insert fails, the array will be marked as NULL #2009

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
60 changes: 60 additions & 0 deletions sql/_08_javasp/cases/cbrd_25746.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- This test case verifies the following issue: CBRD-25746.
-- When a stored procedure is included in the GROUP BY clause with rollup (e.g., GROUP BY test_fc(dept_no), name WITH ROLLUP),
-- ensure that the aggregated rows for some grouping levels no longer show NULL values instead of the expected aggregated values.

CREATE OR REPLACE FUNCTION test_fc_int(i INT) RETURN INT AS LANGUAGE JAVA NAME 'SpTest7.typetestint(int) return int';
CREATE OR REPLACE FUNCTION test_fc_str(i string) RETURN string as language java name 'SpTest7.typeteststring(java.lang.String) return java.lang.String';

CREATE TABLE sales_tbl
(
dept_no INT,
name VARCHAR(20),
sales_month INT,
sales_amount INT DEFAULT 100,
PRIMARY KEY (dept_no, name, sales_month)
);

INSERT INTO sales_tbl VALUES (201, 'George', 1, 450);
INSERT INTO sales_tbl VALUES (202, 'Alice', 1, 550);

evaluate 'Test Case 1: Using ROUND function in GROUP BY with WITH ROLLUP';
junsklee marked this conversation as resolved.
Show resolved Hide resolved
SELECT ROUND(dept_no), name, AVG(sales_amount)
FROM sales_tbl
WHERE sales_amount > 100
GROUP BY dept_no, name WITH ROLLUP;

evaluate 'Test Case 2: Using stored procedure in GROUP BY with WITH ROLLUP';
SELECT dept_no, name, AVG(sales_amount)
FROM sales_tbl
WHERE sales_amount > 100
GROUP BY test_fc_int(dept_no), name WITH ROLLUP;

evaluate 'Test Case 3: Including non-numeric columns in GROUP BY';
SELECT dept_no, name, AVG(sales_amount)
FROM sales_tbl
WHERE sales_amount > 100
GROUP BY dept_no, test_fc_str(name) WITH ROLLUP;

evaluate 'Test Case 4: Using stored procedure in WHERE clause';
SELECT dept_no, name, AVG(sales_amount)
FROM sales_tbl
WHERE test_fc_int(dept_no) > 200
GROUP BY test_fc_int(dept_no), name WITH ROLLUP;

evaluate 'Test Case 5: Using multiple stored procedures in GROUP BY';
SELECT dept_no, AVG(sales_month), SUM(sales_amount)
FROM sales_tbl
WHERE sales_amount > 100
GROUP BY test_fc_int(dept_no), test_fc_int(sales_month) WITH ROLLUP;

evaluate 'Test Case 6: Using HAVING clause with stored procedure';
SELECT dept_no, name, AVG(sales_amount)
FROM sales_tbl
WHERE sales_amount > 100
GROUP BY test_fc_int(dept_no), name WITH ROLLUP
HAVING AVG(sales_amount) > 100;

evaluate 'Cleanup';
DROP FUNCTION test_fc_int;
DROP FUNCTION test_fc_str;
DROP TABLE sales_tbl;