## wiring.stream_results()


Validate a frame and yield the asset's materialization and check results.


Usage

``` python
wiring.stream_results(
    schema,
    returned,
    *,
    context,
    error_rows_writer=None,
    check_granularity=None,
    max_failure_examples=None,
    statistics=None,
    row_sample=None
)
```


## Parameters


`schema: type[dy.Schema]`  
The schema to validate against.

`returned: DecoratedReturn`  
The frame to validate, a `dg.MaterializeResult` whose `value` is the frame, or `None` to skip. The materialization has a returned result's `metadata`, `data_version` and `tags`, and the package's own metadata keys take precedence. `dg.MaterializeResult(value=None)` raises instead of skipping.

`context: dg.AssetExecutionContext`  
The running asset's context, or one from `dg.build_asset_context()` in a direct invocation. Its asset definition must have exactly one asset, as a `@dg.asset` does. The asset key comes from it. The row count is under `dagster/partition_row_count` when the context has a partition key or range, and under `dagster/row_count` otherwise, because Dagster defines `dagster/row_count` as the whole table's count. [build_io_manager_writer](wiring.build_io_manager_writer.md#dagster_dataframely.wiring.build_io_manager_writer) makes the same choice, so the table and the error rows have their row counts under the same key.

`error_rows_writer: ErrorRowsWriter | None = None`  
The writer for the rows that failed an `"error"` rule, called at most once, with the frame [get_error_rows](wiring.get_error_rows.md#dagster_dataframely.wiring.get_error_rows) returns. It receives every such row, because the error rows are the only copy of the rows that a run with `filter=True` leaves out of the table (`docs/out-of-scope/dbt-test-configs.md#limit`). When no such row exists, it receives zero rows. Passing one means `filter=True`, so pass `filter=True` to [build_asset_check_specs](wiring.build_asset_check_specs.md#dagster_dataframely.wiring.build_asset_check_specs) too. With `None`, a row that fails an `"error"` rule fails the run with [ValidationAbortError](errors.ValidationAbortError.md#dagster_dataframely.errors.ValidationAbortError), and the asset writes nothing.

`check_granularity: Granularity | None = None`  
Pass the value [build_asset_check_specs](wiring.build_asset_check_specs.md#dagster_dataframely.wiring.build_asset_check_specs) received, or the results name checks the asset does not declare. `None` uses `DAGSTER_DATAFRAMELY_CHECK_GRANULARITY` if set, else `rule`.

`max_failure_examples: int | None = None`  
A rule's check metadata has at most this many rows that failed it. `None` uses `DAGSTER_DATAFRAMELY_MAX_FAILURE_EXAMPLES` if set, else `5`.

`statistics: bool | None = None`  
Whether the materialization metadata has statistics of the written rows. `None` uses `DAGSTER_DATAFRAMELY_STATISTICS` if set, else `True`.

`row_sample: int | None = None`  
The materialization metadata has at most this many rows of the table, and this many error rows. `None` uses `DAGSTER_DATAFRAMELY_ROW_SAMPLE` if set, else `5`.


## Yields


`dg.MaterializeResult[pl.DataFrame] | dg.AssetCheckResult`  
The asset's `dg.MaterializeResult`, if the run writes its table, then one `dg.AssetCheckResult` per check. On a skip, it yields only the check results, and every check passes. It writes the error rows instead of yielding them.


## Raises


`ReservedColumnError`  
A column name is in the reserved `dy_` namespace.

`InvalidColumnNameError`  
A column name has a character Dagster does not allow in an asset check name.

`CheckNameCollisionError`  
Two rules produce the same asset check name.

`InvalidSeverityError`  
The schema declares a severity this package cannot read.

`InvalidSettingError`  
A setting's argument or environment variable has a value the setting does not allow.

`dagster._core.errors.DagsterInvalidPropertyError`  
`context` is bound to no asset, as a `dg.build_asset_context()` is until an asset is called with it.

`DagsterInvariantViolationError`  
`returned` is not a Polars frame, a `dg.MaterializeResult` or `None`.

`MaterializeResultFieldError`  
`returned` is a `dg.MaterializeResult` that sets `asset_key` or `check_results`.

`MaterializeResultValueError`  
`returned` is a `dg.MaterializeResult` whose `value` is not a Polars frame.

`ColumnSchemaError`  
The frame's columns or dtypes do not match the schema. It yields the column-schema check's failing result first, and writes nothing.

`ValidationAbortError`  
A row failed an `"error"` rule and `error_rows_writer` is `None`, so the package writes nothing.

`NoValidRowsError`  
Every row failed an `"error"` rule. It writes the error rows, and not the asset's table.


## Examples

A hand-wired asset declares the specs and yields from [stream_results](wiring.stream_results.md#dagster_dataframely.wiring.stream_results):


``` python
from collections.abc import Iterator

import dagster as dg
import polars as pl

import dagster_dataframely as dd
from dagster_dataframely.data import OrdersSchema, storefront_orders


@dg.asset(
    metadata=dd.wiring.get_column_schema_metadata(OrdersSchema),
    check_specs=dd.wiring.build_asset_check_specs(OrdersSchema, asset="orders"),
)
def orders(
    context: dg.AssetExecutionContext,
) -> Iterator[dg.MaterializeResult[pl.DataFrame] | dg.AssetCheckResult]:
    yield from dd.wiring.stream_results(
        OrdersSchema, storefront_orders, context=context
    )


dg.materialize([orders]).success
```


    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - RUN_START - Started execution of run for "__ephemeral_asset_job__".
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - ENGINE_EVENT - Executing steps in process (pid: 3707)
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - RESOURCE_INIT_STARTED - Starting initialization of resources [io_manager].
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - RESOURCE_INIT_SUCCESS - Finished initialization of resources [io_manager].
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - LOGS_CAPTURED - Capturing logs for process (pid: 3707).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_START - Started execution of step "orders".
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "result" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - orders - Writing file at: /tmp/tmp06aif2du/storage/orders using PickledObjectFilesystemIOManager...
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_MATERIALIZATION - Materialized value orders.
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - HANDLED_OUTPUT - Handled output "result" using IO manager "io_manager"
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_schema__columns" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_schema__columns' on 'orders' passed. Description: 'Every column matches.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__paid_orders_have_amount" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__paid_orders_have_amount' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__line_numbers_are_dense" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__line_numbers_are_dense' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__primary_key" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__primary_key' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__order_id__nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__order_id__nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__order_id__regex" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__order_id__regex' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__line_no__nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__line_no__nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__line_no__min" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__line_no__min' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__email__nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__email__nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__email__check__lowercase" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__email__check__lowercase' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__email__max_length" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__email__max_length' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__amount__nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__amount__nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__amount__min" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__amount__min' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__quantity__nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__quantity__nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__quantity__min" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__quantity__min' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__quantity__max" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__quantity__max' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__priority__is_in" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__priority__is_in' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__status__nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__status__nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__tracking_id__unique" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__tracking_id__unique' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__is_gift__nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__is_gift__nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__ordered_at__nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__ordered_at__nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__tags__max_length" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__tags__max_length' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__tags__inner_nullability" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__tags__inner_nullability' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_OUTPUT - Yielded output "orders_dy_rule__note__check" of type "Any". (Type check passed).
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - ASSET_CHECK_EVALUATION - Asset check 'dy_rule__note__check' on 'orders' passed. Description: 'No row failed.'
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - orders - STEP_SUCCESS - Finished execution of step "orders" in 142ms.
    /home/runner/work/dagster-dataframely/dagster-dataframely/.venv/lib/python3.12/site-packages/dagster/_core/execution/context_creation_job.py:273: RuntimeWarning: coroutine 'BaseEventLoop.shutdown_asyncgens' was never awaited
      pass
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - ENGINE_EVENT - Finished steps in process (pid: 3707) in 154ms
    2026-10-22 02:11:10 +0000 - dagster - DEBUG - __ephemeral_asset_job__ - 21a46c6e-432b-402d-9778-17752983fc9f - 3707 - RUN_SUCCESS - Finished execution of run for "__ephemeral_asset_job__".


    True
