Feat: add support for freezing time in unit tests#2362
Merged
georgesittas merged 10 commits intomainfrom Mar 29, 2024
Merged
Conversation
519a11d to
f52bf74
Compare
eakmanrq
reviewed
Mar 28, 2024
sqlmesh/core/test/definition.py
Outdated
9e364c1 to
9d76349
Compare
izeigerman
reviewed
Mar 29, 2024
|
|
||
| def _execute(self, query: exp.Expression) -> pd.DataFrame: | ||
| """Executes the query with the engine adapter and returns a DataFrame.""" | ||
| with patch.dict(self._engine_adapter_dialect.generator_class.TRANSFORMS, self._transforms): |
Collaborator
There was a problem hiding this comment.
Does Dialect.get_or_raise(self.engine_adapter.dialect) return a global instance or a new one each time? If it's the latter, can't we just set transformers once and not patch it?
Collaborator
Author
There was a problem hiding this comment.
Unfortunately we can't do this, because TRANSFORMS is a class attribute and since generator classes are singletons we'd end up mutating dialects globally if we didn't patch it.
eakmanrq
approved these changes
Mar 29, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the 8th item in #1637
This seemed like a nice QOL feature to have in unit tests. The relevant Slack thread is: https://tobiko-data.slack.com/archives/C044BRE5W4S/p1711540655441619.