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

Add a special as_text filter to the native env (#2384) #2395

Merged
merged 3 commits into from
May 4, 2020

Conversation

beckjake
Copy link
Contributor

@beckjake beckjake commented May 4, 2020

resolves #2384

Description

Add a special as_text filter to the native env that tells dbt to render the value as a string no matter what.

Use like dataset: "{{ 1991 | as_text }}" -> dataset: "1991"
Also, I moved the weird special quoting handling logic out and instead avoid calling the renderer on column_name arguments entirely. Much better than doing weird things with quotes!

I added some very basic unit tests that should exercise this behavior.

I don't love this fix, but I think it's satisfactory and has the benefit of being really, really simple. There's just so little that can go horribly wrong!

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 May 4, 2020
…er the value as a string no matter what.

Use like "{{ 1991 | as_text }}" -> "1991"
Also, moved the weird special quoting handling logic out and instead avoid calling the renderer on column_name arguments
@beckjake beckjake force-pushed the fix/bigquery-numbery-datasets branch from fc0e978 to 0961bdb Compare May 4, 2020 19:18
@beckjake beckjake requested a review from drewbanin May 4, 2020 19:46
Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

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

one comment then LGTM

return env_cls(**args)
env = env_cls(**args)
if native:
env.filters['as_text'] = TextMarker
Copy link
Contributor

Choose a reason for hiding this comment

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

can we always add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! I think in the else case we actually want to set it to str.

@beckjake beckjake merged commit 7db16f8 into dev/octavius-catto May 4, 2020
@beckjake beckjake deleted the fix/bigquery-numbery-datasets branch May 4, 2020 20:50
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.

Regression: dbt does not allow integer dataset names on BigQuery
2 participants