Skip to content

Add Trino import and check its physical types - #1441

Merged
andredlng merged 1 commit into
mainfrom
import-trino
Jul 28, 2026
Merged

Add Trino import and check its physical types#1441
andredlng merged 1 commit into
mainfrom
import-trino

Conversation

@andredlng

Copy link
Copy Markdown
Collaborator

Summary

Adds datacontract import trino, and fixes a silent hole in Trino testing found while building it.

datacontract import trino --source localhost --catalog my_catalog --schema my_schema --output datacontract.yaml

The guide previously said: run SHOW CREATE TABLE, save the DDL, import it with the postgres dialect, then fill in a servers block of placeholder values.

Trino physical type checks never ran

_CATALOG_STRATEGY mapped Trino to the information_schema reader, which selects character_maximum_length, numeric_precision and numeric_scale. Trino's information_schema.columns has none of those — it has eight columns and no length or precision at all:

table_catalog, table_schema, table_name, column_name,
ordinal_position, column_default, is_nullable, data_type

So the query failed with COLUMN_NOT_FOUND, _rows() swallowed it, and the check was skipped with a debug log nobody sees.

Demonstrated against a real Trino. A contract declaring order_id as integer when the column is varchar(36):

strategy result
before (information_schema) 🟢 passes — check silently skipped
after (full_type) 🔴 expected physical type 'integer' but the column is 'varchar(36)'

Trino's data_type is already a complete type string, the same shape Athena reports, so both now share that reader — renamed from _read_athena to _read_full_type_information_schema since it is no longer Athena-specific.

Verified against a real Trino

Import followed by datacontract test on the unedited file: 12/12 checks passed, with the types taken verbatim:

varchar(36)   decimal(10,2)   integer   timestamp(3)   array(varchar)   varchar

Those physical type checks are now genuinely evaluated rather than skipped.

Testing

tests/test_import_trino.py — 9 tests against a real Trino container, reusing the container helper the existing suite defines. One pins the fix directly: a wrong physicalType must now fail. The existing Trino suites pass unchanged (17 tests total).

Docs

New imports/trino.md; testing/trino.md gets the one-command step 3, step 2 renamed to "Authenticate", and step 4 now shows the check table like the other guides instead of only the summary line.

Create a data contract from a Trino catalog with `datacontract import trino`,
replacing a recipe that told users to run SHOW CREATE TABLE, import the DDL as
postgres, and then fill in a placeholder servers block by hand.

Trino physical type checks never ran: its information_schema has no
character_maximum_length, numeric_precision or numeric_scale, so the catalog
query failed with COLUMN_NOT_FOUND, the failure was swallowed, and a wrong
physicalType still passed. Its data_type is already a complete type string, the
same shape Athena reports, so both now use that reader.
@andredlng andredlng self-assigned this Jul 28, 2026
@github-actions

Copy link
Copy Markdown

📖 Docs preview

Preview site: https://brave-water-0cee36e03-1441.westeurope.7.azurestaticapps.net

Changed pages (most-changed first):

@andredlng
andredlng merged commit b15b920 into main Jul 28, 2026
16 checks passed
@andredlng
andredlng deleted the import-trino branch July 28, 2026 12:55
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