Skip to content

Commit 5ed9cce

Browse files
chalmerloweEthanSteinbergtswast
authored
feat: Add compression option ZSTD. (#1890)
* Add ZSTD to compression types * feat: adds tests re Compression types * revise datatype from Enum to object * adds license text and docstring * change object back to enum datatype * updates compression object comparison * updates Compression class * jsonify and sort the input and output for testing * Update tests/unit/job/test_extract.py * moved json import statement * removed enums test and file --------- Co-authored-by: Ethan Steinberg <[email protected]> Co-authored-by: Tim Sweña (Swast) <[email protected]>
1 parent 19394ab commit 5ed9cce

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

google/cloud/bigquery/enums.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AutoRowIDs(enum.Enum):
2222
GENERATE_UUID = enum.auto()
2323

2424

25-
class Compression(object):
25+
class Compression(str, enum.Enum):
2626
"""The compression type to use for exported files. The default value is
2727
:attr:`NONE`.
2828
@@ -39,6 +39,9 @@ class Compression(object):
3939
SNAPPY = "SNAPPY"
4040
"""Specifies SNAPPY format."""
4141

42+
ZSTD = "ZSTD"
43+
"""Specifies ZSTD format."""
44+
4245
NONE = "NONE"
4346
"""Specifies no compression."""
4447

tests/unit/job/test_extract.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import json
1516
from unittest import mock
1617

1718
from ..helpers import make_connection
@@ -45,9 +46,8 @@ def test_to_api_repr(self):
4546
config.print_header = False
4647
config._properties["extract"]["someNewField"] = "some-value"
4748
config.use_avro_logical_types = True
48-
resource = config.to_api_repr()
49-
self.assertEqual(
50-
resource,
49+
resource = json.dumps(config.to_api_repr(), sort_keys=True)
50+
expected = json.dumps(
5151
{
5252
"extract": {
5353
"compression": "SNAPPY",
@@ -58,6 +58,12 @@ def test_to_api_repr(self):
5858
"useAvroLogicalTypes": True,
5959
}
6060
},
61+
sort_keys=True,
62+
)
63+
64+
self.assertEqual(
65+
resource,
66+
expected,
6167
)
6268

6369
def test_from_api_repr(self):

0 commit comments

Comments
 (0)