-
Notifications
You must be signed in to change notification settings - Fork 58
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 basic templating to snow sql #879
Conversation
cb55c48
to
454ede4
Compare
loader=loaders.FileSystemLoader(template_path.parent), | ||
keep_trailing_newline=True, | ||
undefined=StrictUndefined, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being used in snow app init
, which currently uses the regular jinja syntax {{}}
. I think we can constrain it such that all client side rendering must have &{}
only. I can change our templates to conform to that. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree, for example imagine creating a project for template that includes client side templating...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Native app has custom client-side template logic now that uses the standard jinja2 syntax. We should likely also support the Snowflake CLI syntax, but we can't remove support for the current behaviour without risking breaking existing users. I do agree with Tomasz that the Snowflake CLI does make it easier for clients to mix their own client-side template with ours.
# Using $ as sf variable and client side rendering | ||
("$&{ foo }", "$bar"), | ||
], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is helpful, thank you!
69d1542
to
916238b
Compare
query: Optional[str], | ||
file: Optional[Path], | ||
std_in: bool, | ||
data: Dict | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional[Dict]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP604 make both syntaxes compatible. We don't have a common pattern in our code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python-Version: 3.10
What with 3.8 and 3.9?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sfc-gh-astus we already use it across the code base so this is nothing new. If we want to align to standard format (for example #1001 ) we should do so in other PR.
|
||
|
||
def get_snowflake_cli_jinja_env(): | ||
_random_block = "___very___unique___block___to___disable___logic___blocks___" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is it for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A unique block to disable logic blocks. We don't want to support {% for foo in bar %}
syntax.
Pre-review checklist
Changes description
Add basic rendering of templates in SQL.