|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import pandas as pd |
| 16 | + |
15 | 17 | import bigframes |
16 | 18 | import bigframes.pandas as bpd |
17 | 19 |
|
18 | 20 |
|
19 | | -def test_blob_create_from_uri_str(): |
| 21 | +def test_blob_create_from_uri_str(bq_connection: str, session: bigframes.Session): |
20 | 22 | bigframes.options.experiments.blob = True |
21 | 23 |
|
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 |
27 | 44 | ) |
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") |
30 | 45 |
|
31 | | - pd_blob_series = blob_series.to_pandas() |
32 | 46 |
|
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