World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
-- Automatically generated by Gravitino Spark SQL test
-- !query
WITH web_v1 as (
select
ws_item_sk item_sk, d_date,
sum(sum(ws_sales_price))
over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
from web_sales
,date_dim
where ws_sold_date_sk=d_date_sk
and d_month_seq between 1212 and 1212+11
and ws_item_sk is not NULL
group by ws_item_sk, d_date),
store_v1 as (
select
ss_item_sk item_sk, d_date,
sum(sum(ss_sales_price))
over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
from store_sales
,date_dim
where ss_sold_date_sk=d_date_sk
and d_month_seq between 1212 and 1212+11
and ss_item_sk is not NULL
group by ss_item_sk, d_date)
select *
from (select item_sk
,d_date
,web_sales
,store_sales
,max(web_sales)
over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
,max(store_sales)
over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
,case when web.d_date is not null then web.d_date else store.d_date end d_date
,web.cume_sales web_sales
,store.cume_sales store_sales
from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
and web.d_date = store.d_date)
)x )y
where web_cumulative > store_cumulative
order by item_sk
,d_date
limit 100
-- !query schema
struct<item_sk:bigint,d_date:string,web_sales:decimal(27,2),store_sales:decimal(27,2),web_cumulative:decimal(27,2),store_cumulative:decimal(27,2)>
-- !query output
1007 2001-11-08 NULL 53.02 62.78 53.02
109 2001-04-03 31.62 NULL 31.62 26.77
1129 2001-11-26 23.63 NULL 23.63 1.16
1181 2001-08-30 91.89 NULL 91.89 42.86
1195 2001-09-11 NULL 16.79 64.51 16.79
1219 2001-12-04 43.68 NULL 43.68 0.00
1277 2001-12-30 81.83 NULL 81.83 65.19
1327 2001-07-11 57.69 NULL 57.69 16.37
1331 2001-11-20 40.82 NULL 40.82 13.76
141 2001-09-23 NULL 63.16 89.43 63.16
1411 2001-10-25 19.86 NULL 19.86 17.92
1531 2001-10-04 38.48 NULL 38.48 3.97
157 2001-11-18 48.73 NULL 48.73 27.60
1597 2001-12-30 109.88 NULL 109.88 49.93
1745 2001-11-05 159.66 NULL 159.66 1.12
1755 2001-11-18 29.58 NULL 29.58 24.92
179 2001-09-22 NULL 8.76 62.11 8.76
1883 2001-08-03 NULL 1.40 9.18 1.40
189 2001-05-15 NULL 8.24 86.94 8.24
189 2001-10-05 152.87 NULL 152.87 8.24
1915 2001-07-27 NULL 13.24 124.26 13.24
1915 2001-08-09 NULL 17.71 124.26 17.71
1917 2001-08-09 NULL 36.46 144.47 36.46
1927 2001-08-30 141.37 3.71 141.37 3.71
1967 2001-10-14 NULL 21.78 41.26 21.78
2003 2001-06-10 NULL 2.32 76.51 2.32
2025 2001-08-28 210.83 NULL 210.83 73.43
2025 2001-11-30 NULL 94.99 210.83 94.99
2031 2001-02-21 108.92 NULL 108.92 3.05
2031 2001-05-08 NULL 49.27 108.92 49.27
205 2001-12-23 157.76 NULL 157.76 12.90
2077 2001-12-26 26.09 NULL 26.09 22.45
2081 2001-12-17 162.96 NULL 162.96 56.12
2131 2001-08-18 83.74 NULL 83.74 30.12
223 2001-11-14 78.29 NULL 78.29 40.60
2253 2001-12-23 61.32 NULL 61.32 18.52
2351 2001-12-30 NULL 35.54 137.22 35.54
2367 2001-11-05 8.33 NULL 8.33 5.94
2387 2001-08-18 88.89 NULL 88.89 0.42
2539 2001-11-02 NULL 58.36 74.55 58.36
2551 2001-11-18 104.92 NULL 104.92 31.23
2555 2001-10-15 NULL 21.42 31.93 21.42
2635 2001-12-04 NULL 31.97 60.27 31.97
2635 2001-12-18 NULL 33.12 60.27 33.12
2649 2001-02-26 24.41 NULL 24.41 2.66
2677 2001-12-18 NULL 26.75 331.49 26.75
2689 2001-10-14 NULL 4.85 12.21 4.85
2717 2001-12-14 NULL 33.14 88.10 33.14
2801 2001-07-08 NULL 2.24 54.44 2.24
2801 2001-08-08 NULL 32.66 54.44 32.66
2861 2001-11-05 112.69 NULL 112.69 2.85
2879 2001-10-26 59.67 NULL 59.67 6.09
2927 2001-09-15 60.30 NULL 60.30 6.29
2981 2001-10-04 11.98 NULL 11.98 2.78
3 2001-12-05 NULL 26.32 45.06 26.32
3031 2001-12-22 31.36 NULL 31.36 5.22
3035 2001-09-09 83.98 NULL 83.98 5.58
3085 2001-10-03 59.84 NULL 59.84 37.99
3085 2001-11-04 94.65 NULL 94.65 37.99
3127 2001-12-23 NULL 4.51 86.22 4.51
3181 2001-07-13 NULL 4.89 52.95 4.89
3193 2001-10-27 31.42 NULL 31.42 27.52
3209 2001-10-25 NULL 96.10 125.12 96.10
3209 2001-11-26 130.91 NULL 130.91 96.10
3255 2001-11-10 100.15 NULL 100.15 0.79
3255 2001-11-19 NULL 27.66 100.15 27.66
3265 2001-11-19 58.86 NULL 58.86 22.99
3265 2001-12-13 NULL 54.69 58.86 54.69
3267 2001-03-22 46.94 NULL 46.94 24.10
3429 2001-11-25 NULL 25.61 78.31 25.61
349 2001-04-18 NULL 11.08 19.71 11.08
349 2001-07-06 NULL 12.98 19.71 12.98
3609 2001-10-26 26.85 NULL 26.85 2.57
3635 2001-10-09 NULL 39.09 185.29 39.09
3687 2001-09-18 NULL 31.38 58.63 31.38
3689 2001-07-31 31.73 NULL 31.73 31.31
3689 2001-11-04 NULL 31.31 31.73 31.31
3771 2001-11-19 NULL 0.32 5.33 0.32
3893 2001-09-18 80.40 NULL 80.40 6.86
3969 2001-07-01 NULL 2.27 24.04 2.27
3969 2001-11-26 47.67 NULL 47.67 2.27
4021 2001-03-06 134.88 NULL 134.88 4.79
501 2001-12-27 NULL 12.53 139.83 12.53
523 2001-12-24 NULL 16.30 77.37 16.30
531 2001-09-18 30.69 NULL 30.69 25.57
551 2001-11-24 NULL 13.98 73.40 13.98
599 2001-12-16 NULL 16.34 90.43 16.34
611 2001-11-07 50.01 NULL 50.01 1.24
631 2001-08-31 NULL 123.70 128.11 123.70
683 2001-10-11 54.07 NULL 54.07 2.45
689 2001-10-26 9.52 NULL 9.52 3.54
727 2001-11-09 112.65 NULL 112.65 73.18
731 2001-03-04 80.53 NULL 80.53 41.92
737 2001-11-18 NULL 32.22 61.62 32.22
745 2001-08-06 NULL 48.71 104.31 48.71
745 2001-08-20 NULL 50.27 104.31 50.27
851 2001-05-11 121.22 NULL 121.22 47.85
97 2001-09-28 NULL 5.74 60.99 5.74
97 2001-12-07 81.33 NULL 81.33 5.74
999 2001-09-28 NULL 29.35 72.86 29.35