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
5 changes: 4 additions & 1 deletion google/cloud/bigquery/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AutoRowIDs(enum.Enum):
GENERATE_UUID = enum.auto()


class Compression(object):
class Compression(str, enum.Enum):
"""The compression type to use for exported files. The default value is
:attr:`NONE`.

Expand All @@ -39,6 +39,9 @@ class Compression(object):
SNAPPY = "SNAPPY"
"""Specifies SNAPPY format."""

ZSTD = "ZSTD"
"""Specifies ZSTD format."""

NONE = "NONE"
"""Specifies no compression."""

Expand Down
12 changes: 9 additions & 3 deletions tests/unit/job/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
from unittest import mock

from ..helpers import make_connection
Expand Down Expand Up @@ -45,9 +46,8 @@ def test_to_api_repr(self):
config.print_header = False
config._properties["extract"]["someNewField"] = "some-value"
config.use_avro_logical_types = True
resource = config.to_api_repr()
self.assertEqual(
resource,
resource = json.dumps(config.to_api_repr(), sort_keys=True)
expected = json.dumps(
{
"extract": {
"compression": "SNAPPY",
Expand All @@ -58,6 +58,12 @@ def test_to_api_repr(self):
"useAvroLogicalTypes": True,
}
},
sort_keys=True,
)

self.assertEqual(
resource,
expected,
)

def test_from_api_repr(self):
Expand Down