kunishou's picture
Upload 284 files
2eae90c verified
raw
history blame
No virus
713 Bytes
from spark_queries import utils
Q_NUM = 13
def q():
query_str = f"""
select
c_count, count(*) as custdist
from (
select
c_custkey,
count(o_orderkey)
from
customer left outer join orders on
c_custkey = o_custkey
and o_comment not like '%special%requests%'
group by
c_custkey
)as c_orders (c_custkey, c_count)
group by
c_count
order by
custdist desc,
c_count desc
"""
utils.get_customer_ds()
utils.get_orders_ds()
q_final = utils.get_or_create_spark().sql(query_str)
utils.run_query(Q_NUM, q_final)
if __name__ == "__main__":
q()