Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • As I understand, mydataset.mylen function is applied to each row separately and gets the partitioned group as an argument. That's why the function doesn't have to return a similarly sized array - it's called for each row, not for a group of rows. Commented Nov 26, 2020 at 22:26
  • 1
    This is wonderful! Using this approach I can now transfer my pandas code to BigQuery. The main difference I see is that there is no vectorization: I will be computing the aggregate over the partitioned group for each row. Guess that's a minor thing that BigQuery's optimizer will be able to solve. Commented Nov 26, 2020 at 22:32
  • Not sure what is your expected output, if you only need a group of value, you should use GROUP BY category instead of a window function with category. But the UDF is the same in both case.
    – Yun Zhang
    Commented Nov 27, 2020 at 4:08