I'm running the python script below on Google Cloud Functions. When testing the script I have the following error:
Error: function terminated. Recommended action: inspect logs for termination reason. Details:
run() takes 0 positional arguments but 1 was given
What does it mean?
Here is my script:
from google.cloud import bigquery
client = bigquery.Client()
def run():
csv_file = six.BytesIO(b"""full_name,age
Phred Phlyntstone,32
Wylma Phlyntstone,29
""")
table_ref = dataset.table('ga-online-audit:test_python.test')
job_config = bigquery.LoadJobConfig()
job_config.source_format = 'CSV'
job_config.skip_leading_rows = 1
job = client.load_table_from_file(
csv_file, table_ref, job_config=job_config) # API request
job.result() # Waits for table load to complete.
As I'm learning I took this script from the following documentation https://google-cloud-python.readthedocs.io/en/0.32.0/bigquery/usage.html
run
? The error description is pretty clear:run
accepts 0 arguments but is being passed one by whatever is calling it.google.cloud
, but I'm guessing google is passing some kind ofevent
object to your run function. Someone with more knowledge can build off of this, but in order to figure out exactly what the hack is going on, I would modifyrun
to accept a single argument andprint
the value of that argument right away to see what it looks like.