Skip to content

Commit 22ff695

Browse files
committed
docs: update read_gbq_colab_callback notebook with new parameter name
1 parent b9c9336 commit 22ff695

1 file changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"cells": [
3+
{
4+
"id": "7fb27b941602401d91542211134fc71a",
5+
"cell_type": "markdown",
6+
"source": [
7+
"# Testing Automatic Per-Cell Execution History Filtering in BigQuery DataFrames\n",
8+
"\n",
9+
"This notebook demonstrates automatic per-cell execution history filtering in BigQuery DataFrames.\n",
10+
"In notebook environments (like Colab or Jupyter), `bigframes.execution_history()` automatically isolates and filters query executions to only include those initiated within the current cell."
11+
],
12+
"metadata": {}
13+
},
14+
{
15+
"id": "acae54e37e7d407bbb7b55eff062a284",
16+
"cell_type": "code",
17+
"source": [
18+
"# Copyright 2026 Google LLC\n",
19+
"#\n",
20+
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
21+
"# you may not use this file except in compliance with the License.\n",
22+
"# You may obtain a copy of the License at\n",
23+
"#\n",
24+
"# http://www.apache.org/licenses/LICENSE-2.0\n",
25+
"#\n",
26+
"# Unless required by applicable law or agreed to in writing, software\n",
27+
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
28+
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
29+
"# See the License for the specific language governing permissions and\n",
30+
"# limitations under the License."
31+
],
32+
"metadata": {},
33+
"execution_count": 1,
34+
"outputs": []
35+
},
36+
{
37+
"id": "9a63283cbaf04dbcab1f6479b197f3a8",
38+
"cell_type": "code",
39+
"source": [
40+
"import bigframes\n",
41+
"import bigframes.pandas as bpd\n",
42+
"\n",
43+
"bpd.options.bigquery.location = \"US\""
44+
],
45+
"metadata": {},
46+
"execution_count": 2,
47+
"outputs": []
48+
},
49+
{
50+
"id": "8dd0d8092fe74a7c96281538738b07e2",
51+
"cell_type": "markdown",
52+
"source": [
53+
"## Cell 1: Executing a query\n",
54+
"We will execute a standard query in this cell. Any BigFrames operations that trigger query compilation and execution will be automatically associated with this cell's execution count."
55+
],
56+
"metadata": {}
57+
},
58+
{
59+
"id": "72eea5119410473aa328ad9291626812",
60+
"cell_type": "code",
61+
"source": [
62+
"df1 = bpd.read_gbq(\"SELECT 1 AS col1, 'hello' AS col2\")\n",
63+
"df1.to_pandas()\n",
64+
"\n",
65+
"# Retrieve history for the current cell\n",
66+
"history1 = bigframes.execution_history()\n",
67+
"print(\"Execution history for Cell 1:\")\n",
68+
"print(history1.to_dataframe()[[\"job_id\", \"query\", \"status\"]])"
69+
],
70+
"metadata": {},
71+
"execution_count": 3,
72+
"outputs": []
73+
},
74+
{
75+
"id": "8edb47106e1a46a883d545849b8ab81b",
76+
"cell_type": "markdown",
77+
"source": [
78+
"## Cell 2: Executing a different query (Demonstrating Cell Isolation)\n",
79+
"If we execute a different query in a new cell, the execution history automatically filters to only include the new query from this cell, effectively isolating executions cell-by-cell."
80+
],
81+
"metadata": {}
82+
},
83+
{
84+
"id": "10185d26023b46108eb7d9f57d49d2b3",
85+
"cell_type": "code",
86+
"source": [
87+
"df2 = bpd.read_gbq(\"SELECT 2 AS col1, 'world' AS col2\")\n",
88+
"df2.to_pandas()\n",
89+
"\n",
90+
"# Retrieve history for the current cell\n",
91+
"history2 = bigframes.execution_history()\n",
92+
"print(\"Execution history for Cell 2:\")\n",
93+
"print(history2.to_dataframe()[[\"job_id\", \"query\", \"status\"]])"
94+
],
95+
"metadata": {},
96+
"execution_count": 4,
97+
"outputs": []
98+
},
99+
{
100+
"id": "8763a12b2bbd4a93a75aff182afb95dc",
101+
"cell_type": "markdown",
102+
"source": [
103+
"## Retrieving Complete Execution History (Unfiltered)\n",
104+
"If you want to see all executions across the entire session (spanning all cells), you can pass `current_cell_only=False`."
105+
],
106+
"metadata": {}
107+
},
108+
{
109+
"id": "7623eae2785240b9bd12b16a66d81610",
110+
"cell_type": "code",
111+
"source": [
112+
"full_history = bigframes.execution_history(current_cell_only=False)\n",
113+
"print(\"Complete, unfiltered session execution history:\")\n",
114+
"print(full_history.to_dataframe()[[\"job_id\", \"query\", \"status\"]])"
115+
],
116+
"metadata": {},
117+
"execution_count": 5,
118+
"outputs": []
119+
}
120+
],
121+
"metadata": {
122+
"kernelspec": {
123+
"display_name": "Python 3",
124+
"language": "python",
125+
"name": "python3"
126+
},
127+
"language_info": {
128+
"name": "python"
129+
}
130+
},
131+
"nbformat_minor": 5,
132+
"nbformat": 4
133+
}

0 commit comments

Comments
 (0)