Use a list as variable in SQL Query

Sv3n-Sk4
Level 3
Use a list as variable in SQL Query

Hello everyone, 

I need your help in using a list as project variable in a SQL query.

I have a dataset with a list on numbers, with a custom python recipe, I stored the numbers as list in my variable project. It's looking like this :

{
"liste": [
12265378,
9122915,
12292085,
12514810001,
12241211,
12262172,
4624440]

}

I now would like to use this list in my SQL recipe in my where condition as :

SELECT *

FROM TABLE

WHERE NUMBERS IN ('${liste}')

 

But it seems Dataiku is reading it as a long string.

If anyone could help please (it will help me a lot for this project and a lot of others).

 

Thanks!


Operating system used: Windows

2 Replies
HuiXiangC
Dataiker

You can also create your variable looking like this "liste": "(12265378,
9122915, 12292085, 12514810001, 12241211, 12262172, 4624440)". Instead of using the square brackets, use the curve brackets, so they appear as a string and your sql query will look like this SELECT *FROM "TABLE" WHERE "NUMBERS" IN ${liste}

0 Kudos

Labels

?
Labels (1)

Setup info

?
A banner prompting to get Dataiku