pentaho/pentaho-kettle · error · RuntimeException

The function call quarter requires 1 argument.

Error message

The function call quarter requires 1 argument.

What it means

Arity guard in ScriptAddedFunctions.quarter: the script call's ArgList length is not 1. The single expected argument is a java.util.Date from which the calendar month is mapped to quarter 1-4; any other argument count raises this RuntimeException.

Solutions

  1. Call quarter() with exactly one Date argument.
  2. Convert strings with str2date() first.
  3. Null-check the date before the call.
  4. Inspect e.toString() if the catch path fires with a cast error.

Example fix

// before
var q = quarter("2026-09-13");
// after
var q = quarter(str2date("2026-09-13", "yyyy-MM-dd"));
Defensive patterns

Strategy: validation

Validate before calling

var q = (d != null) ? quarter(d) : null;

Type guard

function isKettleDate(v) { return v != null && v instanceof java.util.Date; }

Try / catch

try {
  var q = quarter(d);
} catch (e) {
  Logger.LogBasic("quarter failed: " + e.message);
  q = null;
}

Prevention

When it happens

Trigger: Calling quarter() with zero or two-plus arguments in a Script step, or an internal failure (bad cast) that bypasses the quarter branches and lands in the catch.

Common situations: Passing string dates; forgetting the argument when refactoring scripts; passing a Date plus a locale/format argument copied from another API.

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/a7836267ca12eb0a. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:895

          return undefinedValue;
        }
        java.util.Date dArg1 = (java.util.Date) ArgList[0];
        Calendar cal = Calendar.getInstance();
        cal.setTime( dArg1 );

        // Patch by Ingo Klose: calendar months start at 0 in java.
        int iMonth = cal.get( Calendar.MONTH );
        if ( iMonth <= 2 ) {
          return new Double( 1 );
        } else if ( iMonth <= 5 ) {
          return new Double( 2 );
        } else if ( iMonth <= 8 ) {
          return new Double( 3 );
        } else {
          return new Double( 4 );
        }
      } else {
        throw new RuntimeException( "The function call quarter requires 1 argument." );
      }
    } catch ( Exception e ) {
      throw new RuntimeException( e.toString() );
    }
  }

  public static Object week( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    try {
      if ( ArgList.length == 1 ) {
        if ( isNull( ArgList[0] ) ) {
          return new Double( Double.NaN );
        } else if ( isUndefined( ArgList[0] ) ) {
          return undefinedValue;
        }
        java.util.Date dArg1 = (java.util.Date) ArgList[0];
        Calendar cal = Calendar.getInstance();
        cal.setTime( dArg1 );

View on GitHub (pinned to f3058517a1)