Skip to content

Commit 070ede2

Browse files
committed
Enhance Doris integration
1 parent 09a628f commit 070ede2

File tree

14 files changed

+229
-48
lines changed

14 files changed

+229
-48
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ risingwave-test: engine-risingwave-up
210210

211211
doris-test: engine-doris-up
212212
pytest -n auto -m "doris" --reruns 3 --junitxml=test-results/junit-doris.xml
213+
213214
#################
214215
# Cloud Engines #
215216
#################

docs/guides/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ These pages describe the connection configuration options for each execution eng
911911
* [Athena](../integrations/engines/athena.md)
912912
* [BigQuery](../integrations/engines/bigquery.md)
913913
* [Databricks](../integrations/engines/databricks.md)
914+
* [Doris](../integrations/engines/doris.md)
914915
* [DuckDB](../integrations/engines/duckdb.md)
915916
* [Fabric](../integrations/engines/fabric.md)
916917
* [MotherDuck](../integrations/engines/motherduck.md)
@@ -953,6 +954,7 @@ Unsupported state engines, even for development:
953954
* [ClickHouse](../integrations/engines/clickhouse.md)
954955
* [Spark](../integrations/engines/spark.md)
955956
* [Trino](../integrations/engines/trino.md)
957+
* [Doris](../integrations/engines/doris.md)
956958

957959
This example gateway configuration uses Snowflake for the data warehouse connection and Postgres for the state backend connection:
958960

docs/guides/connections.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ default_gateway: local_db
8181

8282
* [BigQuery](../integrations/engines/bigquery.md)
8383
* [Databricks](../integrations/engines/databricks.md)
84+
* [Doris](../integrations/engines/doris.md)
8485
* [DuckDB](../integrations/engines/duckdb.md)
8586
* [MotherDuck](../integrations/engines/motherduck.md)
8687
* [MySQL](../integrations/engines/mysql.md)

docs/integrations/engines/doris.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ MODEL (
139139
kind FULL,
140140
partitioned_by RANGE(event_date),
141141
physical_properties (
142-
partitioned_by_expr = (
142+
partitions = (
143143
'PARTITION `p2023` VALUES [("2023-01-01"), ("2024-01-01"))',
144144
'PARTITION `p2024` VALUES [("2024-01-01"), ("2025-01-01"))',
145145
'PARTITION `p2025` VALUES [("2025-01-01"), ("2026-01-01"))',

docs/integrations/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ SQLMesh supports the following execution engines for running SQLMesh projects (e
1616
* [BigQuery](./engines/bigquery.md) (bigquery)
1717
* [ClickHouse](./engines/clickhouse.md) (clickhouse)
1818
* [Databricks](./engines/databricks.md) (databricks)
19+
* [Doris](./engines/doris.md) (doris)
1920
* [DuckDB](./engines/duckdb.md) (duckdb)
2021
* [Fabric](./engines/fabric.md) (fabric)
2122
* [MotherDuck](./engines/motherduck.md) (motherduck)

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ nav:
8282
- integrations/engines/bigquery.md
8383
- integrations/engines/clickhouse.md
8484
- integrations/engines/databricks.md
85+
- integrations/engines/doris.md
8586
- integrations/engines/duckdb.md
8687
- integrations/engines/fabric.md
8788
- integrations/engines/motherduck.md

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ markers = [
272272
"pyspark: test for PySpark that need to run separately from the other spark tests",
273273
"trino: test for Trino (all connectors)",
274274
"risingwave: test for Risingwave",
275-
"doris: test for Doris",,
275+
"doris: test for Doris",
276276

277277
# Other
278278
"set_default_connection",

sqlmesh/core/engine_adapter/doris.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from sqlglot import exp, parse_one
88

9-
from sqlmesh.core.dialect import to_schema, transform_values
9+
from sqlmesh.core.dialect import to_schema
1010

1111
from sqlmesh.core.engine_adapter.base import (
1212
InsertOverwriteStrategy,
@@ -17,21 +17,21 @@
1717
PandasNativeFetchDFSupportMixin,
1818
)
1919
from sqlmesh.core.engine_adapter.shared import (
20+
CatalogSupport,
2021
CommentCreationTable,
2122
CommentCreationView,
2223
DataObject,
2324
DataObjectType,
2425
set_catalog,
2526
)
26-
from sqlmesh.core.schema_diff import SchemaDiffer
27-
from sqlmesh.utils import random_id, get_source_columns_to_types
27+
from sqlmesh.utils import random_id
2828
from sqlmesh.utils.errors import (
2929
SQLMeshError,
3030
)
3131

3232
if t.TYPE_CHECKING:
3333
from sqlmesh.core._typing import SchemaName, TableName
34-
from sqlmesh.core.engine_adapter._typing import QueryOrDF, Query
34+
from sqlmesh.core.engine_adapter._typing import QueryOrDF
3535
from sqlmesh.core.node import IntervalUnit
3636

3737
logger = logging.getLogger(__name__)
@@ -48,13 +48,18 @@ class DorisEngineAdapter(
4848
COMMENT_CREATION_VIEW = CommentCreationView.IN_SCHEMA_DEF_NO_COMMANDS
4949
MAX_TABLE_COMMENT_LENGTH = 2048
5050
MAX_COLUMN_COMMENT_LENGTH = 255
51-
SUPPORTS_REPLACE_TABLE = False
51+
SUPPORTS_INDEXES = True
52+
SUPPORTS_REPLACE_TABLE = False
5253
MAX_IDENTIFIER_LENGTH = 64
5354
SUPPORTS_MATERIALIZED_VIEWS = True
5455
SUPPORTS_MATERIALIZED_VIEW_SCHEMA = True
5556
SUPPORTS_CREATE_DROP_CATALOG = False
5657
INSERT_OVERWRITE_STRATEGY = InsertOverwriteStrategy.DELETE_INSERT
5758

59+
@property
60+
def catalog_support(self) -> CatalogSupport:
61+
return CatalogSupport.FULL_SUPPORT
62+
5863
def create_schema(
5964
self,
6065
schema_name: SchemaName,
@@ -289,7 +294,6 @@ def drop_view(
289294
"""
290295
Drop view in Doris.
291296
"""
292-
# Remove cascade from kwargs as Doris doesn't support it
293297
if materialized and kwargs.get("view_properties"):
294298
view_properties = kwargs.pop("view_properties")
295299
if view_properties.get("materialized_type") == "SYNC" and view_properties.get(
@@ -1116,4 +1120,4 @@ def _properties_to_expressions(self, properties: t.Dict[str, t.Any]) -> t.List[e
11161120
if not isinstance(value, exp.Expression):
11171121
value = exp.Literal.string(str(value))
11181122
expressions.append(exp.Property(this=exp.Literal.string(str(key)), value=value))
1119-
return expressions
1123+
return expressions

tests/core/engine_adapter/integration/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def pytest_marks(self) -> t.List[MarkDecorator]:
7777
IntegrationTestEngine("spark", native_dataframe_type="pyspark"),
7878
IntegrationTestEngine("clickhouse", catalog_types=["standalone", "cluster"]),
7979
IntegrationTestEngine("risingwave"),
80+
IntegrationTestEngine("doris"),
8081
# Cloud engines that need paid accounts / special credentials
8182
IntegrationTestEngine("clickhouse_cloud", cloud=True),
8283
IntegrationTestEngine("redshift", cloud=True),
@@ -448,7 +449,7 @@ def get_table_comment(
448449
AND pgc.relkind = '{"v" if table_kind == "VIEW" else "r"}'
449450
;
450451
"""
451-
elif self.dialect in ["mysql", "snowflake"]:
452+
elif self.dialect in ["mysql", "snowflake", "doris"]:
452453
# Snowflake treats all identifiers as uppercase unless they are lowercase and quoted.
453454
# They are lowercase and quoted in sushi but not in the inline tests.
454455
if self.dialect == "snowflake" and snowflake_capitalize_ids:
@@ -458,6 +459,7 @@ def get_table_comment(
458459
comment_field_name = {
459460
"mysql": "table_comment",
460461
"snowflake": "comment",
462+
"doris": "table_comment",
461463
}
462464

463465
query = f"""
@@ -563,7 +565,7 @@ def get_column_comments(
563565
AND pgc.relkind = '{"v" if table_kind == "VIEW" else "r"}'
564566
;
565567
"""
566-
elif self.dialect in ["mysql", "snowflake", "trino"]:
568+
elif self.dialect in ["mysql", "snowflake", "trino", "doris"]:
567569
# Snowflake treats all identifiers as uppercase unless they are lowercase and quoted.
568570
# They are lowercase and quoted in sushi but not in the inline tests.
569571
if self.dialect == "snowflake" and snowflake_capitalize_ids:
@@ -574,6 +576,7 @@ def get_column_comments(
574576
"mysql": "column_comment",
575577
"snowflake": "comment",
576578
"trino": "comment",
579+
"doris": "column_comment",
577580
}
578581

579582
query = f"""

tests/core/engine_adapter/integration/config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ gateways:
118118
host: {{ env_var('DOCKER_HOSTNAME', 'localhost') }}
119119
port: 4566
120120
check_import: false
121+
inttest_doris:
122+
connection:
123+
type: doris
124+
host: {{ env_var('DOCKER_HOSTNAME', 'localhost') }}
125+
port: 9030
126+
user: root
127+
password: ""
128+
check_import: false
129+
state_connection:
130+
type: duckdb
121131

122132

123133
# Cloud databases

0 commit comments

Comments
 (0)