Analytics Engineering, Bigquery, Sql, Data Engineering, Editors Pick.
if possible. The UDF has the advantage of making the code more generic and safe (with unit tests). However, it has the drawback of being generally less efficient and more costly compared to pure SQL. As an exercise, if you want some practice, I recommend trying to rewrite this exercise yourself