{"record":{"id":"45801552d787845e","repo":"pentaho/pentaho-kettle","slug":"the-function-call-floor-requires-1-argument-458015","errorCode":null,"errorMessage":"The function call floor requires 1 argument.","messagePattern":"The function call floor requires 1 argument\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":432,"sourceCode":"  }\n\n  public static Object floor( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return new Double( Double.NaN );\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return Context.getUndefinedValue();\n        } else {\n          return new Double( Math.floor( Context.toNumber( ArgList[0] ) ) );\n        }\n      } catch ( Exception e ) {\n        return null;\n        // throw Context.reportRuntimeError(e.toString());\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call floor requires 1 argument.\" );\n    }\n  }\n\n  public static Object getDayNumber( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 2 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return new Double( Double.NaN );\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return Context.getUndefinedValue();\n        } else {\n          java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );\n          String strType = Context.toString( ArgList[1] ).toLowerCase();\n          Calendar startDate = Calendar.getInstance();\n          startDate.setTime( dIn );\n          if ( strType.equals( \"y\" ) ) {\n            return new Double( startDate.get( Calendar.DAY_OF_YEAR ) );","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L414-L450","documentation":"Arity guard for floor in the Rhino script-values step: the function floors exactly one numeric argument. Null/undefined are handled specially; any other argument count falls to the else-branch and reports this error.","triggerScenarios":"floor() with no arguments or with more than one argument.","commonSituations":"Passing a digits-precision argument as with spreadsheet FLOOR(value, significance); calling with no args while testing.","solutions":["Call floor with exactly one argument: floor(value).","For significance-based flooring compute Math.floor(value/significance)*significance.","Check the script for an accidental extra comma."],"exampleFix":"// before\nvar f = floor(value, 0.5);\n// after\nvar f = Math.floor(value / 0.5) * 0.5;","handlingStrategy":"validation","validationCode":"var x = +(value);\nif (isNaN(x)) x = 0;\nvar f = floor(x);","typeGuard":"function isNumber(v){ return typeof v === 'number' && !isNaN(v); }","tryCatchPattern":null,"preventionTips":["Pass exactly one numeric argument.","Implement significance-based flooring manually if needed.","Don't mix spreadsheet-function signatures with JS helpers."],"tags":["javascript","argument-count","math","pdi-kettle"],"backgroundTag":"missing-required-argument","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"}