pentaho/pentaho-kettle · error · KettleValueException

Error :

Error message

Error : 

What it means

While building a SQL literal for a Date value, the code formats the java.util.Date with a SimpleDateFormat using the database's date format string. If formatting fails (Exception from SimpleDateFormat, typically an invalid pattern), it throws a KettleValueException with the bare prefix 'Error : ' and the cause attached.

Solutions

  1. Inspect the exception's cause (getCause) to see the actual SimpleDateFormat error and fix the offending dateFormat pattern.
  2. Use a dialect-appropriate date format (e.g. 'yyyy-MM-dd HH:mm:ss') or the database's TO_DATE/CAST syntax.
  3. Ensure the correct DatabaseMeta dialect is detected so its dateFormat field is valid.
  4. Catch KettleValueException and log the dateFormat string in use to identify the bad pattern.

Example fix

// before
String dateFormat = "yyyy-mm-dd hh:mm:ss.SSS"; // 'mm' is minutes in date part, likely intended months

// after
String dateFormat = "yyyy-MM-dd HH:mm:ss.SSS";
Defensive patterns

Strategy: validation

Validate before calling

try {
  new java.text.SimpleDateFormat(dateFormat); // fail fast on invalid pattern
} catch (IllegalArgumentException e) {
  throw new IllegalStateException("Database dialect dateFormat is invalid: " + dateFormat, e);
}

Try / catch

try {
  String sql = buildInsertSql(valueMeta, valueData);
} catch (KettleValueException e) {
  LOG.error("Date literal formatting failed; check dateFormat pattern", e);
}

Prevention

When it happens

Trigger: getSqlValue-style SQL literal construction where valueMeta is a Date and new SimpleDateFormat(dateFormat).format(date) throws — the database dialect's date format pattern is invalid (bad pattern characters) or the format string is empty/mangled.

Common situations: Custom database dialects or overridden dateFormat values containing invalid pattern letters; locale-related pattern issues; misconfigured database type detection selecting the wrong dialect's format string.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/database/BaseDatabaseMeta.java:2199

        case ValueMetaInterface.TYPE_STRING:
          String string = valueMeta.getString( valueData );
          // Have the database dialect do the quoting.
          // This also adds the single quotes around the string (thanks to PostgreSQL)
          //
          string = quoteSQLString( string );
          ins.append( string );
          break;
        case ValueMetaInterface.TYPE_DATE:
          Date date = valueMeta.getDate( valueData );

          if ( Utils.isEmpty( dateFormat ) ) {
            ins.append( "'" + valueMeta.getString( valueData ) + "'" );
          } else {
            try {
              java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat( dateFormat );
              ins.append( "'" + formatter.format( date ) + "'" );
            } catch ( Exception e ) {
              throw new KettleValueException( "Error : ", e );
            }
          }
          break;
        default:
          ins.append( valueMeta.getString( valueData ) );
          break;
      }
    }

    return ins.toString();
  }

  protected String getFieldnameProtector() {
    return FIELDNAME_PROTECTOR;
  }

  /**
   * Sanitize a string for usage as a field name

View on GitHub (pinned to f3058517a1)