Skip to content

Feat: ignore SQL model unit test row order unless query contains ORDER BY#2133

Merged
treysp merged 3 commits intomainfrom
trey/test-row-order
Feb 19, 2024
Merged

Feat: ignore SQL model unit test row order unless query contains ORDER BY#2133
treysp merged 3 commits intomainfrom
trey/test-row-order

Conversation

@treysp
Copy link
Contributor

@treysp treysp commented Feb 16, 2024

SQLMesh unit tests currently require the rows returned by the test query to be in the same order as the output rows specified in the test definition. Different engines may return query rows in different orders, meaning the same unit test will pass on some engines and fail on others.

This PR makes SQL model unit tests row-order agnostic unless the model outer SELECT contains an ORDER BY clause (or a CTE's outer SELECT for CTE-specific tests).

Python model tests are order-dependent because there is no universally reliable way to determine whether the model orders the rows.

@treysp treysp force-pushed the trey/test-row-order branch from f23b9f1 to 383efaa Compare February 16, 2024 21:06
@treysp treysp merged commit 96b3c85 into main Feb 19, 2024
@treysp treysp deleted the trey/test-row-order branch February 19, 2024 16:11
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.

3 participants