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

[Bug] print in jinja do not go through event system #10030

Closed
2 tasks done
ChenyuLInx opened this issue Apr 25, 2024 · 3 comments
Closed
2 tasks done

[Bug] print in jinja do not go through event system #10030

ChenyuLInx opened this issue Apr 25, 2024 · 3 comments

Comments

@ChenyuLInx
Copy link
Contributor

Is this a new bug in dbt-core?

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

Current Behavior

If a user uses the print in the Jinja context, this print will go to stdout directly instead of going through the dbt-core's event system.

This would lead to things printed in jinja do not follow --log-format json config.

Expected Behavior

print in jinja follow dbt-core's flag --log-format

Steps To Reproduce

Run a run operation with a macro that has print inside and use --log-format json at the same time.
You will see dbt-core logs are in json but the things printed in jinja is in plain text.

Relevant log output

No response

Environment

- OS:
- Python:
- dbt:

Which database adapter are you using with dbt?

No response

Additional Context

No response

@ChenyuLInx ChenyuLInx added bug Something isn't working triage Impact: CLI and removed bug Something isn't working labels Apr 25, 2024
@dichenqiandbt
Copy link

dichenqiandbt commented Apr 25, 2024

An example

{% macro test() %}
    {{ print(1234)}}
    {{ return(1233434) }}
{% endmacro %}

When user specify --log-format json, we expect 1234 should be printed in a json format line and maybe logged in dbt.log as well?

The customer uses "generate_source" from codegen dbt package.

@ChenyuLInx
Copy link
Contributor Author

We could use log(info=True) to swap this out.
Things to watch for: can we not add dates in front of the printed line.

@ChenyuLInx
Copy link
Contributor Author

Closing in favor of 8756 since it is the same issue and have a more detailed AC.

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

No branches or pull requests

2 participants