Skip to content

Commit db85c82

Browse files
committed
fix test
1 parent da73cb1 commit db85c82

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

bigframes/operations/blob.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import pandas as pd
2323
import requests
2424

25-
from bigframes import clients
25+
from bigframes import clients, dtypes
2626
from bigframes.core import log_adapter
2727
import bigframes.dataframe
2828
import bigframes.exceptions as bfe
@@ -80,9 +80,17 @@ def metadata(self) -> bigframes.series.Series:
8080
8181
Returns:
8282
bigframes.series.Series: JSON metadata of the Blob. Contains fields: content_type, md5_hash, size and updated(time)."""
83-
details_json = self._apply_unary_op(ops.obj_fetch_metadata_op).struct.field(
84-
"details"
85-
)
83+
series_to_check = bigframes.series.Series(self._block)
84+
# Check if it's a struct series from a verbose operation
85+
if (
86+
dtypes.is_struct_like(series_to_check.dtype)
87+
and "content" in series_to_check.dtype.names
88+
and dtypes.is_blob_like(series_to_check.dtype.field("content").dtype)
89+
):
90+
series_to_check = series_to_check.struct.field("content")
91+
details_json = series_to_check._apply_unary_op(
92+
ops.obj_fetch_metadata_op
93+
).struct.field("details")
8694
import bigframes.bigquery as bbq
8795

8896
return bbq.json_extract(details_json, "$.gcs_metadata").rename("metadata")

tests/system/large/blob/test_function.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ def test_blob_image_blur_to_series(
119119

120120
content_series = actual_exploded["content"]
121121
# Content should be blob objects for GCS destination
122-
assert hasattr(content_series, "blob")
123-
124122
else:
125123
expected_df = pd.DataFrame(
126124
{
@@ -298,6 +296,9 @@ def test_blob_image_resize_to_folder(
298296
# Content should be blob objects for GCS destination
299297
assert hasattr(content_series, "blob")
300298

299+
# verify the files exist
300+
assert not content_series.blob.size().isna().any()
301+
301302
else:
302303
expected_df = pd.DataFrame(
303304
{
@@ -314,8 +315,8 @@ def test_blob_image_resize_to_folder(
314315
check_index_type=False,
315316
)
316317

317-
# verify the files exist
318-
assert not actual.blob.size().isna().any()
318+
# verify the files exist
319+
assert not actual.blob.size().isna().any()
319320

320321

321322
@pytest.mark.parametrize("verbose", [True, False])

0 commit comments

Comments
 (0)