|
37 | 37 | overload, |
38 | 38 | Sequence, |
39 | 39 | Tuple, |
| 40 | +TYPE_CHECKING, |
40 | 41 | TypeVar, |
41 | 42 | Union, |
42 | 43 | ) |
|
47 | 48 | importbigframes_vendored.pandas.pandas._typingasvendored_pandas_typing |
48 | 49 | importgoogle.api_core.exceptions |
49 | 50 | importgoogle.cloud.bigqueryasbigquery |
| 51 | +importgoogle.cloud.bigquery.job |
| 52 | +importgoogle.cloud.bigquery.table |
50 | 53 | importnumpy |
51 | 54 | importpandas |
52 | 55 | frompandas.apiimportextensionsaspd_ext |
|
91 | 94 | importbigframes.session._io.bigquery |
92 | 95 | importbigframes.session.execution_specasex_spec |
93 | 96 |
|
94 | | -iftyping.TYPE_CHECKING: |
| 97 | +ifTYPE_CHECKING: |
95 | 98 | from_typeshedimportSupportsRichComparison |
96 | 99 |
|
| 100 | +importbigframes.extensions.bigframes.dataframe_accessorasbigquery_accessor |
97 | 101 | importbigframes.session |
98 | 102 |
|
99 | 103 | SingleItemValue=Union[ |
@@ -144,7 +148,7 @@ def __init__( |
144 | 148 | ): |
145 | 149 | globalbigframes |
146 | 150 |
|
147 | | -self._query_job: Optional[bigquery.QueryJob] =None |
| 151 | +self._query_job: Optional[google.cloud.bigquery.job.QueryJob] =None |
148 | 152 |
|
149 | 153 | ifcopyisnotNoneandnotcopy: |
150 | 154 | raiseValueError( |
@@ -376,6 +380,25 @@ def bqclient(self) -> bigframes.Session: |
376 | 380 | def_session(self) ->bigframes.Session: |
377 | 381 | returnself._get_block().expr.session |
378 | 382 |
|
| 383 | +@property |
| 384 | +defbigquery( |
| 385 | +self, |
| 386 | + ) ->bigquery_accessor.BigframesBigQueryDataFrameAccessor: |
| 387 | +""" |
| 388 | + Accessor for BigQuery functionality. |
| 389 | +
|
| 390 | + Returns: |
| 391 | + bigframes.extensions.core.dataframe_accessor.BigQueryDataFrameAccessor: |
| 392 | + Accessor that exposes BigQuery functionality on a DataFrame, |
| 393 | + with method names closer to SQL. |
| 394 | + """ |
| 395 | +# Import the accessor here to avoid circular imports. |
| 396 | +importbigframes.extensions.bigframes.dataframe_accessor |
| 397 | + |
| 398 | +returnbigframes.extensions.bigframes.dataframe_accessor.BigframesBigQueryDataFrameAccessor( |
| 399 | +self |
| 400 | + ) |
| 401 | + |
379 | 402 | @property |
380 | 403 | def_has_index(self) ->bool: |
381 | 404 | returnlen(self._block.index_columns) >0 |
@@ -438,7 +461,9 @@ def _should_sql_have_index(self) -> bool: |
438 | 461 | self.index.nameisnotNoneorlen(self.index.names) >1 |
439 | 462 | ) |
440 | 463 |
|
441 | | -def_to_placeholder_table(self, dry_run: bool=False) ->bigquery.TableReference: |
| 464 | +def_to_placeholder_table( |
| 465 | +self, dry_run: bool=False |
| 466 | + ) ->google.cloud.bigquery.table.TableReference: |
442 | 467 | """Compiles this DataFrame's expression tree to SQL and saves it to a |
443 | 468 | (temporary) view or table (in the case of a dry run). |
444 | 469 | """ |
@@ -488,11 +513,11 @@ def sql(self) -> str: |
488 | 513 | ) frome |
489 | 514 |
|
490 | 515 | @property |
491 | | -defquery_job(self) ->Optional[bigquery.QueryJob]: |
| 516 | +defquery_job(self) ->Optional[google.cloud.bigquery.job.QueryJob]: |
492 | 517 | """BigQuery job metadata for the most recent query. |
493 | 518 |
|
494 | 519 | Returns: |
495 | | - None or google.cloud.bigquery.QueryJob: |
| 520 | + None or google.cloud.bigquery.job.QueryJob: |
496 | 521 | The most recent `QueryJob |
497 | 522 | <https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryJob>`_. |
498 | 523 | """ |
@@ -606,7 +631,9 @@ def select_dtypes(self, include=None, exclude=None) -> DataFrame: |
606 | 631 | ) |
607 | 632 | returnDataFrame(self._block.select_columns(selected_columns)) |
608 | 633 |
|
609 | | -def_set_internal_query_job(self, query_job: Optional[bigquery.QueryJob]): |
| 634 | +def_set_internal_query_job( |
| 635 | +self, query_job: Optional[google.cloud.bigquery.job.QueryJob] |
| 636 | + ): |
610 | 637 | self._query_job=query_job |
611 | 638 |
|
612 | 639 | def__getitem__( |
@@ -1782,7 +1809,7 @@ def _to_pandas_batches( |
1782 | 1809 | allow_large_results=allow_large_results, |
1783 | 1810 | ) |
1784 | 1811 |
|
1785 | | -def_compute_dry_run(self) ->bigquery.QueryJob: |
| 1812 | +def_compute_dry_run(self) ->google.cloud.bigquery.job.QueryJob: |
1786 | 1813 | _, query_job=self._block._compute_dry_run() |
1787 | 1814 | returnquery_job |
1788 | 1815 |
|
|
0 commit comments