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
SELECT*FROM
(SELECT i_category,
i_class,
i_brand,
i_product_name,
sumsales,
rank() OVER (PARTITION BY i_category
ORDER BY sumsales DESC) rk
FROM
(SELECT i_category,
i_class,
i_brand,
i_product_name,
d_year,
d_qoy,
d_moy,
s_store_id,
sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
FROM store_sales,
date_dim,
store,
item
WHERE ss_sold_date_sk=d_date_sk
AND ss_item_sk=i_item_sk
AND ss_store_sk = s_store_sk
AND d_month_seq BETWEEN 1200AND1200+11GROUP BY rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
WHERE rk <=100and i_category ='Books'order by i_category nulls first;
The outermost level of this query contains the predicate i_category = 'Books', but the result contains rows where i_category is null.
It also appears that the ROLLUP() method cannot be combined with other GROUP BY columns to reduce the number of generated combinations. This is an example:
DROPTABLE IF EXISTS sales;
CREATETABLEsales (
brand VARCHARNOT NULL,
segment VARCHARNOT NULL,
quantity INTNOT NULL
);
INSERT INTO sales (brand, segment, quantity)
VALUES
('ABC', 'Premium', 100),
('ABC', 'Basic', 200),
('XYZ', 'Premium', 100),
('XYZ', 'Basic', 300);
-- This WorksSELECT
brand,
segment,
SUM (quantity)
FROM
sales
GROUP BY
ROLLUP (brand, segment)
ORDER BY
brand,
segment;
-- This does not workSELECT
brand,
segment,
SUM (quantity)
FROM
sales
GROUP BY
brand,
ROLLUP (segment)
ORDER BY
brand,
segment;
The expected behavior is that the any number of GROUP BY columns can be specified prior to specifying the ROLLUP() columns in order to reduce the calculated columns.
If this is a separate issue from the one above I would be happy to create a new issue.
Search before asking
Version
9c2c3dd
What's Wrong?
The outermost level of this query contains the predicate i_category = 'Books', but the result contains rows where i_category is null.
How to Reproduce?
run
tests/sqllogictests/scripts/prepare_tpcds_data.sh
to construct the datasetAre you willing to submit PR?
The text was updated successfully, but these errors were encountered: