Skip to content

Commit 6262991

Browse files
committed
fix test
1 parent 0f95d28 commit 6262991

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
@@ -120,8 +120,6 @@ def test_blob_image_blur_to_series(
120120

121121
content_series = actual_exploded["content"]
122122
# Content should be blob objects for GCS destination
123-
assert hasattr(content_series, "blob")
124-
125123
else:
126124
expected_df = pd.DataFrame(
127125
{
@@ -299,6 +297,9 @@ def test_blob_image_resize_to_folder(
299297
# Content should be blob objects for GCS destination
300298
assert hasattr(content_series, "blob")
301299

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

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

321322

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

0 commit comments

Comments
 (0)