pentaho/pentaho-kettle · error · KettleValueException

Function TRUNC only works with numbers and dates

Error message

Function TRUNC only works with numbers and dates

What it means

Type dispatch guard in the argumented legacy Value trunc(level) overload: the value is not a Number or Date, so no truncation case matches and the sentinel error is thrown. The input at fault is the current Value of an unsupported type.

Solutions

  1. Ensure the field passed to TRUNC is a Number or Date
  2. Convert the value to a supported type before truncating
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3523 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3523

          cal.set( Calendar.DAY_OF_MONTH, 1 );
          // HOURS
        case 3:
          cal.set( Calendar.HOUR_OF_DAY, 0 );
          // MINUTES
        case 2:
          cal.set( Calendar.MINUTE, 0 );
          // SECONDS
        case 1:
          cal.set( Calendar.SECOND, 0 );
          // MILI-SECONDS
        case 0:
          cal.set( Calendar.MILLISECOND, 0 );
          break;
        default:
          throw new KettleValueException( "Argument of TRUNC of date has to be between 0 and 5" );
      }
    } else {
      throw new KettleValueException( "Function TRUNC only works with numbers and dates" );
    }

    return this;
  }

  /**
   * Change a string into its hexadecimal representation. E.g. if Value contains string "a" afterwards it would contain
   * value "61".
   *
   * Note that transformations happen in groups of 2 hex characters, so the value of a characters is always in the range
   * 0-255.
   *
   * @return Value itself
   * @throws KettleValueException
   */
  public Value byteToHexEncode() {
    final char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

View on GitHub (pinned to f3058517a1)