trilogy-data / trilogy-data/pytrilogy

Unnest Improvements

Open
#208 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
61
Forks
3
Avg merge
7h 18m
Merged PRs (30d)
43

Description

Problem Statement

Handing of the output of an unnest is unclear currently, because it's assumed to come out to the grain of the unnest value, but that may not be unique.

Proposed Solution

We can rationalize different handling by having unnest output a struct of the form value, index - for example in duckdb by including generate_subscripts(l, 1) AS index - and assigning the unnest value as a property of the index.

This would enable someone to do select sum(unnest(x)) properly and count properly.

Alternatives Considered

Please briefly describe which alternatives, if any, have been considered, including merits of alternate approaches and
tradeoffs being made.

Additional Context

Please provide any other information that may be relevant.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the existing unnest handling and its tests, then compare the current grain and aggregation behavior with the proposed value-and-index semantics. Done means the behavior is specified clearly and sum and count over unnest results work consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sql
Domain
data, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.