Skip to content

feat(ers): add postgres_object_array output transformation for multi-strategy ERS #3813

Description

@ryanulit

Summary

Follow-up of #3802, adding support for an array of Postgres JSON/JSONB objects from a query result.

Add a new postgres_object_array output transformation to the multi-strategy entity resolution service (service/entityresolution/multi-strategy/output_mapper.go) that converts a Postgres JSON/JSONB array-of-objects query result into a []map[string]any.

Postgres drivers may return JSON/JSONB array values as []byte, string, an already-parsed []map[string]any, or a []any whose elements are individually decodable as objects. Today, the output mapper has no dedicated transformation for these values, which forces awkward downstream handling when a mapping needs to surface a JSON/JSONB array column as a list of structured claims.

Motivation

When using a SQL-based provider in the multi-strategy ERS with a Postgres source, columns of type json/jsonb that hold an array of objects come back in one of several shapes depending on the driver. Consumers of the mapped claims expect a structured list of objects, not a raw byte slice, JSON-encoded string, or a []any of mixed shapes. A first-class postgres_object_array transformation removes that impedance mismatch and keeps mapping configuration declarative, mirroring the existing postgres_object transformation for single objects.

Proposed Behavior

Add postgres_object_array to the transformation switch in OutputMapper.applyTransformation:

  • nil[]map[string]any{} (empty array)
  • []map[string]any → returned as-is (nil-safe: nil returns []map[string]any{})
  • []any → each element is converted via transformPostgresObject; per-element errors are wrapped with the element index
  • []bytejson.Unmarshal into []map[string]any; empty slice returns []
  • stringjson.Unmarshal into []map[string]any; empty string returns []
  • any other type → error with the concrete type in the message

Errors from json.Unmarshal are wrapped with context indicating the source type ([]byte vs string). Per-element conversion errors on []any inputs include the failing index.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp:coreCore componentenhancementNew feature or requestgoPull requests that update Go code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions