Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 8d758f7

Browse files
committed
Merge branch 'main' into shuowei-fix-describe-unsupported
2 parents 389b023 + 5cf3788 commit 8d758f7

File tree

62 files changed

+12531
-9386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+12531
-9386
lines changed

.github/workflows/docs.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,3 @@ jobs:
3636
run: |
3737
python -m pip install --upgrade setuptools pip wheel
3838
python -m pip install nox
39-
- name: Run docfx
40-
run: |
41-
nox -s docfx

bigframes/bigquery/_operations/ai.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def if_(
745745
or pandas Series.
746746
connection_id (str, optional):
747747
Specifies the connection to use to communicate with the model. For example, `myproject.us.myconnection`.
748-
If not provided, the connection from the current session will be used.
748+
If not provided, the query uses your end-user credential.
749749
750750
Returns:
751751
bigframes.series.Series: A new series of bools.
@@ -756,7 +756,7 @@ def if_(
756756

757757
operator = ai_ops.AIIf(
758758
prompt_context=tuple(prompt_context),
759-
connection_id=_resolve_connection_id(series_list[0], connection_id),
759+
connection_id=connection_id,
760760
)
761761

762762
return series_list[0]._apply_nary_op(operator, series_list[1:])
@@ -800,7 +800,7 @@ def classify(
800800
Categories to classify the input into.
801801
connection_id (str, optional):
802802
Specifies the connection to use to communicate with the model. For example, `myproject.us.myconnection`.
803-
If not provided, the connection from the current session will be used.
803+
If not provided, the query uses your end-user credential.
804804
805805
Returns:
806806
bigframes.series.Series: A new series of strings.
@@ -812,7 +812,7 @@ def classify(
812812
operator = ai_ops.AIClassify(
813813
prompt_context=tuple(prompt_context),
814814
categories=tuple(categories),
815-
connection_id=_resolve_connection_id(series_list[0], connection_id),
815+
connection_id=connection_id,
816816
)
817817

818818
return series_list[0]._apply_nary_op(operator, series_list[1:])
@@ -853,7 +853,7 @@ def score(
853853
or pandas Series.
854854
connection_id (str, optional):
855855
Specifies the connection to use to communicate with the model. For example, `myproject.us.myconnection`.
856-
If not provided, the connection from the current session will be used.
856+
If not provided, the query uses your end-user credential.
857857
858858
Returns:
859859
bigframes.series.Series: A new series of double (float) values.
@@ -864,7 +864,7 @@ def score(
864864

865865
operator = ai_ops.AIScore(
866866
prompt_context=tuple(prompt_context),
867-
connection_id=_resolve_connection_id(series_list[0], connection_id),
867+
connection_id=connection_id,
868868
)
869869

870870
return series_list[0]._apply_nary_op(operator, series_list[1:])

bigframes/core/bigframe_node.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,32 @@ def top_down(
330330
"""
331331
Perform a top-down transformation of the BigFrameNode tree.
332332
"""
333+
results: Dict[BigFrameNode, BigFrameNode] = {}
334+
# Each stack entry is (node, t_node). t_node is None until transform(node) is called.
335+
stack: list[tuple[BigFrameNode, typing.Optional[BigFrameNode]]] = [(self, None)]
333336

334-
@functools.cache
335-
def recursive_transform(node: BigFrameNode) -> BigFrameNode:
336-
return transform(node).transform_children(recursive_transform)
337+
while stack:
338+
node, t_node = stack[-1]
339+
340+
if t_node is None:
341+
if node in results:
342+
stack.pop()
343+
continue
344+
t_node = transform(node)
345+
stack[-1] = (node, t_node)
346+
347+
all_done = True
348+
for child in reversed(t_node.child_nodes):
349+
if child not in results:
350+
stack.append((child, None))
351+
all_done = False
352+
break
353+
354+
if all_done:
355+
results[node] = t_node.transform_children(lambda x: results[x])
356+
stack.pop()
337357

338-
return recursive_transform(self)
358+
return results[self]
339359

340360
def bottom_up(
341361
self: BigFrameNode,

bigframes/core/compile/sqlglot/expressions/ai_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ def _construct_named_args(op: ops.NaryOp) -> list[sge.Kwarg]:
113113
)
114114
)
115115

116-
endpoit = op_args.get("endpoint", None)
117-
if endpoit is not None:
118-
args.append(sge.Kwarg(this="endpoint", expression=sge.Literal.string(endpoit)))
116+
endpoint = op_args.get("endpoint", None)
117+
if endpoint is not None:
118+
args.append(sge.Kwarg(this="endpoint", expression=sge.Literal.string(endpoint)))
119119

120120
request_type = op_args.get("request_type", None)
121121
if request_type is not None:

bigframes/operations/ai_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class AIIf(base_ops.NaryOp):
123123
name: ClassVar[str] = "ai_if"
124124

125125
prompt_context: Tuple[str | None, ...]
126-
connection_id: str
126+
connection_id: str | None
127127

128128
def output_type(self, *input_types: dtypes.ExpressionType) -> dtypes.ExpressionType:
129129
return dtypes.BOOL_DTYPE
@@ -135,7 +135,7 @@ class AIClassify(base_ops.NaryOp):
135135

136136
prompt_context: Tuple[str | None, ...]
137137
categories: tuple[str, ...]
138-
connection_id: str
138+
connection_id: str | None
139139

140140
def output_type(self, *input_types: dtypes.ExpressionType) -> dtypes.ExpressionType:
141141
return dtypes.STRING_DTYPE
@@ -146,7 +146,7 @@ class AIScore(base_ops.NaryOp):
146146
name: ClassVar[str] = "ai_score"
147147

148148
prompt_context: Tuple[str | None, ...]
149-
connection_id: str
149+
connection_id: str | None
150150

151151
def output_type(self, *input_types: dtypes.ExpressionType) -> dtypes.ExpressionType:
152152
return dtypes.FLOAT_DTYPE

docs/conf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@
5959
"sphinx.ext.todo",
6060
"sphinx.ext.viewcode",
6161
"sphinx_sitemap",
62-
"myst_parser",
62+
"myst_nb",
6363
]
6464

65+
# myst-nb configuration
66+
nb_execution_mode = "off"
67+
6568
# autodoc/autosummary flags
6669
autoclass_content = "both"
6770
autodoc_default_options = {"members": True}
@@ -269,12 +272,14 @@
269272

270273

271274
suppress_warnings = [
275+
# Allow unknown mimetype so we can use widgets in tutorial notebooks.
276+
"mystnb.unknown_mime_type",
272277
# Temporarily suppress this to avoid "more than one target found for
273278
# cross-reference" warning, which are intractable for us to avoid while in
274279
# a mono-repo.
275280
# See https://github.com/sphinx-doc/sphinx/blob
276281
# /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843
277-
"ref.python"
282+
"ref.python",
278283
]
279284

280285
# -- Options for LaTeX output ---------------------------------------------

docs/notebooks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../notebooks

docs/user_guide/index.rst

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,116 @@ User Guide
99

1010
Getting Started <https://docs.cloud.google.com/bigquery/docs/dataframes-quickstart>
1111
Cloud Docs User Guides <https://docs.cloud.google.com/bigquery/docs/bigquery-dataframes-introduction>
12+
13+
.. toctree::
14+
:caption: Getting Started
15+
:maxdepth: 1
16+
17+
Quickstart Template <../notebooks/getting_started/bq_dataframes_template.ipynb>
18+
Getting Started <../notebooks/getting_started/getting_started_bq_dataframes.ipynb>
19+
Magics <../notebooks/getting_started/magics.ipynb>
20+
ML Fundamentals <../notebooks/getting_started/ml_fundamentals_bq_dataframes.ipynb>
21+
22+
.. toctree::
23+
:caption: DataFrames
24+
:maxdepth: 1
25+
26+
Anywidget Mode <../notebooks/dataframes/anywidget_mode.ipynb>
27+
Dataframe <../notebooks/dataframes/dataframe.ipynb>
28+
Index Col Null <../notebooks/dataframes/index_col_null.ipynb>
29+
Integrations <../notebooks/dataframes/integrations.ipynb>
30+
Pypi <../notebooks/dataframes/pypi.ipynb>
31+
32+
.. toctree::
33+
:caption: Data Types
34+
:maxdepth: 1
35+
36+
Array <../notebooks/data_types/array.ipynb>
37+
Json <../notebooks/data_types/json.ipynb>
38+
Struct <../notebooks/data_types/struct.ipynb>
39+
Timedelta <../notebooks/data_types/timedelta.ipynb>
40+
41+
.. toctree::
42+
:caption: Generative AI
43+
:maxdepth: 1
44+
45+
AI Functions <../notebooks/generative_ai/ai_functions.ipynb>
46+
AI Forecast <../notebooks/generative_ai/bq_dataframes_ai_forecast.ipynb>
47+
LLM Code Generation <../notebooks/generative_ai/bq_dataframes_llm_code_generation.ipynb>
48+
LLM KMeans <../notebooks/generative_ai/bq_dataframes_llm_kmeans.ipynb>
49+
LLM Output Schema <../notebooks/generative_ai/bq_dataframes_llm_output_schema.ipynb>
50+
LLM Vector Search <../notebooks/generative_ai/bq_dataframes_llm_vector_search.ipynb>
51+
Drug Name Generation <../notebooks/generative_ai/bq_dataframes_ml_drug_name_generation.ipynb>
52+
Large Language Models <../notebooks/generative_ai/large_language_models.ipynb>
53+
54+
.. toctree::
55+
:caption: Machine Learning
56+
:maxdepth: 1
57+
58+
ML Cross Validation <../notebooks/ml/bq_dataframes_ml_cross_validation.ipynb>
59+
Linear Regression <../notebooks/ml/bq_dataframes_ml_linear_regression.ipynb>
60+
Linear Regression BBQ <../notebooks/ml/bq_dataframes_ml_linear_regression_bbq.ipynb>
61+
Linear Regression Big <../notebooks/ml/bq_dataframes_ml_linear_regression_big.ipynb>
62+
Easy Linear Regression <../notebooks/ml/easy_linear_regression.ipynb>
63+
Sklearn Linear Regression <../notebooks/ml/sklearn_linear_regression.ipynb>
64+
Timeseries Analysis <../notebooks/ml/timeseries_analysis.ipynb>
65+
66+
.. toctree::
67+
:caption: Visualization
68+
:maxdepth: 1
69+
70+
COVID Line Graphs <../notebooks/visualization/bq_dataframes_covid_line_graphs.ipynb>
71+
Tutorial <../notebooks/visualization/tutorial.ipynb>
72+
73+
.. toctree::
74+
:caption: Geospatial Data
75+
:maxdepth: 1
76+
77+
Geoseries <../notebooks/geo/geoseries.ipynb>
78+
79+
.. toctree::
80+
:caption: Regionalized BigQuery
81+
:maxdepth: 1
82+
83+
Regionalized <../notebooks/location/regionalized.ipynb>
84+
85+
.. toctree::
86+
:caption: Multimodal
87+
:maxdepth: 1
88+
89+
Multimodal Dataframe <../notebooks/multimodal/multimodal_dataframe.ipynb>
90+
91+
.. toctree::
92+
:caption: Remote Functions
93+
:maxdepth: 1
94+
95+
Remote Function <../notebooks/remote_functions/remote_function.ipynb>
96+
Remote Function Usecases <../notebooks/remote_functions/remote_function_usecases.ipynb>
97+
Remote Function Vertex Claude Model <../notebooks/remote_functions/remote_function_vertex_claude_model.ipynb>
98+
99+
.. toctree::
100+
:caption: Streaming
101+
:maxdepth: 1
102+
103+
Streaming Dataframe <../notebooks/streaming/streaming_dataframe.ipynb>
104+
105+
.. toctree::
106+
:caption: Experimental
107+
:maxdepth: 1
108+
109+
AI Operators <../notebooks/experimental/ai_operators.ipynb>
110+
Semantic Operators <../notebooks/experimental/semantic_operators.ipynb>
111+
112+
.. toctree::
113+
:caption: Apps
114+
:maxdepth: 1
115+
116+
Synthetic Data Generation <../notebooks/apps/synthetic_data_generation.ipynb>
117+
118+
.. toctree::
119+
:caption: Kaggle
120+
:maxdepth: 1
121+
122+
AI Forecast <../notebooks/kaggle/bq_dataframes_ai_forecast.ipynb>
123+
Describe Product Images <../notebooks/kaggle/describe-product-images-with-bigframes-multimodal.ipynb>
124+
Vector Search Over National Jukebox <../notebooks/kaggle/vector-search-with-bigframes-over-national-jukebox.ipynb>

notebooks/dataframes/dataframe.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"id": "13861abc-120c-4db6-ad0c-e414b85d3443",
5050
"metadata": {},
5151
"source": [
52-
"### Select a subset of the DF"
52+
"## Select a subset of the DF"
5353
]
5454
},
5555
{

notebooks/dataframes/index_col_null.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@
358358
"id": "13861abc-120c-4db6-ad0c-e414b85d3443",
359359
"metadata": {},
360360
"source": [
361-
"### Select a subset of the DataFrame\n",
361+
"## Select a subset of the DataFrame",
362362
"\n",
363363
"Filter columns by selecting a list of columns from the DataFrame.\n",
364364
"\n",

0 commit comments

Comments
 (0)