Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/linters/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
extend-ignore = E501
24 changes: 24 additions & 0 deletions .github/linters/.sqlfluff
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[sqlfluff]
dialect = bigquery
max_line_length = 200

[sqlfluff:indentation]
indent_unit = space
tab_space_size = 2
indented_using_on = False
allow_implicit_indents = True

[sqlfluff:layout:type:binary_operator]
line_position = trailing

[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper

[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = upper

[sqlfluff:rules:convention.count_rows]
prefer_count_0 = True

[sqlfluff:rules:convention.quoted_literals]
preferred_quoted_literal_style = single_quotes
6 changes: 3 additions & 3 deletions infra/bigquery-export/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion workspace/project_options.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
SELECT * FROM `httparchive.region-us.INFORMATION_SCHEMA.EFFECTIVE_PROJECT_OPTIONS`;
SELECT
project_id,
option_name,
option_value,
option_type

FROM `httparchive.region-us.INFORMATION_SCHEMA.EFFECTIVE_PROJECT_OPTIONS`;

ALTER PROJECT httparchive SET OPTIONS (
`region-us.default_sql_dialect_option` = 'only_google_sql',
Expand Down
40 changes: 22 additions & 18 deletions workspace/restore_data.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "e6f1073c",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Utilities for restoring deleted BigQuery datasets and tables.\"\"\"\n",
"from google.cloud import bigquery\n",
"\n",
"client = bigquery.Client()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -10,16 +23,11 @@
},
"outputs": [],
"source": [
"# sql_engine: bigquery\n",
"# output_variable: df\n",
"# start _sql\n",
"_sql = \"\"\"\n",
"QUERY = \"\"\"\n",
"## [Restore deleted dataset](https://docs.cloud.google.com/bigquery/docs/restore-deleted-datasets#restore_a_dataset)\n",
"UNDROP SCHEMA httparchive.crawl;\n",
"\"\"\" # end _sql\n",
"from google.colab.sql import bigquery as _bqsqlcell\n",
"df = _bqsqlcell.run(_sql)\n",
"df"
"\"\"\"\n",
"client.query(QUERY).result()"
]
},
{
Expand All @@ -31,9 +39,10 @@
},
"outputs": [],
"source": [
"## [Restore deleted table](https://docs.cloud.google.com/bigquery/docs/restore-deleted-tables#restore_a_table)\n",
"# [Restore deleted table]\n",
"# https://docs.cloud.google.com/bigquery/docs/restore-deleted-tables#restore_a_table\n",
"!date -d '2025-08-04 16:00:00.000000Z' +%s000\n",
"!bq cp httparchive.crawl.pages@1759670400000 httparchive.crawl_staging.pages_restored_20250804"
"!bq cp httparchive.crawl.pages@1759670400000 httparchive.crawl_staging.pages_restored_20250804\n"
]
},
{
Expand All @@ -46,19 +55,14 @@
},
"outputs": [],
"source": [
"# sql_engine: bigquery\n",
"# output_variable: df\n",
"# start _sql\n",
"_sql = \"\"\"\n",
"QUERY = \"\"\"\n",
"## [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",
"CREATE TABLE httparchive.crawl_staging.pages_restored_20250804 AS\n",
"SELECT *\n",
"FROM httparchive.crawl.pages\n",
" FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR);\n",
"\"\"\" # end _sql\n",
"from google.colab.sql import bigquery as _bqsqlcell\n",
"df = _bqsqlcell.run(_sql)\n",
"df"
"\"\"\"\n",
"client.query(QUERY).result()"
]
}
],
Expand Down
Loading