Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Mage ai Mage ai Teradata Source

From Leeroopedia


Knowledge Sources
Domains Data_Integration, Teradata, Source_Connector, SQL_Based
Last Updated 2026-02-09 00:00 GMT

Overview

Concrete tool for extracting data from Teradata database tables provided by the Mage integrations source connector framework.

Description

The Teradata source connector extends the SQL-based Source class (mage_integrations.sources.sql.base.Source) to implement data extraction from Teradata databases. It connects through a TeradataConnection wrapper using host, port (default 1025), database, username, and password, with verbosity toggled off during discovery modes. Discovery queries Teradata's DBC.ColumnsV and DBC.TablesV views to enumerate columns, filtering out procedure objects (TableKind <> 'P'). Teradata's two-character column type codes are mapped to standard SQL type names via a comprehensive COLUMN_TYPE_MAPPING dictionary covering 50+ type codes (e.g., CF for CHAR, I for INTEGER, TS for TIMESTAMP, F for FLOAT, JN for JSON). These mapped types are then converted to Singer schema types: boolean, integer, numeric/decimal/float, datetime/timestamp (string with datetime format), JSON/variant (object), UUID, and string as the default. Primary key and unique constraints are tracked. Column names in SQL queries are wrapped in double quotes. The connector implements Teradata-specific pagination using QUALIFY ROW_NUMBER() OVER (ORDER BY ...) with BETWEEN syntax, requiring explicit order-by columns. The _order_by_query_string() returns an empty string since ordering is handled within the QUALIFY clause. Datetime conversion truncates timezone parts and reformats values using dateutil.parser. The replication method is full-table.

Usage

Use this source connector when building a Mage data pipeline that needs to extract data from Teradata. Configure with host, database, username, password, and optionally port.

Code Reference

Source Location

  • Repository: mage-ai
  • File: mage_integrations/mage_integrations/sources/teradata/__init__.py
  • Lines: 1-255

Signature

class Teradata(Source):
    def build_table_name(self, stream) -> str:
        ...
    def build_connection(self) -> TeradataConnection:
        ...
    def build_discover_query(self, streams: List[str] = None):
        ...
    def convert_datetime(self, val):
        ...
    def column_type_mapping(self, column_type: str, column_format: str = None) -> str:
        ...
    def discover(self, streams: List[str] = None) -> Catalog:
        ...
    def update_column_names(self, columns: List[str]) -> List[str]:
        ...
    def _limit_query_string(self, limit, offset, order_by_columns: List = None):
        ...
    def _order_by_query_string(self, order_by_columns):
        ...

Import

from mage_integrations.sources.teradata import Teradata

I/O Contract

Inputs

Name Type Required Description
config dict Yes Configuration dictionary with Teradata connection settings
catalog Catalog No Singer catalog specifying streams to extract
state dict No Previous sync state for incremental extraction

Configuration Parameters

Name Type Required Description
host str Yes Teradata database host address
port int No Teradata database port (defaults to 1025)
database str Yes Teradata database name
username str Yes Database username
password str Yes Database password

Outputs

Name Type Description
catalog Catalog Discovered tables with schemas from DBC.ColumnsV metadata (from discover())
records Generator[List[Dict]] Batches of extracted records via SQL queries with QUALIFY pagination (inherited from SQL base Source)

Usage Examples

from mage_integrations.sources.teradata import Teradata

config = {
    "host": "teradata.example.com",
    "port": 1025,
    "database": "my_database",
    "username": "admin",
    "password": "password123",
}

source = Teradata(config=config)

# Discover available streams
catalog = source.discover()

# Test connection via inherited test_connection() from SQL base Source

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment