Skip to content

Conversation

@greghutch
Copy link
Contributor

This attemps to get sample bigquery queries into a more easily
consumed form than our documentation. For now, the set of
queries is sources from my somewhat unstructured explorations.

Once we have a published dataset, we can add per-query documentation and
reproducible queries for the user.

Fixes #136

This attemps to get sample bigquery queries into a more easily
consumed form than our documentation.   For now, the set of
queries is sources from my somewhat unstructured explorations.

Once we have a published dataset, we can add per-query documentation and
reproducible queries for the user.

fix: googlemaps#136
@greghutch greghutch requested review from bshi, crystalzha0 and ewbao June 30, 2022 21:06
DATE(timestamp) AS date,
COUNT(DISTINCT labels.task_id) AS active_tasks
FROM
\`${argv.dataset}.fleetengine_googleapis_com_update_task\`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dataset can be specified on the bq command line so it might be cleaner to read to omit it in the raw SQL.

const sql = `
SELECT
*
FROM (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complex queries like this might be useful to document as a view for easy querying (and visualization in datastudio/looker/etc).

@@ -0,0 +1,20 @@
const { exec } = require("child_process");
exports.query = function query(query) {
const cmd = `bq query --nouse_legacy_sql '${query}'`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SQL in this patch would be more readable if dataset were injected here as a command line parameter of bq

@@ -0,0 +1,28 @@
#!/usr/bin/env node
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth writing examples as .sql files with named parameters? Then wrapping not-a-test.sh could just call bq directly. Would remove one layer (nodejs) of indirection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sample biquery queries to fleet-debugger

2 participants