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-2373][Bug] dbt show doesn't work for seeds #7273

Closed
aranke opened this issue Apr 4, 2023 · 5 comments · Fixed by #7544
Closed

[CT-2373][Bug] dbt show doesn't work for seeds #7273

aranke opened this issue Apr 4, 2023 · 5 comments · Fixed by #7544
Assignees
Labels
bug Something isn't working

Comments

@aranke
Copy link
Member

aranke commented Apr 4, 2023

dbt show --select +orders 
19:52:09  Running with dbt=1.5.0-b5
19:52:10  Found 5 models, 20 tests, 0 snapshots, 0 analyses, 309 macros, 0 operations, 3 seed files, 0 sources, 0 exposures, 0 metrics, 0 groups
19:52:10  
19:52:10  Concurrency: 3 threads (target='dev')
19:52:10  
Error: Traceback (most recent call last):
  File "/Users/chenyuli/git/dbt-core/core/dbt/cli/requires.py", line 100, in wrapper
    result, success = func(*args, **kwargs)
  File "/Users/chenyuli/git/dbt-core/core/dbt/cli/main.py", line 345, in show
    results = task.run()
  File "/Users/chenyuli/git/dbt-core/core/dbt/task/runnable.py", line 438, in run
    result = self.execute_with_hooks(selected_uids)
  File "/Users/chenyuli/git/dbt-core/core/dbt/task/runnable.py", line 401, in execute_with_hooks
    res = self.execute_nodes()
  File "/Users/chenyuli/git/dbt-core/core/dbt/task/runnable.py", line 350, in execute_nodes
    self.run_queue(pool)
  File "/Users/chenyuli/git/dbt-core/core/dbt/task/runnable.py", line 259, in run_queue
    self._raise_set_error()
  File "/Users/chenyuli/git/dbt-core/core/dbt/task/runnable.py", line 240, in _raise_set_error
    raise self._raise_next_tick
dbt.exceptions.DbtRuntimeError: Runtime Error
  Database Error in seed raw_payments (seeds/raw_payments.csv)
    can't execute an empty query

Originally posted by @ChenyuLInx in #7208 (review)

@github-actions github-actions bot changed the title dbt show doesn't work for seeds [CT-2373] dbt show doesn't work for seeds Apr 4, 2023
@aranke aranke changed the title [CT-2373] dbt show doesn't work for seeds [CT-2373][Bug] dbt show doesn't work for seeds Apr 4, 2023
@aranke aranke added bug Something isn't working Team:Execution labels Apr 4, 2023
@dbeatty10
Copy link
Contributor

I was about to open a bug report for this, but then I found this one.

@dbeatty10
Copy link
Contributor

dbeatty10 commented Apr 19, 2023

To be clear, the gnarly stack trace is already addressed and it displays much more nicely now (albeit still confusing if the error is intended or not):

$ dbt show -s my_seed

19:13:33  Running with dbt=1.5.0-rc1
19:13:33  Found 4 models, 0 tests, 1 snapshot, 1 analysis, 307 macros, 0 operations, 4 seed files, 3 sources, 0 exposures, 0 metrics, 0 groups
19:13:33  
19:13:33  Concurrency: 5 threads (target='postgres')
19:13:33  
19:13:33  Encountered an error:
Runtime Error
  Database Error in seed my_seed (seeds/my_seed.csv)
    can't execute an empty query

Possible improvements

For a better user experience, we could do one of two things:

  1. Display a message indicating that showing seeds is not supported
  2. Support showing seeds

@dbeatty10
Copy link
Contributor

Workarounds in the meantime

Option 1: dbt seed --show

$ dbt seed --show -s my_seed

19:21:37  Running with dbt=1.5.0-rc1
19:21:38  Found 4 models, 0 tests, 1 snapshot, 1 analysis, 307 macros, 0 operations, 4 seed files, 3 sources, 0 exposures, 0 metrics, 0 groups
19:21:38  
19:21:38  Concurrency: 5 threads (target='postgres')
19:21:38  
19:21:38  1 of 1 START seed file dbt_dbeatty.my_seed ..................................... [RUN]
19:21:38  1 of 1 OK loaded seed file dbt_dbeatty.my_seed ................................. [INSERT 4 in 0.10s]
19:21:38  
19:21:38  Finished running 1 seed in 0 hours 0 minutes and 0.33 seconds (0.33s).
19:21:38  
19:21:38  Random sample of table: dbt_dbeatty.my_seed
19:21:38  -------------------------------------------
| id | fruit  |
| -- | ------ |
|  1 | apple  |
|  2 | orange |
19:21:38  
19:21:38  
19:21:38  Completed successfully
19:21:38  
19:21:38  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1

Option 2: dbt show --inline

Assuming that dbt seed has already been run, then we can use the --inline option to ref the seed:

$ dbt show --inline 'select * from {{ ref("my_seed") }}'

19:17:49  Running with dbt=1.5.0-rc1
19:17:49  Found 4 models, 0 tests, 1 snapshot, 1 analysis, 307 macros, 0 operations, 4 seed files, 3 sources, 0 exposures, 0 metrics, 0 groups
19:17:49  
19:17:50  Concurrency: 5 threads (target='postgres')
19:17:50  
19:17:50  Previewing inline node:
| id | fruit  |
| -- | ------ |
|  1 | apple  |
|  2 | orange |

If dbt seed hasn't already been run, then you'll get an error like this:

Runtime Error
  Database Error in sql operation inline_query (from remote system.sql)
    relation "dbt_dbeatty.my_seed" does not exist
    LINE 2: select * from "postgres"."dbt_dbeatty"."my_seed"

@jtcohen6
Copy link
Contributor

The question is: Do we think there's actual merit in showing a Markdown table preview of a CSV file that's also available locally? (i.e. the little-known, little-used behavior of dbt seed --show)

If we were to support another command or configuration for this (#7391), that would also accomplish what Doug outlined as the second option (= preview the table already built from this seed).

@dbeatty10
Copy link
Contributor

The merit comes in me being able to use my dbt show hammer 🔨 without giving any thought to the resource type(s) I am selecting.

Example use-cases:

  • I want to take a peek at the datasets in a data flow through a series of steps.
  • I'm collaborating with someone in GitHub, and I want to describe a series of transformations.

image

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

Successfully merging a pull request may close this issue.

3 participants