Skip to content
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

Fix row count asset check for vcerare #3993

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/pudl/transform/vcerare.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pyarrow as pa
import pyarrow.parquet as pq
from dagster import (
AssetCheckExecutionContext,
AssetCheckResult,
asset,
asset_check,
Expand Down Expand Up @@ -359,16 +360,25 @@ def _load_duckdb_table():
blocking=True,
description="Check that row count matches expected.",
)
def check_rows() -> AssetCheckResult:
def check_rows(context: AssetCheckExecutionContext) -> AssetCheckResult:
"""Check rows."""
logger.info("Check VCE RARE hourly table is the expected length")

# Define row counts for fast/full etl
row_counts = {
"etl_full": 136437000,
"etl_fast": 27287400,
}

vce = _load_duckdb_table() # noqa: F841
(length,) = duckdb.query("SELECT COUNT(*) FROM vce").fetchone()
if length != 136437000:
if (
expecteded_length := row_counts[context.op_execution_context.job_name]
zschira marked this conversation as resolved.
Show resolved Hide resolved
) != length:
return AssetCheckResult(
passed=False,
description="Table unexpected length",
metadata={"table_length": length, "expected_length": 136437000},
metadata={"table_length": length, "expected_length": expecteded_length},
zschira marked this conversation as resolved.
Show resolved Hide resolved
)
return AssetCheckResult(passed=True)

Expand Down
Loading