Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

5.3 KB
Raw Blame
-- Automatically generated by Gravitino Spark SQL test
-- !query
select  
    sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
   ,i_category
   ,i_class
   ,grouping(i_category)+grouping(i_class) as lochierarchy
   ,rank() over (
 	partition by grouping(i_category)+grouping(i_class),
 	case when grouping(i_class) = 0 then i_category end 
 	order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
 from
    store_sales
   ,date_dim       d1
   ,item
   ,store
 where
    d1.d_year = 2000 
 and d1.d_date_sk = ss_sold_date_sk
 and i_item_sk  = ss_item_sk 
 and s_store_sk  = ss_store_sk
 and s_state in ('TN','TN','TN','TN',
                 'TN','TN','TN','TN')
 group by rollup(i_category,i_class)
 order by
   lochierarchy desc
  ,case when lochierarchy = 0 then i_category end
  ,rank_within_parent
  limit 100
-- !query schema
struct<gross_margin:decimal(37,20),i_category:string,i_class:string,lochierarchy:tinyint,rank_within_parent:int>
-- !query output
-0.01264890089647550043	NULL	womens	0	7
-0.14523606100368196121	Jewelry	bracelets	0	17
-0.15468042459411738024	Books	history	0	16
-0.19922872916269436604	Home	decor	0	16
-0.20509588151314650255	Electronics	automotive	0	16
-0.20961256896707670043	Electronics	personal	0	15
-0.21124334553840655439	Jewelry	NULL	0	16
-0.22296627303554283095	Music	country	0	5
-0.24979851742209881318	Jewelry	consignment	0	15
-0.28077916660781011241	Jewelry	pendants	0	14
-0.29409295349299832109	Books	self-help	0	15
-0.29843520560827983677	Jewelry	diamonds	0	13
-0.30610180459628915193	Electronics	cameras	0	14
-0.31418290010654765495	Jewelry	mens watch	0	12
-0.31720325593592501797	Electronics	portable	0	13
-0.32892350296307104388	Books	entertainments	0	14
-0.32959891609064994329	Men	accessories	0	4
-0.32972697043181863085	Home	blinds/shades	0	15
-0.34221239672768133594	Electronics	musical	0	12
-0.34597949352909043165	Electronics	dvd/vcr players	0	11
-0.37419911325064966488	NULL	swimwear	0	6
-0.37475425504196329570	Jewelry	gold	0	11
-0.39109171644125462424	Music	classical	0	4
-0.40326612662221840888	Books	computers	0	13
-0.40480193226844251260	Shoes	NULL	1	11
-0.41138706773543938330	Electronics	monitors	0	10
-0.41666483173694447503	NULL	pants	0	5
-0.41757113617162301563	Home	bathroom	0	14
-0.41969780847490173868	Jewelry	womens watch	0	10
-0.42258396854328847072	Books	sports	0	12
-0.42316068073131869439	Jewelry	NULL	1	10
-0.42414783886016217292	Electronics	scanners	0	9
-0.43097427860057779911	Music	NULL	1	9
-0.43492834754782185132	Children	newborn	0	5
-0.43510897640832228741	Sports	NULL	1	8
-0.43612836597793282096	Women	NULL	1	7
-0.43668550718121567423	Jewelry	costume	0	9
-0.44446953144880361768	Electronics	NULL	1	6
-0.44462871878010471784	Jewelry	birdal	0	8
-0.44505111959093001255	Electronics	memory	0	8
-0.44933010114058461228	Children	toddlers	0	4
-0.45101464723690427204	NULL	NULL	2	1
-0.45149436669451268618	Jewelry	custom	0	7
-0.45323070910017614607	Home	flatware	0	13
-0.45367725990317559772	Men	sports-apparel	0	3
-0.45570404601501210727	Children	infants	0	3
-0.45651582293848992218	Men	NULL	1	5
-0.45765445417948459366	Home	mattresses	0	12
-0.46066780150548789546	Books	reference	0	11
-0.46711803886179619787	Books	romance	0	10
-0.46740975615487146408	Children	NULL	1	4
-0.46969072125081554150	Electronics	disk drives	0	7
-0.47751096631281680702	Books	fiction	0	9
-0.48332753923216397045	Jewelry	estate	0	6
-0.48842324205437387131	Home	tables	0	11
-0.49167764685197078754	Home	bedding	0	10
-0.49285388516561858927	Home	glassware	0	9
-0.49555383130157789240	Books	NULL	1	3
-0.49869573079346629628	Home	wallpaper	0	8
-0.50195137767665656747	Men	shirts	0	2
-0.51317329165475285461	Electronics	televisions	0	6
-0.52019139602714705343	Home	kids	0	7
-0.52106096865738790648	Home	NULL	1	2
-0.52770274883503683467	Jewelry	semi-precious	0	5
-0.53235016071729528852	Books	science	0	8
-0.53511600747154751061	Children	school-uniforms	0	2
-0.55154735910786286770	Men	pants	0	1
-0.55783152709608756777	Jewelry	rings	0	4
-0.56737322051406426087	Electronics	camcorders	0	5
-0.57535402342712764700	Home	lighting	0	6
-0.58168716434507000495	Home	paint	0	5
-0.58466277918362856200	Electronics	karoke	0	4
-0.58564666572258587170	Books	business	0	7
-0.59280803931608928631	Books	parenting	0	6
-0.59318562327227282298	Jewelry	earings	0	3
-0.60658776473563157155	Music	pop	0	3
-0.61126644298676456352	Books	cooking	0	5
-0.62155832402662009757	Electronics	stereo	0	3
-0.64455401270068720446	Music	rock	0	2
-0.66464647062666815241	Home	rugs	0	4
-0.66656514981351748817	Jewelry	jewelry boxes	0	2
-0.68017453721377526085	NULL	NULL	1	1
-0.68052038217837664421	Home	accent	0	3
-0.69197103383790909707	Jewelry	loose stones	0	1
-0.71185905373555462183	Electronics	audio	0	2
-0.73596178710523167609	Books	arts	0	4
-0.76004592935058719746	Home	curtains/drapes	0	2
-0.77347099531874610770	Home	furniture	0	1
-0.79660923336595668532	NULL	dresses	0	4
-0.82550264053599949882	Books	mystery	0	3
-0.87204387886748408540	Books	home repair	0	2
-0.94648648940741630049	Books	travel	0	1
-1.00000000000000000000	NULL	sports-apparel	0	3
-1.05392921654433740149	Electronics	wireless	0	1
-1.06996587030716723549	Children	NULL	0	1
-1.10725815609067949947	NULL	NULL	0	2
-1.48723744418104636419	Music	NULL	0	1
-2.10482230315207836243	NULL	archery	0	1
0.02928949357520786092	NULL	glassware	0	8
0.15814715171365071938	NULL	outdoor	0	9