Skip to main content

Command Palette

Search for a command to run...

Boolean data type in BigQuery

Updated
1 min read
Boolean data type in BigQuery
C

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

I remember that one of the things that struck me some years ago when switching from SQL Server to BigQuery was the existence of the bool data type in the latter, which I didn't have before.

I still see from time to time BigQuery code that does not leverage it to the fullest.

For example, this means you can just say val_b > val_a AS is_val_b_higher for a boolean flag instead of comparing and determining TRUE/FALSE. Also, just WHERE is_val_b_higher instead of WHERE is_val_b_higher IS/= TRUE.

This, in my opinion, makes the query much more readable when working with boolean flags.

If you properly name the flags, reading the query feels much closer to natural language.

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

Practical SQL

Part 1 of 50

Short, practical posts on SQL and BigQuery — from core language features to advanced query patterns. A reference for data practitioners at every level.

More from this blog

D

Datawise — SQL, BigQuery & Python for Data Engineers

207 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.