{"record":{"id":"f8a5a0f507b48f3e","repo":"pentaho/pentaho-kettle","slug":"field-nr-i-in-file-filename-is-of-data-type-typedesc-while","errorCode":null,"errorMessage":"Field nr {i} in file '{filename}' is of data type '{typeDesc}' while it was '{firstFileTypeDesc}' in the first file","messagePattern":"Field nr (.+?) in file '(.+?)' is of data type '(.+?)' while it was '(.+?)' in the first file","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/sasinput/SasInput.java","lineNumber":123,"sourceCode":"      data.fileLayout = data.helper.getRowMeta();\n    } else {\n      // Verify that all files are of the same file format, this is a requirement...\n      //\n      if ( data.fileLayout.size() != data.helper.getRowMeta().size() ) {\n        throw new KettleException( \"All input files need to have the same number of fields. File '\"\n          + filename + \"' has \" + data.helper.getRowMeta().size() + \" fields while the first file only had \"\n          + data.fileLayout.size() );\n      }\n      for ( int i = 0; i < data.fileLayout.size(); i++ ) {\n        ValueMetaInterface first = data.fileLayout.getValueMeta( i );\n        ValueMetaInterface second = data.helper.getRowMeta().getValueMeta( i );\n        if ( !first.getName().equalsIgnoreCase( second.getName() ) ) {\n          throw new KettleException( \"Field nr \"\n            + i + \" in file '\" + filename + \"' is called '\" + second.getName() + \"' while it was called '\"\n            + first.getName() + \"' in the first file\" );\n        }\n        if ( first.getType() != second.getType() ) {\n          throw new KettleException( \"Field nr \"\n            + i + \" in file '\" + filename + \"' is of data type '\" + second.getTypeDesc() + \"' while it was '\"\n            + first.getTypeDesc() + \"' in the first file\" );\n        }\n      }\n    }\n\n    // Also make sure that we only read the specified fields, not any other...\n    //\n    if ( first ) {\n      first = false;\n\n      data.fieldIndexes = new ArrayList<Integer>();\n      for ( SasInputField field : meta.getOutputFields() ) {\n        int fieldIndex = data.fileLayout.indexOfValue( field.getName() );\n        if ( fieldIndex < 0 ) {\n          throw new KettleException( \"Selected field '\"\n            + field.getName() + \"' couldn't be found in file '\" + filename + \"'\" );\n        }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/sasinput/SasInput.java#L105-L141","documentation":"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.","triggerScenarios":"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()).","commonSituations":"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.","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."],"exampleFix":"// before: file2's 'amount' column is CHAR while file1's is NUMERIC\n// after: re-export file2 so 'amount' is numeric, matching file1's layout","handlingStrategy":"validation","validationCode":"// Verify types match across files before the step runs\nRowMetaInterface firstLayout = helperOf(files.get(0)).getLayout();\nfor (File f : files.subList(1, files.size())) {\n  RowMetaInterface l = helperOf(f).getLayout();\n  for (int i = 0; i < firstLayout.size(); i++) {\n    if (l.getValueMeta(i).getType() != firstLayout.getValueMeta(i).getType())\n      throw new IllegalStateException(\"Type mismatch at field \" + i + \" in \" + f);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["sas","type-mismatch","schema","etl"],"backgroundTag":"incompatible-source-type","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"}