You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address review feedback for AQUMV join exact-match
Fix three issues in aqumv_query_is_exact_match():
- Add groupDistinct comparison (GROUP BY vs GROUP BY DISTINCT)
- Add limitOption comparison (LIMIT vs FETCH FIRST WITH TIES)
- Clear qp_extra in-place via aqumv_context->qp_extra instead of
allocating a local char array; move standard_qp_extra typedef
to planner.h so aqumv.c can reference the proper struct type
Add test cases 26-28 to verify the new comparisons:
- LIMIT vs FETCH FIRST WITH TIES non-match and exact match
- GROUP BY DISTINCT vs GROUP BY non-match
Copy file name to clipboardExpand all lines: src/test/regress/expected/matview_data.out
+153-2Lines changed: 153 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2037,7 +2037,158 @@ select c.region, o.status, count(*) as cnt, sum(o.amount) as total
2037
2037
north | delivered | 16 | 16800.00
2038
2038
(6 rows)
2039
2039
2040
+
-- 26. Non-match: LIMIT vs FETCH FIRST WITH TIES (limitOption differs)
2041
+
create materialized view mv_aqj_limit_test as
2042
+
select o.order_id, o.amount
2043
+
from aqj_orders o join aqj_customers c on o.customer_id = c.customer_id
2044
+
where o.status = 'shipped'
2045
+
order by o.order_id limit 5;
2046
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'order_id' as the Apache Cloudberry data distribution key for this table.
2047
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
2048
+
analyze mv_aqj_limit_test;
2049
+
set enable_answer_query_using_materialized_views = on;
2050
+
-- Same tables/WHERE/ORDER BY but FETCH FIRST WITH TIES: should NOT match
2051
+
explain(costs off)
2052
+
select o.order_id, o.amount
2053
+
from aqj_orders o join aqj_customers c on o.customer_id = c.customer_id
from aqj_orders o join aqj_customers c on o.customer_id = c.customer_id
2078
+
where o.status = 'shipped'
2079
+
order by o.order_id limit 5;
2080
+
QUERY PLAN
2081
+
-------------------------------------------------
2082
+
Limit
2083
+
-> Gather Motion 3:1 (slice1; segments: 3)
2084
+
-> Limit
2085
+
-> Seq Scan on mv_aqj_limit_test
2086
+
Optimizer: Postgres query optimizer
2087
+
(5 rows)
2088
+
2089
+
-- 27. Match: FETCH FIRST WITH TIES exact match
2090
+
create materialized view mv_aqj_with_ties as
2091
+
select o.order_id, o.amount
2092
+
from aqj_orders o join aqj_customers c on o.customer_id = c.customer_id
2093
+
where o.status = 'pending'
2094
+
order by o.order_id fetch first 5 rows with ties;
2095
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'order_id' as the Apache Cloudberry data distribution key for this table.
2096
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
2097
+
analyze mv_aqj_with_ties;
2098
+
set enable_answer_query_using_materialized_views = off;
2099
+
explain(costs off)
2100
+
select o.order_id, o.amount
2101
+
from aqj_orders o join aqj_customers c on o.customer_id = c.customer_id
0 commit comments