← random operator page · numeric/random/ds/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

random(DS_1, 5) on a dataset: the measure is replaced by draws.

Manual:

Random, Example 1: "The operator returns a random decimal number >= 0 and <1." The page prints 0.3582791, 0.428819 and 0.715488 only to illustrate.

Expected:

the identifiers are the page's; Me_1 holds numbers in [0, 1) that are the same on every run.

Adaptation:

no engine can reproduce the printed draws, so Me_1 is blank in the expected file and the example is checked by that property.

script.vtl ⇩

DS_r := random(DS_1,5);

input/DS_1.csv ⇩

Id_1Id_2Me_1
10A16.0
10B4.0
11A7.2

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_2Me_1
10A
10B
11A

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Id_2", "type": "String", "role": "Identifier"},
        {"name": "Me_1", "type": "Number", "role": "Measure"}
      ]
    }
  ]
}