diff --git a/crates/sqlbuild-host/src/entries/_helpers/executor.rs b/crates/sqlbuild-host/src/entries/_helpers/executor.rs index 1087c31918..17302822a0 100644 --- a/crates/sqlbuild-host/src/entries/_helpers/executor.rs +++ b/crates/sqlbuild-host/src/entries/_helpers/executor.rs @@ -504,11 +504,6 @@ pub(crate) const ENTRIES: &[HostEntry] = &[ kind: HostKind::Value, edge: HostEdge::Executor, }, - HostEntry { - name: "MICROBATCH_TABLE_NAME", - kind: HostKind::Value, - edge: HostEdge::Executor, - }, HostEntry { name: "MicrobatchStateError", kind: HostKind::Exception, diff --git a/crates/sqlbuild-host/src/entries/models.rs b/crates/sqlbuild-host/src/entries/models.rs index 057a1d4203..ff74332945 100644 --- a/crates/sqlbuild-host/src/entries/models.rs +++ b/crates/sqlbuild-host/src/entries/models.rs @@ -303,7 +303,6 @@ pub enum ExecutorHost { MicrobatchColumnTypes, MicrobatchDirectIndexes, MicrobatchGenerationWildcard, - MicrobatchTableName, MicrobatchStateError, MicrobatchCoverageProjection, MicrobatchInterval, diff --git a/crates/sqlbuild-orchestration/src/warehouse_metadata/main/ingest/ingest_fingerprints.rs b/crates/sqlbuild-orchestration/src/warehouse_metadata/main/ingest/ingest_fingerprints.rs index 9857bbc6ce..24d5ab0d55 100644 --- a/crates/sqlbuild-orchestration/src/warehouse_metadata/main/ingest/ingest_fingerprints.rs +++ b/crates/sqlbuild-orchestration/src/warehouse_metadata/main/ingest/ingest_fingerprints.rs @@ -1,6 +1,7 @@ //! Import bounded fingerprint history without conflating semantic and exact-content hashes. use serde_json::json; +use sqlbuild_core::constants::FINGERPRINT_TABLE_NAME; use sqlbuild_recall::records::main::sha256_hex::sha256_hex; use uuid::Uuid; @@ -37,7 +38,7 @@ pub async fn ingest_fingerprints( ( record.state_database.as_deref(), &record.state_schema, - "_sqlbuild_fingerprints", + FINGERPRINT_TABLE_NAME, ), &source_event_id, )?; diff --git a/crates/sqlbuild-orchestration/src/warehouse_metadata/main/ingest/ingest_source_freshness.rs b/crates/sqlbuild-orchestration/src/warehouse_metadata/main/ingest/ingest_source_freshness.rs index 7c4e10302e..1d7f925f04 100644 --- a/crates/sqlbuild-orchestration/src/warehouse_metadata/main/ingest/ingest_source_freshness.rs +++ b/crates/sqlbuild-orchestration/src/warehouse_metadata/main/ingest/ingest_source_freshness.rs @@ -1,6 +1,7 @@ //! Persist source identities; only legacy rows use a fixed observation-key fallback. use serde_json::json; +use sqlbuild_core::constants::SOURCE_FRESHNESS_TABLE_NAME; use sqlbuild_state::freshness::main::event_id::event_id as legacy_event_id; use sqlbuild_state::freshness::models::FreshnessEventIdentity; use uuid::Uuid; @@ -53,7 +54,7 @@ pub async fn ingest_source_freshness( ( record.state_database.as_deref(), &record.state_schema, - "_sqlbuild_source_freshness", + SOURCE_FRESHNESS_TABLE_NAME, ), &source_event_id, )?; diff --git a/crates/sqlbuild-python/src/bindings/_helpers/exported_constants/constants.rs b/crates/sqlbuild-python/src/bindings/_helpers/exported_constants/constants.rs index 0b404933d4..13a47eadb0 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/exported_constants/constants.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/exported_constants/constants.rs @@ -18,8 +18,9 @@ use sqlbuild_core::command_output::constants::{ INVOCATION_CONTEXT_ENV, }; use sqlbuild_core::constants::{ - COLUMN_MIGRATION_TABLE_NAME, CONSUMPTION_TABLE_NAME, FINGERPRINT_TABLE_NAME, - MIGRATION_TABLE_NAME, OLD_NAME_VIEW_TABLE_NAME, PROJECT_CONFIG_FILENAME, + AUDIT_RESULTS_TABLE_NAME, COLUMN_MIGRATION_TABLE_NAME, CONSUMPTION_TABLE_NAME, + FINGERPRINT_TABLE_NAME, JANITOR_EVENTS_TABLE_NAME, MICROBATCH_TABLE_NAME, MIGRATION_TABLE_NAME, + NODE_RESULTS_TABLE_NAME, OLD_NAME_VIEW_TABLE_NAME, PROJECT_CONFIG_FILENAME, PYTHON_INIT_MODULE_STEM, PYTHON_NODE_ROOT, SETTINGS_SECTION, SOURCE_FRESHNESS_TABLE_NAME, STAGED_PROMOTION_MODE, TABLE_PROMOTION_MODE_SETTING_KEY, ZERO_DAY_DURATION, }; @@ -88,6 +89,10 @@ pub(crate) const EXPORTED_TEXTS: &[(&str, &str)] = &[ ("MIGRATION_TABLE_NAME", MIGRATION_TABLE_NAME), ("COLUMN_MIGRATION_TABLE_NAME", COLUMN_MIGRATION_TABLE_NAME), ("OLD_NAME_VIEW_TABLE_NAME", OLD_NAME_VIEW_TABLE_NAME), + ("MICROBATCH_TABLE_NAME", MICROBATCH_TABLE_NAME), + ("NODE_RESULTS_TABLE_NAME", NODE_RESULTS_TABLE_NAME), + ("AUDIT_RESULTS_TABLE_NAME", AUDIT_RESULTS_TABLE_NAME), + ("JANITOR_EVENTS_TABLE_NAME", JANITOR_EVENTS_TABLE_NAME), ("COLUMN_NODE_TYPE", COLUMN_NODE_TYPE), ("COLUMN_NODE_NAME", COLUMN_NODE_NAME), ("COLUMN_TARGET_DATABASE", COLUMN_TARGET_DATABASE), diff --git a/crates/sqlbuild-python/src/bindings/_helpers/microbatches/statements.rs b/crates/sqlbuild-python/src/bindings/_helpers/microbatches/statements.rs index 5b93d44494..b4a286f0f3 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/microbatches/statements.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/microbatches/statements.rs @@ -1,8 +1,9 @@ //! Direct-mode microbatch state DDL, idempotent inserts, reads and event IDs. use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyModule, PyModuleMethods, PyResult, Python}; -use pyo3::types::{PyDict, PyTuple}; +use pyo3::types::{PyDict, PyString, PyTuple}; use pyo3::{pyfunction, wrap_pyfunction}; +use sqlbuild_core::constants::MICROBATCH_TABLE_NAME; use sqlbuild_host::entries::models::{AdapterHost, ExecutorHost}; use sqlbuild_state::events::main::microbatch_event_id::microbatch_event_id; use sqlbuild_state::microbatches::main::create_index_sqls::create_index_sqls; @@ -81,7 +82,7 @@ fn qualified_table<'py>( (database, schema): (&Bound<'py, PyAny>, &Bound<'py, PyAny>), ) -> PyResult> { let py: Python<'py> = render_qualified_name.py(); - let table_name: Bound<'py, PyAny> = host::entry(py, ExecutorHost::MicrobatchTableName)?; + let table_name: Bound<'py, PyAny> = PyString::new(py, MICROBATCH_TABLE_NAME).into_any(); optional_text(&call_with( render_qualified_name, &[ @@ -236,14 +237,13 @@ fn create_indexes<'py>(request: Option<&Bound<'py, PyDict>>) -> PyResult = request.get("render_identifier")?; let identifier = |name: &Bound<'_, PyAny>| -> PyResult { diff --git a/crates/sqlbuild-python/src/bindings/_helpers/native_host/warehouse_metadata.rs b/crates/sqlbuild-python/src/bindings/_helpers/native_host/warehouse_metadata.rs index b00d15d6b8..1ec0bd1e50 100644 --- a/crates/sqlbuild-python/src/bindings/_helpers/native_host/warehouse_metadata.rs +++ b/crates/sqlbuild-python/src/bindings/_helpers/native_host/warehouse_metadata.rs @@ -9,8 +9,9 @@ use sqlbuild_config::command_connection::constants::{ DUCKDB_ADAPTER, DUCKDB_MEMORY_DATABASE, LOCAL_DATABASE_PATH_KEYS, }; use sqlbuild_core::constants::{ - COLUMN_MIGRATION_TABLE_NAME, CONSUMPTION_TABLE_NAME, FINGERPRINT_TABLE_NAME, - NODE_RESULTS_TABLE_NAME, SOURCE_FRESHNESS_TABLE_NAME, + AUDIT_RESULTS_TABLE_NAME, COLUMN_MIGRATION_TABLE_NAME, CONSUMPTION_TABLE_NAME, + FINGERPRINT_TABLE_NAME, JANITOR_EVENTS_TABLE_NAME, MICROBATCH_TABLE_NAME, MIGRATION_TABLE_NAME, + NODE_RESULTS_TABLE_NAME, OLD_NAME_VIEW_TABLE_NAME, SOURCE_FRESHNESS_TABLE_NAME, }; use sqlbuild_core::models::SqlValue; use sqlbuild_orchestration::warehouse_metadata::constants::MAX_HISTORY_RECORDS; @@ -167,7 +168,7 @@ fn read_page( read.after.as_ref().map(|cursor| cursor.as_slice()), read.observed_since, read.limit, - "_sqlbuild_audit_results", + AUDIT_RESULTS_TABLE_NAME, event_columns.as_slice(), "occurred_at", ), @@ -176,7 +177,7 @@ fn read_page( read.after.as_ref().map(|cursor| cursor.as_slice()), read.observed_since, read.limit, - "_sqlbuild_janitor_events", + JANITOR_EVENTS_TABLE_NAME, event_columns.as_slice(), "occurred_at", ), @@ -185,7 +186,7 @@ fn read_page( read.after.as_ref().map(|cursor| cursor.as_slice()), read.observed_since, read.limit, - "_sqlbuild_migrations", + MIGRATION_TABLE_NAME, MIGRATION_COLUMNS.as_slice(), "created_at", ), @@ -194,7 +195,7 @@ fn read_page( read.after.as_ref().map(|cursor| cursor.as_slice()), read.observed_since, read.limit, - "_sqlbuild_old_name_views", + OLD_NAME_VIEW_TABLE_NAME, OLD_NAME_VIEW_COLUMNS.as_slice(), "created_at", ), @@ -203,7 +204,7 @@ fn read_page( read.after.as_ref().map(|cursor| cursor.as_slice()), read.observed_since, read.limit, - "_sqlbuild_microbatches", + MICROBATCH_TABLE_NAME, event_columns.as_slice(), "created_at", ), diff --git a/fensu.toml b/fensu.toml index 7a8eac2005..fe1a9384f5 100644 --- a/fensu.toml +++ b/fensu.toml @@ -634,7 +634,7 @@ reason = "Native code resolves these through the sqlbuild._native_host name tabl [[targets.python.dead_code.roots]] modules = ["sqlbuild.microbatches.constants"] -symbols = ["MICROBATCH_COLUMNS", "MICROBATCH_COLUMN_TYPES", "MICROBATCH_DIRECT_INDEXES", "MICROBATCH_GENERATION_WILDCARD", "MICROBATCH_TABLE_NAME"] +symbols = ["MICROBATCH_COLUMNS", "MICROBATCH_COLUMN_TYPES", "MICROBATCH_DIRECT_INDEXES", "MICROBATCH_GENERATION_WILDCARD"] reason = "Native code resolves these through the sqlbuild._native_host name table." [[targets.python.dead_code.roots]] diff --git a/src/sqlbuild/_native.pyi b/src/sqlbuild/_native.pyi index 13bd5eaaca..4e017a8fff 100644 --- a/src/sqlbuild/_native.pyi +++ b/src/sqlbuild/_native.pyi @@ -188,6 +188,10 @@ CONSUMPTION_TABLE_NAME: str MIGRATION_TABLE_NAME: str COLUMN_MIGRATION_TABLE_NAME: str OLD_NAME_VIEW_TABLE_NAME: str +MICROBATCH_TABLE_NAME: str +NODE_RESULTS_TABLE_NAME: str +AUDIT_RESULTS_TABLE_NAME: str +JANITOR_EVENTS_TABLE_NAME: str COLUMN_NODE_TYPE: str COLUMN_NODE_NAME: str COLUMN_TARGET_DATABASE: str diff --git a/src/sqlbuild/_native_host.py b/src/sqlbuild/_native_host.py index fde2109986..c48bcb38e5 100644 --- a/src/sqlbuild/_native_host.py +++ b/src/sqlbuild/_native_host.py @@ -507,7 +507,6 @@ "sqlbuild.microbatches.constants", "MICROBATCH_GENERATION_WILDCARD", ), - "MICROBATCH_TABLE_NAME": ("sqlbuild.microbatches.constants", "MICROBATCH_TABLE_NAME"), "MicrobatchStateError": ("sqlbuild.microbatches.exceptions", "MicrobatchStateError"), "MicrobatchCoverageProjection": ( "sqlbuild.microbatches.models", diff --git a/src/sqlbuild/_native_host.pyi b/src/sqlbuild/_native_host.pyi index 4ca6064432..a796297196 100644 --- a/src/sqlbuild/_native_host.pyi +++ b/src/sqlbuild/_native_host.pyi @@ -444,7 +444,6 @@ from sqlbuild.microbatches.constants import MICROBATCH_DIRECT_INDEXES as MICROBA from sqlbuild.microbatches.constants import ( MICROBATCH_GENERATION_WILDCARD as MICROBATCH_GENERATION_WILDCARD, ) -from sqlbuild.microbatches.constants import MICROBATCH_TABLE_NAME as MICROBATCH_TABLE_NAME from sqlbuild.microbatches.exceptions import MicrobatchStateError as MicrobatchStateError from sqlbuild.microbatches.models import ( MicrobatchCoverageProjection as MicrobatchCoverageProjection, diff --git a/src/sqlbuild/adapters/postgres/classes/postgres_adapter.py b/src/sqlbuild/adapters/postgres/classes/postgres_adapter.py index b55d163b15..b0d22ccdc4 100644 --- a/src/sqlbuild/adapters/postgres/classes/postgres_adapter.py +++ b/src/sqlbuild/adapters/postgres/classes/postgres_adapter.py @@ -1762,7 +1762,7 @@ def render_create_node_result_index_sqls( database: str | None, schema: str, ) -> tuple[str, ...]: - from sqlbuild.executor.node_results.constants import NODE_RESULTS_TABLE_NAME + from sqlbuild._native import NODE_RESULTS_TABLE_NAME table_name: str | None = self.render_qualified_name( database=database, @@ -1798,7 +1798,7 @@ def render_create_audit_result_table_sql(self, *, database: str | None, schema: def render_create_audit_result_index_sqls( self, *, database: str | None, schema: str ) -> tuple[str, ...]: - from sqlbuild.executor.audit_results.constants import AUDIT_RESULTS_TABLE_NAME + from sqlbuild._native import AUDIT_RESULTS_TABLE_NAME return self._state_index_sqls( table=(database, schema, AUDIT_RESULTS_TABLE_NAME), diff --git a/src/sqlbuild/adapters/sqlite/classes/sqlite_adapter.py b/src/sqlbuild/adapters/sqlite/classes/sqlite_adapter.py index 8c923e67d7..89ecddecf3 100644 --- a/src/sqlbuild/adapters/sqlite/classes/sqlite_adapter.py +++ b/src/sqlbuild/adapters/sqlite/classes/sqlite_adapter.py @@ -2549,7 +2549,7 @@ def render_create_node_result_index_sqls( database: str | None, schema: str, ) -> tuple[str, ...]: - from sqlbuild.executor.node_results.constants import NODE_RESULTS_TABLE_NAME + from sqlbuild._native import NODE_RESULTS_TABLE_NAME return self._index_sqls( database=database, @@ -2583,7 +2583,7 @@ def render_create_audit_result_table_sql(self, *, database: str | None, schema: def render_create_audit_result_index_sqls( self, *, database: str | None, schema: str ) -> tuple[str, ...]: - from sqlbuild.executor.audit_results.constants import AUDIT_RESULTS_TABLE_NAME + from sqlbuild._native import AUDIT_RESULTS_TABLE_NAME return self._index_sqls( database=database, diff --git a/src/sqlbuild/adapters/sqlserver/classes/sqlserver_adapter.py b/src/sqlbuild/adapters/sqlserver/classes/sqlserver_adapter.py index 36a8d42f3f..0a7af7476b 100644 --- a/src/sqlbuild/adapters/sqlserver/classes/sqlserver_adapter.py +++ b/src/sqlbuild/adapters/sqlserver/classes/sqlserver_adapter.py @@ -5,6 +5,7 @@ import json import logging import re +from collections.abc import Callable from datetime import date, datetime from decimal import Decimal from pathlib import Path @@ -389,20 +390,13 @@ def render_create_fingerprint_table_sql( ) def render_create_microbatch_state_table_sql(self, *, database: str | None, schema: str) -> str: - from sqlbuild._native import build_microbatch_create_table_sql - from sqlbuild.microbatches.constants import MICROBATCH_TABLE_NAME + from sqlbuild._native import MICROBATCH_TABLE_NAME, build_microbatch_create_table_sql - create_sql: str = build_microbatch_create_table_sql( - database=database, - schema=schema, - render_qualified_name=self.render_qualified_name, - render_framework_type=self.render_framework_type, - ).replace("CREATE TABLE IF NOT EXISTS ", "CREATE TABLE ", 1) - return self._create_table_if_missing_sql( - create_sql=create_sql, + return self._create_state_table_sql( + build=build_microbatch_create_table_sql, + table_name=MICROBATCH_TABLE_NAME, database=database, schema=schema, - table_name=MICROBATCH_TABLE_NAME, ) def render_create_fingerprint_index_sqls( @@ -580,7 +574,7 @@ def render_create_node_result_table_sql( database: str | None, schema: str, ) -> str: - from sqlbuild.executor.node_results.constants import NODE_RESULTS_TABLE_NAME + from sqlbuild._native import NODE_RESULTS_TABLE_NAME from sqlbuild.executor.node_results.main.create_table_sql import ( build_node_results_create_table_sql, ) @@ -614,7 +608,7 @@ def render_create_node_result_index_sqls( database: str | None, schema: str, ) -> tuple[str, ...]: - from sqlbuild.executor.node_results.constants import NODE_RESULTS_TABLE_NAME + from sqlbuild._native import NODE_RESULTS_TABLE_NAME table: tuple[str | None, str, str] = (database, schema, NODE_RESULTS_TABLE_NAME) return self._state_index_sqls( @@ -629,7 +623,7 @@ def render_create_node_result_index_sqls( ) def render_create_audit_result_table_sql(self, *, database: str | None, schema: str) -> str: - from sqlbuild.executor.audit_results.constants import AUDIT_RESULTS_TABLE_NAME + from sqlbuild._native import AUDIT_RESULTS_TABLE_NAME from sqlbuild.executor.audit_results.main.create_table_sql import ( build_audit_results_create_table_sql, ) @@ -665,7 +659,7 @@ def render_create_audit_result_table_sql(self, *, database: str | None, schema: def render_create_audit_result_index_sqls( self, *, database: str | None, schema: str ) -> tuple[str, ...]: - from sqlbuild.executor.audit_results.constants import AUDIT_RESULTS_TABLE_NAME + from sqlbuild._native import AUDIT_RESULTS_TABLE_NAME table_name: str | None = self.render_qualified_name( database=database, schema=schema, name=AUDIT_RESULTS_TABLE_NAME @@ -692,39 +686,27 @@ def render_create_audit_result_index_sqls( ) def render_create_janitor_event_table_sql(self, *, database: str | None, schema: str) -> str: - from sqlbuild.executor.janitor_events.constants import JANITOR_EVENTS_TABLE_NAME + from sqlbuild._native import JANITOR_EVENTS_TABLE_NAME from sqlbuild.executor.janitor_events.main.create_table_sql import ( build_janitor_events_create_table_sql, ) - create_sql: str = build_janitor_events_create_table_sql( - database=database, - schema=schema, - render_qualified_name=self.render_qualified_name, - render_framework_type=self.render_framework_type, - ).replace("CREATE TABLE IF NOT EXISTS", "CREATE TABLE", 1) - return self._create_table_if_missing_sql( - create_sql=create_sql, + return self._create_state_table_sql( + build=build_janitor_events_create_table_sql, + table_name=JANITOR_EVENTS_TABLE_NAME, database=database, schema=schema, - table_name=JANITOR_EVENTS_TABLE_NAME, ) def render_create_migration_state_table_sql(self, *, database: str | None, schema: str) -> str: from sqlbuild._native import MIGRATION_TABLE_NAME, render_migration_state_create_sql - create_sql: str = render_migration_state_create_sql( - kind="model", - database=database, - schema=schema, - render_qualified_name=self.render_qualified_name, - render_framework_type=self.render_framework_type, - ).replace("CREATE TABLE IF NOT EXISTS", "CREATE TABLE", 1) - return self._create_table_if_missing_sql( - create_sql=create_sql, + return self._create_state_table_sql( + build=render_migration_state_create_sql, + table_name=MIGRATION_TABLE_NAME, database=database, schema=schema, - table_name=MIGRATION_TABLE_NAME, + kind="model", ) def render_create_old_name_view_state_table_sql( @@ -732,18 +714,12 @@ def render_create_old_name_view_state_table_sql( ) -> str: from sqlbuild._native import OLD_NAME_VIEW_TABLE_NAME, render_migration_state_create_sql - create_sql: str = render_migration_state_create_sql( - kind="old_name", - database=database, - schema=schema, - render_qualified_name=self.render_qualified_name, - render_framework_type=self.render_framework_type, - ).replace("CREATE TABLE IF NOT EXISTS", "CREATE TABLE", 1) - return self._create_table_if_missing_sql( - create_sql=create_sql, + return self._create_state_table_sql( + build=render_migration_state_create_sql, + table_name=OLD_NAME_VIEW_TABLE_NAME, database=database, schema=schema, - table_name=OLD_NAME_VIEW_TABLE_NAME, + kind="old_name", ) def render_create_column_migration_state_table_sql( @@ -751,18 +727,12 @@ def render_create_column_migration_state_table_sql( ) -> str: from sqlbuild._native import COLUMN_MIGRATION_TABLE_NAME, render_migration_state_create_sql - create_sql: str = render_migration_state_create_sql( - kind="column", - database=database, - schema=schema, - render_qualified_name=self.render_qualified_name, - render_framework_type=self.render_framework_type, - ).replace("CREATE TABLE IF NOT EXISTS", "CREATE TABLE", 1) - return self._create_table_if_missing_sql( - create_sql=create_sql, + return self._create_state_table_sql( + build=render_migration_state_create_sql, + table_name=COLUMN_MIGRATION_TABLE_NAME, database=database, schema=schema, - table_name=COLUMN_MIGRATION_TABLE_NAME, + kind="column", ) def render_read_latest_source_freshness_sql( @@ -872,6 +842,26 @@ def render_rename(self, *, origin: str, destination: str) -> tuple[str, ...]: def render_rename_view(self, *, origin: str, destination: str) -> tuple[str, ...]: return self.render_rename(origin=origin, destination=destination) + def _create_state_table_sql( + self, + *, + build: Callable[..., str], + table_name: str, + database: str | None, + schema: str, + **options: str, + ) -> str: + create_sql: str = build( + database=database, + schema=schema, + render_qualified_name=self.render_qualified_name, + render_framework_type=self.render_framework_type, + **options, + ).replace("CREATE TABLE IF NOT EXISTS", "CREATE TABLE", 1) + return self._create_table_if_missing_sql( + create_sql=create_sql, database=database, schema=schema, table_name=table_name + ) + def _create_table_if_missing_sql( self, *, create_sql: str, database: str | None, schema: str, table_name: str ) -> str: diff --git a/src/sqlbuild/executor/audit_results/_helpers/meta_column.py b/src/sqlbuild/executor/audit_results/_helpers/meta_column.py index 2a27aaf5a3..fdbab4bf29 100644 --- a/src/sqlbuild/executor/audit_results/_helpers/meta_column.py +++ b/src/sqlbuild/executor/audit_results/_helpers/meta_column.py @@ -6,11 +6,11 @@ from collections.abc import Callable from typing import Any +from sqlbuild._native import AUDIT_RESULTS_TABLE_NAME from sqlbuild.adapter.contract.models import ColumnInfo from sqlbuild.adapter.contract.types import AdapterExecute, FrameworkType from sqlbuild.executor.audit_results._helpers.sql import build_qualified_table_name from sqlbuild.executor.audit_results.constants import ( - AUDIT_RESULTS_TABLE_NAME, COLUMN_AUDIT_META_JSON, ) from sqlbuild.executor.audit_results.models import AuditResultColumnEvolution diff --git a/src/sqlbuild/executor/audit_results/_helpers/sql.py b/src/sqlbuild/executor/audit_results/_helpers/sql.py index 6caec57aa4..ae3c2c4f19 100644 --- a/src/sqlbuild/executor/audit_results/_helpers/sql.py +++ b/src/sqlbuild/executor/audit_results/_helpers/sql.py @@ -4,13 +4,16 @@ from collections.abc import Callable, Sequence -from sqlbuild._native import render_state_sql_literal, render_state_table_create_sql +from sqlbuild._native import ( + AUDIT_RESULTS_TABLE_NAME, + render_state_sql_literal, + render_state_table_create_sql, +) from sqlbuild.adapter.contract.types import FrameworkType from sqlbuild.errors.contracts.exceptions import ExecutorInputError from sqlbuild.executor.audit_results.constants import ( AUDIT_RESULT_COLUMN_TYPES, AUDIT_RESULT_COLUMNS, - AUDIT_RESULTS_TABLE_NAME, COLUMN_ATTACHED_COLUMN_NAME, COLUMN_ATTACHED_TARGET_KIND, COLUMN_ATTACHED_TARGET_NAME, diff --git a/src/sqlbuild/executor/audit_results/constants.py b/src/sqlbuild/executor/audit_results/constants.py index f6fd51bb91..0e9f68eacc 100644 --- a/src/sqlbuild/executor/audit_results/constants.py +++ b/src/sqlbuild/executor/audit_results/constants.py @@ -2,7 +2,6 @@ from sqlbuild._native import StateSqlValueType -AUDIT_RESULTS_TABLE_NAME: str = "_sqlbuild_audit_results" AUDIT_RESULT_SCHEMA_VERSION: int = 1 COLUMN_RESULT_ID: str = "result_id" diff --git a/src/sqlbuild/executor/janitor_events/_helpers/sql.py b/src/sqlbuild/executor/janitor_events/_helpers/sql.py index b56c2653e2..2fcd59f9ff 100644 --- a/src/sqlbuild/executor/janitor_events/_helpers/sql.py +++ b/src/sqlbuild/executor/janitor_events/_helpers/sql.py @@ -4,7 +4,11 @@ from collections.abc import Callable -from sqlbuild._native import render_state_sql_literal, render_state_table_create_sql +from sqlbuild._native import ( + JANITOR_EVENTS_TABLE_NAME, + render_state_sql_literal, + render_state_table_create_sql, +) from sqlbuild.adapter.contract.types import FrameworkType from sqlbuild.errors.contracts.exceptions import ExecutorInputError from sqlbuild.executor.janitor_events.constants import ( @@ -24,7 +28,6 @@ JANITOR_EVENT_COLUMN_TYPES, JANITOR_EVENT_COLUMNS, JANITOR_EVENT_REQUIRED_COLUMNS, - JANITOR_EVENTS_TABLE_NAME, ) from sqlbuild.executor.janitor_events.models import JanitorEventRecord diff --git a/src/sqlbuild/executor/janitor_events/constants.py b/src/sqlbuild/executor/janitor_events/constants.py index f120e39903..f4235cd0ad 100644 --- a/src/sqlbuild/executor/janitor_events/constants.py +++ b/src/sqlbuild/executor/janitor_events/constants.py @@ -2,7 +2,6 @@ from sqlbuild._native import StateSqlValueType -JANITOR_EVENTS_TABLE_NAME: str = "_sqlbuild_janitor_events" JANITOR_EVENT_SCHEMA_VERSION: int = 1 COLUMN_EVENT_ID: str = "event_id" diff --git a/src/sqlbuild/executor/node_results/_helpers/sql.py b/src/sqlbuild/executor/node_results/_helpers/sql.py index 003996c925..60eb1168d7 100644 --- a/src/sqlbuild/executor/node_results/_helpers/sql.py +++ b/src/sqlbuild/executor/node_results/_helpers/sql.py @@ -4,7 +4,11 @@ from collections.abc import Callable -from sqlbuild._native import render_state_sql_literal, render_state_table_create_sql +from sqlbuild._native import ( + NODE_RESULTS_TABLE_NAME, + render_state_sql_literal, + render_state_table_create_sql, +) from sqlbuild.adapter.contract.types import FrameworkType from sqlbuild.errors.contracts.exceptions import ExecutorInputError from sqlbuild.executor.node_results.constants import ( @@ -22,7 +26,6 @@ COLUMN_TIMESTAMP, NODE_RESULT_COLUMN_TYPES, NODE_RESULT_COLUMNS, - NODE_RESULTS_TABLE_NAME, ) from sqlbuild.executor.node_results.models import NodeResultQuery, NodeResultRecord diff --git a/src/sqlbuild/executor/node_results/constants.py b/src/sqlbuild/executor/node_results/constants.py index c57129c44c..b2e7444998 100644 --- a/src/sqlbuild/executor/node_results/constants.py +++ b/src/sqlbuild/executor/node_results/constants.py @@ -2,7 +2,6 @@ from sqlbuild._native import StateSqlValueType -NODE_RESULTS_TABLE_NAME: str = "_sqlbuild_node_results" NODE_RESULT_MATERIALIZED_TRUE_VALUE: str = "true" COLUMN_NODE_TYPE: str = "node_type" diff --git a/src/sqlbuild/executor/node_results/main/_read.py b/src/sqlbuild/executor/node_results/main/_read.py index 4fb7f9f480..d969b40dce 100644 --- a/src/sqlbuild/executor/node_results/main/_read.py +++ b/src/sqlbuild/executor/node_results/main/_read.py @@ -6,12 +6,12 @@ from datetime import datetime from typing import Any +from sqlbuild._native import NODE_RESULTS_TABLE_NAME from sqlbuild.adapter.contract.types import AdapterExecute from sqlbuild.executor.node_results._helpers.serialization import decode_json_b64 from sqlbuild.executor.node_results._helpers.sql import build_read_history_sql from sqlbuild.executor.node_results.constants import ( NODE_RESULT_MATERIALIZED_TRUE_VALUE, - NODE_RESULTS_TABLE_NAME, ) from sqlbuild.executor.node_results.models import NodeResultEnvelope, NodeResultQuery diff --git a/src/sqlbuild/microbatches/constants.py b/src/sqlbuild/microbatches/constants.py index f0d2a3b396..9b0bb74c1a 100644 --- a/src/sqlbuild/microbatches/constants.py +++ b/src/sqlbuild/microbatches/constants.py @@ -2,7 +2,6 @@ from sqlbuild._native import StateSqlValueType -MICROBATCH_TABLE_NAME: str = "_sqlbuild_microbatches" DIRECT_MICROBATCH_SCOPE_KIND: str = "direct_logical" MICROBATCH_GENERATION_COMMENT_PREFIX: str = "sqlbuild-generation:" MICROBATCH_REPLAY_GENERATION_PREFIX: str = "replay:" diff --git a/tests/unit/src/sqlbuild/executor/janitor/main/helpers.py b/tests/unit/src/sqlbuild/executor/janitor/main/helpers.py index d4bc3910a3..36ac4605f2 100644 --- a/tests/unit/src/sqlbuild/executor/janitor/main/helpers.py +++ b/tests/unit/src/sqlbuild/executor/janitor/main/helpers.py @@ -11,6 +11,7 @@ from sqlbuild._native import ( FINGERPRINT_TABLE_NAME, + JANITOR_EVENTS_TABLE_NAME, SOURCE_FRESHNESS_TABLE_NAME, CompiledModel, CompiledObjectKey, @@ -43,7 +44,6 @@ from sqlbuild.executor.janitor.types import JanitorAction from sqlbuild.executor.janitor_events.constants import ( JANITOR_EVENT_SCHEMA_VERSION, - JANITOR_EVENTS_TABLE_NAME, ) from sqlbuild.executor.janitor_events.models import JanitorEventRecord from sqlbuild.executor.janitor_events.types import JanitorEventType diff --git a/tests/unit/src/sqlbuild/executor/janitor/main/test_execute.py b/tests/unit/src/sqlbuild/executor/janitor/main/test_execute.py index d0aa8eaa5a..0e0958a079 100644 --- a/tests/unit/src/sqlbuild/executor/janitor/main/test_execute.py +++ b/tests/unit/src/sqlbuild/executor/janitor/main/test_execute.py @@ -6,13 +6,12 @@ import pytest -from sqlbuild._native import build_janitor_plan +from sqlbuild._native import JANITOR_EVENTS_TABLE_NAME, build_janitor_plan from sqlbuild.executor.janitor.main.execute import execute_janitor_plan from sqlbuild.executor.janitor.models import ( JanitorExecutionResult, JanitorPlan, ) -from sqlbuild.executor.janitor_events.constants import JANITOR_EVENTS_TABLE_NAME from tests.unit.src.sqlbuild.executor.janitor.main._test_types import ( JanitorArchiveEventFailureTestCase, JanitorArchiveExecutionTestCase, diff --git a/tests/unit/src/sqlbuild/microbatches/test_sql.py b/tests/unit/src/sqlbuild/microbatches/test_sql.py index 081005fdf6..6e2f4f7328 100644 --- a/tests/unit/src/sqlbuild/microbatches/test_sql.py +++ b/tests/unit/src/sqlbuild/microbatches/test_sql.py @@ -7,6 +7,7 @@ import pytest from sqlbuild._native import ( + MICROBATCH_TABLE_NAME, CursorType, build_microbatch_create_table_sql, build_microbatch_insert_many_sql, @@ -22,7 +23,7 @@ from sqlbuild.adapters.postgres.classes.postgres_adapter import PostgresAdapter from sqlbuild.adapters.snowflake.classes.snowflake_adapter import SnowflakeAdapter from sqlbuild.adapters.sqlserver.classes.sqlserver_adapter import SqlServerAdapter -from sqlbuild.microbatches.constants import MICROBATCH_COLUMNS, MICROBATCH_TABLE_NAME +from sqlbuild.microbatches.constants import MICROBATCH_COLUMNS from sqlbuild.microbatches.models import MicrobatchEvent, MicrobatchScope from sqlbuild.microbatches.types import MicrobatchRecordType from tests.unit.src.sqlbuild.microbatches._test_types import (