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

[CT-963] [Regression] Docs blocks in metric descriptions #5585

Closed
2 tasks done
jtcohen6 opened this issue Jul 30, 2022 · 0 comments · Fixed by #5603
Closed
2 tasks done

[CT-963] [Regression] Docs blocks in metric descriptions #5585

jtcohen6 opened this issue Jul 30, 2022 · 0 comments · Fixed by #5603
Labels
bug Something isn't working regression
Milestone

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented Jul 30, 2022

Is this a regression in a recent version of dbt-core?

  • I believe this is a regression in dbt-core functionality
  • I have searched the existing issues, and I could not find an existing issue for this regression

Current Behavior

References to docs blocks are unsupported in metric description fields in v1.2

Expected/Previous Behavior

References to docs blocks were supported in v1.0 + v1.1, and should be supported again

Steps To Reproduce

-- models/model_a.sql
select 1 as id
-- models/docs.md
{% docs my_doc_block %}
  Something something
{% enddocs %}
# models/schema.yml

version: 2

models:
  - name: model_a
    # this one works!
    description: "{{ doc('my_doc_block') }}"

metrics:
  - name: some_metric
    label: Some Metric
    model: ref('model_a')
    # this one works in v1.1, raises an error in v1.2
    description: "{{ doc('my_doc_block') }}"

    type: count
    sql: user_id

    timestamp: signup_date
    time_grains: [day, week, month]

    dimensions:
      - plan
      - country

Relevant log output

(env) 13:53:00 ~/dev/scratch/testy $ dbt parse
11:53:05  Running with dbt=1.2.0
11:53:05  Start parsing.
11:53:05  Dependencies loaded
11:53:05  ManifestLoader created
11:53:06  Encountered an error:
Compilation Error
  Could not render {{ doc('my_doc_block') }}: 'doc' is undefined
11:53:06  Traceback (most recent call last):
  File "/Users/jerco/dev/product/dbt-core/core/dbt/clients/jinja.py", line 494, in catch_jinja
    yield
  File "/Users/jerco/dev/product/dbt-core/core/dbt/clients/jinja.py", line 526, in render_template
    return template.render(ctx)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/clients/jinja.py", line 178, in render
    return self.environment.handle_exception()
  File "/Users/jerco/dev/product/dbt-core/env/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/Users/jerco/dev/product/dbt-core/env/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/clients/jinja.py", line 135, in quoted_native_concat
    head = list(islice(nodes, 2))
  File "<template>", line 1, in top-level template code
  File "/Users/jerco/dev/product/dbt-core/env/lib/python3.9/site-packages/jinja2/sandbox.py", line 460, in call
    if not __self.is_safe_callable(__obj):
  File "/Users/jerco/dev/product/dbt-core/env/lib/python3.9/site-packages/jinja2/sandbox.py", line 360, in is_safe_callable
    getattr(obj, "unsafe_callable", False) or getattr(obj, "alters_data", False)
jinja2.exceptions.UndefinedError: 'doc' is undefined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jerco/dev/product/dbt-core/core/dbt/config/renderer.py", line 42, in render_value
    return get_rendered(value, self.context, native=True)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/clients/jinja.py", line 571, in get_rendered
    return render_template(template, ctx, node)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/clients/jinja.py", line 526, in render_template
    return template.render(ctx)
  File "/usr/local/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/clients/jinja.py", line 499, in catch_jinja
    raise UndefinedMacroException(str(e), node) from e
dbt.exceptions.UndefinedMacroException: Compilation Error
  'doc' is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/jerco/dev/product/dbt-core/core/dbt/main.py", line 129, in main
    results, succeeded = handle_and_check(args)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/main.py", line 191, in handle_and_check
    task, res = run_from_args(parsed)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/main.py", line 238, in run_from_args
    results = task.run()
  File "/Users/jerco/dev/product/dbt-core/core/dbt/task/parse.py", line 93, in run
    self.get_full_manifest()
  File "/Users/jerco/dev/product/dbt-core/core/dbt/task/parse.py", line 74, in get_full_manifest
    manifest = loader.load()
  File "/Users/jerco/dev/product/dbt-core/core/dbt/parser/manifest.py", line 366, in load
    self.parse_project(
  File "/Users/jerco/dev/product/dbt-core/core/dbt/parser/manifest.py", line 469, in parse_project
    parser.parse_file(block, dct=dct)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/parser/schemas.py", line 544, in parse_file
    for metric_node in metric_parser.parse():
  File "/Users/jerco/dev/product/dbt-core/core/dbt/parser/schemas.py", line 1061, in parse
    for data in self.get_key_dicts():
  File "/Users/jerco/dev/product/dbt-core/core/dbt/parser/schemas.py", line 637, in get_key_dicts
    entry = self.render_entry(entry)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/parser/schemas.py", line 651, in render_entry
    dct = self.renderer.render_data(dct)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/config/renderer.py", line 49, in render_data
    return deep_map_render(self.render_entry, data)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/utils.py", line 228, in deep_map_render
    return _deep_map_render(func, value, ())
  File "/Users/jerco/dev/product/dbt-core/core/dbt/utils.py", line 194, in _deep_map_render
    ret = {k: _deep_map_render(func, v, (keypath + (str(k),))) for k, v in value.items()}
  File "/Users/jerco/dev/product/dbt-core/core/dbt/utils.py", line 194, in <dictcomp>
    ret = {k: _deep_map_render(func, v, (keypath + (str(k),))) for k, v in value.items()}
  File "/Users/jerco/dev/product/dbt-core/core/dbt/utils.py", line 196, in _deep_map_render
    ret = func(value, keypath)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/config/renderer.py", line 33, in render_entry
    return self.render_value(value, keypath)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/config/renderer.py", line 45, in render_value
    raise CompilationException(msg) from exc
dbt.exceptions.CompilationException: Compilation Error
  Could not render {{ doc('my_doc_block') }}: 'doc' is undefined

(env) 13:53:06 ~/dev/scratch/testy $ dbt parse
11:58:05  Running with dbt=1.1.2
11:58:05  Start parsing.
11:58:05  Dependencies loaded
11:58:05  Unable to do partial parsing because of a dbt version mismatch. Saved manifest version: 1.2.0. Current version: 1.1.2.
11:58:05  ManifestLoader created
11:58:06  Manifest loaded
11:58:06  Manifest checked
11:58:06  Flat graph built
11:58:06  Manifest loaded
11:58:06  Performance info: target/perf_info.json
11:58:06  Done.

Environment

- OS: macOS 12.4 / M1
- Python: 3.9.13
- dbt (working version): 1.1.2
- dbt (regression version): 1.2.0

Which database adapter are you using with dbt?

postgres

Additional Context

No response

@jtcohen6 jtcohen6 added bug Something isn't working regression Team:Language labels Jul 30, 2022
@jtcohen6 jtcohen6 added this to the v1.2.x milestone Jul 30, 2022
@github-actions github-actions bot changed the title [Regression] Docs blocks in metric descriptions [CT-963] [Regression] Docs blocks in metric descriptions Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant