diff --git a/sqlmesh/integrations/dlt.py b/sqlmesh/integrations/dlt.py index a2202bea02..146c91b661 100644 --- a/sqlmesh/integrations/dlt.py +++ b/sqlmesh/integrations/dlt.py @@ -214,9 +214,7 @@ def generate_incremental_model( def format_config(configs: t.Dict[str, str], db_type: str) -> str: """Generate a string for the gateway connection config.""" - config = { - "type": db_type, - } + config: t.Dict[str, t.Any] = {} for key, value in configs.items(): if key == "password": @@ -226,6 +224,11 @@ def format_config(configs: t.Dict[str, str], db_type: str) -> str: else: config[key] = value + # Set db_type after iterating credentials so that credential attributes + # with a conflicting name (e.g. GCP service-account JSON contains + # "type": "service_account") cannot overwrite the connection type. + config["type"] = db_type + # Validate the connection config fields invalid_fields = [] try: diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 938f90cc74..eff00a907f 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -1020,8 +1020,8 @@ def test_dlt_pipeline(runner, tmp_path): gateways: duckdb: connection: - type: duckdb database: {dataset_path} + type: duckdb default_gateway: duckdb # --- Model Defaults ---