-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: main
Are you sure you want to change the base?
Conversation
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\` |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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}'`; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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