Skip to content

Fix: Avoid concurrent dialect patching in model testing#4266

Merged
VaggelisD merged 4 commits intomainfrom
vaggelisd/test_concurrency
May 1, 2025
Merged

Fix: Avoid concurrent dialect patching in model testing#4266
VaggelisD merged 4 commits intomainfrom
vaggelisd/test_concurrency

Conversation

@VaggelisD
Copy link
Contributor

To freeze time through execution_time in unit tests we essentially patch the SQLGlot dialects globally to generate any CURRENT_<date/time>() reference as a cast at the specified time & type.

This works fine if tests are run sequentially but runs into race conditions in concurrent execution. This PR:

  • Replaces the global patching for SQL models by instead transforming the corresponding AST nodes before generation

  • Locks the global patching for Python models using the runner's lock; This is required because Python models can execute any SQL statement, so the patching is indeed necessary to cover that globally.

@VaggelisD VaggelisD force-pushed the vaggelisd/test_concurrency branch from 19e24a3 to deca19c Compare April 30, 2025 08:59
@VaggelisD VaggelisD merged commit f3dd3d6 into main May 1, 2025
22 checks passed
@VaggelisD VaggelisD deleted the vaggelisd/test_concurrency branch May 1, 2025 16:01
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.

2 participants