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
8 changes: 4 additions & 4 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
;;
esac
case "${path}" in
scripts/compiler_differential/*|scripts/run_compiler_differential.py|tests/*/scripts/compiler_differential/*|tests/goldens/*|tests/e2e/fixtures/*|website/examples/*|src/sqlbuild/cli/commands/_helpers/compile/*|.github/workflows/verify.yml|Makefile)
scripts/compiler_differential/*|scripts/run_compiler_differential.py|tests/*/scripts/compiler_differential/*|tests/goldens/*|tests/e2e/fixtures/*|website/examples/*|.github/workflows/verify.yml|Makefile)
compiler_differential=true
;;
esac
Expand All @@ -163,16 +163,16 @@ jobs:
performance=true
rules_performance=true
;;
src/sqlbuild/cli/commands/_helpers/compile/*|src/sqlbuild/executor/testing/*|scripts/cold_compile_performance/*|scripts/compile_performance_ratio/*|scripts/compare_compile_performance.py|tests/e2e/src/sqlbuild/cli/commands/main/compile/*)
src/sqlbuild/executor/testing/*|scripts/cold_compile_performance/*|scripts/compile_performance_ratio/*|scripts/compare_compile_performance.py|tests/e2e/src/sqlbuild/cli/commands/main/compile/*)
broad=true
performance=true
;;
src/sqlbuild/cli/commands/_helpers/lineage/*|src/sqlbuild/cli/commands/_helpers/plan/*|src/sqlbuild/cli/commands/_helpers/scope/*|src/sqlbuild/cli/commands/_helpers/build_planning/*|src/sqlbuild/cli/commands/main/inspection/*|src/sqlbuild/cli/commands/main/project/*|src/sqlbuild/cli/output/*|src/sqlbuild/executor/build/*|src/sqlbuild/executor/run/*|src/sqlbuild/presentation/*)
src/sqlbuild/executor/build/*|src/sqlbuild/executor/run/*|src/sqlbuild/presentation/*)
# Inspection, plan, and build guards run inside the fresh-process compile jobs.
broad=true
performance=true
;;
src/sqlbuild/rule_engine/*|src/sqlbuild/lint/*|scripts/rules_benchmark/*|scripts/benchmark_rules_ci.py|tests/performance/*)
src/sqlbuild/rule_engine/*|src/sqlbuild/lint/*|scripts/rules_benchmark/*|scripts/benchmark_rules_ci.py)
broad=true
performance=true
format_performance=true
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL := /bin/bash

.PHONY: verify verify-quick verify-pg coverage cli-preview rust-check check-native-layering check-build-features check-python-boundary check-release-gate check-docs-skill \
.PHONY: verify verify-quick verify-pg coverage cli-preview rust-check check-native-layering check-native-stub check-build-features check-python-boundary check-release-gate check-docs-skill \
check-e2e-shards test-e2e-duckdb test-e2e-duckdb-build-core \
test-e2e-duckdb-build-incremental \
test-e2e-duckdb-cli-data test-e2e-duckdb-cli test-e2e-duckdb-inspection \
Expand Down Expand Up @@ -645,7 +645,7 @@ verify-quick:
exit $$status


check-ci: check-e2e-shards check-native-layering check-build-features check-python-boundary check-release-gate check-docs-skill rust-lint
check-ci: check-e2e-shards check-native-layering check-native-stub check-build-features check-python-boundary check-release-gate check-docs-skill rust-lint
uv run ruff format --check .
uv run ruff check .
uv run ty check src tests
Expand All @@ -657,6 +657,10 @@ check-native-layering:
uv run python -m scripts.check_native_layering


check-native-stub:
uv run python -m scripts.check_native_stub


check-build-features:
uv run python -m scripts.check_build_features

Expand Down
10 changes: 0 additions & 10 deletions crates/sqlbuild-analysis/src/compiled_project/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,6 @@ pub struct ModelLoopSettings {
pub require_sql_analysis: bool,
}

/// The `description` config value's shape.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub enum DescriptionShape {
#[default]
Absent,
Text(String),
/// Present but not a non-blank string.
Invalid,
}

/// The per-model `sql_analysis` / legacy `sql_validation` override.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum AnalysisOverride {
Expand Down
1 change: 0 additions & 1 deletion crates/sqlbuild-config/src/command_connection/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub const CLI_WAREHOUSE_SOURCE: &str = "--warehouse";
pub const CONNECTION_WAREHOUSE_SOURCE: &str = "connection warehouse";
pub const CONNECTION_DEFAULT_WAREHOUSE_SOURCE: &str = "connection default";
pub const CONNECTION_WAREHOUSE_KEY: &str = "warehouse";
pub const CONNECTION_DATABASE_KEY: &str = "database";
pub const CONNECTION_SOURCE_KEY: &str = "source";
pub const DBT_PROFILE_CONNECTION_SOURCE: &str = "dbt_profile";
pub const DUCKDB_ADAPTER: &str = "duckdb";
Expand Down
7 changes: 0 additions & 7 deletions crates/sqlbuild-core/src/dbt_cli/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

/// The dbt executable when no override is set.
pub const DEFAULT_DBT_EXECUTABLE: &str = "dbt";
/// SQLBuild cursor flags `sqb dbt` forwards to SQLBuild.
pub const CURSOR_FLAGS: [&str; 4] = [
"--start-cursor-ts",
"--end-cursor-ts",
"--start-cursor-int",
"--end-cursor-int",
];
/// SQLBuild-only flags `sqb dbt run` and `sqb dbt build` accept.
pub const EXECUTION_SQLBUILD_FLAGS: [&str; 7] = [
"--start-cursor-ts",
Expand Down
1 change: 0 additions & 1 deletion crates/sqlbuild-core/src/diagnostic_routing/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub const SAFE_FIELDS: [&str; 7] = [
/// The safe fields a retained SQL diagnostic keeps.
pub const SQL_SAFE_FIELDS: [&str; 4] = ["sql_action", "sql_digest", "sql_intent", "sql_query_id"];
/// Python logging level numbers.
pub const LEVEL_DEBUG: i64 = 10;
pub const LEVEL_INFO: i64 = 20;
pub const LEVEL_WARNING: i64 = 30;
pub const LEVEL_ERROR: i64 = 40;
Expand Down
1 change: 0 additions & 1 deletion crates/sqlbuild-core/src/event_export/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub const OUTCOME_EVENT_TYPES: [&str; 6] = [
pub const OUTCOME_RESERVE_FRACTION: f64 = 0.25;
pub const RETRY_EVENT_TYPE: &str = "retry_scheduled";
pub const RETRY_EVENT_KIND: &str = "retry";
pub const RESOURCE_EVENT_PREFIX: &str = "resource";
pub const FAILED_EVENT_SUFFIX: &str = "_failed";
pub const FAILED_EVENT_PRIORITY: u8 = 3;
pub const TERMINAL_EVENT_PRIORITY: u8 = 2;
Expand Down
41 changes: 0 additions & 41 deletions crates/sqlbuild-core/src/text/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ pub struct TextPosition {
pub column: usize,
}

/// A half-open range of text.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct TextSpan {
pub start: TextPosition,
pub end: TextPosition,
}

/// Line starts of one text, converting offsets into Python-compatible lines and columns.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LineIndex<'text> {
Expand Down Expand Up @@ -64,38 +57,4 @@ impl<'text> LineIndex<'text> {
column,
})
}

/// The position at a code-point offset (a Python string index), or `None` past the end.
pub fn position_at_char(&self, char_offset: usize) -> Option<TextPosition> {
if char_offset > self.char_len {
return None;
}
let line_index = self
.line_char_starts
.partition_point(|start| *start <= char_offset)
- 1;
let line_start = self.line_byte_starts[line_index];
let column = char_offset - self.line_char_starts[line_index] + 1;
let byte_offset = self.text[line_start..]
.char_indices()
.nth(column - 1)
.map_or(self.text.len(), |(offset, _)| line_start + offset);
Some(TextPosition {
byte_offset,
char_offset,
line: line_index + 1,
column,
})
}

/// The span between two UTF-8 byte offsets, or `None` when either end is not a position.
pub fn span_at_bytes(&self, start: usize, end: usize) -> Option<TextSpan> {
if start > end {
return None;
}
Some(TextSpan {
start: self.position_at_byte(start)?,
end: self.position_at_byte(end)?,
})
}
}
37 changes: 1 addition & 36 deletions crates/sqlbuild-core/src/text/tests/test_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use crate::text::main::decimal_digit_value::decimal_digit_value;
use crate::text::main::decode_text::decode_text;
use crate::text::main::is_decimal_digit::is_decimal_digit;
use crate::text::models::LineIndex;
use crate::text::tests::test_types::{
DecimalDigitTestCase, DecodeTestCase, PositionTestCase, SpanTestCase,
};
use crate::text::tests::test_types::{DecimalDigitTestCase, DecodeTestCase, PositionTestCase};

#[test]
fn given_offsets_when_indexing_text_then_lines_and_columns_match_python() {
Expand Down Expand Up @@ -61,45 +59,12 @@ fn given_offsets_when_indexing_text_then_lines_and_columns_match_python() {
for test_case in test_cases {
let index = LineIndex::new(test_case.text);
let position = index.position_at_byte(test_case.byte_offset);
let round_trip = position.and_then(|found| index.position_at_char(found.char_offset));
assert_eq!(
position.map(|found| (found.char_offset, found.line, found.column)),
test_case.expected_position,
"{}",
test_case.description
);
assert_eq!(round_trip, position, "{} round trip", test_case.description);
}
}

#[test]
fn given_byte_ranges_when_building_spans_then_both_ends_are_positions() {
let test_cases = [
SpanTestCase {
description: "range on the second line",
text: "one\ntwo é three",
byte_range: (8, 10),
expected_ends: Some(((2, 5), (2, 6))),
},
SpanTestCase {
description: "reversed range is rejected",
text: "one",
byte_range: (2, 1),
expected_ends: None,
},
];
for test_case in test_cases {
let span = LineIndex::new(test_case.text)
.span_at_bytes(test_case.byte_range.0, test_case.byte_range.1);
assert_eq!(
span.map(|found| (
(found.start.line, found.start.column),
(found.end.line, found.end.column)
)),
test_case.expected_ends,
"{}",
test_case.description
);
}
}

Expand Down
7 changes: 0 additions & 7 deletions crates/sqlbuild-core/src/text/tests/test_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ pub(super) struct PositionTestCase {
pub(super) expected_position: Option<(usize, usize, usize)>,
}

pub(super) struct SpanTestCase {
pub(super) description: &'static str,
pub(super) text: &'static str,
pub(super) byte_range: (usize, usize),
pub(super) expected_ends: Option<((usize, usize), (usize, usize))>,
}

pub(super) struct DecodeTestCase {
pub(super) description: &'static str,
pub(super) bytes: &'static [u8],
Expand Down
25 changes: 0 additions & 25 deletions crates/sqlbuild-python/src/bindings/_helpers/analysis/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,6 @@ fn query_fingerprint(py: Python<'_>, sql: &str, dialect: &str) -> PyResult<Strin
.map_err(value_error)
}

#[pyfunction(name = "validate_sql_with_schema_json")]
fn schema_validation_json(py: Python<'_>, request_json: &str) -> PyResult<String> {
py.compiler_detach(|| {
sqlbuild_analysis::semantic_validation::main::validation_json(request_json)
})
.map_err(value_error)
}

#[pyfunction]
fn analyze_sql_uses_json(py: Python<'_>, request_json: &str) -> PyResult<String> {
py.compiler_detach(|| sqlbuild_analysis::semantic_usage::main::analyze_json(request_json))
.map_err(value_error)
}

#[pyfunction]
fn analyze_column_references_json(py: Python<'_>, request_json: &str) -> PyResult<String> {
py.compiler_detach(|| {
sqlbuild_analysis::column_references::main::analyze::analyze_json(request_json)
})
.map_err(value_error)
}

#[pyfunction]
fn analyze_queries_json(py: Python<'_>, request_json: &str) -> PyResult<String> {
py.compiler_detach(|| {
Expand Down Expand Up @@ -68,9 +46,6 @@ pub(crate) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
crate::bindings::_helpers::references::explicit_references::register(module)?;
crate::bindings::_helpers::analysis::binding_locations::register(module)?;
module.add_function(wrap_pyfunction!(query_fingerprint, module)?)?;
module.add_function(wrap_pyfunction!(schema_validation_json, module)?)?;
module.add_function(wrap_pyfunction!(analyze_sql_uses_json, module)?)?;
module.add_function(wrap_pyfunction!(analyze_column_references_json, module)?)?;
module.add_function(wrap_pyfunction!(analyze_queries_json, module)?)?;
module.add_function(wrap_pyfunction!(analyze_project_queries_json, module)?)?;
module.add_function(wrap_pyfunction!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use pyo3::types::PyDict;
use pyo3::{pyclass, pyfunction, pymethods, wrap_pyfunction};
use sqlbuild_core::cli_text::models::CliStyle;
use sqlbuild_core::dbt_events::main::consume_dbt_event::consume_dbt_event;
use sqlbuild_core::dbt_events::main::format_dbt_active_nodes::format_dbt_active_nodes;
use sqlbuild_core::dbt_events::main::render_dbt_node_row::render_dbt_node_row;
use sqlbuild_core::dbt_events::models::{DbtRowPosition, DbtStreamState, DbtStreamUpdate};

Expand Down Expand Up @@ -146,17 +145,9 @@ pub(crate) fn render_dbt_node_result(
))
}

/// The progress line listing running dbt nodes by their start time.
#[pyfunction]
#[pyo3(signature = (*, active_nodes, now))]
fn format_dbt_active_node_status(active_nodes: Vec<(String, f64)>, now: f64) -> String {
format_dbt_active_nodes(&active_nodes, now)
}

pub(crate) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
module.add_class::<DbtEventStream>()?;
module.add_class::<DbtEventStreamUpdate>()?;
module.add_function(wrap_pyfunction!(render_dbt_node_result, module)?)?;
module.add_function(wrap_pyfunction!(format_dbt_active_node_status, module)?)?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,11 @@ pub(crate) fn directory_snapshot_scope(
}
}

/// The active snapshot of `project_dir`, or `None` outside its scope.
#[pyfunction]
#[pyo3(signature = (*, project_dir))]
fn active_directory_snapshot<'py>(
project_dir: &Bound<'py, PyAny>,
) -> PyResult<Option<Bound<'py, NativeDirectorySnapshot>>> {
active_snapshot(project_dir)
}

pub(crate) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
module.add_class::<NativeDirectorySnapshot>()?;
module.add_class::<NativeDirectorySnapshotScope>()?;
module.add_function(wrap_pyfunction!(directory_snapshot_scope, module)?)?;
module.add_function(wrap_pyfunction!(active_directory_snapshot, module)?)
Ok(())
}

/// `str(project_dir / "_")` without its probe: the text printed before a relative path.
Expand Down
7 changes: 0 additions & 7 deletions crates/sqlbuild-python/src/bindings/_helpers/graph/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ use crate::bindings::_helpers::records::fields::field as native_field;
use crate::bindings::_helpers::records::fields::mapping_items;
use crate::bindings::_helpers::records::ids::RecordId;

/// The native graph's `(resource type, name)` pair for `key`.
#[pyfunction]
fn native_graph_key(key: &Bound<'_, PyAny>) -> PyResult<ObjectKey> {
native_key(key)
}

/// The native graph's pairs for `keys`, in order.
#[pyfunction]
fn native_graph_keys(keys: &Bound<'_, PyAny>) -> PyResult<Vec<ObjectKey>> {
Expand Down Expand Up @@ -201,7 +195,6 @@ pub(crate) fn native_graph_from_edges(
}

pub(crate) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
module.add_function(wrap_pyfunction!(native_graph_key, module)?)?;
module.add_function(wrap_pyfunction!(native_graph_keys, module)?)?;
module.add_function(wrap_pyfunction!(compiled_graph_keys, module)?)?;
module.add_function(wrap_pyfunction!(lineage_graph_names, module)?)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
//! Column renames validated natively, raised by Python as the attachment raises them.

use pyo3::prelude::{Bound, PyAny, PyAnyMethods, PyModule, PyModuleMethods, PyResult, Python};
use pyo3::prelude::{Bound, PyAnyMethods, PyResult};
use pyo3::types::{PyDict, PyDictMethods, PyString, PyStringMethods};
use pyo3::{IntoPyObject, pyfunction, wrap_pyfunction};
use sqlbuild_model_config::errors::ConfigError;
use sqlbuild_model_config::model_validation::main::validate_column_migrations::validate_column_migrations;
use sqlbuild_model_config::model_validation::models::ColumnMigration;

use crate::bindings::_helpers::boundary::panics::compiler_guard;
use crate::bindings::_helpers::model_config::config_errors::native_config_error;

const MATERIALIZED_KEY: &str = "materialized";
const MIGRATE_FROM_KEY: &str = "migrate_from";

Expand Down Expand Up @@ -38,27 +34,3 @@ pub(crate) fn column_migration_error(
.err(),
)
}

/// `None`, or the native error for the model's first column-rename problem.
#[pyfunction]
fn column_migration_problem<'py>(
py: Python<'py>,
model_name: &str,
values: Bound<'py, PyDict>,
columns: Vec<(String, Option<String>)>,
) -> PyResult<Bound<'py, PyAny>> {
let columns: Vec<ColumnMigration> = columns
.into_iter()
.map(|(name, migrate_from)| ColumnMigration { name, migrate_from })
.collect();
compiler_guard(
|| match column_migration_error(model_name, &values, &columns)? {
Some(error) => Ok(native_config_error(py, error)?.into_bound(py).into_any()),
None => Ok(py.None().into_pyobject(py)?.into_any()),
},
)
}

pub(crate) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
module.add_function(wrap_pyfunction!(column_migration_problem, module)?)
}
Loading
Loading