{"id":15060776,"url":"https://github.com/fpopic/bigquery-schema-select","last_synced_at":"2026-03-15T17:21:37.358Z","repository":{"id":46921986,"uuid":"266426519","full_name":"fpopic/bigquery-schema-select","owner":"fpopic","description":"(Script) Generates SQL query that selects all fields (recursively for nested fields) from the provided BigQuery schema file.","archived":false,"fork":false,"pushed_at":"2024-08-31T13:26:24.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-29T15:18:29.248Z","etag":null,"topics":["bigquery","bigquery-schema","scala","sql"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fpopic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-23T22:00:15.000Z","updated_at":"2024-08-31T13:25:02.000Z","dependencies_parsed_at":"2024-09-29T06:21:17.569Z","dependency_job_id":null,"html_url":"https://github.com/fpopic/bigquery-schema-select","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/fpopic/bigquery-schema-select","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpopic%2Fbigquery-schema-select","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpopic%2Fbigquery-schema-select/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpopic%2Fbigquery-schema-select/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpopic%2Fbigquery-schema-select/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fpopic","download_url":"https://codeload.github.com/fpopic/bigquery-schema-select/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpopic%2Fbigquery-schema-select/sbom","scorecard":{"id":408547,"data":{"date":"2025-08-11","repo":{"name":"github.com/fpopic/bigquery-schema-select","commit":"e92e3e60f003c9009e931d2f8187692a64e37441"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/scala.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/scala.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/fpopic/bigquery-schema-select/scala.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/scala.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/fpopic/bigquery-schema-select/scala.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T22:00:15.720Z","repository_id":46921986,"created_at":"2025-08-18T22:00:15.721Z","updated_at":"2025-08-18T22:00:15.721Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28880230,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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","bigquery-schema","scala","sql"],"created_at":"2024-09-24T23:04:23.950Z","updated_at":"2026-03-15T17:21:37.353Z","avatar_url":"https://github.com/fpopic.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bigquery-schema-select\n\nGenerates SQL query that selects all fields (recursively for nested fields) from the provided BigQuery schema file.\n\n### Motivation\n\nThis tool is designed to help automate the creation of **explicit BigQuery views** that act as a strict schema \"contract\" between different layers of a medallion architecture. Think of these views as the **Public API** for your data: they provide a stable, documented interface that shields downstream consumers from the complexities and changes of the underlying raw data.\n\nBy generating an explicit `SELECT` statement that recursively expands `RECORD` and `REPEATED RECORD` types, it ensures that your views:\n- **Prevent Schema Drift**: New fields added to the underlying source table will not be exposed in the view until you explicitly update the schema and regenerate it (avoiding the pitfalls of `SELECT *`).\n- **Maintain Structure**: Uses `STRUCT(...)` and `ARRAY(SELECT AS STRUCT ...)` to fully specify the output record structure and maintain array order using `WITH OFFSET`.\n- **Enforce Naming Standards**: Optionally aliases camelCase fields to snake_case (using the `--use_snake_case` flag) to maintain a consistent naming convention across your data products.\n- **Automate Redundancy**: Avoids the error-prone and tedious process of manually rewriting complex nested SQL for dozens or hundreds of fields.\n\n### Prerequisites\n\n- `jq` installed on your system.\n- `bash` shell.\n- `bq` (Google Cloud SDK) for direct table schema fetching.\n\n### Installation\n\n#### Option 1: One-liner installer (Recommended)\n```shell script\ncurl -fsSL https://raw.githubusercontent.com/fpopic/bigquery-schema-select/master/install.sh | bash\n```\n\n#### Option 2: Homebrew\n```shell script\nbrew tap fpopic/bigquery-schema-select https://github.com/fpopic/bigquery-schema-select\nbrew install bigquery-schema-select\n```\n\n### Usage\n\nUsing existing table: \n\n```shell script\nbq show --schema --format=prettyjson my_project:my_dataset.my_table | ./bin/bigquery-schema-select\n```\n\nUsing JSON schema file:\n\n```shell script\ncat my_schema.json | ./bin/bigquery-schema-select\n```\n\n#### Example\n\nInput `my_schema.json`:\n```json\n[\n  {\n    \"name\": \"A\",\n    \"type\": \"TIMESTAMP\"\n  },\n  {\n    \"name\": \"B\",\n    \"type\": \"TIMESTAMP\"\n  },\n  {\n    \"name\": \"C\",\n    \"type\": \"RECORD\",\n    \"fields\": [\n      {\n        \"name\": \"D\",\n        \"type\": \"RECORD\",\n        \"fields\": [\n          {\n            \"name\": \"E\",\n            \"type\": \"TIMESTAMP\"\n          },\n          {\n            \"name\": \"F\",\n            \"type\": \"RECORD\",\n            \"mode\": \"REPEATED\",\n            \"fields\": [\n              {\n                \"name\": \"G\",\n                \"type\": \"STRING\"\n              }\n            ]\n          }\n        ]\n      },\n      {\n        \"name\": \"H\",\n        \"type\": \"TIMESTAMP\"\n      }\n    ]\n  },\n  {\n    \"name\": \"I\",\n    \"type\": \"RECORD\",\n    \"fields\": [\n      {\n        \"name\": \"J\",\n        \"type\": \"TIMESTAMP\"\n      },\n      {\n        \"name\": \"K\",\n        \"type\": \"TIMESTAMP\"\n      }\n    ]\n  },\n  {\n    \"name\": \"L\",\n    \"type\": \"RECORD\",\n    \"mode\": \"REPEATED\",\n    \"fields\": [\n      {\n        \"name\": \"M\",\n        \"type\": \"TIMESTAMP\"\n      },\n      {\n        \"name\": \"N\",\n        \"type\": \"TIMESTAMP\"\n      },\n      {\n        \"name\": \"O\",\n        \"type\": \"RECORD\",\n        \"fields\": [\n          {\n            \"name\": \"P\",\n            \"type\": \"TIMESTAMP\"\n          }\n        ]\n      }\n    ]\n  },\n  {\n    \"name\": \"Q\",\n    \"type\": \"TIMESTAMP\",\n    \"mode\": \"REPEATED\"\n  },\n  {\n    \"name\": \"date\",\n    \"type\": \"DATE\"\n  }\n]\n```\n\nGenerates:\n```sql\nSELECT\n  A,\n  B,\n  STRUCT(\n    STRUCT(\n      C.D.E,\n      ARRAY(\n        SELECT AS STRUCT\n          F.G\n        FROM\n          UNNEST(C.D.F) AS F\n        WITH\n          OFFSET\n        ORDER BY\n          OFFSET\n      ) AS F\n    ) AS D,\n    C.H\n  ) AS C,\n  STRUCT(\n    I.J,\n    I.K\n  ) AS I,\n  ARRAY(\n    SELECT AS STRUCT\n      L.M,\n      L.N,\n      STRUCT(\n        L.O.P\n      ) AS O\n    FROM\n      UNNEST(L) AS L\n    WITH\n      OFFSET\n    ORDER BY\n      OFFSET\n  ) AS L,\n  Q,\n  `date`\n```\n\nIn case you would like to use snake_case for field names use flag `--use_snake_case`:\n```shell script\ncat my_schema.json | ./bin/bigquery-schema-select --use_snake_case\n```\n\n### Development\n\nRun tests:\n```shell script\n./run-tests.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpopic%2Fbigquery-schema-select","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffpopic%2Fbigquery-schema-select","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpopic%2Fbigquery-schema-select/lists"}