Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi
I am a but confused by defininf project variables in DataIku. When I read them back, they are all being typed as string? I understand that I should put all values in quotes when defining the variables, but would have thought there was some type of dynamic typing?
Or do I have to manually do python type conversions on all my variables after reading them in as strings, using get_custom_variables()?
Hi,
Variables are defined a JSON. Reading project variables will return a dictionary in python for example get_custom_variables().
When you read a specific variable only it would be returned as a string, regardless of this int or boolean in the JSON. So you will have to manually define its type as python does not infer types by default.
The example below today_year was defined as int 2022, if I want to use at int I can simply use int()
In DSS formulas, you can use either use the variables ${var_name} orf parseJSON(variables["var_name]).
https://doc.dataiku.com/dss/latest/formula/index.html#dss-variables
in the DSS formula there is some auto-typing as explained here :
https://doc.dataiku.com/dss/latest/formula/index.html#variables-typing-and-autotyping
For more information on variables please see :
https://knowledge.dataiku.com/latest/courses/o16n/variables/variables101/variables101-summary.html
Hi,
Variables are defined a JSON. Reading project variables will return a dictionary in python for example get_custom_variables().
When you read a specific variable only it would be returned as a string, regardless of this int or boolean in the JSON. So you will have to manually define its type as python does not infer types by default.
The example below today_year was defined as int 2022, if I want to use at int I can simply use int()
In DSS formulas, you can use either use the variables ${var_name} orf parseJSON(variables["var_name]).
https://doc.dataiku.com/dss/latest/formula/index.html#dss-variables
in the DSS formula there is some auto-typing as explained here :
https://doc.dataiku.com/dss/latest/formula/index.html#variables-typing-and-autotyping
For more information on variables please see :
https://knowledge.dataiku.com/latest/courses/o16n/variables/variables101/variables101-summary.html