{"id":15060764,"url":"https://github.com/yoheimuta/dbq","last_synced_at":"2026-03-07T07:31:03.383Z","repository":{"id":34593450,"uuid":"38540807","full_name":"yoheimuta/dbq","owner":"yoheimuta","description":"CLI tool to easily Decorate BigQuery table name","archived":false,"fork":false,"pushed_at":"2015-07-22T03:22:59.000Z","size":249,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T14:59:26.951Z","etag":null,"topics":["bigquery","bq","cli","golang","table-decorator"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoheimuta.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-04T16:46:54.000Z","updated_at":"2024-10-29T19:40:32.000Z","dependencies_parsed_at":"2022-09-26T19:52:44.467Z","dependency_job_id":null,"html_url":"https://github.com/yoheimuta/dbq","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/yoheimuta/dbq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2Fdbq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2Fdbq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2Fdbq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2Fdbq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoheimuta","download_url":"https://codeload.github.com/yoheimuta/dbq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoheimuta%2Fdbq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30209718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T05:23:27.321Z","status":"ssl_error","status_checked_at":"2026-03-07T05:00:17.256Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigquery","bq","cli","golang","table-decorator"],"created_at":"2024-09-24T23:04:15.817Z","updated_at":"2026-03-07T07:31:03.368Z","avatar_url":"https://github.com/yoheimuta.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dbq #\n\n[![GitHub release](http://img.shields.io/github/release/yoheimuta/go-from-gist-to-issue.svg?style=flat-square)][release]\n[![Wercker](http://img.shields.io/wercker/ci/54393fe184570fc622001411.svg?style=flat-square)][wercker]\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]\n\n[release]: https://github.com/yoheimuta/dbq/releases\n[wercker]: https://app.wercker.com/project/bykey/d232745d4f00166be66404af31469036\n[license]: https://github.com/yoheimuta/dbq/blob/master/LICENSE\n\nCLI tool to easily Decorate BigQuery table name\n\n## Description\n\n`dbq` enables you to use [Table Range Decorators](https://cloud.google.com/bigquery/table-decorators) to perform a more cost-effective query to [BigQuery](https://cloud.google.com/bigquery/what-is-bigquery) without complex calculation.\n\n- `dbq` supports both Relative value and Absolute value\n- `dbq` also supports timezone calculation.\n\n`dbq` will cut down on considerable data processed and spending :bowtie: :moneybag:\n\n- [BigQuery offers on-demand pricing for queries](https://cloud.google.com/bigquery/pricing) and 1 TB of data processed costs $5.\n- For example, a query to a 6TB table costs $30. Any SQL statements (ex. with LIMIT 1) don't affect the pricing.\n\n## Installation\n\nTo install dbq, please use go get.\n\n```\n$ go get github.com/yoheimuta/dbq\n...\n$ dbq help\n...\n```\n\nOr you can download a binary from [github relases page](https://github.com/yoheimuta/dbq/releases) and place it in $PATH directory.\n\n## Requirements\n\n- [bq-command-line-tool](https://cloud.google.com/bigquery/bq-command-line-tool)\n\n## Usage\n\n```ruby\n# no-option equal to `--beforeHour=3`\n$ dbq query \"SELECT * FROM [foo.bar@]\"\n\n# equal to SELECT * FROM [foo.bar@-10800000-]\n$ dbq query \"SELECT * FROM [foo.bar@]\" --beforeHour=3\n\n# equal to SELECT * FROM [foo.bar@1436371200000-]\n$ dbq query \"SELECT * FROM [foo.bar@]\" --startDate=\"2015-07-08 17:00:00\"\n\n# equal to SELECT * FROM [foo.bar@1436371200000-1436382000000]\n$ dbq query \"SELECT * FROM [foo.bar@]\" --startDate=\"2015-07-08 17:00:00\" --endDate=\"2015-07-08 18:00:00\"\n\n# equal to SELECT * FROM [foo.bar@1436338800000-]\n$ dbq query \"SELECT * FROM [foo.bar@]\" --startDate=\"2015-07-08 17:00:00\" --tz=\"-9\"\n\n# equal to SELECT * FROM [foo.bar@1436338800000-] WHERE DATE_ADD('2015-07-08 17:00:00', -9, 'HOUR') \u003c= time and time \u003c= DATE_ADD('2015-07-08 18:00:00', -9, 'HOUR')\n$ dbq query \"SELECT * FROM [foo.bar@] WHERE _tz(2015-07-08 17:00:00) \u003c= time and time \u003c= _tz(2015-07-08 18:00:00)\" --startDate=\"2015-07-08 17:00:00\" --tz=\"-9\"\n```\n\n### Placeholders\n\n- `@` will be replaced with `@\u003ctime1\u003e-\u003ctime2\u003e`\n - required\n- `_tz(datetime)` will be replaced with `DATE_ADD('datetime', tz value, 'HOUR')`\n - optional\n\n## DryRun\n\nThe option of `dryRun` shows how much cut down full scan bytes, so I strongly recommend to use this option before running any queries.\n\n- A query with no table decorator will process 6.0 TiB, then costs `6.0 * $5 = $30`.\n- A query with table decorator will process 110 GiB, then costs `0.1 * $5 = $0.5`. `dbq` will save `$29.5`.\n\n```ruby\n$ dbq query \"SELECT * FROM [foo.bar@]\" --dryRun\nRaw: SELECT * FROM [foo.bar]\nQuery successfully validated. Assuming the tables are not modified, running this query will process 6630178173385 bytes of data.\n- 6630178173385 bytes equal to 6,630,178,173,385 bytes\n- 6630178173385 bytes equal to 6.0TiB\n- 6630178173385 bytes equal to $30.15056 (= 6.03011 TiB * $5)\n\nDecorated: SELECT * FROM [foo.bar@-10800000-]\nQuery successfully validated. Assuming the tables are not modified, running this query will process 117636313873 bytes of data.\n- 117636313873 bytes equal to 117,636,313,873 bytes\n- 117636313873 bytes equal to 110GiB\n- 117636313873 bytes equal to $0.53495 (= 0.10699 TiB * $5)\n```\n\n## Options\n\n```\n$ dbq help query\nNAME:\n   query - Run bq query with complementing table range decorator\n\nUSAGE:\n   command query [command options] [arguments...]\n\nDESCRIPTION:\n\n\nOPTIONS:\n   --beforeHour '3'     a decimal to specify the hour ago, relative to the current time\n   --startDate          a datetime to specify date range with end flag\n   --endDate            a datetime to specify date range with start flag\n   --tz '0'             a decimal of hour or -hour to add to start and end datetime, considering timezone\n   --buffer '1'         a decimal of hour to add to start and end datetime, it's heuristic value\n   --gflags             no support. Use onlyStatement instead\n   --cflags             no support. Use onlyStatement instead\n   --verbose            a flag to output verbosely\n   --dryRun             a flag to run without any changes\n   --onlyStatement      a flag to output only a decorated statement\n```\n\n## CHANGELOG\n\nSee [CHANGELOG](CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoheimuta%2Fdbq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoheimuta%2Fdbq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoheimuta%2Fdbq/lists"}