{"record":{"id":"277b82d56da0c1fc","repo":"pentaho/pentaho-kettle","slug":"multiplication-can-only-be-done-with-numbers-or-a-number-and","errorCode":null,"errorMessage":"Multiplication can only be done with numbers or a number and a string!","messagePattern":"Multiplication can only be done with numbers or a number and a string!","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Value.java","lineNumber":2348,"sourceCode":"        s.setLength( 0 );\n      } else {\n        for ( int i = 1; i < n; i++ ) {\n          s.append( append );\n        }\n      }\n\n      setValue( s );\n    } else if ( isBigNumber() || v.isBigNumber() ) {\n      // big numbers\n      setValue( ValueDataUtil.multiplyBigDecimals( getBigNumber(), v.getBigNumber(), null ) );\n    } else if ( isNumber() || v.isNumber() ) {\n      // numbers\n      setValue( getNumber() * v.getNumber() );\n    } else if ( isInteger() || v.isInteger() ) {\n      // integers\n      setValue( getInteger() * v.getInteger() );\n    } else {\n      throw new KettleValueException( \"Multiplication can only be done with numbers or a number and a string!\" );\n    }\n    return this;\n  }\n\n  // FUNCTIONS!!\n\n  // implement the ABS function, arguments in args[]\n  public Value abs() throws KettleValueException {\n    if ( isNull() ) {\n      return this;\n    }\n\n    if ( isBigNumber() ) {\n      setValue( getBigNumber().abs() );\n    } else if ( isNumber() ) {\n      setValue( Math.abs( getNumber() ) );\n    } else if ( isInteger() ) {\n      setValue( Math.abs( getInteger() ) );","sourceCodeStart":2330,"sourceCodeEnd":2366,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L2330-L2366","documentation":"This KettleValueException is thrown by Value.multiply() when neither operand is a Number, Integer, or BigNumber and the operands don't form the supported number×string case (repeating a string n times). Multiplication in the legacy Value class supports numeric multiplication and string repetition; all other type combinations are rejected.","triggerScenarios":"value.multiply(other) where operands are e.g. BOOLEAN×anything, STRING×STRING, or DATE×anything — typically two string fields multiplied, or a boolean produced by a formula used in multiplication.","commonSituations":"Two text columns from CSV multiplied directly; boolean flags used in calculations without conversion; calculator step mis-wired to non-numeric hops; type inference regressions after upstream changes.","solutions":["Convert operands to numeric types (convertString( VALUE_TYPE_NUMBER ) / setInteger / setNumber) before multiplying.","In the transformation, insert a Calculator/Select Values step to coerce fields to Number or Integer first.","If string repetition was intended (number × string), ensure exactly one operand is numeric and the other is a String.","Validate input field metadata types before arithmetic and fail early with a descriptive message.","Catch KettleValueException to log both operands' types and values for diagnosis."],"exampleFix":"// before\nValue area = widthStr.multiply( heightStr ); // STRING x STRING -> throws\n// after\nwidthStr.convertString( Value.VALUE_TYPE_NUMBER );\nheightStr.convertString( Value.VALUE_TYPE_NUMBER );\nValue area = widthStr.multiply( heightStr );","handlingStrategy":"type-guard","validationCode":"// before multiply\nboolean aNum = a.isNumber() || a.isInteger() || a.isBigNumber();\nboolean bNum = b.isNumber() || b.isInteger() || b.isBigNumber();\nif ( !aNum && !bNum ) throw new IllegalArgumentException( \"At least one operand must be numeric\" );","typeGuard":"boolean canMultiply( Value x, Value y ) {\n  boolean xNum = x != null && ( x.isNumber() || x.isInteger() || x.isBigNumber() );\n  boolean yNum = y != null && ( y.isNumber() || y.isInteger() || y.isBigNumber() );\n  return xNum && yNum || ( xNum && y.isString() ) || ( yNum && x.isString() );\n}","tryCatchPattern":"try {\n  Value product = a.multiply( b );\n} catch ( KettleValueException e ) {\n  throw new IllegalStateException( \"Unsupported multiply operands: \" + a.getType() + \" x \" + b.getType(), e );\n}","preventionTips":["Ensure exactly one numeric operand when using number×string repetition semantics.","Insert Calculator/Select Values conversions before multiplication.","Do not multiply booleans or dates — convert intent explicitly.","Assert field types with metadata checks in tests.","Handle type-inference drift after upstream step changes."],"tags":["arithmetic","type-mismatch","multiplication","value-types"],"backgroundTag":"type-mismatch","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}