Core Constants
Relevant source files
The following files were used as context for generating this wiki page:
Core Constants in the flext-dbt-oracle project provide a centralized Single Source of Truth (SSOT) for dbt-specific defaults, Oracle database connection parameters, and SQL dialect rules. These constants ensure consistency across model generation, connection management, and data transformation workflows within the Oracle ecosystem.
The system utilizes a hierarchical inheritance structure, where FlextDbtOracleConstants (aliased as c) inherits from both flext_db_oracle and flext_meltano constants. This allows the adapter to leverage base Oracle database logic while extending it with specific dbt materialization strategies and environment defaults.
Sources: src/flext_dbt_oracle/constants.py:12-14, src/flext_dbt_oracle/models.py:17-18, rules.json:10-15
Constant Hierarchy and Architecture
The constants are organized into nested namespaces within the FlextDbtOracleConstants class. This structure separates Oracle connection defaults from dbt-specific runtime configurations and model classification logic.
The diagram shows the inheritance from the base Oracle library and the internal namespacing used for logical separation of concerns.
Sources: src/flext_dbt_oracle/constants.py:12-25
Oracle Connection Defaults
These constants define the standard parameters for establishing connections to Oracle databases. They are primarily used in the OracleConnectionConfig model and the test_connection utility.
| Constant | Value | Description |
|---|---|---|
DEFAULT_HOST | LOCALHOST | Default database host (derived from flext-db-oracle) |
DEFAULT_PORT | 1521 | Standard Oracle TNS Listener port |
DEFAULT_SERVICE_NAME | "XEPDB1" | Default Oracle PDB service name |
DEFAULT_PROTOCOL | "tcp" | Default communication protocol |
NLS_LANG | "AMERICAN_AMERICA.AL32UTF8" | National Language Support environment setting |
NLS_DATE_FORMAT | "YYYY-MM-DD" | Default date format for sessions |
Sources: src/flext_dbt_oracle/constants.py:20-25, src/flext_dbt_oracle/constants.py:53-54, rules.json:115-123
dbt Runtime and Materialization Constants
The DbtOracle.Dbt namespace contains constants that govern how dbt behaves during execution, specifically focusing on target environments and materialization strategies.
Materialization Strategies
The system defines a Materialization StrEnum to enforce type safety for dbt model materialization.
- TABLE: Standard table creation.
- VIEW: Virtual table (default).
- INCREMENTAL: Upsert/Merge logic for delta processing.
- SNAPSHOT: Type-2 Slowly Changing Dimension (SCD) support.
Sources: src/flext_dbt_oracle/constants.py:32-41, rules.json:44-51
Execution Environment
| Constant | Value | Description |
|---|---|---|
DEFAULT_TARGET | "dev" | Default dbt profile target |
DEFAULT_PROFILES_DIR | "." | Default directory for profiles.yml |
DEFAULT_MATERIALIZATION | Materialization.VIEW | Fallback materialization for new models |
Sources: src/flext_dbt_oracle/constants.py:43-45
Dialect and Feature Rules
Defined primarily in rules.json, these constants dictate the SQL generation behavior for the Oracle adapter.
The configuration ensures that identifiers are handled in standard Oracle uppercase and supports modern SQL features like Lateral Joins and Analytic functions.
Sources: rules.json:34-42, rules.json:76-86
Model Generation Constants
Constants used by the ModelGenerator to produce deterministic staging models.
- DEFAULT_MODEL_TYPE:
"staging"- The default classification for generated dbt models. - DEFAULT_SOURCE_NAME:
"oracle"- The name used in the{{ source() }}macro within SQL files. - DEFAULT_SCHEMA_NAME:
"public"- The default schema when none is specified. - PERFORMANCE_RECOMMENDATION_THRESHOLD:
20- A numeric threshold used to trigger performance suggestions during modeling.
Sources: src/flext_dbt_oracle/constants.py:47-52, src/flext_dbt_oracle/models.py:30-40
Testing Constants
Test-specific constants extend the core constants to provide environment-aware paths and depth for unit testing.
class TestsFlextDbtOracleConstants(FlextTestsConstants, FlextDbtOracleConstants):
class DbtOracle(FlextDbtOracleConstants.DbtOracle):
class Tests:
PROJECT_ROOT_PARENT_DEPTH: Final[int] = 1
SRC_DIR: Final[str] = "src"
PACKAGE_DIR: Final[str] = "flext_dbt_oracle"
Sources: tests/constants.py:19-32
Summary
The Core Constants of flext-dbt-oracle establish a rigid yet extensible framework for Oracle-based dbt workflows. By namespacing connection defaults, materialization enums, and SQL dialect rules, the project ensures that dbt models generated for Oracle are compliant with database constraints while maintaining compatibility with the broader flext ecosystem.