Skip to content

content: Implement getDistinctFieldValues #1413

Description

@grigasp

Goal: Replace the stub with a self-contained single-field DISTINCT query. This phase both builds and executes, returning AsyncIterable<Value> directly — no descriptor, no ContentItem, no base join shape.

Work

  1. Build: from the PropertyField/CalculatedField, build a minimal FROM + just the JOINs needed to reach that one field's class (from its pathFromTarget), per target. Apply the target filter and value filters (reuse the shared target-filter helper extracted in content: Shared base-query builder (FROM / JOIN / WHERE) #1409). SELECT DISTINCT the field's column ($->[Prop] for property fields, the expression for calculated).
  2. Execute: for multi-target, run one query per target and merge their streams (rxjs mergeMap, mirroring ResolveContentSources.ts); de-duplicate across targets when the same raw value appears for more than one. Use createQueryReader(query, { rowFormat: "Indexes" }) with finalize(() => reader.return?.()) for cancellation, consistent with Stage 1.
  3. Yield raw Values as an AsyncIterable (no formatting — formatting/grouping is the consumer's job). The optional reduce-style grouping utility (formatter → Map<formatted, raw[]>) noted in the design can land here if not already present.

Tests: distinct over direct + related field; filter application; multi-target merge + cross-target de-dup; raw (unformatted) output; reader cancellation frees resources.

Dependencies: shared target-filter helper from #1409.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions