Extract elements from Dataiku variable in SQL query

cclee93
cclee93 Registered Posts: 4 ✭
edited July 2024 in Using Dataiku

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

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023, Circle Member Posts: 2,726 Neuron

    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.

Setup Info
    Tags
      Help me…