{"record":{"id":"174462a620561fff","repo":"pentaho/pentaho-kettle","slug":"the-combination1-function-only-works-on-numeric-data","errorCode":null,"errorMessage":"The 'combination1' function only works on numeric data","messagePattern":"The 'combination1' function only works on numeric data","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java","lineNumber":1142,"sourceCode":"  public static Object combination1( ValueMetaInterface metaA, Object dataA, ValueMetaInterface metaB,\n    Object dataB, ValueMetaInterface metaC, Object dataC ) throws KettleValueException {\n    if ( dataA == null || dataB == null || dataC == null ) {\n      return null;\n    }\n\n    switch ( metaA.getType() ) {\n      case ValueMetaInterface.TYPE_NUMBER:\n        return new Double( metaA.getNumber( dataA ).doubleValue()\n          + ( metaB.getNumber( dataB ).doubleValue() * metaC.getNumber( dataC ).doubleValue() ) );\n      case ValueMetaInterface.TYPE_INTEGER:\n        return new Long( metaA.getInteger( dataA ).longValue()\n          + ( metaB.getInteger( dataB ).longValue() * metaC.getInteger( dataC ).longValue() ) );\n      case ValueMetaInterface.TYPE_BIGNUMBER:\n        return metaA.getBigNumber( dataA ).add(\n          multiplyBigDecimals( metaB.getBigNumber( dataB ), metaC.getBigNumber( dataC ), null ) );\n\n      default:\n        throw new KettleValueException( \"The 'combination1' function only works on numeric data\" );\n    }\n  }\n\n  /**\n   * SQRT( A*A + B*B )\n   *\n   * @param metaA\n   * @param dataA\n   * @param metaB\n   * @param dataB\n   * @return\n   * @throws KettleValueException\n   */\n  public static Object combination2( ValueMetaInterface metaA, Object dataA, ValueMetaInterface metaB, Object dataB ) throws KettleValueException {\n    if ( dataA == null || dataB == null ) {\n      return null;\n    }\n","sourceCodeStart":1124,"sourceCodeEnd":1160,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java#L1124-L1160","documentation":"ValueDataUtil's 'combination1' helper (multiply-accumulate arithmetic A + B*C) computes with type-specific getters only for numeric value types (Number, Integer, String-as-numeric? no — String, Date, Boolean, BigNumber etc. that fall through). When metaA's type is not one of the handled numeric cases, the default branch throws this KettleValueException. Kettle/PDI calc functions require numeric input metadata; non-numeric types cannot participate in this arithmetic.","triggerScenarios":"Calling ValueDataUtil.combination1 (or the Calculator plugin's 'A + B * C' combination type) where the metadata type of the A field is not TYPE_NUMBER, TYPE_INTEGER, or TYPE_BIGNUMBER — e.g. a String, Date, or Boolean field is wired into the calculator step.","commonSituations":"Calculator step fed a CSV field read as String instead of Number; a type change upstream (e.g. a field switched from Integer to String) silently propagates; using a Date or Boolean output of another step in a combination formula.","solutions":["Change the Calculator step field type (or upstream Select Values / field metadata) to Number, Integer, or BigNumber before the combination1 calculation.","Insert a 'String to number' conversion (Select Values metadata or a User Defined Java Expression / JavaScript step) for the offending field.","If fields can be null or mixed, guard the calculation in a UDJC/Script step checking metaA.getType() before calling combination1."],"exampleFix":"// before: Calculator 'A + B*C' with fieldA declared as String\n// after: in Select Values step preceding the Calculator, set fieldA Metadata -> Type: Number\n// then Calculator: combination1 with A=fieldA (Number), B=fieldB, C=fieldC","handlingStrategy":"type-guard","validationCode":"// Java (PDI)\nint t = metaA.getType();\nif (t != ValueMetaInterface.TYPE_NUMBER && t != ValueMetaInterface.TYPE_INTEGER && t != ValueMetaInterface.TYPE_BIGNUMBER) {\n  throw new KettleValueException(\"combination1 requires numeric field A, got type \" + t);\n}","typeGuard":"public static boolean isNumericMeta(ValueMetaInterface m) {\n  int t = m.getType();\n  return t == ValueMetaInterface.TYPE_NUMBER || t == ValueMetaInterface.TYPE_INTEGER || t == ValueMetaInterface.TYPE_BIGNUMBER;\n}","tryCatchPattern":"try {\n  result = ValueDataUtil.combination1(metaA, dataA, metaB, dataB, metaC, dataC);\n} catch (KettleValueException e) {\n  logError(\"combination1 needs numeric inputs: \" + e.getMessage());\n  // route row to error handling stream or convert types and retry\n}","preventionTips":["Always set explicit field types (Select Values metadata) before Calculator steps.","Convert string fields from text/CSV inputs to numbers immediately after input steps.","Enable row-level error handling on Calculator steps to catch type errors per row.","Preview data types at each hop to catch silent re-typing."],"tags":["kettle","pdi","calculator","numeric-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"}