-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError in pandas.io.gbq.read_gbq when no DataFrame should be returned #45
Comments
I suppose this would be ok. most sql interfaces expose something like cc @parthea |
Though why use pandas if you only want to send a query? Why not use the bigquery python library? |
@MaximilianR That is definitely a very good point. I am working in a development environment where it is much harder to set-up and use the BigQuery python library directly, but I also feel that it is a good idea to be able to execute insert and update statements from pandas. @jreback Thanks so much for the help! Please do let me know what would be the best way to go ahead on this. |
Problem description
I am trying to use the
read_gbq
function frompandas.io.gbq
as a means to executeINSERT
orUPDATE
queries on BigQuery. These queries do not return anything and so there is nothing for pandas to retrieve and return to my program, and so my expected output for something like this would be that no dataframe is returned (ie. it should ideally returnNone
), instead of throwing aKeyError
despite the fact that theINSERT
orUPDATE
statement executed successfully.Code Sample
Actual vs Expected Output
Expected that
None
would be returned forINSERT
orUPDATE
statements that don't have any results to retrieve. Actual output is as follows:Current Workaround
Proposed Solution
This could be fixed in a fairly simple manner by catching the KeyError right there, skipping the row retrieval parts, and returning
None
. I would be happy to create a pull request to resolve this.The text was updated successfully, but these errors were encountered: