@@ -1475,6 +1475,63 @@ def _start_query_ml_ddl(
1475
1475
self .bqclient , sql , job_config , metrics = self ._metrics
1476
1476
)
1477
1477
1478
+ def _create_object_table (self , path : str , connection : str ) -> str :
1479
+ """Create a random id Object Table from the input path and connection."""
1480
+ table = str (self ._loader ._storage_manager ._random_table ())
1481
+
1482
+ import textwrap
1483
+
1484
+ sql = textwrap .dedent (
1485
+ f"""
1486
+ CREATE EXTERNAL TABLE `{ table } `
1487
+ WITH CONNECTION `{ connection } `
1488
+ OPTIONS(
1489
+ object_metadata = 'SIMPLE',
1490
+ uris = ['{ path } ']);
1491
+ """
1492
+ )
1493
+ bf_io_bigquery .start_query_with_client (
1494
+ self .bqclient ,
1495
+ sql ,
1496
+ job_config = bigquery .QueryJobConfig (),
1497
+ metrics = self ._metrics ,
1498
+ )
1499
+
1500
+ return table
1501
+
1502
+ def from_glob_path (
1503
+ self , path : str , * , connection : Optional [str ] = None , name : Optional [str ] = None
1504
+ ) -> dataframe .DataFrame :
1505
+ r"""Create a BigFrames DataFrame that contains a BigFrames Blob column from a global wildcard path.
1506
+
1507
+ Args:
1508
+ path (str):
1509
+ The wildcard global path, such as "gs://<bucket>/<folder>/\*".
1510
+ connection (str or None, default None):
1511
+ Connection to connect with remote service. str of the format <PROJECT_NUMBER/PROJECT_ID>.<LOCATION>.<CONNECTION_ID>.
1512
+ If None, use default connection in session context. BigQuery DataFrame will try to create the connection and attach
1513
+ permission if the connection isn't fully set up.
1514
+ name (str):
1515
+ The column name of the Blob column.
1516
+ Returns:
1517
+ bigframes.pandas.DataFrame:
1518
+ Result BigFrames DataFrame.
1519
+ """
1520
+ if not bigframes .options .experiments .blob :
1521
+ raise NotImplementedError ()
1522
+
1523
+ connection = connection or self ._bq_connection
1524
+ connection = bigframes .clients .resolve_full_bq_connection_name (
1525
+ connection ,
1526
+ default_project = self ._project ,
1527
+ default_location = self ._location ,
1528
+ )
1529
+
1530
+ table = self ._create_object_table (path , connection )
1531
+
1532
+ s = self .read_gbq (table )["uri" ].str .to_blob (connection )
1533
+ return s .rename (name ).to_frame ()
1534
+
1478
1535
1479
1536
def connect (context : Optional [bigquery_options .BigQueryOptions ] = None ) -> Session :
1480
1537
return Session (context )
0 commit comments