業務で「文字列を集計する関数」を使う機会があったので、その使い方をまとめます。 配列にピボットされた入力値を返します。 入力が空の場合、関数は空の配列を返します。 ARRAY_AGG( [ DISTINCT ] <expr1> ) [ WITHIN GROUP ( <orderby_clause> ) ] ・expr1:配列に入れる値 ...
-- Objective: Collect top product names per department into arrays. -- Data/location: thelook_ecommerce.products (US). -- Expected result: One ordered three-name array per department. -- Standard ...
Returns a list of objects with duplicates. from pyspark.sql import functions as sf df = spark.createDataFrame([[1],[1],[2]], ["c"]) df.agg(sf.sort_array(sf.array_agg ...
select u.id, jsonb_agg(p.*) as posts from users u left join posts p on p.user_id = u.id group by u.id ...