Skip to main content

Command Palette

Search for a command to run...

Query parameters in BigQuery

Updated
1 min read
Query parameters in BigQuery
C

Senior Data Engineer • Contractor / Freelancer • GCP & AWS Certified

Query parameters in BigQuery. You need to know about them if you're constructing queries based on user input. What do they do?

They can help secure your query against SQL injection and can be recognized by the @ (for named usage) and ? (for positional usage).

Unlike variables, with whom we should not confound them, one cannot use them in the console (web IDE), but only with bq command line interface, API or client libraries.

You can ✅ :
- use parameters for expressions
- provide a datatype for the query parameter or omit it with STRING as default
- use complex types such as ARRAY or STRUCT

But you cannot ❌ :
- pass parameters as column or table names
- use positional AND named parameters at the same time

Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.


Enjoyed this? Here are some related articles you might find useful:

More from this blog

D

Datawise: A blog on SQL, BigQuery, Analytics, Python Tips and Tricks

204 posts

Data Engineer with a passion for transforming complex data landscapes into insightful stories. Here on my blog, I share insights, challenges, and the ever-evolving dance of technology and business.