{"record":{"id":"76bda46782b24e52","repo":"pentaho/pentaho-kettle","slug":"field-nr-i-in-file-filename-is-called-fieldname-while-it-was","errorCode":null,"errorMessage":"Field nr {i} in file '{filename}' is called '{fieldName}' while it was called '{firstFileName}' in the first file","messagePattern":"Field nr (.+?) in file '(.+?)' is called '(.+?)' while it was called '(.+?)' 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":118,"sourceCode":"    logBasic( BaseMessages.getString( PKG, \"SASInput.Log.OpenedSASFile\" ) + \" : [\" + data.helper + \"]\" );\n\n    // verify the row layout...\n    //\n    if ( data.fileLayout == null ) {\n      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() ) {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/sasinput/SasInput.java#L100-L136","documentation":"The SAS Input step validates that every file processed after the first has exactly the same field layout as the first file, since a single row layout is shared for all input files. When field at index i has a different (case-insensitive) name than the same-position field in the first file, processRow throws this KettleException.","triggerScenarios":"Running the SasInput step with multiple SAS7BAT files where a later file's column at position i is named differently from the first file's column at position i (comparison is case-insensitive, so only true name differences trigger).","commonSituations":"Pointing the step at a directory of SAS export files where some exports came from a newer/older schema; files generated by different tools with renamed columns; a typo in one file's column headers.","solutions":["Open the offending file (named in the message) in a SAS viewer and rename the field to match the first file.","Restructure the transformation to use separate SasInput steps per file schema, then merge rows downstream.","Pre-export the files so all share an identical column layout, then re-run the transformation."],"exampleFix":"// before: files with inconsistent columns read by one step\n// after: rename the column in the mismatched SAS file to match the first file,\n// or split into two SasInput steps and union the streams","handlingStrategy":"validation","validationCode":"// Compare column layouts before feeding multiple files to one step\nList<String> first = layoutOf(files.get(0));\nfor (File f : files.subList(1, files.size())) {\n  List<String> cols = layoutOf(f);\n  if (cols.size() != first.size()) throw new IllegalStateException(\"Column count differs in \" + f);\n  for (int i = 0; i < cols.size(); i++) {\n    if (!cols.get(i).equalsIgnoreCase(first.get(i)))\n      throw new IllegalStateException(\"Field \" + i + \" mismatch in \" + f + \": \" + cols.get(i) + \" vs \" + first.get(i));\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export all SAS files from the same schema/version and diff column lists before running the transformation.","Keep one SasInput step per file schema; union streams downstream instead of sharing a step.","Automate a pre-check that compares SAS file layouts before scheduling the transformation."],"tags":["sas","field-mismatch","schema","etl"],"backgroundTag":"schema-validation-failed","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"}