Skip to content

Commit 779c2d4

Browse files
authored
chore: add experimental blob from_glob_path test (#1406)
* chore: add experimental blob from_glob_path test * fix pandas < 2.2
1 parent 6ee48d5 commit 779c2d4

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

tests/system/small/blob/test_io.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,57 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import pandas as pd
16+
1517
import bigframes
1618
import bigframes.pandas as bpd
1719

1820

19-
def test_blob_create_from_uri_str():
21+
def test_blob_create_from_uri_str(bq_connection: str, session: bigframes.Session):
2022
bigframes.options.experiments.blob = True
2123

22-
uri_series = bpd.Series(
23-
[
24-
"gs://bigframes_blob_test/images/img0.jpg",
25-
"gs://bigframes_blob_test/images/img1.jpg",
26-
]
24+
uris = [
25+
"gs://bigframes_blob_test/images/img0.jpg",
26+
"gs://bigframes_blob_test/images/img1.jpg",
27+
]
28+
29+
uri_series = bpd.Series(uris, session=session)
30+
blob_series = uri_series.str.to_blob(connection=bq_connection)
31+
32+
pd_blob_df = blob_series.struct.explode().to_pandas()
33+
expected_pd_df = pd.DataFrame(
34+
{
35+
"uri": uris,
36+
"version": [None, None],
37+
"authorizer": [bq_connection.casefold(), bq_connection.casefold()],
38+
"details": [None, None],
39+
}
40+
)
41+
42+
pd.testing.assert_frame_equal(
43+
pd_blob_df, expected_pd_df, check_dtype=False, check_index_type=False
2744
)
28-
# TODO: use bq_connection fixture when MMD location capitalization fix is in prod
29-
blob_series = uri_series.str.to_blob(connection="us.bigframes-default-connection")
3045

31-
pd_blob_series = blob_series.to_pandas()
3246

33-
assert len(pd_blob_series) == 2
47+
def test_blob_create_from_glob_path(bq_connection: str, session: bigframes.Session):
48+
bigframes.options.experiments.blob = True
49+
50+
blob_df = session.from_glob_path(
51+
"gs://bigframes_blob_test/images/*", connection=bq_connection, name="blob_col"
52+
)
53+
pd_blob_df = blob_df["blob_col"].struct.explode().to_pandas()
54+
expected_df = pd.DataFrame(
55+
{
56+
"uri": [
57+
"gs://bigframes_blob_test/images/img0.jpg",
58+
"gs://bigframes_blob_test/images/img1.jpg",
59+
],
60+
"version": [None, None],
61+
"authorizer": [bq_connection.casefold(), bq_connection.casefold()],
62+
"details": [None, None],
63+
}
64+
)
65+
66+
pd.testing.assert_frame_equal(
67+
pd_blob_df, expected_df, check_dtype=False, check_index_type=False
68+
)

0 commit comments

Comments
 (0)