{"record":{"id":"ccbf65455afe1459","repo":"pentaho/pentaho-kettle","slug":"avroinput-error","errorCode":null,"errorMessage":"AvroInput.Error.UnexpectedArrayElementTypeAtNonExpansionPoint","messagePattern":"AvroInput\\.Error\\.UnexpectedArrayElementTypeAtNonExpansionPoint","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/input/AvroNestedReader.java","lineNumber":1291,"sourceCode":"          }\n        }\n\n        // what have we got?\n        if ( elementType.getType() == Schema.Type.RECORD ) {\n          return convertToKettleValues( (GenericData.Record) value, elementType, defaultSchema, space, ignoreMissing );\n        } else if ( elementType.getType() == Schema.Type.ARRAY ) {\n          return convertToKettleValues( (GenericData.Array) value, elementType, defaultSchema, space, ignoreMissing );\n        } else if ( elementType.getType() == Schema.Type.MAP ) {\n          return convertToKettleValues( (Map<Utf8, Object>) value, elementType, defaultSchema, space, ignoreMissing );\n        } else {\n          // we shouldn't have a primitive at this point. If we are\n          // extracting a particular index from the array then we're not to the\n          // expansion phase,\n          // so normally there must be a non-primitive sub-structure. Only if\n          // the user is switching schema versions on a per-row basis or the\n          // schema is a union at the top level could we end up here\n          if ( !ignoreMissing ) {\n            throw new KettleException( BaseMessages.getString( PKG,\n              \"AvroInput.Error.UnexpectedArrayElementTypeAtNonExpansionPoint\" ) );\n          } else {\n            Object[][] result = new Object[ 1 ][ m_outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE ];\n            return result;\n          }\n        }\n      }\n    }\n\n    /**\n     * Processes a record at this point in the path.\n     *\n     * @param record        the record to process\n     * @param s             the current schema at this point in the path\n     * @param space         environment variables\n     * @param ignoreMissing true if null is to be returned for user fields that don't appear in the schema\n     * @return an array of Kettle rows corresponding to the expanded map/array and containing all leaf values as defined\n     * in the paths","sourceCodeStart":1273,"sourceCodeEnd":1309,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/input/AvroNestedReader.java#L1273-L1309","documentation":"Mirror of the map error for arrays: while resolving an array path at a non-expansion point, the element's schema type is an array where a non-primitive sub-structure (record) was expected to continue traversal.","triggerScenarios":"Nested arrays (array of arrays) with a path that does not supply an index at the inner level, e.g. 'matrix[0]' where matrix is array<array<int>> and the path expects 'matrix[0][1]'; top-level union or per-row schema switching producing nested arrays.","commonSituations":"Nested-array schemas where the user forgot the second index; schema evolution wrapped an array inside another array; union branches with different array nesting depths.","solutions":["Add an index for every array level: 'matrix[0][1]'","Flatten nested arrays in the schema or pre-process the data","Enable 'Ignore missing paths' for heterogeneous schema versions","Define paths per schema version when nesting differs"],"exampleFix":"// before\npath: matrix[0].value   // matrix is array<array<int>>\n// after\npath: matrix[0][1]","handlingStrategy":"validation","validationCode":"// Count array nesting depth in schema and require an index per level\nint depth = 0;\nSchema s = schema.getField(\"matrix\").schema();\nwhile (s.getType() == Schema.Type.ARRAY) { depth++; s = s.getElementType(); }\nlong indexesInPath = path.chars().filter(c -> c == '[').count();\nif (indexesInPath < depth) {\n  throw new IllegalArgumentException(\"Need \" + depth + \" indexes, path has \" + indexesInPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return reader.convertArray(...);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"UnexpectedArrayElementTypeAtNonExpansionPoint\")) {\n    return emptyRow();\n  }\n  throw e;\n}","preventionTips":["Supply an [n] index for every nested array level","Flatten nested arrays in the schema when possible","Test paths against top-level unions and per-row schema variants","Enable 'Ignore missing paths' for mixed-version inputs"],"tags":["avro","array","schema","path-parsing"],"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"}