{"id":13703169,"url":"https://github.com/gilcrest/dbt-cue","last_synced_at":"2025-07-31T19:33:10.634Z","repository":{"id":87416018,"uuid":"563983352","full_name":"gilcrest/dbt-cue","owner":"gilcrest","description":"Generate dbt yml files using the CUE language","archived":false,"fork":false,"pushed_at":"2024-02-14T02:52:28.000Z","size":35,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T13:49:54.087Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CUE","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilcrest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-11-09T18:40:56.000Z","updated_at":"2025-01-20T01:33:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef7560c6-7d3c-4d86-a022-32d8bbee97c1","html_url":"https://github.com/gilcrest/dbt-cue","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilcrest%2Fdbt-cue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilcrest%2Fdbt-cue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilcrest%2Fdbt-cue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilcrest%2Fdbt-cue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilcrest","download_url":"https://codeload.github.com/gilcrest/dbt-cue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241976820,"owners_count":20051718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-02T21:00:51.296Z","updated_at":"2025-03-05T06:25:10.489Z","avatar_url":"https://github.com/gilcrest.png","language":"CUE","readme":"# dbt-cue\n\nGenerate dbt yml files using the [CUE language](https://cuelang.org/)\n\n## About\n\nI personally don't love YAML and find it error prone. I use the CUE language to generate and validate all YAML files for just about everything I do at this point (Kubernetes, config, etc.) This repo demonstrates using CUE to generate [dbt](https://docs.getdbt.com/reference/source-properties) YAML files. There are a lot more checks to be added and you can easily clone and add your own validations as well, but this is a start.\n\n## Minimum Requirements\n\n- [CUE cli](https://github.com/cue-lang/cue#download-and-install)\n\n## Getting Started\n\nThe [schema.cue](https://github.com/gilcrest/dbt-cue/blob/main/schema.cue) file defines the [types and values](https://cuetorials.com/overview/types-and-values/) that are used to build the dbt yaml files. For now, I've only worked through building the [Source](https://docs.getdbt.com/reference/source-properties) yaml file. I will add more later. The `schema.cue` file is for shared type and value definitions only and should not be edited.\n\nUser input goes into a `src_` file (though the name doesn't matter), where the various objects are built.\n\n```cue\nsources: #sourceList \u0026 [_jaffleShop]\n\n_jaffleShop: #Source \u0026 {\n  name:        \"jaffle_shop\"\n  description: \"Jaffle Shop is the testing source for dbt\"\n  database:    \"dbt-tutorial\"\n  schema:      \"jaffle_shop\"\n  meta: [{\"contains_pii\": true, \"owner\": \"@alice\"}]\n  tags: [\"ecom\", \"pii\"]\n  quoting: #Quoting \u0026 {\n    database:   false\n    schema:     false\n    identifier: false\n  }\n  tables: [_jaffleOrderTable, _jaffleCustomerTable]\n}\n\n_jaffleOrderTable: #Table \u0026 {\n  name:            \"orders\"\n  identifier:      \"Orders_\"\n  loaded_at_field: \"updated_at\"\n  columns: [\n    #Column \u0026 {\n      name: \"id\"\n      tests: [\"unique\", \"not_null\"]\n    },\n    #Column \u0026 {\n      name: \"status\"\n      tests: [#AcceptedValues \u0026 {\n        accepted_values: {\n          values: [\"placed\", \"shipped\", \"completed\", \"returned\"]\n        }\n      }]\n    },\n    #Column \u0026 {\n      name: \"price_in_usd\"\n      tests: [\"not_null\"]\n    },\n    #Column \u0026 {\n      name: \"customer_id\"\n      tests: [\n        #Relationship \u0026 {\n          relationships: {\n            to:    \"ref('customers')\"\n            field: \"id\"\n          }\n        },\n      ]\n    },\n  ]\n}\n\n_jaffleCustomerTable: #Table \u0026 {\n  name:    \"customers\"\n  quoting: #Quoting \u0026 {\n    identifier: true\n  }\n}\n\n```\n\n\u003e Creating CUE values reads well as it is a superset of JSON. Here we are creating a _jaffleShop value, which is a dbt Source (see `schema.cue`) for the #Source definition. We can add whatever key value pairs we like as meta, any list of strings for tags, etc. For more complex structures like a `table` or `quoting`, we use CUE [definitions](https://cuetorials.com/overview/types-and-values/#definitions), there are examples here of creating them inline as well as separate entities.\n\n## File Generation\n\nThe CUE cli is used to **vet** (validate the data against the schema), **fmt** (format - which nicely standardizes the input files) and finally **export** the data to the named file. CUE works with the concept of packages, so you can merge multiple files together. As noted before, I put my general types and values in the `schema.cue` file and implement those types and values in a separate file (in this case `src_jaffleshop.cue`).\n\n```bash\ncue vet schema.cue src_jaffleshop.cue\ncue fmt schema.cue src_jaffleshop.cue\ncue export schema.cue src_jaffleshop.cue --force --out yaml --outfile _jaffle_shop__sources.yml\n```\n\n\u003e For each command (vet, fmt, export) I am passing the list of files to be used when generating the output. --out is what type of output (yaml, json, etc.) The --outfile is what we want to name our output file.\n\nI provided 2 different sample bash scripts (`run_jaffleshop.sh` and `run_stripe.sh`) that you can use to generate output or, if you prefer, you can input the cli commands yourself.\n\n## Output\n\nThe below output is from CUE, you'll find it basically a match (minus spaces) of the [Source example](https://docs.getdbt.com/reference/source-properties#example). I have added some additional examples beyond the example to demonstrate things like using `accepted_values` tests, etc.\n\n```yml\nversion: 2\nsources:\n  - name: jaffle_shop\n    description: Jaffle Shop is the testing source for dbt\n    database: dbt-tutorial\n    schema: jaffle_shop\n    meta:\n      - contains_pii: true\n        owner: '@alice'\n    tags:\n      - ecom\n      - pii\n    quoting:\n      database: false\n      schema: false\n      identifier: false\n    tables:\n      - name: orders\n        identifier: Orders_\n        loaded_at_field: updated_at\n        columns:\n          - name: id\n            tests:\n              - unique\n              - not_null\n          - name: status\n            tests:\n              - accepted_values:\n                  values:\n                    - placed\n                    - shipped\n                    - completed\n                    - returned\n          - name: price_in_usd\n            tests:\n              - not_null\n          - name: customer_id\n            tests:\n              - relationships:\n                  to: ref('customers')\n                  field: id\n      - name: customers\n        quoting:\n          identifier: true\n```\n","funding_links":[],"categories":["Utilities","others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilcrest%2Fdbt-cue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilcrest%2Fdbt-cue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilcrest%2Fdbt-cue/lists"}