-
Notifications
You must be signed in to change notification settings - Fork 190
Feature: Add Teradata SQL importer #986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature: Add Teradata SQL importer #986
Conversation
…commands from legacy; resolving linting and typing errors
There was a problem hiding this 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 ofDict[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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
jochenchrist
left a comment
There was a problem hiding this 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.
|
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:
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 |
There was a problem hiding this comment.
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
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.pyandodcs_helper.pyusing modern Python typing syntax (e.g.dict[str, str]instead ofDict[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