Skip to content

Prioritize default schema/database when resolving ambiguous name-only ref() calls #22

@ihistand

Description

@ihistand

What

When a name-only ref() / resolve() / .dependencies() reference matches multiple actions in different schemas or databases, prefer the single candidate in the project's defaultDatabase / defaultSchema instead of failing with "Ambiguous Action name". If no single candidate matches the defaults, the ambiguity error is preserved (still listing all candidates).

Why

Ports the behavior requested upstream in dataform-co/dataform#2146: deploying the same set of views to multiple databases (e.g. staging and production) currently forces fully-qualified refs everywhere.

This scenario is arguably more common in sqlanvil than in BigQuery-land — in Postgres, the same action name in multiple schemas of one database (e.g. staging.users and public.users) is a routine layout.

Scope

  • Session.resolve() and dependency fully-qualification tie-break using project defaults, narrowing only on qualification levels the reference omitted (database first, then schema).
  • CLI action filters (matchPatterns) and the JIT runtime context are intentionally unchanged — they operate on selectors / already-qualified targets, not compile-time ref() resolution.
  • Disambiguation is silent: the codebase has no compile-warning facility, only compileError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions