pentaho/pentaho-kettle · error · KettleException
Field nr in file ' ' is of data type ' ' while it was ' '…
Error message
Field nr {i} in file '{filename}' is of data type '{typeDesc}' while it was '{firstFileTypeDesc}' in the first file What it means
When reading multiple SAS7BAT files, SasInput requires all files to share one field layout, including data types. If field i in a subsequent file has a different Kettle value type than the same-position field in the first file, processRow throws this KettleException.
Solutions
- Convert the column type in the mismatched file so it matches the first file, then re-run.
- Add a Select Values / type-conversion step per file group and merge streams after conversion.
- Regenerate all input files from the same source schema/export settings.
Example fix
// before: file2's 'amount' column is CHAR while file1's is NUMERIC // after: re-export file2 so 'amount' is numeric, matching file1's layout
Defensive patterns
Strategy: validation
Validate before calling
// Verify types match across files before the step runs
RowMetaInterface firstLayout = helperOf(files.get(0)).getLayout();
for (File f : files.subList(1, files.size())) {
RowMetaInterface l = helperOf(f).getLayout();
for (int i = 0; i < firstLayout.size(); i++) {
if (l.getValueMeta(i).getType() != firstLayout.getValueMeta(i).getType())
throw new IllegalStateException("Type mismatch at field " + i + " in " + f);
}
} Prevention
- Standardize column types at export time (e.g. always export IDs as numeric).
- Insert explicit type-conversion (Select Values) steps when merging differently-typed sources.
- Regression-check file schemas whenever upstream SAS jobs change.
When it happens
Trigger: Running the step with several files where the same-position column is, e.g., TYPE_NUMBER in the first file but TYPE_STRING in a later file (first.getType() != second.getType()).
Common situations: Files exported at different times with a column's type changed (numeric ID became text); mixed CHAR/NUMERIC SAS columns across files; a schema migration affecting one batch of files.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Field nr in file ' ' is called ' ' while it was called ' '…
- AvroInput.Error.UnexpectedRecordFieldTypeAtNonExpansionPoint
- Selected field ' ' couldn't be found in file
- There was an error reading from SAS7BAT file
- Unable to create new value meta type
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/f8a5a0f507b48f3e.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/sasinput/SasInput.java:123
data.fileLayout = data.helper.getRowMeta();
} else {
// Verify that all files are of the same file format, this is a requirement...
//
if ( data.fileLayout.size() != data.helper.getRowMeta().size() ) {
throw new KettleException( "All input files need to have the same number of fields. File '"
+ filename + "' has " + data.helper.getRowMeta().size() + " fields while the first file only had "
+ data.fileLayout.size() );
}
for ( int i = 0; i < data.fileLayout.size(); i++ ) {
ValueMetaInterface first = data.fileLayout.getValueMeta( i );
ValueMetaInterface second = data.helper.getRowMeta().getValueMeta( i );
if ( !first.getName().equalsIgnoreCase( second.getName() ) ) {
throw new KettleException( "Field nr "
+ i + " in file '" + filename + "' is called '" + second.getName() + "' while it was called '"
+ first.getName() + "' in the first file" );
}
if ( first.getType() != second.getType() ) {
throw new KettleException( "Field nr "
+ i + " in file '" + filename + "' is of data type '" + second.getTypeDesc() + "' while it was '"
+ first.getTypeDesc() + "' in the first file" );
}
}
}
// Also make sure that we only read the specified fields, not any other...
//
if ( first ) {
first = false;
data.fieldIndexes = new ArrayList<Integer>();
for ( SasInputField field : meta.getOutputFields() ) {
int fieldIndex = data.fileLayout.indexOfValue( field.getName() );
if ( fieldIndex < 0 ) {
throw new KettleException( "Selected field '"
+ field.getName() + "' couldn't be found in file '" + filename + "'" );
}View on GitHub (pinned to f3058517a1)