140015
Databricks Partner

Unfortunately, it didnt work that way, expect don't see scalar values saved as variables

@dlt.expect_or_fail("equal_number_of_records", "qa_silver_row_count == bronze_count")

@dlt.table()

def silver():

bronze_count == bronze_table.count()

silver_table = # transformations on bronze table

silver_table = silver_table.withColumn("qa_silver_row_count", F.lit(silver_table.count()))

The way I manage to make it run is:

@dlt.expect_or_fail("equal_number_of_records", "qa_silver_row_count == qa_bronze_row_count")

@dlt.table()

def silver():

bronze_table = #load bronze table

   silver_table = upstream_table.withColumn("qa_bronze_row_count", F.lit(bronze_table..count()))

silver_table = # transformations on bronze table

silver_table = silver_table.withColumn("qa_silver_row_count", F.lit(silver_table.count()))

It is a little bit cumbersome. It is a little annoying that DLT actually makes row count automatically but it can't be easily accessed. Maybe it is possible to get this data from the event log table I will try to find out