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

[Regression] show command should more gracefully handle/fail queries that fail to execute #9946

Closed
dataders opened this issue Apr 15, 2024 · 4 comments
Labels
awaiting_response bug Something isn't working regression stale Issues that have gone stale

Comments

@dataders
Copy link
Contributor

dataders commented Apr 15, 2024

Describe the feature

I'm noticing that #8166 is happening again on dbt-core==1.7.11 with multiple adapters.

If as user calls dbt show on a model or inline-query that the underlying data platform does not like, dbt should quit and return the database error. Instead, show continues, which results in an stack trace resulting from dbt trying to call Agate.Table.print_table() on a None.

The undesirable behavior is consistent across both the --inline and -s some_model usage patterns.

Reproducible Example

input

# notice `SLECT`'s missing `E` 
 dbt show --inline "SLECT 1 as my_col" 

output

14:25:25  Running with dbt=1.7.11
14:25:26  Registered adapter: snowflake=1.7.3
14:25:26  Unable to do partial parsing because config vars, config profile, or config target have changed
14:25:26  Unable to do partial parsing because a project dependency has been added
14:25:27  Found 6 models, 3 seeds, 20 tests, 0 sources, 0 exposures, 0 metrics, 430 macros, 0 groups, 0 semantic models
14:25:27  
14:25:28  Concurrency: 10 threads (target='snowflake')
14:25:28  
14:25:29  CANCEL query sql_operation.jaffle_shop.inline_query ............................ [CANCEL]
14:25:29  
14:25:29    Database Error in sql_operation inline_query (from remote system.sql)
  001003 (42000): SQL compilation error:
  syntax error line 3 at position 8 unexpected 'SLECT'.
14:25:29  Encountered an error:
'NoneType' object has no attribute 'print_table'
14:25:29  Traceback (most recent call last):
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/cli/requires.py", line 91, in wrapper
    result, success = func(*args, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/cli/requires.py", line 76, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/cli/requires.py", line 169, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/cli/requires.py", line 198, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/cli/requires.py", line 245, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/cli/requires.py", line 278, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/cli/main.py", line 418, in show
    results = task.run()
              ^^^^^^^^^^
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/task/runnable.py", line 521, in run
    self.task_end_messages(result.results)
  File "/Users/dataders/miniforge3/envs/dbt/lib/python3.11/site-packages/dbt/task/show.py", line 93, in task_end_messages
    table.print_table(output=output, max_rows=None)
    ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'print_table'

Describe alternatives you've considered

Perhaps there's a try-catch that if there's a database error and no ResultSet is returned, then dbt show can return/print an empty Agate table? or even a table with the database error in it?

Who will this benefit?

All users of dbt show as well as users of downstream tools that make use of the same.

Are you interested in contributing this feature?

No response

Anything else?

No response

@dataders dataders added enhancement New feature or request triage regression and removed enhancement New feature or request labels Apr 15, 2024
@dataders dataders changed the title [Feature] show command should more gracefully handle/fail queris that fail to execute [Regression] show command should more gracefully handle/fail queris that fail to execute Apr 15, 2024
@dbeatty10 dbeatty10 added the bug Something isn't working label Aug 2, 2024
@dbeatty10 dbeatty10 changed the title [Regression] show command should more gracefully handle/fail queris that fail to execute [Regression] show command should more gracefully handle/fail queries that fail to execute Aug 2, 2024
@dbeatty10
Copy link
Contributor

@dataders are you still seeing this issue in dbt 1.7 or 1.8?

I wasn't able to reproduce this with Python 3.10.10 and the same versions of dbt-core and dbt-snowflake as you -- here's what I got instead:

(dbt_1.7) $ dbt show --inline "SLECT 1 as my_col"
23:20:10  Running with dbt=1.7.11
23:20:12  Registered adapter: snowflake=1.7.3
23:20:12  Found 1 model, 1 seed, 0 sources, 0 exposures, 0 metrics, 430 macros, 0 groups, 0 semantic models
23:20:12  
23:20:13  Concurrency: 10 threads (target='snowflake')
23:20:13  
23:20:14  Encountered an error:
Runtime Error
  Database Error in sql_operation inline_query (from remote system.sql)
    001003 (42000): SQL compilation error:
    syntax error line 3 at position 8 unexpected 'SLECT'.
(dbt_1.7) $ 

Copy link
Contributor

github-actions bot commented Nov 2, 2024

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues that have gone stale label Nov 2, 2024
Copy link
Contributor

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2024
Copy link
Contributor

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting_response bug Something isn't working regression stale Issues that have gone stale
Projects
None yet
Development

No branches or pull requests

2 participants