-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Question] Unit Testing #60
Comments
I don't have a specific recommendation but I think you're quite flexible:
Anything specific you'd want to test? |
I think were interested unit testing more of our DBT pipelines in general and dbt-ibis seems like an interesting bridge to get there (we're aware of dbt unit tests). Specifically there are CTEs defined in SQL that we would like to be unit tested due to some complex business logic.
Could you provide a simple example of how you would use the aforementioned function in something like |
Not sure how you could make dbt-ibis work with SQL models, curious to see what you come up with! Here's a minimal example:
from dbt_ibis import depends_on, ref
@depends_on(ref("stg_orders"))
def model(orders):
return orders.limit(2) In your tests, you could then do: from pathlib import Path
import ibis
import pandas as pd
from dbt_ibis import _get_expr_func
def test_some_orders_model():
# Setup with some mock data in an in-memory duckdb database
model = _get_expr_func(Path("<path to your dbt model>/some_orders_model.ibis"))
con = ibis.duckdb.connect()
orders = con.read_in_memory(pd.DataFrame.from_dict({"order_id": [0, 1, 2, 3, 4]}))
# Test
result_table = model(orders)
result_df = result_table.execute()
# Assert
assert result_df.shape[0] == 2
# ... Add more tests either on the Ibis table or on the Pandas dataframe or ... |
Is there a recommended path for how to unit test dbt-ibis models?
The text was updated successfully, but these errors were encountered: