Skip to content

Feat!: Support pre-post statements in python models at creation time#2977

Merged
themisvaltinos merged 8 commits intomainfrom
themis/prepost_statements
Aug 8, 2024
Merged

Feat!: Support pre-post statements in python models at creation time#2977
themisvaltinos merged 8 commits intomainfrom
themis/prepost_statements

Conversation

@themisvaltinos
Copy link
Contributor

This update introduces the ability to enable pre- and post-statements in python models that can be executed during the table creation phase, fixes: #2866

The SqlBased model renderers has been moved to the _Model class, so that the logic can be reused by python models. Also to support macro calls in the pre- and post-statements, the python environment is updated with the referenced macros (similarly to sql models).

@themisvaltinos themisvaltinos force-pushed the themis/prepost_statements branch from 49adc9e to 8aedc9a Compare August 6, 2024 09:29
@themisvaltinos
Copy link
Contributor Author

addressed comments and added functionality to support jinjas. Thank you @georgesittas, when you have time if you could take another look

a change in particular that I'm not entirely sure if it might have unforeseen consequences is replacing the maybe_parse function with parse_one (so that Jinja statements can be parsed) in the decorator:

https://github.com/TobikoData/sqlmesh/blob/8aedc9a02c2186230fcb50d8f304f6c6d2a92c3c/sqlmesh/core/model/decorator.py#L130

@georgesittas georgesittas requested a review from a team August 6, 2024 14:51
@themisvaltinos themisvaltinos force-pushed the themis/prepost_statements branch from 527477a to 30d607a Compare August 7, 2024 16:22
@themisvaltinos themisvaltinos changed the title Feat: Support pre-post statements in python models at creation time Feat!: Support pre-post statements in python models at creation time Aug 7, 2024
@themisvaltinos themisvaltinos merged commit 6405aed into main Aug 8, 2024
@themisvaltinos themisvaltinos deleted the themis/prepost_statements branch August 8, 2024 12:31
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

Successfully merging this pull request may close these issues.

Support pre/post-statements in Python models that yield DataFrames

2 participants