Skip to content

docs: document Compiler shared-state semantics (attrs.evolve + _subqueries) #47

@dtsong

Description

@dtsong

Problem

base.py:260 uses attrs.evolve(compiler, root=False) which produces a shallow copy. Child compilers share _subqueries, _table_context, and _counter with their parent. This is intentional — CTEs bubble up from nested compiles to the root WITH clause — but completely undocumented.

Any future change assuming evolve gives isolation will introduce bugs.

Scope

Add docstring/comments to:

  • Compiler class explaining the shared-state contract
  • attrs.evolve call site explaining why shallow copy is intentional
  • _subqueries dict explaining the CTE bubbling mechanism

Key Files

  • data_diff/databases/base.py:127 (_subqueries)
  • data_diff/databases/base.py:260 (evolve call)

Acceptance Criteria

  • Compiler shared-state semantics documented in code
  • Future contributors understand the isolation boundary

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumMedium priority, next 1-2 monthsdocumentationImprovements or additions to documentationtriage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions