← parentheses operator page · general/parentheses/sc/addition_first

Addition first 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

Parentheses on scalars: (SC_1 + SC_2) * SC_3 with SC_1 = 2, SC_2 = 3 and SC_3 = 4 adds before it multiplies.

Manual:

Parentheses: "For example (2+3)*4 returns 20, instead 2+3*4 returns 14 because the multiplication has higher precedence than the addition."

Expected:

SC_r = 20, an Integer, as the operands are integers.

script.vtl ⇩

SC_r := (SC_1 + SC_2) * SC_3;

input/scalars.csv ⇩

SC_1SC_2SC_3
234

input/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_1", "type": "Integer"},
    {"name": "SC_2", "type": "Integer"},
    {"name": "SC_3", "type": "Integer"}
  ]
}

expected/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_r", "type": "Integer", "value": "20"}
  ]
}