Skip to content

Commit 7ed0e37

Browse files
TeodorDjeliccloud-fan
authored andcommitted
[SPARK-53536][CORE][FOLLOWUP] Fixing Flakiness of Golden File Test With Randomly Generated SQL Scripts
### What changes were proposed in this pull request? - Fix the flakiness of the new golden file test with randomly generated SQL Scripts. - One of the scripts was not executing deterministically, and removing it fixed the flakiness. Referenced PR: #52287 ### Why are the changes needed? Changes are needed to fix the test flakiness. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Golden file was regenerated and run 10 times locally without a hiccup, where as with the flaky script, it could not run trice without the test failing. ### Was this patch authored or co-authored using generative AI tooling? No Closes #52500 from TeodorDjelic/golden-file-flakiness-fix. Authored-by: Teodor Djelic <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
1 parent 848e47a commit 7ed0e37

File tree

3 files changed

+28
-284
lines changed

3 files changed

+28
-284
lines changed

sql/core/src/test/resources/sql-tests/analyzer-results/scripting/randomly_generated_scripts.sql.out

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5098,90 +5098,6 @@ END
50985098
LocalRelation [col1#x]
50995099

51005100

5101-
-- !query
5102-
BEGIN
5103-
DECLARE v_no_last_order_customers INT;
5104-
DECLARE v_no_sale_days INT;
5105-
DECLARE v_customer_id INT;
5106-
DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN VALUES('Customer no-sale error'); END;
5107-
5108-
L0: BEGIN
5109-
SET v_no_last_order_customers = (SELECT COUNT(*) FROM customers WHERE customer_last_order_date IS NULL);
5110-
IF v_no_last_order_customers > 0 THEN
5111-
L1: BEGIN
5112-
FOR cust AS SELECT customer_id FROM customers WHERE customer_last_order_date IS NULL LIMIT 3 DO
5113-
IF RANDOM() > 0.7 THEN
5114-
INSERT INTO orders (
5115-
order_id,
5116-
customer_id,
5117-
order_date,
5118-
order_status,
5119-
order_total,
5120-
order_tax,
5121-
order_discount,
5122-
order_shipping
5123-
) VALUES (
5124-
(SELECT MAX(order_id) + 1 FROM orders),
5125-
cust.customer_id,
5126-
DATEADD(DAY, -ROUND(RANDOM() * 100), CURRENT_TIMESTAMP),
5127-
'No-Sale Fix',
5128-
ROUND(RANDOM() * 100, 2),
5129-
0.0,
5130-
0.0,
5131-
ROUND(RANDOM() * 10, 2)
5132-
);
5133-
UPDATE customers
5134-
SET customer_last_order_date = (
5135-
SELECT order_date
5136-
FROM orders
5137-
WHERE customer_id = cust.customer_id
5138-
LIMIT 1
5139-
)
5140-
WHERE customer_id = cust.customer_id;
5141-
END IF;
5142-
END FOR;
5143-
SET v_no_last_order_customers = (SELECT COUNT(*) FROM customers WHERE customer_last_order_date IS NULL);
5144-
END L1;
5145-
END IF;
5146-
5147-
L2: BEGIN
5148-
SET v_no_sale_days = (SELECT MIN(DATEDIFF(DAY, COALESCE(customer_last_order_date, DATEADD(DAY, -3, CURRENT_TIMESTAMP)), CURRENT_TIMESTAMP)) FROM customers);
5149-
IF v_no_sale_days > 90 THEN
5150-
REPEAT
5151-
SET v_customer_id = (SELECT MIN(customer_id) FROM customers WHERE DATEDIFF(DAY, COALESCE(customer_last_order_date, DATEADD(DAY, -3, CURRENT_TIMESTAMP)), CURRENT_TIMESTAMP) > 90);
5152-
INSERT INTO orders (
5153-
order_id,
5154-
customer_id,
5155-
order_date,
5156-
order_status,
5157-
order_total,
5158-
order_tax,
5159-
order_discount,
5160-
order_shipping
5161-
) VALUES (
5162-
(SELECT MAX(order_id) + 1 FROM orders),
5163-
v_customer_id,
5164-
CURRENT_TIMESTAMP,
5165-
'Revival',
5166-
25.0,
5167-
2.5,
5168-
0.0,
5169-
2.5
5170-
);
5171-
UPDATE customers
5172-
SET customer_last_order_date = CURRENT_TIMESTAMP
5173-
WHERE customer_id = v_customer_id;
5174-
SET v_no_sale_days = (SELECT MIN(DATEDIFF(DAY, COALESCE(customer_last_order_date, DATEADD(DAY, -3, CURRENT_TIMESTAMP)), CURRENT_TIMESTAMP)) FROM customers);
5175-
UNTIL v_no_sale_days <= 90
5176-
END REPEAT;
5177-
END IF;
5178-
END L2;
5179-
END L0;
5180-
END
5181-
-- !query analysis
5182-
LocalRelation <empty>
5183-
5184-
51855101
-- !query
51865102
BEGIN
51875103
DECLARE v_employee_tenure_years INT;

0 commit comments

Comments
 (0)