← random operator page · numeric/random/comp/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

random on a component inside calc, next to the seed Me_1.

Manual:

Random, Example 2: "The operator returns a random decimal number >= 0 and <1." The page prints 0.7545341, 0.3457166 and 0.5183224 only to illustrate.

Expected:

Me_2 holds numbers in [0, 1) that are the same on every run; the seed Me_1 (16.0, 4.0 and 7.2) is kept and compared as written.

Adaptation:

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

script.vtl ⇩

DS_r  := DS_1 [ calc Me_2 := random( Me_1, 8 ) ];

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_1Me_2
10A16.0
10B4.0
11A7.2

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"},
        {"name": "Me_2", "type": "Number", "role": "Measure"}
      ]
    }
  ]
}