← eval operator page · general/eval/comp/inside_calc

Inside calc 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

eval inside calc, after the page's DS_1 [calc Me := eval ( f (Me ) language "Java" returns integer) ]: the routine runs on the Me_1 of each data point.

Manual:

Evaluation of an external routine: eval "returns its result as a Data Set or a scalar", of a type "given in the invocation". The page contradicts itself: "eval cannot be nested as the operand of another operation", its result "must be persistent", "This is not a scalar operation" and its "Result type" is result :: dataset, yet its own example nests it in calc, assigns it with := and gives an integer per data point; the example follows that example, with <-.

Expected:

the error 1-3-2-5, "At op eval: Eval in component execution is not supported, it only applies to Data Sets": by a team decision, eval runs on data sets only, never inside a component expression.

script.vtl ⇩

DS_r <- DS_1[calc Me_2 := eval(SQL_4(Me_1) language "SQL" returns integer)];

input/DS_1.csv ⇩

Id_1Me_1
110
220

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/error.json ⇩

{"code": "1-3-2-5"}

external_routines/SQL_4.json ⇩

{
  "name": "SQL_4",
  "query": "SELECT $1 * 2"
}