Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: require-dbt-versions no longer serialized as a list of characters #151

Conversation

nicholasyager
Copy link
Collaborator

Description and motivations

The internal Project representation of the require-dbt-versions field within dbt-core is a list of strings, where each part of the version is an element in the list. When serialized in write_project_file, the resulting YAML is also a list of strings. This PR adds some formatting to the write_project_file function to join the elements of the list into one complete string.

Resolves: #138

Example

Input

# Name your project! Project names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: "split_proj"
version: "1.0.0"
config-version: 2

# This setting configures which "profile" dbt uses for this project.
profile: "split_proj"

# These configurations specify where dbt should look for different types of files.
# The `model-paths` config, for example, states that models in this project can be
# found in the "models/" directory. You probably won't need to change these!
model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds", "jaffle_data"]
# seed-paths: ["jaffle_data"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]

require-dbt-version: ">=1.6.0"

clean-targets: # directories to be removed by `dbt clean`
  - "target"
  - "dbt_packages"

vars:
  truncate_timespan_to: "{{ current_timestamp() }}"

# Configuring models
# Full documentation: https://docs.getdbt.com/docs/configuring-models

# In this example config, we tell dbt to build all models in the example/
# directory as views. These settings can be overridden in the individual model
# files using the `{{ config(...) }}` macro.
models:
  split_proj:
    # Config indicated by + and applies to all files under models/example/
    +on_schema_change: append_new_columns
    example:
      +materialized: view

seeds:
  +schema: jaffle_raw
# the below config for seeds is only relevant when seeding the project for the fist time with the raw jaffle data
# pont the seed path to the jaffle data directory and make sure this is uncommented

# seeds:
#   split_proj:
#     +schema: jaffle_raw

Command

dbt-meshify --debug split orders --select +stg_orders+           

Output

name: orders
config-version: 2
model-paths:
  - models
macro-paths:
  - macros
seed-paths:
  - seeds
  - jaffle_data
test-paths:
  - tests
analysis-paths:
  - analyses
snapshot-paths:
  - snapshots
clean-targets:
  - target
  - dbt_packages
profile: split_proj
require-dbt-version: '>=1.6.0'
models:
  orders:
    +on_schema_change: append_new_columns
    example:
      +materialized: view
seeds:
  +schema: jaffle_raw
vars:
  truncate_timespan_to: '{{ current_timestamp() }}'

@nicholasyager nicholasyager added the bug Something isn't working label Aug 25, 2023
@nicholasyager nicholasyager self-assigned this Aug 25, 2023
@dave-connors-3
Copy link
Collaborator

This looks good! I think we'd also want to test out the case when someone has a range of dbt versions in their project:

require-dbt-version: [">=1.6.0", "<1.7.0"]

I wonder if we'd accidentally end up with a big long string with this approach!

@nicholasyager
Copy link
Collaborator Author

This looks good! I think we'd also want to test out the case when someone has a range of dbt versions in their project:

require-dbt-version: [">=1.6.0", "<1.7.0"]

I wonder if we'd accidentally end up with a big long string with this approach!

Ha! that'd definitely break. Pulling this back.

@nicholasyager nicholasyager marked this pull request as draft August 25, 2023 14:27
@nicholasyager nicholasyager marked this pull request as ready for review August 26, 2023 22:10
@nicholasyager
Copy link
Collaborator Author

Alrighty, this has been update to support both singular version strings and lists of versions.

Copy link
Collaborator

@dave-connors-3 dave-connors-3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦞

@dave-connors-3 dave-connors-3 merged commit 283d64e into dbt-labs:main Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

require-dbt-version improperly handled on a split
2 participants