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

Compiled dbt Preview button not working #1226

Open
mdesmet opened this issue Jun 18, 2024 Discussed in #1225 · 10 comments
Open

Compiled dbt Preview button not working #1226

mdesmet opened this issue Jun 18, 2024 Discussed in #1225 · 10 comments
Assignees

Comments

@mdesmet
Copy link
Contributor

mdesmet commented Jun 18, 2024

Discussed in #1225

Originally posted by letuio June 18, 2024
Hi everyone,

I was looking for some help, since this option was working fine for me until yesterday afternoon. It was fine in the morning and for the life of me I can't figure out why it stopped in the middle of the day, as far as I know there shouldn't have been any changes.

The problem is the following, the button to see the compiled dbt preview stopped working and it is giving me the following issue, no matter the model that I am using. For example:
image

It always seems to be the same problem, no matter the model. I am not sure what changed, but I've been using it for quite a while with no issues. I am able to run models and compile models using the right click menu or through the CLI, I can see the compiled code on the target folder. But this specific button is not working.

Seems to indicate that it expects a 'NodeInfo' object to have the 'keys' attribute, but I don't know anything about that.

Any help would be appreciated, as I like this feature a lot and I use it constantly. Only work-around I've seen is to compile the code manually and then use the command to "open dbt target folder compiled" but that is hardly as convenient.

Thanks in advance.

@EFox2413
Copy link

+1

Getting the same issue when trying to preview compiled SQL via ctrl+enter. Running dbt models and building works as expected, but executing SQL previews gives the no keys attribute error on the NodeInfo object.

Downgrading to v0.39.20 fixes the issue as the previous version doesn't have this problem.
FYI @mdesmet

@davidwitk
Copy link

+1

We face a similar issue on >=0.40.

Running with dbt=1.8.2
dbt version: 1.8.2
python version: 3.8.18

Additional info: We use it (sometimes) in combination with the upstream_prod package, which overrides the ref macro https://github.com/LewisDavies/upstream-prod

Exception: Compilation Error in sql_operation t_04688e1e7d094694bd6db7270f80272d (from remote system.sql)
  'dict object' has no attribute 'nodes'
  
  > in macro find_model_node (macros/upstream_prod/find_model_node.sql)
  > called by macro default__ref (../utils/macros/global/ref.sql)
  > called by macro ref (../utils/macros/global/ref.sql)
  > called by sql_operation t_04688e1e7d094694bd6db7270f80272d (from remote system.sql)

Downgrading to v0.39.20 fixes the issue.

@anandgupta42
Copy link
Contributor

anandgupta42 commented Jun 20, 2024

@davidwitk @EFox2413 Can you please upgrade to version 0.40.2 and let us know if the issue has been fixed? Also, we no longer support version < 1.6, so please consider updating your dbt version.

@davidwitk
Copy link

@anandgupta42 I tried 0.40.2 and 0.40.3, but still the same error

@romiof
Copy link

romiof commented Jun 21, 2024

Same issue here !

@anandgupta42 version 0.40.3 fix preview query execution (Ctrl + Enter)... but Compiled dbt Preview (Ctrl + ~) stills broken.

Downgrade to 0.39.20 fixes both.

@mdesmet
Copy link
Contributor Author

mdesmet commented Jun 23, 2024

@davidwitk : Can you provide the full stack trace?

@davidwitk
Copy link

davidwitk commented Jun 25, 2024

@mdesmet Here you go, on 0.40.3:

Traceback (most recent call last):
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 326, in exception_handler
    yield
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 298, in call_macro
    return macro(*args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/runtime.py", line 768, in __call__
    return self._invoke(arguments, autoescape)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/runtime.py", line 782, in _invoke
    rv = self._func(*arguments)
  File "<template>", line 51, in macro
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/sandbox.py", line 327, in getattr
    value = getattr(obj, attribute)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/runtime.py", line 864, in __getattr__
    return self._fail_with_undefined_error()
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/runtime.py", line 857, in _fail_with_undefined_error
    raise self._undefined_exception(self._undefined_message)
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'nodes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/davidwitkowski/.vscode/extensions/innoverio.vscode-dbt-power-user-0.40.3/dist/dbt_core_integration.py", line 713, in _compile_node
    compiled_node = self.sql_compiler.compile(self.dbt)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt/task/sql.py", line 44, in compile
    return self.compiler.compile_node(self.node, manifest, {}, write=False)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt/compilation.py", line 533, in compile_node
    node = self._compile_code(node, manifest, extra_context)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt/compilation.py", line 421, in _compile_code
    node.compiled_code = jinja.get_rendered(
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt/clients/jinja.py", line 146, in get_rendered
    rendered = render_template(template, ctx, node)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 539, in render_template
    return template.render(ctx)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 144, in render
    return self.environment.handle_exception()
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 19, in top-level template code
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/sandbox.py", line 394, in call
    return __context.call(__obj, *args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt/clients/jinja.py", line 84, in __call__
    return self.call_macro(*args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 298, in call_macro
    return macro(*args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/runtime.py", line 782, in _invoke
    rv = self._func(*arguments)
  File "<template>", line 12, in template
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/sandbox.py", line 394, in call
    return __context.call(__obj, *args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt/clients/jinja.py", line 84, in __call__
    return self.call_macro(*args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 298, in call_macro
    return macro(*args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/runtime.py", line 782, in _invoke
    rv = self._func(*arguments)
  File "<template>", line 30, in template
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/sandbox.py", line 394, in call
    return __context.call(__obj, *args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt/clients/jinja.py", line 84, in __call__
    return self.call_macro(*args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 298, in call_macro
    return macro(*args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/runtime.py", line 782, in _invoke
    rv = self._func(*arguments)
  File "<template>", line 2, in template
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/jinja2/sandbox.py", line 394, in call
    return __context.call(__obj, *args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt/clients/jinja.py", line 84, in __call__
    return self.call_macro(*args, **kwargs)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 300, in call_macro
    return e.value
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/davidwitkowski/.pyenv/versions/3.8.18/envs/dbt-bbc/lib/python3.8/site-packages/dbt_common/clients/jinja.py", line 328, in exception_handler
    raise CaughtMacroErrorWithNodeError(exc=e, node=self.macro)
dbt_common.exceptions.macros.CaughtMacroErrorWithNodeError: Compilation Error in sql_operation t_7e835b69b0844abe872beb17ada1bda3 (from remote system.sql)
  'dict object' has no attribute 'nodes'
  
  > in macro find_model_node (macros/upstream_prod/find_model_node.sql)
  > called by macro default__ref (../utils/macros/global/ref.sql)
  > called by macro ref (../utils/macros/global/ref.sql)
  > called by sql_operation t_7e835b69b0844abe872beb17ada1bda3 (from remote system.sql)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/davidwitkowski/.vscode/extensions/innoverio.vscode-dbt-power-user-0.40.3/dist/dbt_core_integration.py", line 693, in _compile_sql
    node = self._compile_node(server_node)
  File "/Users/davidwitkowski/.vscode/extensions/innoverio.vscode-dbt-power-user-0.40.3/dist/dbt_core_integration.py", line 720, in _compile_node
    raise Exception(str(e))
Exception: Compilation Error in sql_operation t_7e835b69b0844abe872beb17ada1bda3 (from remote system.sql)
  'dict object' has no attribute 'nodes'
  
  > in macro find_model_node (macros/upstream_prod/find_model_node.sql)
  > called by macro default__ref (../utils/macros/global/ref.sql)
  > called by macro ref (../utils/macros/global/ref.sql)
  > called by sql_operation t_7e835b69b0844abe872beb17ada1bda3 (from remote system.sql)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/davidwitkowski/.vscode/extensions/innoverio.vscode-dbt-power-user-0.40.3/dist/dbt_core_integration.py", line 675, in compile_sql
    return self._compile_sql(raw_sql, original_node)
  File "/Users/davidwitkowski/.vscode/extensions/innoverio.vscode-dbt-power-user-0.40.3/dist/dbt_core_integration.py", line 697, in _compile_sql
    raise Exception(str(e))
Exception: Compilation Error in sql_operation t_7e835b69b0844abe872beb17ada1bda3 (from remote system.sql)
  'dict object' has no attribute 'nodes'
  
  > in macro find_model_node (macros/upstream_prod/find_model_node.sql)
  > called by macro default__ref (../utils/macros/global/ref.sql)
  > called by macro ref (../utils/macros/global/ref.sql)
  > called by sql_operation t_7e835b69b0844abe872beb17ada1bda3 (from remote system.sql)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/davidwitkowski/.vscode/extensions/innoverio.vscode-dbt-power-user-0.40.3/dist/node_python_bridge.py", line 104, in <module>
    value = eval(_compile(data['code'], '<input>', 'eval'), _locals)
  File "<input>", line 1, in <module>
  File "/Users/davidwitkowski/.vscode/extensions/innoverio.vscode-dbt-power-user-0.40.3/dist/dbt_core_integration.py", line 677, in compile_sql
    raise Exception(str(e))
Exception: Compilation Error in sql_operation t_7e835b69b0844abe872beb17ada1bda3 (from remote system.sql)
  'dict object' has no attribute 'nodes'
  
  > in macro find_model_node (macros/upstream_prod/find_model_node.sql)
  > called by macro default__ref (../utils/macros/global/ref.sql)
  > called by macro ref (../utils/macros/global/ref.sql)
  > called by sql_operation t_7e835b69b0844abe872beb17ada1bda3 (from remote system.sql)

@anandgupta42
Copy link
Contributor

@davidwitk is this still and issue?

@davidwitk
Copy link

@anandgupta42 Yes, still an issue, even when upgrading to v0.43.5. Last working version is v0.39.20

@kyleburke-meq
Copy link

kyleburke-meq commented Aug 20, 2024

I am getting a similar issue on v0.44.3 and dbt version 1.4.5:

Traceback (most recent call last):
  File "/root/.vscode-server/extensions/innoverio.vscode-dbt-power-user-0.44.3/dist/dbt_core_integration.py", line 730, in _compile_sql
    server_node = self.get_server_node(raw_sql, temp_node_id, original_node)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.vscode-server/extensions/innoverio.vscode-dbt-power-user-0.44.3/dist/dbt_core_integration.py", line 639, in get_server_node
    process_node(self.config, self.dbt, sql_node)
  File "/usr/local/lib/python3.11/site-packages/dbt/parser/manifest.py", line 1406, in process_node
    _process_refs_for_node(manifest, config.project_name, node)
  File "/usr/local/lib/python3.11/site-packages/dbt/parser/manifest.py", line 1311, in _process_refs_for_node
    manifest.update_node(node)
  File "/usr/local/lib/python3.11/site-packages/dbt/contracts/graph/manifest.py", line 656, in update_node
    _update_into(self.nodes, new_node)
  File "/usr/local/lib/python3.11/site-packages/dbt/contracts/graph/manifest.py", line 483, in _update_into
    raise dbt.exceptions.DbtRuntimeError(
dbt.exceptions.DbtRuntimeError: Runtime Error
  got an update_sql operation call with an unrecognized sql operation: sql operation...

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.vscode-server/extensions/innoverio.vscode-dbt-power-user-0.44.3/dist/dbt_core_integration.py", line 713, in compile_sql
    return self._compile_sql(raw_sql, original_node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.vscode-server/extensions/innoverio.vscode-dbt-power-user-0.44.3/dist/dbt_core_integration.py", line 735, in _compile_sql
    raise Exception(str(e))
Exception: Runtime Error
  got an update_sql operation call with an unrecognized sql operation: sql operation.meq_dbt...

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.vscode-server/extensions/innoverio.vscode-dbt-power-user-0.44.3/dist/node_python_bridge.py", line 104, in <module>
    value = eval(_compile(data['code'], '<input>', 'eval'), _locals)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<input>", line 1, in <module>
  File "/root/.vscode-server/extensions/innoverio.vscode-dbt-power-user-0.44.3/dist/dbt_core_integration.py", line 715, in compile_sql
    raise Exception(str(e))
Exception: Runtime Error
  got an update_sql operation call with an unrecognized sql operation: sql operation...

The models build and compile fine but the preview will usually throw an error. Sometimes it will work though its just very inconsistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants