diff --git a/google/cloud/bigquery/external_config.py b/google/cloud/bigquery/external_config.py
index d702d9d8..112dfdba 100644
--- a/google/cloud/bigquery/external_config.py
+++ b/google/cloud/bigquery/external_config.py
@@ -586,6 +586,21 @@ class HivePartitioningOptions(object):
     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.
 

Add require_partition_filter in bigquery.external_config.HivePartitioningOptions
I want to force partition filters when user run queries on external tables that uses HivePartitioning.

Please add property require_partition_filter within bigquery.external_config.HivePartitioningOptions()

I tried using table.require_partition_filter = True, but I get an error when my table contains hive_partitioning within external_data_configuration:


> google.api_core.exceptions.BadRequest: 400 POST require_partition_filter has been set for a hive-partitioned table without using the HivePartitioningOptions. To configure external, hive-partitioned tables -- including setting require_partition_filter -- please use the HivePartitioningOptions. Setting require_partition_filter on the top-level table definition, or via the TimePartitioning field, does not configure hive-partitioned tables.

diff --git a/tests/unit/test_external_config.py b/tests/unit/test_external_config.py
index 6028d069..4b6ef511 100644
--- a/tests/unit/test_external_config.py
+++ b/tests/unit/test_external_config.py
@@ -181,6 +181,7 @@ class TestExternalConfig(unittest.TestCase):
                 "hivePartitioningOptions": {
                     "sourceUriPrefix": "http://foo/bar",
                     "mode": "STRINGS",
+                    "requirePartitionFilter": True,
                 },
             },
         )
@@ -194,6 +195,7 @@ class TestExternalConfig(unittest.TestCase):
         )
         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()
@@ -210,6 +212,7 @@ class TestExternalConfig(unittest.TestCase):
         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
@@ -221,6 +224,7 @@ class TestExternalConfig(unittest.TestCase):
             "hivePartitioningOptions": {
                 "sourceUriPrefix": "http://foo/bar",
                 "mode": "STRINGS",
+                "requirePartitionFilter": False,
             },
         }
         self.assertEqual(got_resource, expected_resource)

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc
3.8
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
cachetools==4.2.4
certifi==2025.1.31
charset-normalizer==3.4.1
coverage==7.6.1
exceptiongroup==1.2.2
execnet==2.1.1
google-api-core==1.34.1
google-auth==1.35.0
-e git+https://github.com/googleapis/python-bigquery.git@a125160696d1453b04a66c967819f90e70e03a52#egg=google_cloud_bigquery
google-cloud-bigquery-storage==1.1.2
google-cloud-core==1.7.3
google-crc32c==1.5.0
google-resumable-media==1.3.3
googleapis-common-protos==1.69.2
grpcio==1.70.0
grpcio-status==1.48.2
idna==3.10
iniconfig==2.1.0
numpy==1.24.4
packaging==24.2
pandas==2.0.3
pluggy==1.5.0
protobuf==3.20.3
pyarrow==1.0.1
pyasn1==0.6.1
pyasn1_modules==0.4.2
pytest==8.3.5
pytest-asyncio==0.24.0
pytest-cov==5.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.32.3
rsa==4.9
six==1.17.0
tomli==2.2.1
tqdm==4.67.1
tzdata==2025.2
urllib3==2.2.3

name: python-bigquery
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=24.2=py38h06a4308_0
  - python=3.8.20=he870216_0
  - readline=8.2=h5eee18b_0
  - setuptools=75.1.0=py38h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.44.0=py38h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cachetools==4.2.4
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - coverage==7.6.1
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - google-api-core==1.34.1
      - google-auth==1.35.0
      - google-cloud-bigquery-storage==1.1.2
      - google-cloud-core==1.7.3
      - google-crc32c==1.5.0
      - google-resumable-media==1.3.3
      - googleapis-common-protos==1.69.2
      - grpcio==1.70.0
      - grpcio-status==1.48.2
      - idna==3.10
      - iniconfig==2.1.0
      - numpy==1.24.4
      - packaging==24.2
      - pandas==2.0.3
      - pluggy==1.5.0
      - protobuf==3.20.3
      - pyarrow==1.0.1
      - pyasn1==0.6.1
      - pyasn1-modules==0.4.2
      - pytest==8.3.5
      - pytest-asyncio==0.24.0
      - pytest-cov==5.0.0
      - pytest-mock==3.14.0
      - pytest-xdist==3.6.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - requests==2.32.3
      - rsa==4.9
      - six==1.17.0
      - tomli==2.2.1
      - tqdm==4.67.1
      - tzdata==2025.2
      - urllib3==2.2.3
prefix: /opt/conda/envs/python-bigquery

tests/unit/test_external_config.py::TestExternalConfig::test_from_api_repr_hive_partitioning tests/unit/test_external_config.py::TestExternalConfig::test_to_api_repr_hive_partitioning
tests/unit/test_external_config.py::TestExternalConfig::test_from_api_repr_base tests/unit/test_external_config.py::TestExternalConfig::test_from_api_repr_bigtable tests/unit/test_external_config.py::TestExternalConfig::test_from_api_repr_csv tests/unit/test_external_config.py::TestExternalConfig::test_from_api_repr_sheets tests/unit/test_external_config.py::TestExternalConfig::test_schema_None tests/unit/test_external_config.py::TestExternalConfig::test_schema_empty tests/unit/test_external_config.py::TestExternalConfig::test_to_api_repr_base tests/unit/test_external_config.py::TestExternalConfig::test_to_api_repr_bigtable tests/unit/test_external_config.py::TestExternalConfig::test_to_api_repr_csv tests/unit/test_external_config.py::TestExternalConfig::test_to_api_repr_sheets tests/unit/test_external_config.py::TestExternalConfig::test_to_api_repr_source_format
google/cloud/bigquery/external_config.py
google/cloud/bigquery/external_config.py