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

Add (missing) sample parameter values #428

Merged
merged 5 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
31 changes: 19 additions & 12 deletions bigquery/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
'use strict';

// [START bigquery_simple_app_all]
// [START bigquery_simple_app_print]
function printResult (rows) {
// [START bigquery_simple_app_print]
console.log('Query Results:');
rows.forEach(function (row) {
let str = '';
Expand All @@ -29,25 +29,26 @@ function printResult (rows) {
}
console.log(str);
});
// [END bigquery_simple_app_print]
}
// [END bigquery_simple_app_print]

// [START bigquery_simple_app_query]
const sqlQuery = `SELECT
corpus, COUNT(*) as unique_words
FROM publicdata.samples.shakespeare
GROUP BY
corpus
ORDER BY
unique_words DESC LIMIT 10;`;

function queryShakespeare (projectId) {
// [START bigquery_simple_app_query]
// Imports the Google Cloud client library
const BigQuery = require('@google-cloud/bigquery');

// The project ID to use, e.g. "your-project-id"
// const projectId = "your-project-id";

// The SQL query to run
const sqlQuery = `SELECT
corpus, COUNT(*) as unique_words
FROM publicdata.samples.shakespeare
GROUP BY
corpus
ORDER BY
unique_words DESC LIMIT 10;`;

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand All @@ -69,8 +70,8 @@ function queryShakespeare (projectId) {
.catch((err) => {
console.error('ERROR:', err);
});
// [END bigquery_simple_app_query]
}
// [END bigquery_simple_app_query]
// [END bigquery_simple_app_all]

function syncQuery (sqlQuery, projectId) {
Expand All @@ -81,6 +82,9 @@ function syncQuery (sqlQuery, projectId) {
// The project ID to use, e.g. "your-project-id"
// const projectId = "your-project-id";

// The SQL query to run, e.g. "SELECT * FROM publicdata.samples.natality LIMIT 5;"
// const sqlQuery = "SELECT * FROM publicdata.samples.natality LIMIT 5;";

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand Down Expand Up @@ -115,6 +119,9 @@ function asyncQuery (sqlQuery, projectId) {
// The project ID to use, e.g. "your-project-id"
// const projectId = "your-project-id";

// The SQL query to run, e.g. "SELECT * FROM publicdata.samples.natality LIMIT 5;"
// const sqlQuery = "SELECT * FROM publicdata.samples.natality LIMIT 5;";

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand Down
7 changes: 7 additions & 0 deletions bigquery/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ function listTables (datasetId, projectId) {
// The project ID to use, e.g. "your-project-id"
// const projectId = "your-project-id";

// The ID of the dataset to list tables in, e.g. "my_dataset"
// const datasetId = "my_dataset";

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand Down Expand Up @@ -401,6 +404,10 @@ function insertRowsAsStream (datasetId, tableId, rows, projectId) {
// The ID of the table into which data should be inserted, e.g. "my_table"
// const tableId = "my_table";

// The rows to insert into the table
// Customize this object to match your table's schema
// const rows = [{name: "Tom", age: 30}, {name: "Jane", age: 32}];

// Instantiates a client
const bigquery = BigQuery({
projectId: projectId
Expand Down