dbt YAML validator in JetBrains

Yu Ishikawa
4 min readFeb 28, 2023

--

dbt and its ecosystem have been growing. We make use of not only the dbt-core but also community tools. For example, dbt labs published a github repository to take advantage of JSON schemas of dbt YAML validator in VisualStudio code. And Wizard for dbt Core (TM) is another VS code extension to accelerate our dbt environment set up.

I would like to describe how to quickly set up dbt YAML validators in JetBrains in the article, because I think there are some PyCharm users to develop their dbt projects like me. The dbt YAML validator in JetBrains shows code complition of dbt YAML. So, we can get more productive to develop our dbt projects.

An example of code suggestion of a dbt property YAML

First, I will briefly describe the feature of JSON schema mapping in JetBrains. Second, I will introduce dbt labs published a VisualStudio code extension using the JSON schemas of dbt YAML. Third, I will show you we can make use of the JSON schemas in JetBrains as well. Lastly, I will describe recommended configurations of JSON schema mappings with the JSON schemas of dbt YAML.

JSON schema mapping in JetBrains

IDEs provided by Jetbrains enable us to validate JSON and YAML files with the JSON schema mapping feature. We are able to use builtin JSON schemas and custom JSON schemas. We can configure target files, file patterns and directories with a JSON schema. For instance, we can validate kustomize YAML with the builtin JSON schema to a directory under kustomize, as the subsequent image shows. The preference exists in ‘Languages & Frameworks’ >> ‘Schemas and DTDs’ >> ‘JSON Schema Mapping’ in PyCharm.

An example of JSON schema mapping with the builtin kustomize JSON schema

Besides, the subsequent article described how to set up a validator of GitHub Actions with the officieal JSON schema. The JSON schema mapping feature would be awesome to be more productive. There’s no reason we don’t make use of it for our dbt projects too.

dbt YAML validator with JSON schemas

dbt labs published a github repository dbt-labs/dbt-jsonschema so that dbt users can validate dbt YAML in VisualStudio code. At the time of writing the article, there are four JSON schemas for project definition files (dbt_project.yml), package files (packages.yml), selectors files (selectors.yml) and property files (models/whatever.yml).

According to the documentation of the github repository, the four schemas have the published URLs respectively. For instance, the subsequent URL is for the JSON schema of dbt YAML files. As I explained above, we can take advantage of the URLs of the JSON schemas to validate dbt YAML in JetBrains as well.

https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/dbt_yml_files.json

Let’s take dbt YAML files, for instance. We can configure a custom JSON schema mapping in PyCharm as the subsequent image shows. By doing so, PyCharm validates dbt YAML and shows code completion of a dbt property YAML.

JSON schema mapping in PyCharm

Recommended configurations

Since dbt labs provides the four JSON schemas, we can configure four JSON schema mappings corresponding to them respectively. All of the JSON schemas must be JSON schema version 7. Moreover, we specify the following URLs of the JSON schemas and mappings.

Project definition files

Package files

Selectors files

Property files

Summary

I explained how to take advantage of the JSON schemas of dbt YAML published by dbt labs in JetBrains. The JSON schemas enables us to validate and suggest code on JetBrains as well. We can set up them in an instant, as I have described above. Unfortunately, it doesn’t show code suggestion of YAML valus like a dbt model name and column names. But, I hope it would be useful for many dbt users who use JetBrains.

Last but not least, thank dbt labs very much for publishing the JSON schemas. JetBrains users can take advantage of them so that we accelerate to develop our dbt projects.

--

--

Yu Ishikawa
Yu Ishikawa

Written by Yu Ishikawa

Data Engineering / Machine Learning / MLOps / Data Governance / Privacy Engineering

No responses yet