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

reading from encrypted parquet file #419

Open
jb8628 opened this issue Jul 28, 2024 · 5 comments
Open

reading from encrypted parquet file #419

jb8628 opened this issue Jul 28, 2024 · 5 comments

Comments

@jb8628
Copy link

jb8628 commented Jul 28, 2024

DuckDB allows use of encrypted Parquet files.

The key is set via a PRAGMA statement like PRAGMA add_parquet_key('key128', '0123456789112345');

On reading the syntax is read_parquet('file.parquet', encryption_config = {footer_key: 'key128'});

Is it possible to set the parquet key within dbt on using an encrypted parquet file as source, so that it can be accessed as follows?

meta:
external_location: "read_parquet('file.parquet', encryption_config = {footer_key: 'key128'})"
formatter: oldstyle

I have tried config and dbt hooks without success.

@jwills
Copy link
Collaborator

jwills commented Jul 29, 2024

It's not obvious to me why that wouldn't work with an on-run-start hook to set the key via the pragma statement and the external location as you had it configured; how does it fail? And what does the compiled output look like?

@jb8628
Copy link
Author

jb8628 commented Jul 29, 2024

Thanks for your reply! It fails with:

Binder Error: No key with name "key128" exists. Add it with PRAGMA add_parquet_key('<key_name>','');

on running a model using the source.

This is with on-run-start: "PRAGMA add_parquet_key('key128', '0123456789112345');" in dbt_project.yml.

The compiled output of the model looks correct but it does not seem to have access to the key. Am I doing something wrong with the hook?

@jwills
Copy link
Collaborator

jwills commented Jul 29, 2024

Ah-- I bet the key is only cached on the specific connection that uses it-- try it with the keep_open: true setting enabled in your profile?

@jb8628
Copy link
Author

jb8628 commented Jul 29, 2024

Yes, that works. Gives a good option for ingesting more sensitive data. Thank you so much for your help.

@jb8628
Copy link
Author

jb8628 commented Jul 29, 2024

In fact, following your pointer, I now seem to have this working without keep_open: true by specifying +pre-hook: "PRAGMA add_parquet_key('key128', '0123456789112345');" for the model resource.

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

No branches or pull requests

2 participants