{"record":{"id":"ff215f7dbe0c531a","repo":"pentaho/pentaho-kettle","slug":"the-ceil-function-only-works-on-numeric-data","errorCode":null,"errorMessage":"The 'ceil' function only works on numeric data","messagePattern":"The 'ceil' 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":1350,"sourceCode":"    }\n    int roundingMode = valueC.intValue();\n    return round( metaA, dataA, metaB, dataB, roundingMode );\n  }\n\n  public static Object ceil( 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.ceil( metaA.getNumber( dataA ).doubleValue() ) );\n      case ValueMetaInterface.TYPE_INTEGER:\n        return metaA.getInteger( dataA );\n      case ValueMetaInterface.TYPE_BIGNUMBER:\n        return new BigDecimal( Math.ceil( metaA.getNumber( dataA ).doubleValue() ) );\n\n      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    }","sourceCodeStart":1332,"sourceCodeEnd":1368,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java#L1332-L1368","documentation":"The ceil helper computes the smallest integer >= A, handling Number, Integer, and BigNumber metadata types. Non-numeric types (String, Date, Boolean, etc.) fall through to the default branch and throw this KettleValueException.","triggerScenarios":"Calling ValueDataUtil.ceil(metaA, dataA) (Calculator 'CEIL( A )') where metaA.getType() is not TYPE_NUMBER, TYPE_INTEGER, or TYPE_BIGNUMBER — e.g. a String-typed numeric-looking value like \"3.2\".","commonSituations":"Numeric values ingested as strings from text/JSON inputs; applying CEIL to a date or boolean field; upstream type changes.","solutions":["Type the field as Number/Integer/BigNumber before the Calculator step.","Insert a string-to-number conversion for the field.","Check metaA.getType() in a UDJC step before calling ceil."],"exampleFix":"// before: CEIL(fieldS:String = \"3.2\") -> throws\n// after: Select Values: fieldS Type=Number; then CEIL(fieldS) -> 4","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(\"ceil(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  c = ValueDataUtil.ceil(metaA, dataA);\n} catch (KettleValueException e) {\n  logError(\"ceil on non-numeric field: \" + e.getMessage());\n  c = null;\n}","preventionTips":["Convert numeric-looking strings (e.g. \"3.2\") to Number before ceil/floor.","Never wire Date or Boolean fields into CEIL/FLOOR calculator functions.","Use field metadata steps to pin types right after input."],"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"}