Type Definitions
Relevant source files
The following files were used as context for generating this wiki page:
- src/flext_dbt_oracle/typings.py
- src/flext_dbt_oracle/models.py
- src/flext_dbt_oracle/utilities.py
- tests/typings.py
- rules.json
- src/flext_dbt_oracle/settings.py (Inferred from project structure and imports in
utilities.py)
Type Definitions in the flext-dbt-oracle project provide a structured and type-safe foundation for dbt (data build tool) workflows targeting Oracle databases. This module utilizes Method Resolution Order (MRO) composition to integrate types from parent namespaces, specifically combining Meltano and Oracle database type definitions.
The system ensures consistency across model metadata, connection configurations, and data payloads. By centralizing these definitions, the project facilitates robust validation of SQL models, database interactions, and integration pipeline results.
Architecture and Hierarchy
The type system is built on a hierarchical facade that inherits from multiple base libraries. The primary entry point, FlextDbtOracleTypes, acts as a bridge between general data integration types (via flext-meltano) and specific database types (via flext-db-oracle).
The diagram shows the MRO composition of the primary type facade.
Sources: src/flext_dbt_oracle/typings.py:16-19
Core Domain Types
The project defines specific aliases for handling Oracle data payloads, ensuring that data moving through the pipeline adheres to JSON-compatible mapping structures.
| Type Alias | Base Type | Description |
|---|---|---|
OraclePayload | t.JsonMapping | A single record or data unit represented as a JSON mapping. |
OraclePayloadList | t.SequenceOf[OraclePayload] | A collection of records used in batch operations or extractions. |
Sources: src/flext_dbt_oracle/typings.py:22-25
Model and Data Structure Definitions
The flext-dbt-oracle project implements complex data structures for dbt model metadata and database connections using Pydantic-based models. These models provide runtime validation and computed properties.
dbt Model Metadata
The Model class encapsulates all necessary information to define a dbt model within an Oracle environment, including its materialization strategy and dependencies.
Structure of the dbt model metadata payload.
Sources: src/flext_dbt_oracle/models.py:23-56
Oracle Connection Types
The OracleConnectionConfig model defines the required fields and logic for establishing connectivity to an Oracle instance. It includes support for both Service Names and SIDs.
| Field | Type | Description |
|---|---|---|
host | str | Database host address. |
port | t.PortNumber | Connection port (defaults to 1521). |
username | str | Database user identity. |
password | str | t.SecretStr | Secure password storage. |
service_name | str | Oracle service identifier. |
sid | str | None | Optional Oracle System ID. |
protocol | str | Connection protocol (e.g., tcp, tcps). |
Sources: src/flext_dbt_oracle/models.py:82-109
SQL Dialect and Mapping
The project maintains a strict mapping between dbt-standard types and Oracle-specific SQL types to ensure compatible materialization.
| dbt / Generic Type | Oracle SQL Type |
|---|---|
string | VARCHAR2(4000) |
text | CLOB |
integer | NUMBER(38,0) |
boolean | NUMBER(1,0) |
timestamp | TIMESTAMP |
timestamptz | TIMESTAMP WITH TIME ZONE |
float | BINARY_DOUBLE |
Sources: rules.json:62-78
Test-Specific Type Extensions
To support rigorous validation, the project includes a testing type namespace that merges production types with test-specific aliases.
class TestsFlextDbtOracleTypes(FlextTestsTypes, FlextDbtOracleTypes):
"""Test types combining FlextTestsTypes with flext-dbt-oracle types."""
class DbtOracle(FlextDbtOracleTypes.DbtOracle):
"""DbtOracle test types namespace."""
class Tests:
"""Test-specific type aliases."""
Sources: tests/typings.py:15-23
Summary
Type Definitions in flext-dbt-oracle serve as the contract for data integrity across the dbt-to-Oracle pipeline. By leveraging a facade architecture, the project provides a unified t namespace that covers everything from low-level Oracle payload mappings to high-level dbt model configurations and connection string generation. This structure supports automated metadata generation, such as the ModelGenerator which creates staging models dynamically based on source table names.
Sources: src/flext_dbt_oracle/models.py:58-79, src/flext_dbt_oracle/typings.py:1-29