File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
google/cloud/bigtable/data/execute_query
tests/unit/data/execute_query Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -369,6 +369,8 @@ def _pb_metadata_to_metadata_types(
369369) -> Metadata :
370370 if "proto_schema" in metadata_pb :
371371 fields : List [Tuple [Optional [str ], SqlType .Type ]] = []
372+ if not metadata_pb .proto_schema .columns :
373+ raise ValueError ("Invalid empty ResultSetMetadata received." )
372374 for column_metadata in metadata_pb .proto_schema .columns :
373375 fields .append (
374376 (column_metadata .name , _pb_type_to_metadata_type (column_metadata .type ))
Original file line number Diff line number Diff line change 1+ # Copyright 2025 Google LLC
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+ import pytest
15+
16+ from google .cloud .bigtable .data .execute_query .metadata import (
17+ _pb_metadata_to_metadata_types ,
18+ )
19+ from google .cloud .bigtable_v2 .types .data import ResultSetMetadata
20+
21+
22+ def test_empty_metadata_fails_parsing ():
23+ invalid_md_proto = ResultSetMetadata ({"proto_schema" : {"columns" : []}})
24+ with pytest .raises (ValueError ):
25+ _pb_metadata_to_metadata_types (invalid_md_proto )
You can’t perform that action at this time.
0 commit comments