pentaho/pentaho-kettle · error

The function call floor requires 1 argument.

Error message

The function call floor requires 1 argument.

What it means

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.

Solutions

  1. Call floor with exactly one argument: floor(value).
  2. For significance-based flooring compute Math.floor(value/significance)*significance.
  3. Check the script for an accidental extra comma.

Example fix

// before
var f = floor(value, 0.5);
// after
var f = Math.floor(value / 0.5) * 0.5;
Defensive patterns

Strategy: validation

Validate before calling

var x = +(value);
if (isNaN(x)) x = 0;
var f = floor(x);

Type guard

function isNumber(v){ return typeof v === 'number' && !isNaN(v); }

Prevention

When it happens

Trigger: floor() with no arguments or with more than one argument.

Common situations: Passing a digits-precision argument as with spreadsheet FLOOR(value, significance); calling with no args while testing.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/45801552d787845e. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:432

  }

  public static Object floor( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return new Double( Double.NaN );
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        } else {
          return new Double( Math.floor( Context.toNumber( ArgList[0] ) ) );
        }
      } catch ( Exception e ) {
        return null;
        // throw Context.reportRuntimeError(e.toString());
      }
    } else {
      throw Context.reportRuntimeError( "The function call floor requires 1 argument." );
    }
  }

  public static Object getDayNumber( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 2 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return new Double( Double.NaN );
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        } else {
          java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
          String strType = Context.toString( ArgList[1] ).toLowerCase();
          Calendar startDate = Calendar.getInstance();
          startDate.setTime( dIn );
          if ( strType.equals( "y" ) ) {
            return new Double( startDate.get( Calendar.DAY_OF_YEAR ) );

View on GitHub (pinned to f3058517a1)