https://kedro.org/ logo
#questions
Title
# questions
a

Afiq Johari

02/08/2024, 2:57 PM
Hi, How can I parameterised a SQL data query based on the parameters.yml file? for example in catalog.yml I have
Copy code
my_sql:
 type: pandas.SQLQueryDataset
 sql: "SELECT * FROM [ABC].[date_20180401]"
 credentials: mycred
I want to use the following parameter from parameters.yml
Copy code
ABC:
 latest_date: "20180401"
So the expectation in catalog.yml would be something like
Copy code
my_sql:
 type: pandas.SQLQueryDataset
 sql: "SELECT * FROM [ABC].[date_{params[ABC.latest_date]}]"
 credentials: mycred
K 1
a

Ahdra Merali

02/08/2024, 6:42 PM
I think using globals might be more suited to this particular case instead of parameters
a

Afiq Johari

02/09/2024, 9:51 AM
@Ahdra Merali thanks for the tips! I read about global.yml and I thought that it's also possible to reference the parameters from the parameters.yml file. I'll explore using global.yml
👍 1
2 Views