dbt-labs / dbt-jsonschema

Apache License 2.0
109 stars 40 forks source link

Add transient option to node configurations #48

Closed dwreeves closed 1 year ago

dwreeves commented 1 year ago

The Snowflake adapter allows for +transient: [boolean] as a configuration option:

See docs here: https://docs.getdbt.com/reference/resource-configs/snowflake-configs

Docs example:

name: my_project

...

models:
  +transient: false
  my_project:
    ...

This pull request adds +transient as a supported attribute in the JSONSchema for node configurations.

I also confirmed that it is a boolean and not a #/$defs/boolean_or_jinja_string, i.e. "{{ True }}" renders as a string literal in the manifest.json, not as true.

dwreeves commented 1 year ago

@joellabes Ah! Learned something new about dbt.

Made the requested change, although it means the description has to go, unless you want to do something like {"allOf": [{"$ref": "#/$defs/string_or_array_of_strings"}], "description": "..."}.

joellabes commented 1 year ago

@dwreeves sorry for the delay getting back to you! I don't think that's right - wouldn't it behave the same as https://github.com/dbt-labs/dbt-jsonschema/blob/main/schemas/dbt_project.json#L343-L347 where you can have a ref and then extend it with extra context?

dwreeves commented 1 year ago

Ah, can you do that? I am not well versed enough at JSONSchema to know if that works. I was basing my assumption off googling for various things and sort of half-following what others were saying.

It seems in the earliest draft of JSONSchema this would not have been supported, and frankly I'm not entirely following the discussions I'm reading on how this has changed over time.

An object schema with a "$ref" property MUST be interpreted as a "$ref" reference. The value of the "$ref" property MUST be a URI Reference. Resolved against the current URI base, it identifies the URI of a schema to use. All other properties in a "$ref" object MUST be ignored.

Still, regardless of whether it works or not to just add the description, I don't know if I want to be the first person to add a description attribute to an object with a $ref property in this JSON.

So, is it OK if we leave the description out? 😬 Or do you want it in still?

joellabes commented 1 year ago

Hmmmm that stack overflow post is pretty definitive! I also don't know a ton about JSON schema - I've picked up the basics from developing this repo but not an expert.

I think that for now let's leave the description out, and I'll do some experimenting some other time