Skip to content

Commit 67933b4

Browse files
committed
refactor(native): raise the shared native stage mismatch error for model config
1 parent a93afa5 commit 67933b4

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎src/sqlbuild/compiler/compile/_helpers/attachment/model_config.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
MODEL_AUDIT_OVERRIDE_KEYS,
2727
MODEL_HEADER_METADATA_KEYS,
2828
)
29-
from sqlbuild.compiler.compile.exceptions import CompileInputError, NativeModelConfigMismatchError
29+
from sqlbuild.compiler.compile.exceptions import CompileInputError
3030
from sqlbuild.compiler.compile.models import (
3131
CachedModelHeaderColumns,
3232
CompileModelConfig,
@@ -42,6 +42,7 @@
4242
DiscoveredSqlModelFile,
4343
ModelSchemaDeclaration,
4444
)
45+
from sqlbuild.compiler.frontier.exceptions import NativeStageMismatchError
4546
from sqlbuild.compiler.model_config.main._native_config_contains_macro_call import (
4647
native_config_contains_macro_call,
4748
)
@@ -359,7 +360,7 @@ def build_model_header_schema_entry(
359360
)
360361
)
361362
if native is not None and native.invalid:
362-
raise NativeModelConfigMismatchError(
363+
raise NativeStageMismatchError(
363364
f"{file_path}: native model config rejected MODEL columns or audits that the Python "
364365
"model config accepts; run with SQLBUILD_COMPILER_ENGINE=python"
365366
)

‎src/sqlbuild/compiler/compile/_helpers/render/context_templates.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from sqlbuild.compiler.compile._helpers.render.templating import expand_template_data
1010
from sqlbuild.compiler.compile.constants import COMPILE_INPUT_READS, PRESERVE_TARGET_VALUE
11-
from sqlbuild.compiler.compile.exceptions import NativeModelConfigMismatchError
1211
from sqlbuild.compiler.compile.types import CompileContextKey
12+
from sqlbuild.compiler.frontier.exceptions import NativeStageMismatchError
1313
from sqlbuild.compiler.model_config.constants import ENVIRONMENT_READ, INVALID_OUTCOME
1414
from sqlbuild.compiler.model_config.main._expand_native_config_templates import (
1515
expand_native_config_templates,
@@ -278,7 +278,7 @@ def expand_config_templates(
278278
preserve_unknown_context=preserve_unknown_context,
279279
)
280280
if outcome == INVALID_OUTCOME:
281-
raise NativeModelConfigMismatchError(
281+
raise NativeStageMismatchError(
282282
f"Native model config rejected {context_label} templates that the Python model "
283283
"config expands; run with SQLBUILD_COMPILER_ENGINE=python"
284284
)

‎src/sqlbuild/compiler/compile/exceptions.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,3 @@ class CompactAnalysisInputError(CompileInputError):
2929

3030
class AnalysisCacheEntryError(ValueError):
3131
"""Raised when a persisted model analysis cache entry is invalid."""
32-
33-
34-
class NativeModelConfigMismatchError(RuntimeError):
35-
"""Raised when native model config rejects a value the Python model config accepts."""

‎tests/integration/src/sqlbuild/compiler/model_config/helpers.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
expand_template_data,
2222
)
2323
from sqlbuild.compiler.compile.constants import COMPILE_INPUT_READS, MACRO_CALL_PATTERN
24-
from sqlbuild.compiler.compile.exceptions import CompileInputError, NativeModelConfigMismatchError
24+
from sqlbuild.compiler.compile.exceptions import CompileInputError
2525
from sqlbuild.compiler.compile.main._build_compile_inputs import build_compile_inputs
2626
from sqlbuild.compiler.compile.models import CompileAdapterContext, CompileProjectInputs
2727
from sqlbuild.compiler.discovery.main._model_schema_columns import parse_schema_columns
2828
from sqlbuild.compiler.discovery.main.discover import discover_project_inputs
2929
from sqlbuild.compiler.discovery.models import DiscoveredProjectInputs, DiscoveredSqlModelFile
3030
from sqlbuild.compiler.frontier.constants import COMPILER_ENGINE_ENV_VAR
31+
from sqlbuild.compiler.frontier.exceptions import NativeStageMismatchError
3132
from sqlbuild.compiler.model_config.constants import INVALID_OUTCOME, UNSUPPORTED_OUTCOME
3233
from sqlbuild.compiler.model_config.main._native_config_contains_macro_call import (
3334
native_config_contains_macro_call,
@@ -227,7 +228,7 @@ def native_rejection_error(
227228
_ = model_config_engine_outcome(
228229
project_dir=project_dir, engine="native-preview", monkeypatch=monkeypatch
229230
)
230-
except NativeModelConfigMismatchError as error:
231+
except NativeStageMismatchError as error:
231232
return str(error)
232233
return "no error"
233234

@@ -332,7 +333,7 @@ def _native_expansion(value: object, flags: TemplateFlags) -> object:
332333
)
333334
except CompileInputError:
334335
return _RAISES
335-
except NativeModelConfigMismatchError as error:
336+
except NativeStageMismatchError as error:
336337
return str(error)
337338
return (_expansion_shape(result), reads.environment_names, reads.read_run_id)
338339

0 commit comments

Comments
 (0)