My BigQuery Stories — Dynamically passing filters to BigQuery Stored Procedure

By Bihag Kashikar | @intelia | November 6

Introduction

In this article of My BigQuery Stories — I would like to share one of common use cases involving a Stored procedure.

There are always instances where in you have created a stored procedure which needs to evolve with the changing data and hence we need to make the procedure reusable by dynamically passing the “condition” upon which the stored procedures yields a particular outcome.

Once such instance being, in one my recent projects, I had created a stored procedure to INSERT some data into a BigQuery table. I had to change the procedure to accept parameter which is passed as an condition to execute the INSERT statement.

The below statement gives away the approach in which I made this work.

Stored procedure code:

Call to procedure:

In this call to the procedure, the case condition 1 is evaluated to true and hence INSERTS condition 1 in table tblOne.

 

 

 

Hope this helps. Keep an eye out for more of Bihag’s BigQuery learnings and stories coming ahead.