{"record":{"id":"afee065cdc0439f1","repo":"pentaho/pentaho-kettle","slug":"unknown-data-type-for-aggregation","errorCode":null,"errorMessage":"Unknown data type for aggregation : ","messagePattern":"Unknown data type for aggregation : ","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/memgroupby/MemoryGroupBy.java","lineNumber":472,"sourceCode":"        case MemoryGroupByMeta.TYPE_GROUP_LAST:\n        case MemoryGroupByMeta.TYPE_GROUP_FIRST_INCL_NULL:\n        case MemoryGroupByMeta.TYPE_GROUP_LAST_INCL_NULL:\n        case MemoryGroupByMeta.TYPE_GROUP_MIN:\n        case MemoryGroupByMeta.TYPE_GROUP_MAX:\n          vMeta = subjMeta.clone();\n          vMeta.setName( meta.getAggregateField()[i] );\n          v = r == null ? null : r[data.subjectnrs[i]];\n          break;\n        case MemoryGroupByMeta.TYPE_GROUP_CONCAT_COMMA:\n          vMeta = new ValueMetaString( meta.getAggregateField()[i] );\n          v = new StringBuilder();\n          break;\n        case MemoryGroupByMeta.TYPE_GROUP_CONCAT_STRING:\n          vMeta = new ValueMetaString( meta.getAggregateField()[i] );\n          v = new StringBuilder();\n          break;\n        default:\n          throw new KettleException( \"Unknown data type for aggregation : \" + meta.getAggregateField()[i] );\n      }\n\n      if ( meta.getAggregateType()[i] != MemoryGroupByMeta.TYPE_GROUP_COUNT_ALL\n        && meta.getAggregateType()[i] != MemoryGroupByMeta.TYPE_GROUP_COUNT_DISTINCT\n        && meta.getAggregateType()[i] != MemoryGroupByMeta.TYPE_GROUP_COUNT_ANY ) {\n        vMeta.setLength( subjMeta.getLength(), subjMeta.getPrecision() );\n      }\n      if ( aggregate == null ) {\n        data.aggMeta.addValueMeta( vMeta );\n      } else {\n        aggregate.agg[i] = v;\n      }\n    }\n  }\n\n  private void initGroupMeta( RowMetaInterface previousRowMeta ) throws KettleValueException {\n    data.groupMeta = new RowMeta();\n    data.entryMeta = new RowMeta();","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/memgroupby/MemoryGroupBy.java#L454-L490","documentation":"MemoryGroupBy.newAggregate() builds the aggregate ValueMeta for each aggregation field based on the configured aggregate type. When the aggregate type doesn't match any known MemoryGroupByMeta TYPE_GROUP_* constant (e.g. an out-of-range or unrecognized value), the switch's default branch throws this KettleException naming the offending aggregate field. This is an internal configuration corruption, not a normal user error.","triggerScenarios":"A MemoryGroupBy step whose aggregateType[i] array contains a value that is not one of the defined TYPE_GROUP_* constants — usually from deserializing a corrupted/hand-edited transformation XML or repository record, or programmatic meta construction using a wrong integer constant.","commonSituations":"Manually editing the .ktr XML and mistyping the aggregate type; transformations written by a different plugin version where type codes shifted; Java code building MemoryGroupByMeta and passing an invalid type int; XML/repo corruption after a failed save.","solutions":["Open the transformation in Spoon, inspect the MemoryGroupBy step's aggregation table, and fix the invalid aggregation type dropdown entry.","Re-enter all aggregation rows in the step dialog to regenerate valid type codes, then re-save.","If building MemoryGroupByMeta in code, use MemoryGroupByMeta.getType(\"...\") or the TYPE_GROUP_* constants instead of raw integers.","Diff the .ktr XML (aggregate_type attributes) against a known-good transformation to spot the corrupted value."],"exampleFix":"// before: raw constant, possibly invalid\nmeta.getAggregateType()[0] = 99;\n\n// after: use defined constants\nmeta.getAggregateType()[0] = MemoryGroupByMeta.TYPE_GROUP_SUM; // or TYPE_GROUP_COUNT_ALL, etc.","handlingStrategy":"validation","validationCode":"int type = meta.getAggregateType()[i];\nboolean isValid = type == MemoryGroupByMeta.TYPE_GROUP_SUM\n  || type == MemoryGroupByMeta.TYPE_GROUP_AVERAGE\n  || type == MemoryGroupByMeta.TYPE_GROUP_COUNT_ALL\n  || type == MemoryGroupByMeta.TYPE_GROUP_COUNT_DISTINCT\n  || type == MemoryGroupByMeta.TYPE_GROUP_COUNT_ANY\n  || type == MemoryGroupByMeta.TYPE_GROUP_MIN\n  || type == MemoryGroupByMeta.TYPE_GROUP_MAX\n  || type == MemoryGroupByMeta.TYPE_GROUP_FIRST\n  || type == MemoryGroupByMeta.TYPE_GROUP_LAST\n  || type == MemoryGroupByMeta.TYPE_GROUP_CONCAT_STRING;\nif (!isValid) throw new IllegalArgumentException(\"Invalid aggregate type \" + type + \" for field \" + meta.getAggregateField()[i]);","typeGuard":"boolean isValidAggregateType(int t) {\n  return t >= MemoryGroupByMeta.TYPE_GROUP_SUM && t <= MemoryGroupByMeta.TYPE_GROUP_CONCAT_STRING;\n}","tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown data type for aggregation\")) {\n    logError(\"Corrupt aggregate type in MemoryGroupBy step; re-open and re-save the step in Spoon\", e);\n  }\n  throw e;\n}","preventionTips":["Never hand-edit aggregate_type values in .ktr XML or repository tables.","Use MemoryGroupByMeta.getType()/TYPE_GROUP_* constants when building meta in code.","Re-save the step dialog after upgrading Pentaho versions.","Keep .ktr files in version control to spot corrupted diffs."],"tags":["kettle","memory-groupby","aggregation","invalid-enum"],"backgroundTag":"invalid-enum-value","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"}