desired_date = "2022-09-28" #@param {type:"date"}
import pandas as pd
df = pd.io.gbq.read_gbq('''
SELECT *
FROM `gdelt-bq.gdeltv2.geg_gcnlapi`
WHERE DATE(date) = desired_date
LIMIT 1000
''', project_id=project_id, dialect='standard')
Trying to pass desired_date to the SQL query, but everything I seem to do results in the following error:
Reason: 400 No matching signature for operator = for argument types: DATE, INT64. Supported signature: ANY = ANY at [4:9]
Thank you for the assistance.
>Solution :
You must set the value of the variable in the query, not the variable name.
For eg.,
df = pd.io.gbq.read_gbq(f'''
SELECT *
FROM `gdelt-bq.gdeltv2.geg_gcnlapi`
WHERE DATE(date) = "{desired_date}"
LIMIT 1000
''', project_id=project_id, dialect='standard')
Just using = desired_date
passes the query as with date as ‘desired_date’ and not its value!