Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 741c75e

Browse files
ashleyxuutswast
andauthoredNov 10, 2023
fix: use random table for read_pandas (#192)
* fix: use random table for read_pandas * fix: default to 7 days expiration for `read_csv`, `read_json`, `read_parquet` (#193) Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Follow-up to https://togithub.com/googleapis/python-bigquery-dataframes/pull/175/files#r1389686556 🦕 * fix: use random table for read_pandas * fix: use the real table expression --------- Co-authored-by: Tim Swast <swast@google.com>
1 parent 03606cd commit 741c75e

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed
 

‎bigframes/core/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def cached(self, cluster_cols: typing.Sequence[str]) -> ArrayValue:
165165
ibis_expr = compiled_value._to_ibis_expr(
166166
ordering_mode="unordered", expose_hidden_cols=True
167167
)
168-
tmp_table = self.session._ibis_to_session_table(
168+
tmp_table = self.session._ibis_to_temp_table(
169169
ibis_expr, cluster_cols=cluster_cols, api_name="cached"
170170
)
171171

‎bigframes/session/__init__.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
Tuple,
3737
Union,
3838
)
39-
import uuid
4039
import warnings
4140

4241
import google.api_core.client_info
@@ -986,7 +985,7 @@ def _read_pandas(
986985
job_config.clustering_fields = cluster_cols
987986
job_config.labels = {"bigframes-api": api_name}
988987

989-
load_table_destination = self._create_session_table()
988+
load_table_destination = bigframes_io.random_table(self._anonymous_dataset)
990989
load_job = self.bqclient.load_table_from_dataframe(
991990
pandas_dataframe_copy,
992991
load_table_destination,
@@ -999,8 +998,9 @@ def _read_pandas(
999998
total_ordering_columns=frozenset([ordering_col]),
1000999
integer_encoding=IntegerEncoding(True, is_sequential=True),
10011000
)
1002-
table_expression = self.ibis_client.sql(
1003-
f"SELECT * FROM `{load_table_destination.table_id}`"
1001+
table_expression = self.ibis_client.table(
1002+
load_table_destination.table_id,
1003+
database=f"{load_table_destination.project}.{load_table_destination.dataset_id}",
10041004
)
10051005

10061006
# b/297590178 Potentially a bug in bqclient.load_table_from_dataframe(), that only when the DF is empty, the index columns disappear in table_expression.
@@ -1278,13 +1278,6 @@ def _check_file_size(self, filepath: str):
12781278
"for large files to avoid loading the file into local memory."
12791279
)
12801280

1281-
def _create_session_table(self) -> bigquery.TableReference:
1282-
table_name = f"{uuid.uuid4().hex}"
1283-
dataset = bigquery.Dataset(
1284-
bigquery.DatasetReference(self.bqclient.project, "_SESSION")
1285-
)
1286-
return dataset.table(table_name)
1287-
12881281
def _create_empty_temp_table(
12891282
self,
12901283
schema: Iterable[bigquery.SchemaField],
@@ -1319,7 +1312,7 @@ def _create_sequential_ordering(
13191312
ibis.row_number().cast(ibis_dtypes.int64).name(default_ordering_name)
13201313
)
13211314
table = table.mutate(**{default_ordering_name: default_ordering_col})
1322-
table_ref = self._ibis_to_session_table(
1315+
table_ref = self._ibis_to_temp_table(
13231316
table,
13241317
cluster_cols=list(index_cols) + [default_ordering_name],
13251318
api_name=api_name,
@@ -1335,7 +1328,7 @@ def _create_sequential_ordering(
13351328
)
13361329
return table, ordering
13371330

1338-
def _ibis_to_session_table(
1331+
def _ibis_to_temp_table(
13391332
self,
13401333
table: ibis_types.Table,
13411334
cluster_cols: Iterable[str],

0 commit comments

Comments
 (0)
Failed to load comments.