{"record":{"id":"3f03d9a446716d87","repo":"pentaho/pentaho-kettle","slug":"the-floor-function-only-works-on-numeric-data","errorCode":null,"errorMessage":"The 'floor' function only works on numeric data","messagePattern":"The 'floor' 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":1367,"sourceCode":"      default:\n        throw new KettleValueException( \"The 'ceil' function only works on numeric data\" );\n    }\n  }\n\n  public static Object floor( ValueMetaInterface metaA, Object dataA ) throws KettleValueException {\n    if ( dataA == null ) {\n      return null;\n    }\n    switch ( metaA.getType() ) {\n      case ValueMetaInterface.TYPE_NUMBER:\n        return new Double( Math.floor( metaA.getNumber( dataA ).doubleValue() ) );\n      case ValueMetaInterface.TYPE_INTEGER:\n        return metaA.getInteger( dataA );\n      case ValueMetaInterface.TYPE_BIGNUMBER:\n        return new BigDecimal( Math.floor( metaA.getNumber( dataA ).doubleValue() ) );\n\n      default:\n        throw new KettleValueException( \"The 'floor' function only works on numeric data\" );\n    }\n  }\n\n  public static Object abs( ValueMetaInterface metaA, Object dataA ) throws KettleValueException {\n    if ( dataA == null ) {\n      return null;\n    }\n\n    switch ( metaA.getType() ) {\n      case ValueMetaInterface.TYPE_NUMBER:\n        return new Double( Math.abs( metaA.getNumber( dataA ).doubleValue() ) );\n      case ValueMetaInterface.TYPE_INTEGER:\n        return metaA.getInteger( Math.abs( metaA.getNumber( dataA ).longValue() ) );\n      case ValueMetaInterface.TYPE_BIGNUMBER:\n        return metaA.getBigNumber( dataA ).abs();\n\n      default:\n        throw new KettleValueException( \"The 'abs' function only works on numeric data\" );","sourceCodeStart":1349,"sourceCodeEnd":1385,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java#L1349-L1385","documentation":"The floor helper computes the largest integer <= A and, like ceil, only supports Number, Integer, and BigNumber metadata types. Any other type reaches the default branch and throws this KettleValueException.","triggerScenarios":"Calling ValueDataUtil.floor(metaA, dataA) (Calculator 'FLOOR( A )') where metaA.getType() is not numeric (TYPE_NUMBER/TYPE_INTEGER/TYPE_BIGNUMBER), e.g. String \"7.9\" or a Date field.","commonSituations":"Flooring a string value from a file input; flooring a timestamp; a field silently re-typed by an upstream step.","solutions":["Convert the field to a numeric type before the Calculator step.","Fix field metadata (Select Values) so the value is Number/Integer/BigNumber.","Guard with a type check in UDJC/UDJE before calling floor."],"exampleFix":"// before: FLOOR(fieldS:String = \"7.9\") -> throws\n// after: convert fieldS to Number; FLOOR(fieldS) -> 7","handlingStrategy":"type-guard","validationCode":"int t = metaA.getType();\nif (t != ValueMetaInterface.TYPE_NUMBER && t != ValueMetaInterface.TYPE_INTEGER && t != ValueMetaInterface.TYPE_BIGNUMBER) {\n  throw new KettleValueException(\"floor(A) requires numeric field, 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  f = ValueDataUtil.floor(metaA, dataA);\n} catch (KettleValueException e) {\n  logError(\"floor on non-numeric field: \" + e.getMessage());\n  f = null;\n}","preventionTips":["Add explicit string-to-number conversions after text-file/JSON input steps.","Preview field types before Calculator steps in every transformation.","Enable safe mode (transformation 'Safe mode' option) to catch type errors early."],"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"}