Skip to content

Commit

Permalink
fix: changes to the mechanism for determining the dbt asset check des…
Browse files Browse the repository at this point in the history
…cription
  • Loading branch information
rexledesma committed Jan 30, 2024
1 parent ccc7c48 commit eaa6920
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
from .utils import input_name_fn, output_name_fn

if TYPE_CHECKING:
from .dagster_dbt_translator import (
DagsterDbtTranslator,
DbtManifestWrapper,
)
from .dagster_dbt_translator import DagsterDbtTranslator, DbtManifestWrapper

MANIFEST_METADATA_KEY = "dagster_dbt/manifest"
DAGSTER_DBT_TRANSLATOR_METADATA_KEY = "dagster_dbt/dagster_dbt_translator"
Expand Down Expand Up @@ -557,7 +554,7 @@ def default_asset_check_fn(
return AssetCheckSpec(
name=test_resource_props["name"],
asset=asset_key,
description=test_resource_props["description"],
description=test_resource_props.get("meta", {}).get("description"),
additional_deps=additional_deps,
)

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ models:
- accepted_values:
values:
["placed", "shipped", "completed", "return_pending", "returned"]
config:
meta:
description: "Status must be one of ['placed', 'shipped', 'completed', 'return_pending', or 'returned']"

- name: amount
description: Total amount (AUD) of the order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,105 +73,94 @@ def my_dbt_assets_with_checks():
"customers_not_null_customers_customer_id": AssetCheckSpec(
name="not_null_customers_customer_id",
asset=AssetKey(["customers"]),
description="",
),
"customers_unique_customers_customer_id": AssetCheckSpec(
name="unique_customers_customer_id",
asset=AssetKey(["customers"]),
description="",
),
"orders_accepted_values_orders_status__placed__shipped__completed__return_pending__returned": AssetCheckSpec(
name="accepted_values_orders_status__placed__shipped__completed__return_pending__returned",
asset=AssetKey(["orders"]),
description="",
description="Status must be one of ['placed', 'shipped', 'completed', 'return_pending', or 'returned']",
),
"orders_not_null_orders_amount": AssetCheckSpec(
name="not_null_orders_amount", asset=AssetKey(["orders"]), description=""
name="not_null_orders_amount",
asset=AssetKey(["orders"]),
),
"orders_not_null_orders_bank_transfer_amount": AssetCheckSpec(
name="not_null_orders_bank_transfer_amount",
asset=AssetKey(["orders"]),
description="",
),
"orders_not_null_orders_coupon_amount": AssetCheckSpec(
name="not_null_orders_coupon_amount", asset=AssetKey(["orders"]), description=""
name="not_null_orders_coupon_amount",
asset=AssetKey(["orders"]),
),
"orders_not_null_orders_credit_card_amount": AssetCheckSpec(
name="not_null_orders_credit_card_amount",
asset=AssetKey(["orders"]),
description="",
),
"orders_not_null_orders_customer_id": AssetCheckSpec(
name="not_null_orders_customer_id", asset=AssetKey(["orders"]), description=""
name="not_null_orders_customer_id",
asset=AssetKey(["orders"]),
),
"orders_not_null_orders_gift_card_amount": AssetCheckSpec(
name="not_null_orders_gift_card_amount",
asset=AssetKey(["orders"]),
description="",
),
"orders_not_null_orders_order_id": AssetCheckSpec(
name="not_null_orders_order_id", asset=AssetKey(["orders"]), description=""
name="not_null_orders_order_id",
asset=AssetKey(["orders"]),
),
"orders_relationships_orders_customer_id__customer_id__ref_customers_": AssetCheckSpec(
name="relationships_orders_customer_id__customer_id__ref_customers_",
asset=AssetKey(["orders"]),
description="",
additional_deps=[
AssetKey(["customers"]),
],
),
"orders_unique_orders_order_id": AssetCheckSpec(
name="unique_orders_order_id", asset=AssetKey(["orders"]), description=""
name="unique_orders_order_id",
asset=AssetKey(["orders"]),
),
"stg_customers_not_null_stg_customers_customer_id": AssetCheckSpec(
name="not_null_stg_customers_customer_id",
asset=AssetKey(["stg_customers"]),
description="",
),
"stg_customers_unique_stg_customers_customer_id": AssetCheckSpec(
name="unique_stg_customers_customer_id",
asset=AssetKey(["stg_customers"]),
description="",
),
"stg_orders_accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned": AssetCheckSpec(
name="accepted_values_stg_orders_status__placed__shipped__completed__return_pending__returned",
asset=AssetKey(["stg_orders"]),
description="",
),
"stg_orders_not_null_stg_orders_order_id": AssetCheckSpec(
name="not_null_stg_orders_order_id",
asset=AssetKey(["stg_orders"]),
description="",
),
"stg_orders_unique_stg_orders_order_id": AssetCheckSpec(
name="unique_stg_orders_order_id",
asset=AssetKey(["stg_orders"]),
description="",
),
"stg_payments_accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card": AssetCheckSpec(
name="accepted_values_stg_payments_payment_method__credit_card__coupon__bank_transfer__gift_card",
asset=AssetKey(["stg_payments"]),
description="",
),
"stg_payments_not_null_stg_payments_payment_id": AssetCheckSpec(
name="not_null_stg_payments_payment_id",
asset=AssetKey(["stg_payments"]),
description="",
),
"stg_payments_unique_stg_payments_payment_id": AssetCheckSpec(
name="unique_stg_payments_payment_id",
asset=AssetKey(["stg_payments"]),
description="",
),
"fail_tests_model_accepted_values_fail_tests_model_first_name__foo__bar__baz": AssetCheckSpec(
name="accepted_values_fail_tests_model_first_name__foo__bar__baz",
asset=AssetKey(["fail_tests_model"]),
description="",
),
"fail_tests_model_unique_fail_tests_model_id": AssetCheckSpec(
name="unique_fail_tests_model_id",
asset=AssetKey(["fail_tests_model"]),
description="",
),
}

Expand Down Expand Up @@ -246,7 +235,7 @@ def my_dbt_assets(context: AssetExecutionContext, dbt: DbtCliResource):
def test_materialize_no_selection(dbt_commands: List[List[str]]) -> None:
result = _materialize_dbt_assets(dbt_commands, selection=None, raise_on_error=False)
assert not result.success # fail_tests_model fails
assert len(result.get_asset_materialization_events()) == 9
assert len(result.get_asset_materialization_events()) == 10
assert len(result.get_asset_check_evaluations()) == 22


Expand Down

0 comments on commit eaa6920

Please sign in to comment.