Skip to content

BigQuery: Allow choice of compression for loading from dataframe #7701

Closed

Description

@awgymer

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

Activity

  1. added
    api: bigqueryIssues related to the BigQuery API.
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    good first issueThis issue is a good place to started contributing to this repository.
    on Apr 12, 2019
  2. tswast commented on Apr 12, 2019

    @tswast
    Contributor

    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.

    Happy to accept a PR for this.

  3. awgymer commented on Apr 20, 2019

    @awgymer
    Author

    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?

  4. tswast commented on Apr 24, 2019

    @tswast
    Contributor

    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.

  5. awgymer commented on Apr 24, 2019

    @awgymer
    Author

    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?

  6. tswast commented on Apr 24, 2019

    @tswast
    Contributor

    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.

  7. self-assigned this
    on Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.good first issueThis issue is a good place to started contributing to this repository.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions