Skip to content

Fix Trino parameterized type mapping - #7672

Open
nmurrell07 wants to merge 2 commits into
getredash:masterfrom
nmurrell07:fix-trino-parameterized-types
Open

Fix Trino parameterized type mapping#7672
nmurrell07 wants to merge 2 commits into
getredash:masterfrom
nmurrell07:fix-trino-parameterized-types

Conversation

@nmurrell07

Copy link
Copy Markdown

Trino columns with parameterized types like timestamp(0) or decimal(10,2) were not being mapped correctly because TRINO_TYPES_MAPPING only contains base type keys without parameters.

This fix adds a _map_trino_type helper function that:

  1. First tries direct lookup in TRINO_TYPES_MAPPING
  2. If not found and the type contains parentheses, strips the parameters and looks up just the base type (e.g., 'timestamp' from 'timestamp(0)')
  3. Returns None if no mapping is found

This ensures columns with parameterized types are correctly mapped to their Redash equivalents.

Trino columns with parameterized types like timestamp(0) or decimal(10,2) were
not being mapped correctly because TRINO_TYPES_MAPPING only contains base type
keys without parameters.

This fix adds a _map_trino_type helper function that:
1. First tries direct lookup in TRINO_TYPES_MAPPING
2. If not found and the type contains parentheses, strips the parameters
   and looks up just the base type (e.g., 'timestamp' from 'timestamp(0)')
3. Returns None if no mapping is found

This ensures columns with parameterized types are correctly mapped to their
Redash equivalents.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown

Greptile Summary

The PR fixes Redash type detection for parameterized Trino column types by retrying failed mappings with the type parameters removed.

  • Adds _map_trino_type with direct, parameter-stripped, and unknown-type paths.
  • Uses the helper when translating Trino cursor metadata into Redash columns.

Confidence Score: 5/5

The PR appears safe to merge because parameterized types now resolve through their existing base-type mappings without changing unsupported-type behavior.

The helper preserves exact mappings first, safely handles None, strips only parameters after a failed lookup, and is called with the Trino driver's string type codes.

Important Files Changed

Filename Overview
redash/query_runner/trino.py Correctly normalizes parameterized cursor type names while preserving direct mappings and existing unknown-type behavior.

Reviews (1): Last reviewed commit: "Merge branch 'master' into fix-trino-par..." | Re-trigger Greptile

@yoshiokatsuneo

yoshiokatsuneo commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@nmurrell07

Can you fix the lint error by running black ?

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.

2 participants