GBQ DML unable to delete rows by condition

I'm using the Python library google.cloud.bigquery. Usually I use DML to delete rows based on date condition and it works fine. Now I need to delete rows by another condition. My table looks like this:

data frame

I am trying to query:

 DELETE project-290504.table.advertisementresults
WHERE Monthnumber IN('202008','202009')

And nothing happens; no error appears, no stat deleted. The interesting thing is that I've tried this on another table from GBQ and exactly the same script worked well. Values from column which were taken as conditions are strings.

Full code:

dml_query = """
    DELETE project-290504.table.advertisementresults
    WHERE Monthnumber IN('202008','202009')
""" 
    
dml_query_job = client.query(dml_query)

Upvotes: 0

Views: 66

Answers (1)

For this project i simply added ` quotes like this:

dml_query = """
    DELETE `project-290504.table.advertisementresults`
    WHERE Monthnumber IN('202008','202009')
""" 
    
dml_query_job = client.query(dml_query)

I don't really know why on different gbq project script worked fine without ``.

Upvotes: 1

Related Questions