Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explanation of Parsing vs. Compilation vs. Runtime #8744

Merged
merged 11 commits into from
Oct 10, 2023

Conversation

dbeatty10
Copy link
Contributor

@dbeatty10 dbeatty10 commented Sep 28, 2023

🎩 Preview

Problem

There’s a lot of confusion about what dbt does at parse time vs. compile time / runtime. Even that separation is a relative simplification: parsing includes multiple steps, and while there are some distinctions between "compiling" and "running" a model, the two are very closely related.

It's come up many times before, and we expect it will keep coming up! A decent number of bug reports in dbt-core are actually rooted in a misunderstanding of when configs are resolved, especially when folks are using pre/post hooks, or configs that alter materialization behavior (partitions, merge_exclude_columns, etc).

Solution

So let's publish something that we can use as a reference! Markdown within the code base would be a good first step.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • Tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc)
  • This PR includes type annotations for new and modified functions

@dbeatty10 dbeatty10 added the Skip Changelog Skips GHA to check for changelog file label Sep 28, 2023
@cla-bot cla-bot bot added the cla:yes label Sep 28, 2023
@dbeatty10 dbeatty10 force-pushed the dbeatty/parsing-compilation-etc branch from f83a15a to 7d73d81 Compare September 28, 2023 23:02
@dbeatty10 dbeatty10 marked this pull request as ready for review September 28, 2023 23:04
@dbeatty10 dbeatty10 requested a review from a team as a code owner September 28, 2023 23:04
@dbeatty10 dbeatty10 requested a review from gshank September 28, 2023 23:04
@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (408a789) 86.65% compared to head (4fc26eb) 86.43%.
Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8744      +/-   ##
==========================================
- Coverage   86.65%   86.43%   -0.23%     
==========================================
  Files         176      176              
  Lines       25772    26009     +237     
==========================================
+ Hits        22332    22480     +148     
- Misses       3440     3529      +89     
Flag Coverage Δ
integration 83.22% <ø> (-0.19%) ⬇️
unit 64.86% <ø> (-0.28%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 25 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this happen @dbeatty10! Talk is cheap, PRs are precious ;)

  • I left a first round of comments, mostly catching things that have changed since I initially wrote this last December
  • As far as where in the repo this should land - I wonder if the docs/architecture subfolder could be the right place? Perhaps (in the future) accompanied by some diagrams?

core/dbt/parser/parsing-vs-compilation-vs-runtime.md Outdated Show resolved Hide resolved
core/dbt/parser/parsing-vs-compilation-vs-runtime.md Outdated Show resolved Hide resolved
core/dbt/parser/parsing-vs-compilation-vs-runtime.md Outdated Show resolved Hide resolved
core/dbt/parser/parsing-vs-compilation-vs-runtime.md Outdated Show resolved Hide resolved
core/dbt/parser/parsing-vs-compilation-vs-runtime.md Outdated Show resolved Hide resolved
core/dbt/parser/parsing-vs-compilation-vs-runtime.md Outdated Show resolved Hide resolved
core/dbt/parser/parsing-vs-compilation-vs-runtime.md Outdated Show resolved Hide resolved
@dbeatty10
Copy link
Contributor Author

  • As far as where in the repo this should land - I wonder if the docs/architecture subfolder could be the right place? Perhaps (in the future) accompanied by some diagrams?

I'm guessing we'll want to move and/or rename this at least one more time. But in the interim, moved it here:
docs/eli64/parsing-vs-compilation-vs-runtime.md

when ELI5 just isn't detailed enough


### Parsing

As a user, you write models as SQL + YAML. dbt wants to understand each model as a Python object, defined by an internal data structure. It also wants to know its dependencies and configuration (= its place in the DAG). dbt reads your code **for that one model,** and attempts to construct that object, raising a **validation** error if it can’t.
Copy link
Contributor

@MichelleArk MichelleArk Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL (or Python!) + YAML

I can see how that can make the rest of the section a little more complicated to follow, so feel free to keep it simple

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

Attempted to address this in 4fc26eb

Disambiguate Python references and delineate SQL models ("Jinja-SQL") from Python models ("dbt-py")
@dbeatty10 dbeatty10 merged commit 339957b into main Oct 10, 2023
49 of 50 checks passed
@dbeatty10 dbeatty10 deleted the dbeatty/parsing-compilation-etc branch October 10, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Skip Changelog Skips GHA to check for changelog file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants