Skip to content

Two tables differing only by qualifier collapse into one alias, silently dropping an alias #292

Description

@fupelaqu

From.tableAliases is keyed by table.name, so two tables in one FROM that differ only by their quoted qualifier strip to the same bare index name and the ListMap keeps only the last entry.

Measured

SELECT a FROM "prod_us".orders o, "prod_eu".orders p
  => From.tableAliases = ListMap(orders -> p)      alias `o` is silently gone

With o missing from the alias map, Identifier.update cannot resolve o.a: the name stays o.a and the query asks Elasticsearch for a field literally named o.a, which matches nothing. No error is raised.

Why it matters

This is the shape cross-cluster federation exists for — the same index name in two clusters — and it is the first thing a consumer of the qualifier information will write. The double-quoted spelling reaches it today; the backtick and JOIN spellings become reachable once quoted table names are supported.

Fix

Key the alias maps by the table's qualified reference where, and only where, the bare name is ambiguous — i.e. when one FROM uses that bare index name for more than one distinct qualified reference. Keying every qualified table by its qualified name unconditionally was measured to break consumers that legitimately look a table up by its bare index name (Identifier.table, and downstream softclient4es-extensions' materialized-view planner) for statements that work today.

SingleSearch.sources — the indices actually read — must not change.

Anything inside the sql module that compares Identifier.table against an index name has to speak the same key language, since Identifier.table is an alias-map key: TemporalLiterals' cross-index join-leg guard built its set from the bare join-source names and needs the same keying.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions