-
Notifications
You must be signed in to change notification settings - Fork 5
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
Idea: not having to define input mocks for downstream tables when using assert_cte_equal #46
Comments
Good point. One way around it is to use defaults in the table mock definition: @table_meta(
query_path="./examples/test_query.sql",
default_inputs=[
UserTable([]),
SubscriptionTable([]),
], # We can provide defaults for the class if needed. Then we don't always need to provide data for all input tables.
)
class MultipleSubscriptionUsersTable(ClickHouseTableMock):
user_id = col.Int(default=1) As in the example above, they can also be empty by default. Maybe this can solve your problem in the meanwhile. I think the issue is that we currently call the validation when you use the Pros
Cons
|
Thanks Thomas. Having thought about it there are some possible solutions: Proposal 1: Then we don't have to define anything else and we have declared upfront that we will only be doing validations until the declared cte. input_table_mock = UserTable.from_dicts(user_table_data)
res = MultipleSubscriptionUsersTable.from_mocks(input_data=[input_table_mock], cte='cte_users') This does leave the question what to does Proposal 2: You would need to be more flexible in the validation when doing You can provide an error at the Checks happen once but error thrown out is in the context of what you are trying to run. Proposal 3: Then I define it something like this in the models.py: @table_meta(query=QUERY, cte=`cte_users`)
class CTEUsersMock(ClickHouseTableMock):
user_id = col.Int(default=1) I like this one in the send that it forces you to be more explicit with your cte schema testing definition but means you will have to write more models in Let me know what you think. |
When I run
assert_cte_equal
I have to define all downstream tables even if they are not needed. I think this is just an issue in the checks not an actual runtime issue, so I propose a change invalidate_all_input_mocks_for_query_provided
so it also ignores downstream CTEs when runningassert_cte_equal
.This would be a step forward in treating each CTE as a unit and being able to isolate every CTE and define the bare minimum to test it.
The text was updated successfully, but these errors were encountered: