Skip to content

Feat: Add Apache Doris engine adapter with OLAP and Iceberg multi-catalog support - #6154

Open
brucearctor wants to merge 4 commits into
SQLMesh:mainfrom
brucearctor:feat/doris-engine-adapter
Open

brucearctor wants to merge 4 commits into
SQLMesh:mainfrom
brucearctor:feat/doris-engine-adapter

Conversation

@brucearctor

Copy link
Copy Markdown

Summary

Adds first-class Apache Doris (DorisEngineAdapter and DorisConnectionConfig) engine support to SQLMesh, including both native Doris OLAP tables (UNIQUE KEY Merge-on-Write, DUPLICATE KEY, AGGREGATE KEY) and Doris-backed Apache Iceberg multi-catalog tables (catalog.db.table / table_format = 'iceberg').

Closes #5875
Supersedes / builds upon #5033 (with Co-authored-by: xinge.ji <xinge.ji@outlook.com>)

Key Capabilities

  • Connection & Session Management (DorisConnectionConfig):
    • Connects via PyMySQL (sqlmesh[doris]) with autocommit=True and automatic cursor reconnect on transient MySQL-protocol disconnects (OperationalError 2006 / 2013 / 2055) when outside a transaction.
    • Supports catalog, session_variables (e.g., workload_group, enable_unique_key_partial_update), ssl, and configurable connect_timeout / read_timeout / write_timeout.
    • Registered in FORBIDDEN_STATE_SYNC_ENGINES with a clear configuration error guiding users to configure a dedicated state_connection.
  • Native Doris OLAP Table Models & Key Prefix Ordering:
    • Supports UNIQUE KEY (including INCREMENTAL_BY_UNIQUE_KEY auto-propagation, Merge-on-Write properties, and custom order_by sort keys), DUPLICATE KEY, and AGGREGATE KEY.
    • Automatically reorders OLAP key columns to the leading prefix of CREATE TABLE schemas and CTAS projections (_reorder_olap_columns) and ensures column index 0 is a valid Doris OLAP key type (never FLOAT, DOUBLE, ARRAY, MAP, STRUCT, JSON, or VARIANT).
  • Doris DeleteHandler & Logical Merge Semantics:
    • Rewrites DELETE FROM ... WHERE col IN (SELECT ...) (and CONCAT_WS composite keys from LogicalMergeMixin) into Doris's DELETE FROM target AS _t1 USING (...) AS _t2 WHERE ... syntax for UNIQUE KEY tables.
    • Provides automatic fallback to cardinality-aware batched literal DELETE (_delete_by_literal_keys) for DUPLICATE KEY, AGGREGATE KEY, and Iceberg tables without emitting OR or BETWEEN predicates rejected by Doris's DeleteHandler.
  • Partitioning (RANGE, LIST, Dynamic, AUTO PARTITION, and Iceberg Transforms):
    • Supports manual RANGE / LIST partitions, dynamic_partition.* properties, auto_partition (AUTO PARTITION BY RANGE (DATE_TRUNC(...)) ()), and Iceberg partition transforms (PARTITION BY LIST (day(ts), region) ()).
    • Extracts underlying base columns from partition transform expressions during insert_overwrite_by_partition.
  • Materialized Views (Async MTMV & Sync Rollup MV):
    • Supports both asynchronous multi-table materialized views (BUILD IMMEDIATE|DEFERRED, REFRESH ... ON MANUAL|COMMIT|SCHEDULE) and synchronized single-table rollup materialized views (materialized_type = 'SYNC').
  • Apache Iceberg & External Multi-Catalog (CatalogSupport.FULL_SUPPORT):
    • Supports 3-part catalog.db.table naming, SWITCH <catalog>, catalog-scoped information_schema.tables discovery, INSERT OVERWRITE TABLE for Iceberg full refresh, and safe view guards / environment_catalog_mapping support when targeting external catalogs.

Testing

  • Unit & Invariant Tests: 52 unit and parametrized invariant tests in tests/core/engine_adapter/test_doris.py and tests/core/test_connection_config.py.
  • Live Docker Integration Suite (apache/doris:fe-4.0.8 & apache/doris:be-4.0.8):
    • All shared engine integration tests in tests/core/engine_adapter/integration/test_integration.py (-m "doris", including test_sushi in full and dev_only modes, test_value_normalization, test_table_diff, test_alter_table, test_materialized_view, SCD Type 2, and incremental strategies) pass against Doris 4.0.8.
    • Doris-specific and local Iceberg multi-catalog integration tests in tests/core/engine_adapter/integration/test_integration_doris.py.

@brucearctor
brucearctor force-pushed the feat/doris-engine-adapter branch 2 times, most recently from c7d92a2 to 0b5eaea Compare October 18, 2026 23:55
…alog support

Closes SQLMesh#5875

Co-authored-by: xinge.ji <xinge.ji@outlook.com>
Signed-off-by: Bruce Arctor <5032356+brucearctor@users.noreply.github.com>
@brucearctor
brucearctor force-pushed the feat/doris-engine-adapter branch from 0b5eaea to 8a5ce1c Compare October 19, 2026 00:35
brucearctor and others added 3 commits October 18, 2026 17:54
…ris constraints

Co-authored-by: xinge.ji <xinge.ji@outlook.com>
Signed-off-by: Bruce Arctor <5032356+brucearctor@users.noreply.github.com>
…t-for-db.sh

Co-authored-by: xinge.ji <xinge.ji@outlook.com>
Signed-off-by: Bruce Arctor <5032356+brucearctor@users.noreply.github.com>
…s, and move MV tests to test_integration_doris

Co-authored-by: xinge.ji <xinge.ji@outlook.com>
Signed-off-by: Bruce Arctor <5032356+brucearctor@users.noreply.github.com>
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.

feat(engine): Add Doris engine support

1 participant