diff --git a/google/cloud/bigquery/format_options.py b/google/cloud/bigquery/format_options.py index 1208565a9..ad5591b1c 100644 --- a/google/cloud/bigquery/format_options.py +++ b/google/cloud/bigquery/format_options.py @@ -105,6 +105,21 @@ def enable_list_inference(self) -> bool: def enable_list_inference(self, value: bool) -> None: self._properties["enableListInference"] = value + @property + def map_target_type(self) -> str: + """Indicates whether to simplify the representation of parquet maps to only show keys and values.""" + + return self._properties.get("mapTargetType") + + @map_target_type.setter + def map_target_type(self, value: str) -> None: + """Sets the map target type. + + Args: + value: The map target type (eg ARRAY_OF_STRUCT). + """ + self._properties["mapTargetType"] = value + @classmethod def from_api_repr(cls, resource: Dict[str, bool]) -> "ParquetOptions": """Factory: construct an instance from a resource dict. diff --git a/tests/unit/test_format_options.py b/tests/unit/test_format_options.py index c8fecbfa6..94a01570f 100644 --- a/tests/unit/test_format_options.py +++ b/tests/unit/test_format_options.py @@ -54,11 +54,17 @@ def test_from_api_repr(self): ) assert not config.enum_as_string assert config.enable_list_inference + assert config.map_target_type is None def test_to_api_repr(self): config = self._get_target_class()() config.enum_as_string = True config.enable_list_inference = False + config.map_target_type = "ARRAY_OF_STRUCT" result = config.to_api_repr() - assert result == {"enumAsString": True, "enableListInference": False} + assert result == { + "enumAsString": True, + "enableListInference": False, + "mapTargetType": "ARRAY_OF_STRUCT", + }