Pandas should get the schema from bigquery if pushing to a table that already exists
See original GitHub issueRight now, when pushing new data to an already existing table using to_gbq, with option if_exists=append, but no explicit table_schema, pandas generates a default table schema, where the mode of the column, which takes value either REQUIRED or NULLABLE, by default is always NULLABLE.
It would make sense for pandas to fetch schema, and apply those for case where if_exists=append instead of passing a NULLABLE mode.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Pandas should get the schema from bigquery if pushing to a ...
Right now, when pushing new data to an already existing table using to_gbq, with option if_exists=append, but no explicit table_schema, ...
Read more >google bigquery - pandas to gbq claims a schema mismatch ...
Rename your dataframe accordingly: data.columns = [i.name for i in table.schema]. Pass the same schema while pushing it to BigQuery:
Read more >pandas.DataFrame.to_gbq — pandas 1.5.2 documentation
Write a DataFrame to a Google BigQuery table. ... If schema is not provided, it will be generated according to dtypes of DataFrame...
Read more >Load data from DataFrame | BigQuery - Google Cloud
Load contents of a pandas DataFrame to a table. ... schema=[ # Specify the type of columns whose type cannot be auto-detected. For...
Read more >Writing Tables - pandas-gbq - Read the Docs
If the if_exists argument is set to 'append' , the destination dataframe will be written to the table using the defined table schema...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It actually works for
TIMESTAMPalso ! We just needed to cast the string timestamp todatetimeI made a test corresponding to the example you provided in https://github.com/pydata/pandas-gbq/issues/315#issuecomment-597145800 but it still fails due to different types. It is expected that the pandas.Timestamp dtype is used for uploading to TIMESTAMP columns. Please open a separate feature request for that issue if different types is a problem for you.
Let’s use this issue to track the problem different modes (required vs. nullable).