Here's a great use case for GenAI writing SQL

Senior Data Engineer • Contractor / Freelancer • GCP & AWS Certified
Search for a command to run...

Senior Data Engineer • Contractor / Freelancer • GCP & AWS Certified
No comments yet. Be the first to comment.
Short, practical posts on SQL and BigQuery — from core language features to advanced query patterns. A reference for data practitioners at every level.
Long time, no see! Here's a quick SQL exercise that illustrates some important modern concepts. So, we're given a list of updates per each order, and at each point in time we have some flags. Our goal here is to check for each order if there was any ...
Here's a useful Dataform concept: pre_operations and post_operations. As the name implies, these represent a set of actions that run before and after the main operation (table, view, or SQL operations

BigQuery has always been a SQL engine for tabular data. Object tables add an interesting twist to that. Instead of rows containing values, an object table gives you one row per file — pointing at da

Query your data lake with warehouse-grade security and performance — without moving a single file.

Ever run a heavy BigQuery SQL query, processed gigabytes of data — and then accidentally closed the tab or forgot to save the results? 😬 Don't re-run it. Your results are still there. BigQuery automa

You can use query parameters in BigQuery hashtag#SQL (now in the console as well!) — but how are they different from variables, and when should you use each? Both parameters and variables act as place

Truth be told, I almost never use GenAI as part of my day-to-day work as a Data Engineer. For the most part, it’s just easier and faster for me to write the SQL code myself.
There are a few reasons for this:
➡️ If the task is complex enough to need ChatGPT, it usually requires providing a lot of context, iterating on prompts, thinking up some illustrative play data (since sharing real customer data is a big no-go), and then thoroughly understanding and verifying the solution it suggests.
➡️ Most of the time, by the time I’ve done all of that, I could’ve just written the code manually.
➡️ I trust my 10+ years of experience writing SQL more.
That said, I’ve used GenAI occasionally for tasks that are tedious and time-consuming, like fixing scrambled code that needed proper formatting. And I fully recognize its value as a prototyping tool or as a quick way to iterate over ideas.
Now, I recently had a situation where the stars aligned perfectly.
I needed to compute the list of all possible combinations of 9 elements. Essentially: C(9, 1) + C(9, 2) + … + C(9, 9).
In total, math tells us there should be 511 combinations.
This would’ve taken me quite a bit of time to write manually, but with 2–3 prompts (where GPT fixed its own errors), I ended up with the below solution.
If you're not familiar with recursive CTEs, check out my previous post.
Sometimes, it’s about knowing when and where to use the tools at your disposal. While it might not work for many tasks, I appreciate the moments where it can help streamline things significantly.
What’s your experience? Do you use tools like ChatGPT regularly for your Data Engineering tasks?
Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.