← eval operator page · general/eval/sql_dataset/sql_query_on_dataset
pandas ✅ · DuckDB ✅
eval of a SQL routine on a dataset, with the structure of its result declared in returns.
Evaluation of an external routine: "The eval operator invokes an external, non-VTL routine, and returns its result as a Data Set or a scalar", and "The result of an expression containing eval must be persistent", so the script uses <-.
vtlengine reads the routine as the SQL query of external_routines/SQL_1.json, SELECT Id_1, Me_1 * 2 AS Me_1 FROM DS_1: the declared structure, with Me_1 20 and 40.
DS_r <- eval(SQL_1(DS_1) language "SQL" returns dataset {identifier<integer> Id_1, measure<integer> Me_1});
| Id_1 | Me_1 |
|---|---|
| 1 | 10 |
| 2 | 20 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 1 | 20 |
| 2 | 40 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}
{
"name": "SQL_1",
"query": "SELECT Id_1, Me_1 * 2 AS Me_1 FROM DS_1"
}