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

Fix compiled_code, reimplement sql as wrapper #9503

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Conversation

jtcohen6
Copy link
Contributor

@jtcohen6 jtcohen6 commented Feb 1, 2024

resolves #9502

Problem

Solution

  • Update the logic for compiled_code context member
  • Reimplement sql context member as a wrapper around compiled_code, to prevent future divergence

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
  • This PR includes tests, or 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) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@jtcohen6 jtcohen6 requested a review from a team as a code owner February 1, 2024 11:43
@cla-bot cla-bot bot added the cla:yes label Feb 1, 2024
Copy link
Contributor

github-actions bot commented Feb 1, 2024

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2d59a51) 88.03% compared to head (c523369) 88.01%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9503      +/-   ##
==========================================
- Coverage   88.03%   88.01%   -0.03%     
==========================================
  Files         167      167              
  Lines       22130    22126       -4     
==========================================
- Hits        19482    19474       -8     
- Misses       2648     2652       +4     
Flag Coverage Δ
integration 85.56% <100.00%> (-0.04%) ⬇️
unit 62.36% <100.00%> (-0.01%) ⬇️

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

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

def sql(self) -> Optional[str]:
# only set this for sql models, for backward compatibility
if self.model.language == ModelLanguage.sql: # type: ignore[union-attr]
return self.compiled_code
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm following the logic correctly, I think this previously resulted in self.model.compiled_code. I want to make sure this is intentional since both are syntactically correct.

@jtcohen6
Copy link
Contributor Author

jtcohen6 commented Feb 1, 2024

🎩 Confirmed this fix locally by running an incremental model on dbt-snowflake

Before:

On model.my_project.my_model: /* {"app": "dbt", "dbt_version": "1.8.0a1", "profile_name": "snowflake", "target_name": "dev", "node_id": "model.my_project.my_model"} */
create or replace transient table analytics_dev.dbt_jcohen.my_model
         as
        (select * from analytics.analytics.my_model
        );

After:

On model.my_project.my_model: /* {"app": "dbt", "dbt_version": "1.8.0a1", "profile_name": "snowflake", "target_name": "dev", "node_id": "model.my_project.my_model"} */
create or replace transient table analytics_dev.dbt_jcohen.my_model
         as
        (

... tons of SQL ...
);

@jtcohen6 jtcohen6 merged commit 1a5d692 into main Feb 1, 2024
51 checks passed
@jtcohen6 jtcohen6 deleted the jerco/fix-9502 branch February 1, 2024 15:20
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.

[Bug] Update command-based logic in compiled_code context member, to match sql
4 participants