Skip to content

Commit c10983b

Browse files
Merge remote-tracking branch 'github/main' into b428037029
2 parents 460075e + e3c06b4 commit c10983b

38 files changed

+490
-62
lines changed

bigframes/core/array_value.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,27 @@ def create_constant(
330330

331331
return self.project_to_id(ex.const(value, dtype))
332332

333-
def select_columns(self, column_ids: typing.Sequence[str]) -> ArrayValue:
333+
def select_columns(
334+
self, column_ids: typing.Sequence[str], allow_renames: bool = False
335+
) -> ArrayValue:
334336
# This basically just drops and reorders columns - logically a no-op except as a final step
335-
selections = (
336-
bigframes.core.nodes.AliasedRef.identity(ids.ColumnId(col_id))
337-
for col_id in column_ids
338-
)
337+
selections = []
338+
seen = set()
339+
340+
for id in column_ids:
341+
if id not in seen:
342+
ref = nodes.AliasedRef.identity(ids.ColumnId(id))
343+
elif allow_renames:
344+
ref = nodes.AliasedRef(
345+
ex.deref(id), ids.ColumnId(bigframes.core.guid.generate_guid())
346+
)
347+
else:
348+
raise ValueError(
349+
"Must set allow_renames=True to select columns repeatedly"
350+
)
351+
selections.append(ref)
352+
seen.add(id)
353+
339354
return ArrayValue(
340355
nodes.SelectionNode(
341356
child=self.node,

bigframes/core/blocks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,10 @@ def select_column(self, id: str) -> Block:
12101210
return self.select_columns([id])
12111211

12121212
def select_columns(self, ids: typing.Sequence[str]) -> Block:
1213-
expr = self._expr.select_columns([*self.index_columns, *ids])
1213+
# Allow renames as may end up selecting same columns multiple times
1214+
expr = self._expr.select_columns(
1215+
[*self.index_columns, *ids], allow_renames=True
1216+
)
12141217
col_labels = self._get_labels_for_columns(ids)
12151218
return Block(expr, self.index_columns, col_labels, self.index.names)
12161219

bigframes/core/indexes/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ def dtypes(self) -> pandas.Series:
174174
index=typing.cast(typing.Tuple, self._block.index.names),
175175
)
176176

177+
def __setitem__(self, key, value) -> None:
178+
"""Index objects are immutable. Use Index constructor to create
179+
modified Index."""
180+
raise TypeError("Index does not support mutable operations")
181+
177182
@property
178183
def size(self) -> int:
179184
return self.shape[0]

notebooks/experimental/ai_operators.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
"\n",
3636
" <td>\n",
3737
" <a href=\"https://colab.research.google.com/github/googleapis/python-bigquery-dataframes/blob/main/notebooks/experimental/ai_operators.ipynb\">\n",
38-
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
38+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/colab-logo.png\" alt=\"Colab logo\"> Run in Colab\n",
3939
" </a>\n",
4040
" </td>\n",
4141
" <td>\n",
4242
" <a href=\"https://github.com/googleapis/python-bigquery-dataframes/blob/main/notebooks/experimental/ai_operators.ipynb\">\n",
43-
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
43+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/github-logo.png\" width=\"32\" alt=\"GitHub logo\">\n",
4444
" View on GitHub\n",
4545
" </a>\n",
4646
" </td>\n",

notebooks/generative_ai/bq_dataframes_ai_forecast.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
"\n",
3232
" <td>\n",
3333
" <a href=\"https://colab.research.google.com/github/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_ai_forecast.ipynb\">\n",
34-
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
34+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/colab-logo.png\" alt=\"Colab logo\"> Run in Colab\n",
3535
" </a>\n",
3636
" </td>\n",
3737
" <td>\n",
3838
" <a href=\"https://github.com/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_ai_forecast.ipynb\">\n",
39-
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
39+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/github-logo.png\" width=\"32\" alt=\"GitHub logo\">\n",
4040
" View on GitHub\n",
4141
" </a>\n",
4242
" </td>\n",

notebooks/generative_ai/bq_dataframes_llm_code_generation.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
"\n",
3636
" <td>\n",
3737
" <a href=\"https://colab.research.google.com/github/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_llm_code_generation.ipynb\">\n",
38-
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
38+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/colab-logo.png\" alt=\"Colab logo\"> Run in Colab\n",
3939
" </a>\n",
4040
" </td>\n",
4141
" <td>\n",
4242
" <a href=\"https://github.com/googleapis/python-bigquery-dataframes/tree/main/notebooks/generative_ai/bq_dataframes_llm_code_generation.ipynb\">\n",
43-
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
43+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/github-logo.png\" width=\"32\" alt=\"GitHub logo\">\n",
4444
" View on GitHub\n",
4545
" </a>\n",
4646
" </td>\n",

notebooks/generative_ai/bq_dataframes_llm_kmeans.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
"\n",
3333
" <td>\n",
3434
" <a href=\"https://colab.research.google.com/github/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_llm_kmeans.ipynb\">\n",
35-
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
35+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/colab-logo.png\" alt=\"Colab logo\"> Run in Colab\n",
3636
" </a>\n",
3737
" </td>\n",
3838
" <td>\n",
3939
" <a href=\"https://github.com/googleapis/python-bigquery-dataframes/tree/main/notebooks/generative_ai/bq_dataframes_llm_kmeans.ipynb\">\n",
40-
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
40+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/github-logo.png\" width=\"32\" alt=\"GitHub logo\">\n",
4141
" View on GitHub\n",
4242
" </a>\n",
4343
" </td>\n",

notebooks/generative_ai/bq_dataframes_llm_output_schema.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
"\n",
3232
" <td>\n",
3333
" <a href=\"https://colab.research.google.com/github/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_llm_output_schema.ipynb\">\n",
34-
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
34+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/colab-logo.png\" alt=\"Colab logo\"> Run in Colab\n",
3535
" </a>\n",
3636
" </td>\n",
3737
" <td>\n",
3838
" <a href=\"https://github.com/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_llm_output_schema.ipynb\">\n",
39-
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
39+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/github-logo.png\" width=\"32\" alt=\"GitHub logo\">\n",
4040
" View on GitHub\n",
4141
" </a>\n",
4242
" </td>\n",

notebooks/generative_ai/bq_dataframes_llm_vector_search.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
"\n",
3636
" <td>\n",
3737
" <a href=\"https://colab.research.google.com/github/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_llm_kmeans.ipynb\">\n",
38-
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
38+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/colab-logo.png\" alt=\"Colab logo\"> Run in Colab\n",
3939
" </a>\n",
4040
" </td>\n",
4141
" <td>\n",
4242
" <a href=\"https://github.com/googleapis/python-bigquery-dataframes/tree/main/notebooks/generative_ai/bq_dataframes_llm_kmeans.ipynb\">\n",
43-
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
43+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/github-logo.png\" width=\"32\" alt=\"GitHub logo\">\n",
4444
" View on GitHub\n",
4545
" </a>\n",
4646
" </td>\n",

notebooks/generative_ai/bq_dataframes_ml_drug_name_generation.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
"<table align=\"left\">\n",
3535
" <td>\n",
3636
" <a href=\"https://colab.research.google.com/github/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_ml_drug_name_generation.ipynb\">\n",
37-
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
37+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/colab-logo.png\" alt=\"Colab logo\"> Run in Colab\n",
3838
" </a>\n",
3939
" </td>\n",
4040
" <td>\n",
4141
" <a href=\"https://github.com/googleapis/python-bigquery-dataframes/blob/main/notebooks/generative_ai/bq_dataframes_ml_drug_name_generation.ipynb\">\n",
42-
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
42+
" <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/github-logo.png\" width=\"32\" alt=\"GitHub logo\">\n",
4343
" View on GitHub\n",
4444
" </a>\n",
4545
" </td>\n",

0 commit comments

Comments
 (0)