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

Commit 7221178

Browse files
committed
docs: Add manual test notebook for job_history()
1 parent 9c2513e commit 7221178

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Job History Manual Test\\n",
8+
"\\n",
9+
"This notebook demonstrates and manually tests the `bigframes.pandas.job_history()` functionality."
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"import pandas as pd\\n",
19+
"import bigframes.pandas as bpd\\n",
20+
"\\n",
21+
"# Set options if needed, e.g. project/location\\n",
22+
"# bpd.options.bigquery.project = \"YOUR_PROJECT\"\\n",
23+
"# bpd.options.bigquery.location = \"US\""
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"metadata": {},
29+
"source": [
30+
"## 1. Trigger a Query Job (read_gbq)"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"df = bpd.read_gbq(\"SELECT 1 as a, 2 as b\")\\n",
40+
"df.head()"
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"metadata": {},
46+
"source": [
47+
"## 2. Trigger a Load Job (read_pandas)"
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"local_df = pd.DataFrame({'col1': [1, 2, 3], 'col2': ['a', 'b', 'c']})\\n",
57+
"bf_df = bpd.read_pandas(local_df)\\n",
58+
"bf_df.head()"
59+
]
60+
},
61+
{
62+
"cell_type": "markdown",
63+
"metadata": {},
64+
"source": [
65+
"## 3. Trigger a Computation (Computation Job)"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": null,
71+
"metadata": {},
72+
"outputs": [],
73+
"source": [
74+
"# Perform a simple aggregation to trigger a computation\\n",
75+
"agg_df = bf_df.groupby('col2').sum()\\n",
76+
"agg_df.head()"
77+
]
78+
},
79+
{
80+
"cell_type": "markdown",
81+
"metadata": {},
82+
"source": [
83+
"## 4. Check Job History"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"metadata": {},
90+
"outputs": [],
91+
"source": [
92+
"history = bpd.job_history()\\n",
93+
"history"
94+
]
95+
},
96+
{
97+
"cell_type": "markdown",
98+
"metadata": {},
99+
"source": [
100+
"### Verify Specific Columns"
101+
]
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": null,
106+
"metadata": {},
107+
"outputs": [],
108+
"source": [
109+
"# Display key columns to verify data population\\n",
110+
"cols_to_check = [\\n",
111+
" 'job_id', \\n",
112+
" 'job_type', \\n",
113+
" 'creation_time', \\n",
114+
" 'duration_seconds', \\n",
115+
" 'total_bytes_processed', \\n",
116+
" 'query', \\n",
117+
" 'input_files', # Should be populated for Load Job\\n",
118+
" 'destination_table'\\n",
119+
"]\\n",
120+
"\\n",
121+
"# Filter columns that exist in the history DataFrame\\n",
122+
"existing_cols = [col for col in cols_to_check if col in history.columns]\\n",
123+
"history[existing_cols]"
124+
]
125+
}
126+
],
127+
"metadata": {
128+
"kernelspec": {
129+
"display_name": "Python 3",
130+
"language": "python",
131+
"name": "python3"
132+
},
133+
"language_info": {
134+
"codemirror_mode": {
135+
"name": "ipython",
136+
"version": 3
137+
},
138+
"file_extension": ".py",
139+
"mimetype": "text/x-python",
140+
"name": "python",
141+
"nbconvert_exporter": "python",
142+
"pygments_lexer": "ipython3",
143+
"version": "3.8.5"
144+
}
145+
},
146+
"nbformat": 4,
147+
"nbformat_minor": 4
148+
}

0 commit comments

Comments
 (0)