Skip to content

Commit 2057ff0

Browse files
committed
Refactor restore_data notebook to streamline SQL execution and remove unnecessary comments
1 parent cb08a28 commit 2057ff0

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

workspace/restore_data.ipynb

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@
1010
},
1111
"outputs": [],
1212
"source": [
13-
"# sql_engine: bigquery\n",
14-
"# output_variable: df\n",
15-
"# start _sql\n",
16-
"_sql = \"\"\"\n",
13+
"from google.cloud import bigquery\n",
14+
"\n",
15+
"client = bigquery.Client()\n",
16+
"sql = \"\"\"\n",
1717
"## [Restore deleted dataset](https://docs.cloud.google.com/bigquery/docs/restore-deleted-datasets#restore_a_dataset)\n",
1818
"UNDROP SCHEMA httparchive.crawl;\n",
19-
"\"\"\" # end _sql\n",
20-
"from google.colab.sql import bigquery as _bqsqlcell\n",
21-
"df = _bqsqlcell.run(_sql)\n",
22-
"df"
19+
"\"\"\"\n",
20+
"client.query(sql).result()"
2321
]
2422
},
2523
{
@@ -46,19 +44,17 @@
4644
},
4745
"outputs": [],
4846
"source": [
49-
"# sql_engine: bigquery\n",
50-
"# output_variable: df\n",
51-
"# start _sql\n",
52-
"_sql = \"\"\"\n",
47+
"from google.cloud import bigquery\n",
48+
"\n",
49+
"client = bigquery.Client()\n",
50+
"sql = \"\"\"\n",
5351
"## [Restore a table to a specific point in time](https://cloud.google.com/bigquery/docs/restore-tables#restoring_a_table_to_a_specific_point_in_time)\n",
5452
"CREATE TABLE httparchive.crawl_staging.pages_restored_20250804 AS\n",
5553
"SELECT *\n",
5654
"FROM httparchive.crawl.pages\n",
5755
" FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR);\n",
58-
"\"\"\" # end _sql\n",
59-
"from google.colab.sql import bigquery as _bqsqlcell\n",
60-
"df = _bqsqlcell.run(_sql)\n",
61-
"df"
56+
"\"\"\"\n",
57+
"client.query(sql).result()"
6258
]
6359
}
6460
],

0 commit comments

Comments
 (0)