← Back to context

Comment by middayc

1 year ago

Looking at the first example from PDF:

    FROM customer
    |> LEFT OUTER JOIN orders ON c_custkey = o_custkey
    AND o_comment NOT LIKE '%unusual%packages%'
    |> AGGREGATE COUNT(o_orderkey) c_count
    GROUP BY c_custkey
    |> AGGREGATE COUNT(*) AS custdist
    GROUP BY c_count
    |> ORDER BY custdist DESC, c_count DESC;

You could do something similar with Ryelang's spreadsheet datatype:

    customers: load\csv %customers.csv
    orders: load\csv %orders.csv

    orders .where-not-contains 'o_comment "unusual packages" 
    |left-join customers 'o_custkey 'c_custkey
    |group-by 'c_custkey { 'c_custkey count }
    |group-by 'c_custkey_count { 'c_custkey_count count }
    |order-by 'c_custkey_count_count 'descending

Looking at this, maybe we should add an option to name the new aggregate column (now they get named automatically) in group-by function because c_custkey_count_count is not that elegant for example.