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: changed log output of dbt-core v1.0.0 causes log parsing to fail. #13

Closed
ciklista opened this issue Dec 8, 2021 · 1 comment · Fixed by #14
Closed

Bug: changed log output of dbt-core v1.0.0 causes log parsing to fail. #13

ciklista opened this issue Dec 8, 2021 · 1 comment · Fixed by #14

Comments

@ciklista
Copy link
Contributor

ciklista commented Dec 8, 2021

Problem:
The v1.0.0 release introduced structured logging across all of dbt logs (also those printed to stdout) (release notes). See also dbt-labs/dbt-core#3359 (comment) and dbt-labs/dbt-core#4055.

Unfortunately (or thankfully), this means that logs for dbt run-operation now look like

dbt run-operation --project-dir /pat/to/dir/ --args '{"sql": "SELECT 1 AS __dbt_invoke_check_macro__log_columns_list LIMIT 0"}'

08:58:14  Running with dbt=1.0.0
08:58:15  ['__dbt_invoke_check_macro__log_columns_list']

instead of

dbt run-operation --project-dir /pat/to/dir/ --args '{"sql": "SELECT 1 AS __dbt_invoke_check_macro__log_columns_list LIMIT 0"}'

Running with dbt=0.21.0
['__dbt_invoke_check_macro__log_columns_list']

In the case that I am currently looking at (generating the column names), logs are parsed based on line start and ends

result_list_strings = [
s for s in result_lines if s.startswith('[') and s.endswith(']')
]

Possible solution
One possibility might be to switch to json logs to facilitate log parsing (using the global cli flag log-format, e.g. dbt --log-format=json run-operation)

dbt --log-format=json run-operation --project-dir /pat/to/dir/ _log_columns_list --args '{"sql": "SELECT 1 AS __dbt_invoke
_check_macro__log_columns_list LIMIT 0"}'

{"timestamp": "2021-12-08T09:13:56.977677Z", "message": "Running with dbt=0.21.0", "channel": "dbt", "level": 11, "levelname": "INFO", "thread_name": "MainThread", "process": 2960718, "extra": {"run_state": "internal"}}
{"timestamp": "2021-12-08T09:13:59.541933Z", "message": "['__dbt_invoke_check_macro__log_columns_list']", "channel": "dbt", "level": 11, "levelname": "INFO", "thread_name": "MainThread", "process": 2960718, "extra": {"run_state": "internal"}}

This is just a first investigation of the issue (or potential breaking changes of V1.0.0) and I will continue to look into it as I would really enjoy keeping dbt-invoke for subsequent dbt releases

@ciklista ciklista mentioned this issue Dec 8, 2021
robastel added a commit that referenced this issue Dec 15, 2021
* fix for dbt v1.0.0

* updating workflow

* allow multiple lines in log result

Co-authored-by: robastel <rob.astel@gmail.com>

* bump versions

* hardcoding json log format

* missing and

* linter reformats

* Run workflow on pull request synchronize

* fixing python version for test in workflow

* Exclude Python 3.9 dbt 0.18.x test combo

* Update README.md

Co-authored-by: robastel <rob.astel@gmail.com>
Co-authored-by: Jan Nitschke <jan.nitschke.ext@statista.com>
@robastel
Copy link
Member

Closed by merge of PR #14. Thank you, @ciklista, for the solution!

@robastel robastel linked a pull request Jan 1, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants