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

Remove injected_sql. Store non-ephemeral injected_sql in compiled_sql #2834

Merged
merged 1 commit into from
Oct 19, 2020

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Oct 15, 2020

resolves #2762

Description

The 'injected_sql' field in the manifest nodes is confusing, since it's another form of compiled_sql. The injected_sql field is used internally in compiling ephemeral nodes. This code removed injected_sql from the classes and artifacts, and copies it into 'compiled_sql' for executable nodes. Ephemeral nodes will retain their original 'compiled_sql', since it didn't work to overwrite compiled_sql with injected_sql for those nodes. Since ephemeral nodes do not show up in executable SQL files, this will not hopefully be an issue.

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

@cla-bot cla-bot bot added the cla:yes label Oct 15, 2020
@gshank gshank force-pushed the feature/remove_injected_sql branch 4 times, most recently from 2339c5b to 8be9825 Compare October 15, 2020 15:40
@gshank gshank force-pushed the feature/remove_injected_sql branch from 8be9825 to 512c41d Compare October 15, 2020 15:52
@gshank gshank requested review from jtcohen6, kwigley and iktl and removed request for kwigley and iktl October 15, 2020 16:23
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.

I took this for a spin locally and tried a bunch of hacky things with ephemeral models and dynamic templating (via run_query). The compiled_sql in the manifest looks good every time.

Really happy to see all the code comments in compilation.py! I can actually follow what's happening.

After we merge this and before a v0.19 prerelease, we'll want to merge the corresponding dbt-docs PR: dbt-labs/dbt-docs#148

self.assertGreaterEqual(result[1].replace(tzinfo=pytz.UTC), self._invalidated_snapshot_datetime)
# there are milliseconds (part of microseconds in datetime objects) in the
# invalidated_snapshot_datetime and not in result datetime so set the microseconds to 0
self.assertGreaterEqual(result[1].replace(tzinfo=pytz.UTC), self._invalidated_snapshot_datetime.replace(microsecond=0))
Copy link
Contributor

Choose a reason for hiding this comment

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

nice catch

Copy link
Contributor

@kwigley kwigley 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 being patient with me! This looks great, just one small stylistic question

core/dbt/context/providers.py Show resolved Hide resolved
@gshank gshank merged commit 2783825 into dev/kiyoshi-kuromiya Oct 19, 2020
@jtcohen6 jtcohen6 mentioned this pull request Dec 17, 2020
1 task
@kwigley kwigley deleted the feature/remove_injected_sql branch February 12, 2021 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove injected_sql
3 participants