dbt-duckdb icon indicating copy to clipboard operation
dbt-duckdb copied to clipboard

PRAGMA

Open Phil-T1 opened this issue 1 year ago • 5 comments

Hi,

This is awesome!

Would it be possible to set pragma globally?

I'd like to tweak some DuckDB settings.

Thanks very much,

PHil.

Phil-T1 avatar Aug 16 '23 15:08 Phil-T1

Ah you mean like beyond what can be done with the built-in “settings” construct?

You can use dbt-duckdb plugins to do any kind of customization of the DuckDB connection that you want before a set of dbt model runs occurs; the motherduck and postgres plugins that ship with the project illustrate how to do it.

jwills avatar Aug 16 '23 17:08 jwills

Docs are here: https://github.com/jwills/dbt-duckdb#configuring-dbt-duckdb-plugins

jwills avatar Aug 16 '23 17:08 jwills

Thanks, I've checked the docs and I'm not sure how I would implement using the instructions there (probably just me!).

I'll elaborate: basically I'm having issues when a type conversion fails. The runtime error (which I presume comes from DuckDB rather than dbt according to the dbt docs) does not specify which column had the type conversion, so debugging relies on querying many columns using trial and error.

I wanted to check DuckDB external logs using:

-- Set a path for query logging PRAGMA log_query_path='/tmp/duckdb_log/';

Again, thanks for this and for responding so quickly. If I'd built my project with just Python and DuckDB, it would've been tonnes more code and a lot less elegant!

Phil.

Phil-T1 avatar Aug 17 '23 20:08 Phil-T1

The log_query_path is a setting, so you can specify it like:

SET log_query_path = '/tmp/duckdb_log/';

...which you can express in a dbt profile config like this:

default:
  outputs:
    dev:
      type: duckdb
      path: /tmp/dbt.duckdb
      settings:
        log_query_path: '/tmp/duckdb_log/'
  target: dev

jwills avatar Aug 17 '23 22:08 jwills

That's great, I didn't realise it was so straightforward!

Thanks again for all your work,

Phil.

Phil-T1 avatar Aug 21 '23 16:08 Phil-T1