{"record":{"id":"1a0e350d97929ce1","repo":"pentaho/pentaho-kettle","slug":"the-combination2-function-only-works-on-numeric-data","errorCode":null,"errorMessage":"The 'combination2' function only works on numeric data","messagePattern":"The 'combination2' 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":1178,"sourceCode":"\n    switch ( metaA.getType() ) {\n      case ValueMetaInterface.TYPE_NUMBER:\n        return new Double( Math.sqrt( metaA.getNumber( dataA ).doubleValue()\n          * metaA.getNumber( dataA ).doubleValue() + metaB.getNumber( dataB ).doubleValue()\n          * metaB.getNumber( dataB ).doubleValue() ) );\n\n      case ValueMetaInterface.TYPE_INTEGER:\n        return new Long( Math.round( Math.sqrt( metaA.getInteger( dataA ).longValue()\n          * metaA.getInteger( dataA ).longValue() + metaB.getInteger( dataB ).longValue()\n          * metaB.getInteger( dataB ).longValue() ) ) );\n\n      case ValueMetaInterface.TYPE_BIGNUMBER:\n        return BigDecimal.valueOf( Math.sqrt( metaA.getNumber( dataA ).doubleValue()\n          * metaA.getNumber( dataA ).doubleValue() + metaB.getNumber( dataB ).doubleValue()\n          * metaB.getNumber( dataB ).doubleValue() ) );\n\n      default:\n        throw new KettleValueException( \"The 'combination2' function only works on numeric data\" );\n    }\n  }\n\n  /**\n   * Rounding with no decimal places (using default rounding method ROUND_HALF_CEILING)\n   *\n   * @param metaA\n   *          Metadata of value to round\n   * @param dataA\n   *          Value to round\n   * @return The rounded value\n   * @throws KettleValueException\n   */\n  public static Object round( ValueMetaInterface metaA, Object dataA ) throws KettleValueException {\n    if ( dataA == null ) {\n      return null;\n    }\n","sourceCodeStart":1160,"sourceCodeEnd":1196,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java#L1160-L1196","documentation":"The 'combination2' helper computes SQRT(A*A + B*B) and handles only numeric value types (Number, Integer, BigNumber). Any other metadata type for A reaches the default branch and throws this KettleValueException. It exists because hypotenuse-style math is only defined on numeric data.","triggerScenarios":"Calling ValueDataUtil.combination2 (Calculator type 'SQRT( A*A + B*B )') where metaA.getType() is not TYPE_NUMBER, TYPE_INTEGER, or TYPE_BIGNUMBER — e.g. String or Date input fields.","commonSituations":"Calculator step receiving string fields from a text file input without conversion; upstream step changed a field's type; user connected a timestamp field into the combination2 calculation.","solutions":["Ensure fields A and B are typed Number/Integer/BigNumber in the Calculator step (fix metadata in a preceding Select Values step).","Convert string inputs to numbers before the Calculator step.","Wrap the calculation in a UDJC/UDJE step that validates ValueMetaInterface.getType() first."],"exampleFix":"// before: Calculator combination2 fed fieldA as String\n// after: Select Values step: fieldA -> Type: Number; then combination2(A=fieldA, B=fieldB)","handlingStrategy":"type-guard","validationCode":"if (!isNumericMeta(metaA) || !isNumericMeta(metaB)) {\n  throw new KettleValueException(\"combination2 (SQRT(A*A+B*B)) requires numeric A and B\");\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.combination2(metaA, dataA, metaB, dataB);\n} catch (KettleValueException e) {\n  logError(\"combination2 requires numeric fields: \" + e.getMessage());\n  result = null; // or send row to error stream\n}","preventionTips":["Enforce numeric types on fields used in geometric/distance-style calculations.","Add a 'Filter rows' or validation step that drops non-numeric rows before arithmetic.","Keep field type definitions in one transformation location to avoid drift."],"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"}