Just because you can, doesn’t mean you should. But in this case, you definitely should! Learn how this one weird trick (Jinja templating) will supercharge your analytics workflows and help you do more, better, faster with SQL.
3. ● Open core data modeling software
● dbt provides a SQL-first workflow for:
- Data modeling
- Data testing
- Data documentation
- And more!
You can learn more at getdbt.com
We’re the makers of dbt
4. Confessions & disclaimers
● I have never written a line of production Scala code in my life
● I have written a whole lot of SQL in my life
● People who tolerate Python packaging don’t get to complain about the JVM
5. I ❤ SQL
, Expressive
, Accessible
, Universal
, Declarative
, Thought provoking….?
6. I ❤ SQL
, Expressive - SQL reads more or less like a real sentence
, Accessible
, Universal
, Declarative
, Thought provoking….?
7. I ❤ SQL
, Expressive
, Accessible - Lots of people can learn in pretty quickly
, Universal
, Declarative
, Thought provoking….?
8. I ❤ SQL
, Expressive
, Accessible
, Universal - Most databases speak SQL with pretty consistent support
, Declarative
, Thought provoking….?
9. I ❤ SQL
, Expressive
, Accessible
, Universal
, Declarative - No moving parts, limited opportunities for the bad kind of magic
, Thought provoking….?
10. I ❤ SQL
, Expressive
, Accessible
, Universal
, Declarative
, Thought provoking….?
13. What: convert rows of data into columns of data
Why: to derive new metrics from existing rows in a table
Pivoting columns
14. What: convert rows of data into columns of data
Why: to derive new metrics from existing rows in a table
Pivoting columns
user_id event_name happened_at
1 signup 2021-01-01
1 purchase 2021-01-02
2 signup 2021-01-03
3 signup 2021-01-04
3 purchase 2021-01-05
1 purchase 2021-01-05
15. What: convert rows of data into columns of data
Why: to derive new metrics from existing rows in a table
Pivoting columns
user_id event_name happened_at
1 signup 2021-01-01
1 purchase 2021-01-02
2 signup 2021-01-03
3 signup 2021-01-04
3 purchase 2021-01-05
1 purchase 2021-01-05
16. What: convert rows of data into columns of data
Why: to derive new metrics from existing rows in a table
Pivoting columns
user_id event_name happened_at
1 signup 2021-01-01
1 purchase 2021-01-02
2 signup 2021-01-03
3 signup 2021-01-04
3 purchase 2021-01-05
1 purchase 2021-01-05
user_id signup_date purchases
1 2021-01-01 2
2 2021-01-02 0
3 2021-01-04 1
21. Unions
What: append tables together
Why: combine tables into a taller table
source user_id event_name happened_at
mobile 1 app_install 2021-01-01
mobile 1 screen_view 2021-01-02
mobile 2 app_install 2021-01-03
web 1 signup 2021-01-01
web 1 purchase 2021-01-02
web 2 signup 2021-01-03
all_events
30. SQL: The bad parts
● No “functions” for code reuse
● Lots of typing → lots of typos
● It might be the most copy/pasted language of all time!
○ Citation needed
● But…. what if we add templating?
31.
32.
33. ● Yes!
● Accessibility is 🔑
● What happens when you teach people SQL?
○ Data (engineers|scientists|analysts) can collaborate in code
○ Non-engineers are empowered to understand business logic
○ More people can contribute!
You can do it in SQL… but should you?
34. What does the future hold?
● More data workloads will converge around SQL
● Databases will improve support for sophisticated SQL operations
- AI & ML?
- Streaming?
- ….?
● More roles will require SQL knowledge and aptitude
● More & better tools will exist to aid in writing and managing SQL