← cast operator page Ā· general/cast/number_to_string_mask/decimal_mask

Decimal mask 🟢 all ok

pandas āœ… Ā· DuckDB āœ…

Tests:

cast(Me_1, string, "DD.DDD") on a Number measure: the mask of the page's Example 1.

Manual:

Type Conversion and Formatting Mask: "ā€œDā€ one numeric digit (for the mantissa of the scientific notation)" and "ā€œ.ā€ (dot) can be used as a separator between the integer and the decimal parts".

Expected:

12.375 and 40.125, and 03.500 from 3.5: two digits, a dot and three digits, a digit for each D, so 3.5 gets a leading zero and two trailing zeros, which the conversion without a mask does not write. The values are exact in binary floating point, so none is rounded.

script.vtl ⇩

DS_r := DS_1[calc Me_2 := cast(Me_1, string, "DD.DDD")];

input/DS_1.csv ⇩

Id_1Me_1
112.375
240.125
33.5

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1Me_2
112.37512.375
240.12540.125
33.503.500

expected/DS_r.json ⇩

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