Skip to content

Conversation

@rory-data
Copy link

@rory-data rory-data commented Dec 19, 2025

This pull request adds support for importing Teradata SQL DDL files into ODCS data contracts, while also improving typing, fixing linter issues, and simplifying code in the SQL importer module.

Key Changes:

  • Added Teradata dialect support with mapping for Teradata-specific types (BYTEINT, BYTE, VARBYTE, INTERVAL types)

  • Improved type annotations throughout sql_importer.py and odcs_helper.py using modern Python typing syntax (e.g. dict[str, str] instead of Dict[str, str])

  • Refactored code for better maintainability using match statements and simplified conditionals

  • Tests pass

  • ruff format

  • README.md updated (if relevant)

  •  CHANGELOG.md entry added

Copilot AI review requested due to automatic review settings December 19, 2025 08:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for importing Teradata SQL DDL files into ODCS data contracts, while also improving typing, fixing linter issues, and simplifying code in the SQL importer module.

Key Changes:

  • Added Teradata dialect support with mapping for Teradata-specific types (BYTEINT, BYTE, VARBYTE, INTERVAL types)
  • Improved type annotations throughout sql_importer.py and odcs_helper.py using modern Python typing syntax (e.g., dict[str, str] instead of Dict[str, str])
  • Refactored code for better maintainability using match statements and simplified conditionals

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
datacontract/imports/sql_importer.py Main implementation: Added Teradata support, improved typing, refactored helper functions with match statements, enhanced error handling
datacontract/imports/odcs_helper.py Updated type annotations to use modern Python syntax (PEP 604 union types), improved parameter defaults
tests/test_import_sql_unit.py New comprehensive unit tests for SQL importer helper functions including Teradata BYTEINT type
tests/test_import_sql_integration.py New integration tests for end-to-end SQL import functionality
tests/test_import_sql_teradata.py New Teradata-specific tests validating DDL import and type mappings
tests/fixtures/teradata/import/ddl.sql Test fixture with comprehensive Teradata data types
tests/fixtures/teradata/data/data_constraints.sql Test fixture with NOT NULL constraints and table comments
pyproject.toml Formatting cleanup: collapsed multi-line dependency arrays to single lines
.pre-commit-config.yaml Fixed ruff hook ID from 'ruff' to 'ruff-check'

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"""Helper functions for creating ODCS (OpenDataContractStandard) objects."""

from typing import Any, Dict, List
from __future__ import annotations
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Author

Choose a reason for hiding this comment

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

The annotations import was added to resolve test failures due to the introduction of the | option type hint. Have just tested again with that commented out to reproduce the original test error, but it looks like a subsequent commit has removed the need for it altogether as the tests are passing.

@@ -1,9 +1,17 @@
"""SQL importer for data contracts.
Copy link
Contributor

Choose a reason for hiding this comment

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

This doc does not help

Copy link
Author

Choose a reason for hiding this comment

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

The callout on the generated docstrings quality is fair; a good reminder to not let a bad habit form there.

Copy link
Contributor

@jochenchrist jochenchrist left a comment

Choose a reason for hiding this comment

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

Sorry, this PR is not reviewable.

AI added too many obvious comments, and made refactorings that are not relevant to the actual teradata change.

@rory-data
Copy link
Author

Thanks for the feedback, @jochenchrist. This was my first contribution PR (outside of work) so I admittedly have my training wheels on. As you've suggested, I've likely gone a step or two too far; I'm still learning the etiquette of contributing.

My additional changes were in three areas:

  • Primarily resolving issues that my typer was calling out
  • I have some fairly opinionated Ruff rules defined on my local (including pyupgrade (UP)) which made additional changes during pre-commit's ruff check --fix.
  • I also tried adding some simplifications, map_type_from_sql being the big one.

If you prefer that I pare it back to just adding Teradata as an import dialect and handling its type mapping, I'd be happy to do that. 👍🏻

@jochenchrist
Copy link
Contributor

If you prefer that I pare it back to just adding Teradata as an import dialect and handling its type mapping, I'd be happy to do that. 👍🏻

To be honest, I would appreciate that.

status: draft
servers:
- server: teradata
type: teradata
Copy link
Contributor

Choose a reason for hiding this comment

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

The type teradata is not part of the supported types in ODCS (see https://bitol-io.github.io/open-data-contract-standard/latest/infrastructure-servers/). We would need to add that to the standard. Until then, you have to use custom, and use a custom property to specify the serverType:

server: teradata
type: custom
customProperties:
- property: customType
  value: teradata

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.

3 participants