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 target variable to templating environment #149

Closed
jthandy opened this issue Sep 16, 2016 · 2 comments
Closed

add target variable to templating environment #149

jthandy opened this issue Sep 16, 2016 · 2 comments
Assignees

Comments

@jthandy
Copy link
Member

jthandy commented Sep 16, 2016

this would allow the user to do things like this in their models:

select *
from snowplow.sessions
{ if target == dev }
where session_start_timestamp between 1 and 7 days ago
{ end }

there is a ton of value to be had out of an extremely simple environment variable, this is just one example.

make sure to add this usage to the best practices guide in the help docs once this feature is added.

@jthandy jthandy changed the title add target variable to templating env add target variable to templating environment Sep 16, 2016
@jthandy jthandy mentioned this issue Sep 17, 2016
@drewbanin drewbanin modified the milestone: 0.5.1 Release Sep 28, 2016
@drewbanin drewbanin self-assigned this Sep 28, 2016
@drewbanin
Copy link
Contributor

This is a good idea and it should be super quick to add. I think that in practice, relying on the name of the target is a bad idea. Different people within the same org can have different target names b/c it's defined in the profiles.yml file. Moreover, there's no way this would work reliably in a package management world.

If the divide is dev/prod, should we add an environment var to the target? That sounds like a more dependable way to accomplish what you're looking for

@drewbanin drewbanin added the help_wanted Trickier changes, with a clear starting point, good for previous/experienced contributors label Sep 28, 2016
@jthandy
Copy link
Member Author

jthandy commented Sep 29, 2016

We talked about this yesterday. I'm still not sure I agree with you. Rails has database.yml and the three entries in there (development, test, production) are standard across rails deployments. What is the thing that is preventing us from doing the same? If target isn't that, then I think we should change it to that. People don't need arbitrary control over this, I think we should be opinionated about what the correct usage is here. I would be ok going so far as to validate acceptable values. You can name your profile whatever you want, but your target should be dev/prod/test. If that's not what you're thinking target is, then let's talk further.

@drewbanin drewbanin added code review and removed help_wanted Trickier changes, with a clear starting point, good for previous/experienced contributors labels Dec 4, 2016
yu-iskw pushed a commit to yu-iskw/dbt that referenced this issue Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants