Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/sqlbuild/cli/commands/_helpers/compile/target_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@
from sqlbuild.runtime.observability.classes.operation_lifecycle import OperationLifecycle

_COMPILED_DIR: str = "compiled"
_RUN_DIR: str = "run"
_MODELS_DIR: str = "models"
_FUNCTIONS_DIR: str = "functions"
_SQL_FUNCTIONS_DIR: str = "sql"
_AUDITS_DIR: str = "audits"
_GENERIC_DIR: str = "generic"
_SINGULAR_DIR: str = "singular"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
)

_SCENARIO_NAME_WIDTH: int = 64
_EXPECTATION_LABEL_WIDTH: int = 10
_EXPECTATION_NAME_WIDTH: int = 50
_CAPTURE_RELATION_KIND_WIDTH: int = 8
_CAPTURE_RELATION_NAME_WIDTH: int = _SCENARIO_NAME_WIDTH - 4 - _CAPTURE_RELATION_KIND_WIDTH - 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
from sqlbuild.spec.contracts.models import SourceEntry

_TYPE_WIDTH: int = 10
_MAX_NAME_WIDTH: int = 60
_MIN_NAME_WIDTH: int = 20
_NAME_PADDING: int = 2
_SUB_INDENT: int = 2
Expand Down
5 changes: 0 additions & 5 deletions src/sqlbuild/cli/output/_helpers/execution_result_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@
from sqlbuild.virtual.executor.models import VirtualCloneResult

_JSON_VERSION: int = 1
_SUCCESS_STATUS: str = "success"
_FAILED_STATUS: str = "failed"
_SKIPPED_STATUS: str = "skipped"
_WARNING_STATUS: str = "warning"
_WARN_STATUS: str = "warn"
_SCENARIO_RESOURCE_NAMESPACE: ContextVar[str | None] = ContextVar(
"sqlbuild_scenario_resource_namespace", default=None
)
Expand Down
21 changes: 0 additions & 21 deletions src/sqlbuild/compiler/compile/_helpers/analysis/compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

import logging
import re
from collections.abc import Sequence
from dataclasses import replace
from typing import Any, cast
Expand Down Expand Up @@ -61,13 +60,6 @@
InferredNullability,
)
from sqlbuild.compiler.profiling.main.record import record_compile_timing
from sqlbuild.compiler.references.main._quoted_reference_call_pattern import (
quoted_reference_call_pattern,
)
from sqlbuild.compiler.references.main.reference_call_prefix_pattern_text import (
reference_call_prefix_pattern_text,
)
from sqlbuild.compiler.references.types import SqlReferenceKind
from sqlbuild.compiler.sql_analysis.constants import (
POLYGLOT_ANALYSIS_BASE_TABLES as _POLYGLOT_ANALYSIS_BASE_TABLES,
)
Expand Down Expand Up @@ -175,19 +167,6 @@
_LARGE_COMPACT_PROJECT_MODELS: int = 10_000
_LARGE_COMPACT_SQL_BYTES: int = 48 * 1024 * 1024
_NATIVE_LEGACY_FALLBACK: str = "native project type recovery requires legacy fallback"
_REF_PATTERN: re.Pattern[str] = quoted_reference_call_pattern(SqlReferenceKind.REF)
_SEED_PATTERN: re.Pattern[str] = quoted_reference_call_pattern(SqlReferenceKind.SEED)
_SOURCE_PATTERN: re.Pattern[str] = quoted_reference_call_pattern(SqlReferenceKind.SOURCE)
_DBT_REF_PATTERN: re.Pattern[str] = quoted_reference_call_pattern(SqlReferenceKind.DBT_REF)
_UDF_PATTERN: re.Pattern[str] = re.compile(
rf"{reference_call_prefix_pattern_text(SqlReferenceKind.UDF)}"
r'"([A-Za-z_][A-Za-z0-9_]*)"\)\s*(?=\()'
)
_TABLE_FUNCTION_PATTERN: re.Pattern[str] = re.compile(
rf"{reference_call_prefix_pattern_text(SqlReferenceKind.TABLE_FUNCTION)}"
r'"([A-Za-z_][A-Za-z0-9_]*)"\)\s*(?=\()'
)
_PLACEHOLDER_PATTERN: re.Pattern[str] = re.compile(r"@@@(\w+)")


def infer_columns_with_sql_analysis(
Expand Down
6 changes: 0 additions & 6 deletions src/sqlbuild/compiler/compile/_helpers/attachment/audits.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ def remember_scoped_declarations(
self.scoped_declarations[key] = declarations


_MODEL_HOOK_KEYS: frozenset[str] = frozenset({"pre_hooks", "post_hooks"})
_HOOK_CONTEXT_PARAMETER_NAMES: frozenset[str] = frozenset(
{"ctx", "context", "_ctx", "hook_context"}
)


def build_audit_inputs(
*,
discovered_inputs: DiscoveredProjectInputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import re
from dataclasses import dataclass
from pathlib import Path
from typing import Any, cast
Expand Down Expand Up @@ -79,13 +78,6 @@ class _PythonFunctionBuildContext:
python_functions_inherit_default_namespace: bool


_HOOK_TEMPLATE_PATTERN: re.Pattern[str] = re.compile(r"\$\{[^}]+\}")
_MODEL_HOOK_KEYS: frozenset[str] = frozenset({"pre_hooks", "post_hooks"})
_HOOK_CONTEXT_PARAMETER_NAMES: frozenset[str] = frozenset(
{"ctx", "context", "_ctx", "hook_context"}
)


def build_sql_function_inputs(
*,
discovered_inputs: DiscoveredProjectInputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

import re

from sqlbuild.compiler.compile.constants import TABLE_FUNCTION_RETURN_KEYS
from sqlbuild.compiler.compile.exceptions import CompileInputError
from sqlbuild.compiler.compile.models import (
Expand All @@ -19,12 +17,6 @@
)
from sqlbuild.compiler.references.types import ExternalSqlReferenceResolver, SqlReferenceKind

_HOOK_TEMPLATE_PATTERN: re.Pattern[str] = re.compile(r"\$\{[^}]+\}")
_MODEL_HOOK_KEYS: frozenset[str] = frozenset({"pre_hooks", "post_hooks"})
_HOOK_CONTEXT_PARAMETER_NAMES: frozenset[str] = frozenset(
{"ctx", "context", "_ctx", "hook_context"}
)


def validate_model_references(
*,
Expand Down
7 changes: 0 additions & 7 deletions src/sqlbuild/compiler/compile/_helpers/attachment/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import re
from dataclasses import replace
from pathlib import Path
from typing import cast
Expand Down Expand Up @@ -38,12 +37,6 @@
SourceEntry,
)

_HOOK_TEMPLATE_PATTERN: re.Pattern[str] = re.compile(r"\$\{[^}]+\}")
_MODEL_HOOK_KEYS: frozenset[str] = frozenset({"pre_hooks", "post_hooks"})
_HOOK_CONTEXT_PARAMETER_NAMES: frozenset[str] = frozenset(
{"ctx", "context", "_ctx", "hook_context"}
)


def build_source_inputs(
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import re
from dataclasses import dataclass, replace
from pathlib import Path

Expand Down Expand Up @@ -76,12 +75,6 @@
)
from sqlbuild.compiler.scopes.types import ResourceKind, ScopeKind, UsageKind

_HOOK_TEMPLATE_PATTERN: re.Pattern[str] = re.compile(r"\$\{[^}]+\}")
_MODEL_HOOK_KEYS: frozenset[str] = frozenset({"pre_hooks", "post_hooks"})
_HOOK_CONTEXT_PARAMETER_NAMES: frozenset[str] = frozenset(
{"ctx", "context", "_ctx", "hook_context"}
)


@dataclass(frozen=True)
class _ExpandedSqlTest:
Expand Down
2 changes: 0 additions & 2 deletions src/sqlbuild/compiler/compile/main/_cursor_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def resolve_cursor_input_roles(*, model: CompiledModel) -> CursorInputRoles:
return CursorInputRoles(
filter_inputs=filter_inputs,
watermark_inputs=watermark_inputs,
filter_field=CURSOR_INPUTS_CONFIG_KEY,
watermark_field=CURSOR_INPUTS_CONFIG_KEY,
)


Expand Down
2 changes: 0 additions & 2 deletions src/sqlbuild/compiler/compile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ class CursorInputRoles:

filter_inputs: dict[str, str]
watermark_inputs: dict[str, str]
filter_field: str
watermark_field: str


@dataclass(frozen=True)
Expand Down
29 changes: 0 additions & 29 deletions src/sqlbuild/compiler/discovery/_helpers/sql/model_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,22 @@
PythonHookEntry,
SqlHookEntry,
)
from sqlbuild.compiler.references.types import SqlReferenceKind
from sqlbuild.spec.contracts.models import SourceLocation
from sqlbuild.sql_values.models import AuthoredSqlSet, AuthoredSqlValueCall

_MODEL_HEADER_END_TOKEN: str = "end"
_MODEL_HEADER_WORD_TOKEN: str = "word"
_MODEL_HEADER_STRING_TOKEN: str = "string"
_MODEL_HEADER_SYMBOL_TOKEN: str = "symbol"
_MODEL_HEADER_SYMBOLS: frozenset[str] = frozenset({"(", ")", "[", "]", "{", "}", ","})
_MODEL_HEADER_OPEN_PAREN: str = "("
_MODEL_HEADER_CLOSE_PAREN: str = ")"
_MODEL_HEADER_OPEN_BRACKET: str = "["
_MODEL_HEADER_CLOSE_BRACKET: str = "]"
_MODEL_HEADER_OPEN_BRACE: str = "{"
_MODEL_HEADER_CLOSE_BRACE: str = "}"
_MODEL_HEADER_COMMA: str = ","
_MODEL_HEADER_KEY_VALUE_SEPARATOR: str = ":"
_MODEL_HEADER_QUOTE_NAMES: dict[str, str] = {"'": "single", '"': "double"}
_MODEL_HEADER_ESCAPE_CHARACTER: str = "\\"
_MODEL_HEADER_COLUMNS_KEY: str = "columns"
_MODEL_HEADER_TYPE_KEY: str = "type"
_MODEL_HEADER_RELATION_CALL_NAMES: frozenset[str] = frozenset(
{
SqlReferenceKind.REF.function_name,
SqlReferenceKind.SEED.function_name,
SqlReferenceKind.SOURCE.function_name,
}
)
_MODEL_HEADER_INLINE_SQL_HOOK_CALL: str = "inline_sql"
_MODEL_HEADER_NAMED_SQL_HOOK_CALL: str = "sql"
_MODEL_HEADER_PYTHON_HOOK_CALL: str = "python"
_MODEL_HEADER_HOOK_CALL_NAMES: frozenset[str] = frozenset(
{
_MODEL_HEADER_INLINE_SQL_HOOK_CALL,
_MODEL_HEADER_NAMED_SQL_HOOK_CALL,
_MODEL_HEADER_PYTHON_HOOK_CALL,
}
)
_MODEL_HEADER_HOOK_FIELD_NAMES: frozenset[str] = frozenset({"pre_hooks", "post_hooks"})
_MODEL_HEADER_TRUE_VALUE: str = "true"
_MODEL_HEADER_FALSE_VALUE: str = "false"
_MODEL_HEADER_NULL_VALUE: str = "null"
_MODEL_HEADER_TYPED_CONSTANT_CALL: str = "constant"
_MODEL_HEADER_THRESHOLDS_KEY: str = "thresholds"
_MODEL_HEADER_THRESHOLD_BOUND_KEYS: frozenset[str] = frozenset({"warn", "error"})
_SQL_IDENTIFIER_SEPARATOR: str = "_"
_SQL_SELECT_KEYWORD: str = "SELECT"
_SQL_UNION_KEYWORD: str = "UNION"
Expand Down
17 changes: 0 additions & 17 deletions src/sqlbuild/compiler/planner/_helpers/output/cursor_type_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@
from sqlbuild.diagnostics.main.log_debug_event import log_debug_event

_DEBUG_LOGGER: logging.Logger = logging.getLogger("sqlbuild.planner")
_TIMESTAMP_SUBSTRINGS: frozenset[str] = frozenset(
{
"TIMESTAMP",
"DATETIME",
"DATE",
}
)

_INTEGER_SUBSTRINGS: frozenset[str] = frozenset(
{
"BIGINT",
"SMALLINT",
"TINYINT",
"MEDIUMINT",
"INT",
}
)

_POLYGLOT_TIMESTAMP_TYPE_NAMES: frozenset[str] = frozenset(
{
Expand Down
23 changes: 10 additions & 13 deletions src/sqlbuild/compiler/planner/_helpers/output/plan_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from sqlbuild.adapter.contract.classes.base_adapter import BaseAdapter
from sqlbuild.adapter.contract.models import ColumnInfo, RelationInfo
from sqlbuild.compiler.compile.constants import CURSOR_INPUTS_CONFIG_KEY
from sqlbuild.compiler.compile.exceptions import CompileInputError
from sqlbuild.compiler.compile.main._cursor_roles import resolve_cursor_input_roles
from sqlbuild.compiler.compile.models import (
Expand Down Expand Up @@ -143,7 +144,6 @@
)
from sqlbuild.spec.contracts.types import MicrobatchLimitAction, TableType

_MODELS_DIR_PREFIX: str = "models/"
_IDEMPOTENT_MICROBATCH_STRATEGIES: frozenset[IncrementalStrategy] = frozenset(
(IncrementalStrategy.DELETE_INSERT, IncrementalStrategy.MERGE)
)
Expand Down Expand Up @@ -1684,17 +1684,12 @@ def validate_source_cursor_input_columns(
cursor_roles: CursorInputRoles = resolve_cursor_input_roles(model=model)
effective_models_by_name: dict[str, CompiledModel] = models_by_name or {}
effective_source_map: dict[str, SourceEntry] = source_map or {}
authored_inputs: tuple[tuple[str, str, str], ...] = tuple(
(cursor_roles.filter_field, name, column)
for name, column in cursor_roles.filter_inputs.items()
) + tuple(
(cursor_roles.watermark_field, name, column)
for name, column in cursor_roles.watermark_inputs.items()
)
config_field: str
authored_inputs: tuple[tuple[str, str], ...] = tuple(
cursor_roles.filter_inputs.items()
) + tuple(cursor_roles.watermark_inputs.items())
input_name: str
input_cursor_column: str
for config_field, input_name, input_cursor_column in authored_inputs:
for input_name, input_cursor_column in authored_inputs:
ref: CompileSqlReference = resolve_lineage_reference(
model=model,
input_name=input_name,
Expand All @@ -1715,7 +1710,8 @@ def validate_source_cursor_input_columns(
continue
declared_display: str = ", ".join(declared_names) or "none"
raise PlannerInputError(
f"model '{model.name}': {config_field} references model '{ref.ref_name}' "
f"model '{model.name}': {CURSOR_INPUTS_CONFIG_KEY} "
f"references model '{ref.ref_name}' "
f"column '{input_cursor_column}', but that model contract does not expose "
f"the column. Known output columns: {declared_display}",
code="S302",
Expand All @@ -1729,7 +1725,8 @@ def validate_source_cursor_input_columns(
continue
declared_display = ", ".join(declared_names) or "none"
raise PlannerInputError(
f"model '{model.name}': {config_field} references source '{ref.ref_name}' "
f"model '{model.name}': {CURSOR_INPUTS_CONFIG_KEY} "
f"references source '{ref.ref_name}' "
f"column '{input_cursor_column}', but that source contract does not expose "
f"the column. Declared contract columns: {declared_display}",
code="S302",
Expand All @@ -1742,7 +1739,7 @@ def validate_source_cursor_input_columns(
continue
known_display: str = ", ".join(col.name for col in known_columns) or "none"
raise PlannerInputError(
f"model '{model.name}': {config_field} references source '{ref.ref_name}' "
f"model '{model.name}': {CURSOR_INPUTS_CONFIG_KEY} references source '{ref.ref_name}' "
f"column '{input_cursor_column}', but that source does not expose the column. "
f"Known source columns: {known_display}",
code="S302",
Expand Down
2 changes: 0 additions & 2 deletions src/sqlbuild/compiler/planner/_helpers/output/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
)

_DEFAULT_ON_SCHEMA_CHANGE: OnSchemaChange = OnSchemaChange.APPEND_NEW_COLUMNS
_DDL_MERGE_SOURCE_ALIAS: str = "__source"
_DDL_MERGE_TARGET_ALIAS: str = "target"


def resolve_model_plan_action(
Expand Down
Loading
Loading