pentaho/pentaho-kettle · error · KettleStepException

Unable to find fieldname [" + meta.getFieldName()[f] + "]…

Error message

Unable to find fieldname [" + meta.getFieldName()[f] + "] in row : " + data.rowMeta

What it means

SortedMerge.getRowSorted() lazily computes the indexes of the configured sort fields in the incoming row metadata. If a configured field name is not present in the row (indexOfValue returns -1), it throws a KettleStepException 'Unable to find fieldname [...] in row : ...', including the row metadata description.

Solutions

  1. Verify every input stream of the Sorted Merge contains all configured sort fields (preview each hop).
  2. Re-select the field names in the Sorted Merge dialog after upstream changes.
  3. Fix case/whitespace mismatches between streams (e.g., 'ID' vs 'id').
  4. Add a Select values / Add constants step upstream to normalize or add the missing field.
  5. Ensure each hop feeding the merge comes from the intended stream.

Example fix

// before
sortField[0] = "OrderDate"; // stream B renamed it to ORDER_DATE
// after
// add a Select values rename in stream B: ORDER_DATE -> OrderDate, or update sortField to ORDER_DATE
Defensive patterns

Strategy: validation

Validate before calling

for (String f : meta.getFieldName()) {
  if (streamRowMeta.indexOfValue(f) < 0) {
    throw new IllegalArgumentException("SortedMerge field missing: " + f);
  }
}

Try / catch

try { trans.execute(new String[0]); } catch (KettleStepException e) {
  if (e.getMessage().startsWith("Unable to find fieldname")) {
    logError("Fix sort field config or upstream stream: " + e.getMessage());
  }
}

Prevention

When it happens

Trigger: A sort field configured in the Sorted Merge step does not exist in the rows arriving from its multiple input hops — upstream rename/removal, case mismatch, or heterogeneous streams where one input lacks the field.

Common situations: Merging streams whose fields drifted apart after upstream edits; wrong hop assigned as one of the merge inputs; field name typo or trailing whitespace.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/sortedmerge/SortedMerge.java:107

          // Which is not yet sorted, we'll get to that later.
          //
          data.sortedBuffer.add( new RowSetRow( rowSet, rowSet.getRowMeta(), row ) );
          if ( data.rowMeta == null ) {
            data.rowMeta = rowSet.getRowMeta().clone();
          }

          // What fields do we compare on and in what order?

          // Better cache the location of the partitioning column
          // First time operation only
          //
          if ( data.fieldIndices == null ) {
            // Get the indexes of the specified sort fields...
            data.fieldIndices = new int[meta.getFieldName().length];
            for ( int f = 0; f < data.fieldIndices.length; f++ ) {
              data.fieldIndices[f] = data.rowMeta.indexOfValue( meta.getFieldName()[f] );
              if ( data.fieldIndices[f] < 0 ) {
                throw new KettleStepException( "Unable to find fieldname ["
                  + meta.getFieldName()[f] + "] in row : " + data.rowMeta );
              }

              data.rowMeta.getValueMeta( data.fieldIndices[f] ).setSortedDescending( !meta.getAscending()[f] );
            }
          }
        }

        data.comparator = new Comparator<RowSetRow>() {

          public int compare( RowSetRow o1, RowSetRow o2 ) {
            try {
              return o1.getRowMeta().compare( o1.getRowData(), o2.getRowData(), data.fieldIndices );
            } catch ( KettleValueException e ) {
              return 0; // TODO see if we should fire off alarms over here... Perhaps throw a RuntimeException.
            }
          }
        };

View on GitHub (pinned to f3058517a1)