Skip to content
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

feat: Add compression option ZSTD. #1890

Merged
merged 13 commits into from
Apr 11, 2024
Prev Previous commit
Next Next commit
adds license text and docstring
  • Loading branch information
chalmerlowe committed Apr 8, 2024
commit b801aafc327c74b13caf039cbf24000d72f88f98
19 changes: 19 additions & 0 deletions tests/unit/test_enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


def test_compression_enums():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how useful this test is? Seems an awful lot like a change-detector test to me. I'd be fine adding the constant without adding the test.

Alternatively, maybe there's a system test we could write to make sure this is synced with the bigquery discovery document? But even then, compression isn't a true enum. The allowed values are only listed in the documentation string from what I can tell.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tswast

I will remove this test.

In terms of attempting to ensure that this matches the discovery docs... the terms referenced by the docs are present in the description, as you note, so we would need some mechanism to extract them from the discovery doc, which feels somewhat fragile (ie extract all words that are ALL CAPS and deduplicate them). Thoughts?

"JobConfigurationExtract": {
      ...
      "properties": {
        "compression": {
          "description": "Optional. The compression type to use for exported files.
Possible values include DEFLATE, GZIP, NONE, SNAPPY, and ZSTD. The
default value is NONE. Not all compression formats are support for all
file formats. DEFLATE is only supported for Avro. ZSTD is only supported
for Parquet. Not applicable when extracting models.",
          "type": "string"
        },

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Without a structured representation of the allowed values, it's too fragile.

"""Ensures that the compression enum has all the allowed types of
compression algorithms present.
"""

from google.cloud.bigquery.enums import Compression

expected_comps_sorted = ["DEFLATE", "GZIP", "NONE", "SNAPPY", "ZSTD"]
Expand Down