Skip to content

Handle relation metadata column names case-insensitively - #57

Open
tom-ph wants to merge 1 commit into
IBM:mainfrom
tom-ph:fix-list-relations-column-casing
Open

tom-ph wants to merge 1 commit into
IBM:mainfrom
tom-ph:fix-list-relations-column-casing

Conversation

@tom-ph

@tom-ph tom-ph commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Resolve the metadata columns returned by list_relations_without_caching case-insensitively.

Some Netezza environments or drivers preserve unquoted column aliases as lowercase or mixed-case values. The adapter currently assumes that the result columns are always named DATABASE, SCHEMA, NAME, and TYPE.

Because Agate column selection is case-sensitive, this causes list_relations_without_caching to fail when the driver returns names such as database, schema, name, and type.

Changes

  • Build a case-insensitive mapping of the result column names.
  • Select the original column names returned by the driver.
  • Raise a descriptive CompilationError when one or more expected metadata columns are missing.
  • Add a unit test covering uppercase, lowercase, and mixed-case column names.

Reproduction

The issue occurs when the result of the list_relations_without_caching macro has column names such as:

database
schema
name
type

instead of:

DATABASE
SCHEMA
NAME
TYPE

The existing implementation calls:

results.select(["DATABASE", "SCHEMA", "NAME", "TYPE"])

which fails because Agate column selection is case-sensitive.

Testing

tox -e py311 -- tests/unit/test_adapter.py -k list_relations

Signed-off-by: Fougier Tommaso <ICTTF0@MIL.ESSELUNGA.NET>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant