Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hacker_news.stories to hacker_news.full and SAFE_OFFSET, fixes #2432 and fixes #2434 #2433

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions blogs/textclassification/txtcls.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"SELECT\n",
" url, title, score\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 10\n",
" AND score > 10\n",
Expand All @@ -215,10 +215,10 @@
"source": [
"query=\"\"\"\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" COUNT(title) AS num_articles\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down Expand Up @@ -408,10 +408,10 @@
"query=\"\"\"\n",
"SELECT source, REGEXP_REPLACE(title, '[^a-zA-Z0-9 $.-]', ' ') AS title FROM\n",
"(SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" title\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"SELECT\n",
" url, title, score\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 10\n",
" AND score > 10\n",
Expand All @@ -150,10 +150,10 @@
"%%bigquery --project $PROJECT\n",
"\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" COUNT(title) AS num_articles\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down Expand Up @@ -182,10 +182,10 @@
"sub_query = \"\"\"\n",
"SELECT\n",
" title,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[OFFSET(1)] AS source\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[SAFE_OFFSET(1)] AS source\n",
" \n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '{0}'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"SELECT\n",
" url, title, score\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 10\n",
" AND score > 10\n",
Expand All @@ -194,10 +194,10 @@
"source": [
"%%bigquery --project $PROJECT\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" COUNT(title) AS num_articles\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down Expand Up @@ -226,10 +226,10 @@
"query=\"\"\"\n",
"SELECT source, LOWER(REGEXP_REPLACE(title, '[^a-zA-Z0-9 $.-]', ' ')) AS title FROM\n",
" (SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" title\n",
" FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
" WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"SELECT\n",
" url, title, score\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 10\n",
" AND score > 10\n",
Expand All @@ -150,10 +150,10 @@
"%%bigquery --project $PROJECT\n",
"\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" COUNT(title) AS num_articles\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down Expand Up @@ -182,10 +182,10 @@
"sub_query = \"\"\"\n",
"SELECT\n",
" title,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[OFFSET(1)] AS source\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[SAFE_OFFSET(1)] AS source\n",
" \n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '{0}'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"SELECT\n",
" url, title, score\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 10\n",
" AND score > 10\n",
Expand All @@ -195,10 +195,10 @@
"source": [
"%%bigquery --project $PROJECT\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" COUNT(title) AS num_articles\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down Expand Up @@ -227,10 +227,10 @@
"query=\"\"\"\n",
"SELECT source, LOWER(REGEXP_REPLACE(title, '[^a-zA-Z0-9 $.-]', ' ')) AS title FROM\n",
" (SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" title\n",
" FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
" WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
" \" \", \n",
" LOWER(REGEXP_REPLACE(text, '[^a-zA-Z $-]', ' '))) AS text\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 100\n",
" AND LENGTH(text) > 100\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"SELECT\n",
" url, title, score\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 10\n",
" AND score > 10\n",
Expand All @@ -108,10 +108,10 @@
"source": [
"query=\"\"\"\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" COUNT(title) AS num_articles\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down Expand Up @@ -140,10 +140,10 @@
"query=\"\"\"\n",
"SELECT source, LOWER(REGEXP_REPLACE(title, '[^a-zA-Z0-9 $.-]', ' ')) AS title FROM\n",
" (SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" title\n",
" FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
" WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"SELECT\n",
" url, title, score\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 10\n",
" AND score > 10\n",
Expand All @@ -125,10 +125,10 @@
"source": [
"%%bigquery --project $PROJECT\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" COUNT(title) AS num_articles\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down Expand Up @@ -157,10 +157,10 @@
"query=\"\"\"\n",
"SELECT source, LOWER(REGEXP_REPLACE(title, '[^a-zA-Z0-9 $.-]', ' ')) AS title FROM\n",
" (SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" title\n",
" FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
" WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
" \" \", \n",
" LOWER(REGEXP_REPLACE(text, '[^a-zA-Z $-]', ' '))) AS text\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 100\n",
" AND LENGTH(text) > 100\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"Hacker news headlines are available as a BigQuery public dataset. The [dataset](https://console.cloud.google.com/bigquery?p=bigquery-public-data&d=hacker_news&page=table&t=stories) contains all headlines from the sites inception in October 2006 until October 2015. \n",
"\n",
"### Lab Task 1a: \n",
"Complete the query below to create a sample dataset containing the `url`, `title`, and `score` of articles from the public dataset `bigquery-public-data.hacker_news.stories`. Use a WHERE clause to restrict to only those articles with\n",
"Complete the query below to create a sample dataset containing the `url`, `title`, and `score` of articles from the public dataset `bigquery-public-data.hacker_news.full`. Use a WHERE clause to restrict to only those articles with\n",
"* title length greater than 10 characters\n",
"* score greater than 10\n",
"* url length greater than 0 characters"
Expand Down Expand Up @@ -134,10 +134,10 @@
"%%bigquery --project $PROJECT\n",
"\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" # TODO: Your code goes here.\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" # TODO: Your code goes here.\n",
Expand Down Expand Up @@ -166,10 +166,10 @@
"sub_query = \"\"\"\n",
"SELECT\n",
" title,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[OFFSET(1)] AS source\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[SAFE_OFFSET(1)] AS source\n",
" \n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '{0}'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"Hacker news headlines are available as a BigQuery public dataset. The [dataset](https://console.cloud.google.com/bigquery?project=bigquery-public-data&page=table&t=stories&d=hacker_news&p=bigquery-public-data&redirect_from_classic=true) contains all headlines from the sites inception in October 2006 until October 2015. \n",
"\n",
"### Lab Task 1a: \n",
"Complete the query below to create a sample dataset containing the `url`, `title`, and `score` of articles from the public dataset `bigquery-public-data.hacker_news.stories`. Use a WHERE clause to restrict to only those articles with\n",
"Complete the query below to create a sample dataset containing the `url`, `title`, and `score` of articles from the public dataset `bigquery-public-data.hacker_news.full`. Use a WHERE clause to restrict to only those articles with\n",
"* title length greater than 10 characters\n",
"* score greater than 10\n",
"* url length greater than 0 characters"
Expand Down Expand Up @@ -126,10 +126,10 @@
"%%bigquery --project $PROJECT\n",
"\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" # TODO: Your code goes here.\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" # TODO: Your code goes here.\n",
Expand Down Expand Up @@ -158,10 +158,10 @@
"sub_query = \"\"\"\n",
"SELECT\n",
" title,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[OFFSET(1)] AS source\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[SAFE_OFFSET(1)] AS source\n",
" \n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '{0}'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"SELECT\n",
" url, title, score\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" LENGTH(title) > 10\n",
" AND score > 10\n",
Expand All @@ -122,10 +122,10 @@
"%%bigquery --project $PROJECT\n",
"\n",
"SELECT\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[OFFSET(1)] AS source,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.'))[SAFE_OFFSET(1)] AS source,\n",
" COUNT(title) AS num_articles\n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '.*://(.[^/]+)/'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down Expand Up @@ -154,10 +154,10 @@
"sub_query = \"\"\"\n",
"SELECT\n",
" title,\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[OFFSET(1)] AS source\n",
" ARRAY_REVERSE(SPLIT(REGEXP_EXTRACT(url, '{0}'), '.'))[SAFE_OFFSET(1)] AS source\n",
" \n",
"FROM\n",
" `bigquery-public-data.hacker_news.stories`\n",
" `bigquery-public-data.hacker_news.full`\n",
"WHERE\n",
" REGEXP_CONTAINS(REGEXP_EXTRACT(url, '{0}'), '.com$')\n",
" AND LENGTH(title) > 10\n",
Expand Down
Loading