You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BigQuery: Allow choice of compression for loading from dataframe #7701
pandas.Dataframe.to_parquet() allows a choice of compression, with the deafult of snappy. When using the client.load_table_from_dataframe the call to this function only allows the use of the default.
Is it possible to allow a choice so that gzip can be used instead so that installing snappy on the system is not necessary
Thanks for the report @awgymer . This is a great suggestion. I agree that the snappy system requirement can be painful to install. I think we can mirror the compression argument from pandas in the load_table_from_dataframe method.
So on a little more looking, the pandas.Dataframe.to_parquet() allows three (four if you count uncompressed) options: snappy, gzip, and brotli, whilst the official docs say that
BigQuery supports Snappy, GZip, and LZO_1X codecs for compressed data blocks in Parquet files
So I don't know now if it is in fact more confusing to move to allowing 2/3 of the options (again uncompressed too?) rather than remaining fixed to 1 and simply making the requirement for snappy more clear in the docs?
What dependencies are needed for gzip? Is it a noticeable difference in performance? I'm open to changing the default if it's easier to install and not a noticeable difference.
Also I'm actually a bit wary of exposing compression, since I'd like to keep the option open to change the file format we serialize to. Parquet happens to be the best match to BigQuery's data types right now, but it'd be good to keep the option open to move to something else in the future.
As far as I can tell it uses the standard python gzip/zlib which use the zlib library. I couldn't speak for performance difference at the moment, but I appreciate your point about not exposing the parameter, so perhaps just making it clearer that snappy is a dependency for that function in the docs would be a suitable solution?
making it clearer that snappy is a dependency for that function in the docs would be a suitable solution?
Yeah, that seems reasonable. We already talk about needing pyarrow. We should mention snappy, too.
Related: The required system packages for snappy are one of the reasons I think conda is still relevant, despite wheels and why I publish the google-cloud-bigquery package to conda-forge.
Activity
tswast commentedon Apr 12, 2019
Thanks for the report @awgymer . This is a great suggestion. I agree that the
snappysystem requirement can be painful to install. I think we can mirror thecompressionargument from pandas in theload_table_from_dataframemethod.Happy to accept a PR for this.
awgymer commentedon Apr 20, 2019
So on a little more looking, the
pandas.Dataframe.to_parquet()allows three (four if you count uncompressed) options:snappy,gzip, andbrotli, whilst the official docs say thatSo I don't know now if it is in fact more confusing to move to allowing 2/3 of the options (again uncompressed too?) rather than remaining fixed to 1 and simply making the requirement for
snappymore clear in the docs?tswast commentedon Apr 24, 2019
What dependencies are needed for
gzip? Is it a noticeable difference in performance? I'm open to changing the default if it's easier to install and not a noticeable difference.Also I'm actually a bit wary of exposing
compression, since I'd like to keep the option open to change the file format we serialize to. Parquet happens to be the best match to BigQuery's data types right now, but it'd be good to keep the option open to move to something else in the future.awgymer commentedon Apr 24, 2019
As far as I can tell it uses the standard python
gzip/zlibwhich use thezliblibrary. I couldn't speak for performance difference at the moment, but I appreciate your point about not exposing the parameter, so perhaps just making it clearer thatsnappyis a dependency for that function in the docs would be a suitable solution?tswast commentedon Apr 24, 2019
Yeah, that seems reasonable. We already talk about needing
pyarrow. We should mention snappy, too.Related: The required system packages for snappy are one of the reasons I think
condais still relevant, despite wheels and why I publish thegoogle-cloud-bigquerypackage to conda-forge.