2020 TableNamingConvention,
2121 VirtualEnvironmentMode,
2222)
23- from sqlmesh.core.config.base import BaseConfig, UpdateStrategy, DbtConfigInfo
23+ from sqlmesh.core.config.base import BaseConfig, UpdateStrategy
2424from sqlmesh.core.config.common import variables_validator, compile_regex_mapping
2525from sqlmesh.core.config.connection import (
2626 ConnectionConfig,
3737from sqlmesh.core.config.linter import LinterConfig as LinterConfig
3838from sqlmesh.core.config.plan import PlanConfig
3939from sqlmesh.core.config.run import RunConfig
40+ from sqlmesh.core.config.dbt import DbtConfig
4041from sqlmesh.core.config.scheduler import (
4142 BuiltInSchedulerConfig,
4243 SchedulerConfig,
@@ -99,8 +100,6 @@ class Config(BaseConfig):
99100 default_test_connection: The default connection to use for tests if one is not specified in a gateway.
100101 default_scheduler: The default scheduler configuration to use if one is not specified in a gateway.
101102 default_gateway: The default gateway.
102- state_schema_naming_pattern: A pattern supporting variable substitutions to determine the state schema name, rather than just using 'sqlmesh'.
103- Only applies when the state schema is not explicitly set in the gateway config
104103 notification_targets: The notification targets to use.
105104 project: The project name of this config. Used for multi-repo setups.
106105 snapshot_ttl: The period of time that a model snapshot that is not a part of any environment should exist before being deleted.
@@ -133,7 +132,6 @@ class Config(BaseConfig):
133132 before_all: SQL statements or macros to be executed at the start of the `sqlmesh plan` and `sqlmesh run` commands.
134133 after_all: SQL statements or macros to be executed at the end of the `sqlmesh plan` and `sqlmesh run` commands.
135134 cache_dir: The directory to store the SQLMesh cache. Defaults to .cache in the project folder.
136- dbt_config_info: Dbt-specific properties (such as profile and target) for dbt projects loaded by the dbt loader
137135 """
138136
139137 gateways: GatewayDict = {"": GatewayConfig()}
@@ -143,7 +141,6 @@ class Config(BaseConfig):
143141 )
144142 default_scheduler: SchedulerConfig = BuiltInSchedulerConfig()
145143 default_gateway: str = ""
146- state_schema_naming_pattern: t.Optional[str] = None
147144 notification_targets: t.List[NotificationTarget] = []
148145 project: str = ""
149146 snapshot_ttl: NoPastTTLString = c.DEFAULT_SNAPSHOT_TTL
@@ -180,7 +177,7 @@ class Config(BaseConfig):
180177 linter: LinterConfig = LinterConfig()
181178 janitor: JanitorConfig = JanitorConfig()
182179 cache_dir: t.Optional[str] = None
183- dbt_config_info : t.Optional[DbtConfigInfo ] = None
180+ dbt : t.Optional[DbtConfig ] = None
184181
185182 _FIELD_UPDATE_STRATEGY: t.ClassVar[t.Dict[str, UpdateStrategy]] = {
186183 "gateways": UpdateStrategy.NESTED_UPDATE,
@@ -199,6 +196,7 @@ class Config(BaseConfig):
199196 "before_all": UpdateStrategy.EXTEND,
200197 "after_all": UpdateStrategy.EXTEND,
201198 "linter": UpdateStrategy.NESTED_UPDATE,
199+ "dbt": UpdateStrategy.NESTED_UPDATE,
202200 }
203201
204202 _connection_config_validator = connection_config_validator
@@ -352,27 +350,8 @@ def get_test_connection(
352350 def get_scheduler(self, gateway_name: t.Optional[str] = None) -> SchedulerConfig:
353351 return self.get_gateway(gateway_name).scheduler or self.default_scheduler
354352
355- def get_state_schema(self, gateway_name: t.Optional[str] = None) -> str:
356- state_schema = self.get_gateway(gateway_name).state_schema
357-
358- if state_schema is None and self.state_schema_naming_pattern:
359- substitutions = {}
360- if dbt := self.dbt_config_info:
361- # TODO: keeping this simple for now rather than trying to set up a Jinja or SQLMesh Macro rendering context
362- substitutions.update(
363- {
364- "@{dbt_profile_name}": dbt.profile_name,
365- # TODO @iaroslav: what was the problem with using target name instead of the default schema name again?
366- "@{dbt_target_name}": dbt.target_name,
367- }
368- )
369- state_schema = self.state_schema_naming_pattern
370- for pattern, value in substitutions.items():
371- state_schema = state_schema.replace(pattern, value)
372-
373- logger.info("Inferring state schema: %s", state_schema)
374-
375- return state_schema or c.SQLMESH
353+ def get_state_schema(self, gateway_name: t.Optional[str] = None) -> t.Optional[str]:
354+ return self.get_gateway(gateway_name).state_schema
376355
377356 @property
378357 def default_gateway_name(self) -> str:
0 commit comments