← log operator page · numeric/log/sc_comp/component_base

Component base 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

log of a scalar number with the base in a component, inside calc.

Manual:

Logarithm: "log ( 1024, 2 ) gives 10", although the page's table and its sentence "calculates the logarithm of num base op" put the base first. The page types the second operand as component<integer> | integer, so that operand may be a component while the first is a scalar.

Expected:

Me_2 = log(1024, Me_1), read as the page's examples read it: base 2 gives 10.0, base 4 gives 5.0 and base 32 gives 2.0, a Number although both operands are Integers; the other components are kept.

script.vtl ⇩

DS_r := DS_1[calc Me_2 := log(1024, Me_1)];

input/DS_1.csv ⇩

Id_1Me_1
12
24
332

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
1210.000000
245.000000
3322.000000

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