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

Load data using dbt seed from .tpl file present in repository #3519

Closed
1 task
jyotisingh-deloitte opened this issue Jun 30, 2021 · 3 comments
Closed
1 task
Labels
bug Something isn't working wontfix Not a bug or out of scope for dbt-core

Comments

@jyotisingh-deloitte
Copy link

Describe the bug

I have different types of files in my repo - .csv and .tpl and I want to run dbt seed command to load the data in snowflake.
When I run the command, it applies all the .csv files and ignores .tpl files.
How can I use dbt seed for other format data files?

Steps To Reproduce

In data folder, add few files with .csv format and some for .tpl
Run dbt seed command, it will apply csv files and igonors the tpl files

Expected behavior

I am looking to load data from different types of files instead of just from .csv

System information

Which database are you using dbt with?

  • snowflake

The output of dbt --version:

dbt=0.20.0-b1
@jyotisingh-deloitte jyotisingh-deloitte added bug Something isn't working triage labels Jun 30, 2021
@jtcohen6
Copy link
Contributor

jtcohen6 commented Jul 2, 2021

@JyotiSingh7 Thanks for opening, you're in good company (#2365).

I'm not familiar with .tpl-formatted data. (From what I see online, it's a way of storing template information, for web development?) Could you provide an example seed file you're looking to upload to the database? Or, better yet, a little more context for the specific use case you're after?

@jtcohen6 jtcohen6 removed the triage label Jul 2, 2021
@jyotisingh-deloitte
Copy link
Author

Hi @jtcohen6
Thanks for your response.
To give more context, I have a data folder which contains .csv & .tpl files. Eg:

  • File1.csv
  • File2.csv
  • File3.csv.tpl

File3.csv.tpl file looks like this:

CONFIG_KEY,CONFIG_VALUE,STATUS,DESCRIPTION
HostIP,{{ HOST_NAME }},Y,This is the APP VM Host Name/IP address.
SSHKeyFilePath,{{ SSH_KEY_PATH }},Y,This is the path on APP VM to the SSH key file for Login User

I want to replace the variables in my files during runtime and then seed all these files into my snowflake database. What is the best way to handle this use-case?

@jtcohen6 jtcohen6 added the wontfix Not a bug or out of scope for dbt-core label Jul 10, 2021
@jtcohen6
Copy link
Contributor

@JyotiSingh7 Got it! Seeds are intended for static data only; they can't take advantage of Jinja templating, as other dbt resources can.

I'd recommend you change File3.csv.tpl to be a model instead, and accomplish the runtime templating via dbt-Jinja functions var or env_var:

-- models/File3.sql

select
    'HostIP' as CONFIG_KEY,
    '{{ env_var('HOST_NAME') }}' as CONFIG_VALUE,
    'Y' as STATUS,
    'This is the APP VM Host Name/IP address' as DESCRIPTION

union all

select
    'SSHKeyFilePath' as CONFIG_KEY,
    '{{ env_var('SSH_KEY_PATH') }}' as CONFIG_VALUE,
    'Y' as STATUS,
    'This is the path on APP VM to the SSH key file for Login User' as DESCRIPTION

You could get fancier by including the static data in a seed, the dynamic inputs in a model, and joining on a common key.

In the meantime, I'm going to close this issue, since we don't plan to make seed files dynamic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix Not a bug or out of scope for dbt-core
Projects
None yet
Development

No branches or pull requests

2 participants