Riley Runnoe
04/25/2023, 2:33 PMruntime_metadata_fn
to gather this metadata about partitioned builds.
The custom function I am using and the load_assets_from_dbt_project
read as follows:
def custom_metadata_fn(context, node_info):
table_name = node_info["name"]
table_schema = node_info["schema"]
n_rows = f"SELECT 1 from {table_schema}.{table_name} where date = {context.partition_key}"
return {"n_rows": n_rows}
dbt_assets = load_assets_from_dbt_project(
project_dir=DBT_PROJECT_PATH,
profiles_dir=DBT_PROFILES,
use_build_command=True,
partitions_def=DailyPartitionsDefinition(start_date="2023-04-14"),
partition_key_to_vars_fn=partition_key_to_dbt_vars,
runtime_metadata_fn=custom_metadata_fn,
)
The question I have is how do I pass that n_rows
query to either an io_manager or some other mechanism to actually query the {table_schema}.{table_name}
table? do i just have to access the bigquery sdk? or is there a dagster api I can interface with?
using:
dbt-bigquery==1.1.0
dagster==1.3.0
dagit==1.3.0
dagster-dbt==0.19.0
jamie
04/25/2023, 3:18 PM