← cast operator page · general/cast/integer_to_string/digits_and_sign

Digits and sign 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

cast(Me_1, string) on an Integer measure, without a mask: the default format.

Manual:

Type conversion: "From integer: the integer value is printed as a sequence of digits, without any leading zeroes or thousands separators, possibly preceded by a -."

Expected:

1500 with no thousands separator, -7 preceded by -, and 0.

script.vtl ⇩

DS_r := DS_1[calc Me_2 := cast(Me_1, string)];

input/DS_1.csv ⇩

Id_1Me_1
11500
2-7
30

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/DS_r.csv ⇩

Id_1Me_1Me_2
115001500
2-7-7
300

expected/DS_r.json ⇩

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