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

feat: add some sample queries to fleet-debugger #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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
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