{"record":{"id":"bb406d35e8455d0b","repo":"pentaho/pentaho-kettle","slug":"it-s-not-possible-to-convert-from-timestamp-to-boolean","errorCode":null,"errorMessage":": it's not possible to convert from Timestamp to Boolean","messagePattern":": it's not possible to convert from Timestamp to Boolean","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java","lineNumber":117,"sourceCode":"      return timestampAsInteger.doubleValue();\n    } else {\n      return null;\n    }\n  }\n\n  @Override\n  public BigDecimal getBigNumber( Object object ) throws KettleValueException {\n    Long timestampAsInteger = getInteger( object );\n    if ( null != timestampAsInteger ) {\n      return BigDecimal.valueOf( timestampAsInteger );\n    } else {\n      return null;\n    }\n  }\n\n  @Override\n  public Boolean getBoolean( Object object ) throws KettleValueException {\n    throw new KettleValueException( toStringMeta() + \": it's not possible to convert from Timestamp to Boolean\" );\n  }\n\n  @Override\n  public String getString( Object object ) throws KettleValueException {\n    return convertTimestampToString( getTimestamp( object ) );\n  }\n\n  public Timestamp getTimestamp( Object object ) throws KettleValueException {\n    if ( object == null ) {\n      return null;\n    }\n    switch ( type ) {\n      case TYPE_TIMESTAMP:\n        switch ( storageType ) {\n          case STORAGE_TYPE_NORMAL:\n            return (Timestamp) object;\n          case STORAGE_TYPE_BINARY_STRING:\n            return (Timestamp) convertBinaryStringToNativeType( (byte[]) object );","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaTimestamp.java#L99-L135","documentation":"ValueMetaTimestamp.getBoolean() is deliberately unimplemented in PDI (Kettle): the library refuses to implicitly convert a java.sql.Timestamp value to a Boolean because such a conversion has no well-defined semantics. Instead of guessing (e.g. non-null=true), it throws a KettleValueException with a message built from the field's meta description. Any row-processing step that calls getBoolean() on a Timestamp-typed field will hit this.","triggerScenarios":"Calling ValueMetaInterface.getBoolean(object) on a metadata instance whose type is TYPE_TIMESTAMP (ValueMetaTimestamp), regardless of storage type, even when the object is non-null. Typical call path: a step or transformation calls row.getBoolean(field) while the field was declared as Timestamp.","commonSituations":"A transformation field type changed from Boolean/String to Timestamp (e.g. after a database column or CSV type change) while downstream steps still read it as boolean; generic code that copies row data calling getBoolean for every field; unit tests like testConvertTimestampToBoolean_Null documenting that only null is safe.","solutions":["Convert explicitly before calling getBoolean: wrap the value with a conversion step or call valueMeta.getString(object)/getTimestamp(object) and apply your own rule (e.g. non-null -> true).","Change the reading code to request the value as String or Timestamp via getString()/getTimestamp() and parse to Boolean with explicit logic.","If the field should actually be Boolean, fix the field's declared type (ValueMetaInterface setType(TYPE_BOOLEAN) or correct the table/stream definition) so ValueMetaBoolean.getBoolean() is used instead.","If only null must pass, guard with if (object == null) before calling getBoolean(), since null returns null without throwing (see getBoolean's null check above line 117)."],"exampleFix":"// before\nBoolean b = timestampMeta.getBoolean( rowValue ); // throws\n// after\nBoolean b = null;\nif ( rowValue != null ) {\n  Timestamp ts = timestampMeta.getTimestamp( rowValue );\n  b = ts != null; // explicit rule chosen by the developer\n}","handlingStrategy":"validation","validationCode":"if ( object != null && meta.getType() == ValueMetaInterface.TYPE_TIMESTAMP ) {\n  // convert via getTimestamp()/getString() with an explicit rule instead of getBoolean()\n}","typeGuard":"boolean isBooleanConvertible( ValueMetaInterface meta, Object v ) {\n  return v == null || meta.getType() == ValueMetaInterface.TYPE_BOOLEAN;\n}","tryCatchPattern":"try {\n  b = meta.getBoolean( value );\n} catch ( KettleValueException e ) {\n  if ( e.getMessage().contains( \"not possible to convert from Timestamp to Boolean\" ) ) {\n    b = meta.getTimestamp( value ) != null; // explicit fallback rule\n  } else { throw e; }\n}","preventionTips":["Never call getBoolean() on Timestamp-typed fields; check getType() first.","Declare boolean fields as TYPE_BOOLEAN so ValueMetaBoolean handles them.","Keep field types stable across steps; re-check metadata after upstream type changes.","Remember only null is safely readable via getBoolean() on this class."],"tags":["kettle","pdi","type-conversion","timestamp","boolean"],"backgroundTag":"unsupported-operation","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"}