4 Functions in Google BigQuery you might not know about
What are the lesser known but practical Functions in BigQuery SQL?

BigQuery is the flagship analytics service in its Google Cloud. It is a SaaS Data Warehouse, or can also be referred to as a Data Lakehouse, that offers data analysis via SQL, data integration services, BI integration and even machine learning via SQL. In addition to the very well-known functions in BigQuery SQL, I would like to list four functions that are perhaps not so common, but nevertheless quite practical.
Function 1: Data Validation with SAFE CAST
Especially in the data integration process, it’s necessary to validate the date. Here, the SAFE_CAST function is a big help to prevent errors. If the value cannot be converted, it returns NULL instead of an error. The SAFE_CAST function can be useful when dealing with data of different types, for example when loading data from source systems via tool or CSV file.
Function 2: Aggregation Functions within an Array
BigQuery provides many aggregation functions, such as SUM, COUNT, AVG, MIN, and MAX. However, there are also some lesser known aggregation functions that can be very useful, such as ARRAY_AGG, which aggregates values in an array. This function can be useful when you need to combine multiple values in a single array [1].
Function 3: Analytic Functions
Analytic functions can be used for example by Data Analysts and Scientists to perform calculations over a group of rows in a table. BigQuery provides many analytical functions, such as RANK, DENSE_RANK, NTILE, and LEAD. These functions can be used to perform complex calculations and analysis on your data.
Function 4: BigQuery ML Functions
Also perhaps surprising and unknown to many, BigQuery offers BigQuery ML, a toolset that allows you to easily develop more and run SQL Machine Learning models.
This of course has advantages for Data Scientists, since data does not have to be loaded into another tool like a notebook. Also, BigQuery has a lot of capacity for scaling, which can be an advantage with large data sets, also only SQL is needed, which enables Machine Learning with a smaller skillset.
Summary
I hope you enjoyed the article and maybe found some new ideas for working with BigQuery, because the functions listed here are very useful but may not be as well known as other functions. They support Data Engineers in data integration as well as Data Analysts in performing deeper analysis.
Sources and Further Readings
[1] Google, ARRAY_AGG (2023)




