Skip to content

Commit

Permalink
Merge branch 'master' into fix-cellmagic-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Sep 9, 2020
2 parents 46d1def + aa1613c commit ed01a66
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions google/cloud/bigquery/external_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,21 @@ def source_uri_prefix(self):
def source_uri_prefix(self, value):
self._properties["sourceUriPrefix"] = value

@property
def require_partition_filter(self):
"""Optional[bool]: If set to true, queries over the partitioned table require a
partition filter that can be used for partition elimination to be
specified.
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#HivePartitioningOptions.FIELDS.mode
"""
return self._properties.get("requirePartitionFilter")

@require_partition_filter.setter
def require_partition_filter(self, value):
self._properties["requirePartitionFilter"] = value

def to_api_repr(self):
"""Build an API representation of this object.
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_external_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def test_from_api_repr_hive_partitioning(self):
"hivePartitioningOptions": {
"sourceUriPrefix": "http://foo/bar",
"mode": "STRINGS",
"requirePartitionFilter": True,
},
},
)
Expand All @@ -194,6 +195,7 @@ def test_from_api_repr_hive_partitioning(self):
)
self.assertEqual(ec.hive_partitioning.source_uri_prefix, "http://foo/bar")
self.assertEqual(ec.hive_partitioning.mode, "STRINGS")
self.assertEqual(ec.hive_partitioning.require_partition_filter, True)

# converting back to API representation should yield the same result
got_resource = ec.to_api_repr()
Expand All @@ -210,6 +212,7 @@ def test_to_api_repr_hive_partitioning(self):
hive_partitioning = external_config.HivePartitioningOptions()
hive_partitioning.source_uri_prefix = "http://foo/bar"
hive_partitioning.mode = "STRINGS"
hive_partitioning.require_partition_filter = False

ec = external_config.ExternalConfig("FORMAT_FOO")
ec.hive_partitioning = hive_partitioning
Expand All @@ -221,6 +224,7 @@ def test_to_api_repr_hive_partitioning(self):
"hivePartitioningOptions": {
"sourceUriPrefix": "http://foo/bar",
"mode": "STRINGS",
"requirePartitionFilter": False,
},
}
self.assertEqual(got_resource, expected_resource)
Expand Down

0 comments on commit ed01a66

Please sign in to comment.