Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

Extract elements from Dataiku variable in SQL query

cclee93
Level 2
Extract elements from Dataiku variable in SQL query

Hello,

I declare a variable List_x in Dataiku project as a tuple of 3 elements A, B and C.

{
  "List_x" : "('A', 'B', 'C')"
}

With SQL query, how could I extract each element of this variable ?

The goal is to use "List_x" in a Case when syntax, like this:

SELECT *,
   CASE WHEN X = List_x(0) THEN 1
        WHEN X = List_x(1) THEN 2
        WHEN X = List_x(2) THEN 3
   END AS Y
FROM TABLE

  

Thank you in advance for your helps

0 Kudos
1 Reply
Turribeach

I don't believe this is possible with a SQL recipe as I think they will only accept simple variables. Depending on where you want to use this SQL it may be possible to handle the variables with the DSS array formula. Otherwise you will need to use a Python SQLExecutor2 recipe

0 Kudos