I want to check the value of dml_affected_rows with BigQuery Client.
I have checked [1], and it works when the query (or DML) contains a single job. However, when the results are written from children's jobs like the below script, the num_dml_affected_rows is void. How can I check the child job's num_dml_affected_rows. I am think something like below.
query_job.children_job[-1].num_dml_affected_rows # (last child dml result)
But couldn't find the right way (or method) to accomplish it from the documents [2, 3].
[1] BigQuery update how to get number of updated rows
[2] BQ REST
[3] BQ Client API (dev)
Sample Script (python3)
sql = """
INSERT `project.dataset.table` (logdatetime)
SELECT
CURRENT_DATETIME() as logdatetime
;
SELECT 1
;
INSERT `project.dataset.table` (logdatetime)
SELECT
CURRENT_DATETIME() as logdatetime
;
"""
query_job = bigquery.Client().query(sql)
query_job.result()
print(query_job.num_child_jobs) # 3
print(query_job.num_dml_affected_rows) # None
p.s. My current solution is to store the rows counts of destination table before and after the DML to check the difference, but this is unnecessary if I am able to directly access DML results of the child job.