Skip to content

Commit 993eb19

Browse files
committed
Merge remote-tracking branch 'origin/main' into refactor/python-base-crate
# Conflicts: # fensu.toml
2 parents 2eb9ca1 + d704d4c commit 993eb19

26 files changed

Lines changed: 403 additions & 61 deletions

File tree

‎.release-please-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.231.0"
2+
".": "0.232.0"
33
}

‎CHANGELOG.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## [0.232.0](https://github.com/sqlstack-io/sqlbuild/compare/v0.231.0...v0.232.0) (2026-11-15)
4+
5+
6+
### ⚠ BREAKING CHANGES
7+
8+
* share Python identity work per discovery pass and keep compile phases out of sinks ([#1501](https://github.com/sqlstack-io/sqlbuild/issues/1501))
9+
10+
### Performance Improvements
11+
12+
* share Python identity work per discovery pass and keep compile phases out of sinks ([#1501](https://github.com/sqlstack-io/sqlbuild/issues/1501)) ([d15ee25](https://github.com/sqlstack-io/sqlbuild/commit/d15ee25919dedb6abde6e1b1c6ad8b5a46cf322b))
13+
314
## [0.231.0](https://github.com/sqlstack-io/sqlbuild/compare/v0.230.1...v0.231.0) (2026-11-15)
415

516

‎Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/sqlbuild-cli/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlbuild-cli"
3-
version = "0.231.0"
3+
version = "0.232.0"
44
description = "The native `sqb` executable: reused compiles and Python-free commands served without Python, every other command handed to the Python CLI."
55
edition.workspace = true
66
license-file = "LICENSE"

‎crates/sqlbuild-cli/src/native_commands/_helpers/execution.rs‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,13 @@ pub(crate) async fn read_metadata_page(
12321232
Some(reader) => reader,
12331233
None => match open_location_runtime(options, script, Vec::new()) {
12341234
Ok(reader) => reader,
1235-
Err(_) => return Ok(Some((state, None))),
1235+
Err(error) => {
1236+
drop(write_output(&[(
1237+
Stream::Stderr,
1238+
&format!("Warehouse metadata reader did not start: {error}\n"),
1239+
)]));
1240+
return Ok(Some((state, None)));
1241+
}
12361242
},
12371243
};
12381244
tokio::pin!(stopped);
@@ -1254,11 +1260,23 @@ pub(crate) async fn read_metadata_page(
12541260
state.reader = Some(reader);
12551261
Ok(Some((state, None)))
12561262
}
1257-
Ok((reader, Err(_))) => {
1263+
Ok((reader, Err(error))) => {
1264+
drop(write_output(&[(
1265+
Stream::Stderr,
1266+
&format!("Warehouse metadata reader failed: {error}\n"),
1267+
)]));
12581268
stop_location_runtime(Some(reader)).await?;
12591269
Ok(Some((state, None)))
12601270
}
1261-
Err(_) => Ok(Some((state, None))),
1271+
Err(_) => {
1272+
drop(write_output(&[(
1273+
Stream::Stderr,
1274+
&format!(
1275+
"Warehouse metadata read did not answer within {METADATA_POLL_SECONDS}s.\n"
1276+
),
1277+
)]));
1278+
Ok(Some((state, None)))
1279+
}
12621280
},
12631281
}
12641282
}

‎crates/sqlbuild-python/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlbuild-python"
3-
version = "0.231.0"
3+
version = "0.232.0"
44
description = "The sqlbuild._native Python extension module."
55
edition.workspace = true
66
license.workspace = true

‎crates/sqlbuild-python/src/bindings/_helpers/location_command/runtime.rs‎

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
33
use std::io::{self, Write};
44

5+
use pyo3::PyErr;
56
use pyo3::exceptions::PyValueError;
67
use pyo3::prelude::{Bound, PyAnyMethods, PyResult, Python};
78
use pyo3::types::{PyDict, PyDictMethods};
9+
use sqlbuild_core::redaction::main::redact_error_text::redact_error_text;
810
use sqlbuild_orchestration::sensors::models::{CustomSensorOutcome, SensorEvaluationRequest};
911
use sqlbuild_orchestration::warehouse_metadata::models::{
1012
WarehouseHistoryKind, WarehouseHistoryRead,
@@ -55,9 +57,9 @@ pub(super) fn run_runtime(py: Python<'_>, options: Bound<'_, PyDict>) -> PyResul
5557
}
5658
};
5759
serde_json::to_string(&record)
58-
} else if WarehouseHistoryKind::ALL
60+
} else if let Some(kind) = WarehouseHistoryKind::ALL
5961
.iter()
60-
.any(|kind| request.get(kind.as_str()).is_some())
62+
.find(|kind| request.get(kind.as_str()).is_some())
6163
{
6264
let metadata: WarehouseHistoryRead =
6365
serde_json::from_value(request).map_err(|_| {
@@ -73,7 +75,10 @@ pub(super) fn run_runtime(py: Python<'_>, options: Bound<'_, PyDict>) -> PyResul
7375
if !busy {
7476
write_stderr(
7577
py,
76-
"Warehouse connection for metadata reads failed.\n",
78+
&format!(
79+
"Warehouse connection for metadata reads failed: {}\n",
80+
failure_reason(&error)
81+
),
7782
)?;
7883
} else if !reported_busy {
7984
write_stderr(
@@ -86,16 +91,13 @@ pub(super) fn run_runtime(py: Python<'_>, options: Bound<'_, PyDict>) -> PyResul
8691
};
8792
}
8893
let page = match &session {
89-
Some(opened) => {
90-
match read_history(py, (opened, stream.take()), &metadata) {
91-
Ok((page, open)) => {
92-
stream = open;
93-
Some(page)
94-
}
95-
Err(_) => None,
96-
}
97-
}
98-
None => None,
94+
Some(opened) => read_history(py, (opened, stream.take()), &metadata)
95+
.map(|(page, open)| {
96+
stream = open;
97+
page
98+
})
99+
.map_err(|error| format!(": {}", failure_reason(&error))),
100+
None => Err(String::new()),
99101
};
100102
if session.as_ref().is_some_and(|opened| opened.local)
101103
&& let Some(opened) = session.take()
@@ -106,16 +108,23 @@ pub(super) fn run_runtime(py: Python<'_>, options: Bound<'_, PyDict>) -> PyResul
106108
if busy {
107109
serde_json::to_string(&serde_json::json!({ "busy": true }))
108110
} else {
109-
if page.is_none() {
110-
if let Some(opened) = session.take() {
111-
drop(close_history_session(opened, None));
111+
let delivered = match &page {
112+
Ok(page) => Some(page),
113+
Err(reason) => {
114+
if let Some(opened) = session.take() {
115+
drop(close_history_session(opened, None));
116+
}
117+
write_stderr(
118+
py,
119+
&format!(
120+
"Warehouse metadata read ({}) failed{reason}. No page delivered.\n",
121+
kind.as_str()
122+
),
123+
)?;
124+
None
112125
}
113-
write_stderr(
114-
py,
115-
"Warehouse metadata read failed. No page delivered.\n",
116-
)?;
117-
}
118-
serde_json::to_string(&page)
126+
};
127+
serde_json::to_string(&delivered)
119128
}
120129
} else {
121130
let evaluation: SensorEvaluationRequest = serde_json::from_value(request)
@@ -162,3 +171,11 @@ pub(super) fn run_runtime(py: Python<'_>, options: Bound<'_, PyDict>) -> PyResul
162171
result
163172
})
164173
}
174+
175+
/// The driver's class and message on one line, redacted as warehouse error text.
176+
fn failure_reason(error: &PyErr) -> String {
177+
redact_error_text(&error.to_string())
178+
.split_whitespace()
179+
.collect::<Vec<_>>()
180+
.join(" ")
181+
}

‎crates/sqlbuild-python/src/bindings/_helpers/native_host/warehouse_metadata.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use sqlbuild_state::freshness::constants::{
2929
};
3030
use sqlbuild_state::observations::constants::OBSERVATION_COLUMN_TYPES;
3131
use sqlbuild_state::resource_costs::constants::RESOURCE_COST_COLUMN_TYPES;
32+
use sqlbuild_state::state_tables::main::event_id_index::event_id_index;
3233
use sqlbuild_state::state_tables::main::read_history_sql::read_history_sql;
3334
use sqlbuild_state::state_tables::models::HistoryRead;
3435

@@ -447,7 +448,7 @@ fn read_page<'py>(
447448
.then_some(index)
448449
})
449450
.collect();
450-
cursor_indexes.push(columns.len());
451+
cursor_indexes.push(event_id_index(columns));
451452
let mut literals = vec![None; key_columns.unwrap_or(columns).len() + 1];
452453
if let Some(after) = after {
453454
let classes = SqlValueClasses::load(py)?;
@@ -773,7 +774,7 @@ fn decode_record(
773774
let mut value = json!({
774775
"state_database": location.database,
775776
"state_schema": location.schema,
776-
"event_id": row.get_item(columns.len())?.extract::<Option<String>>()?,
777+
"event_id": row.get_item(event_id_index(columns))?.extract::<Option<String>>()?,
777778
});
778779
for name in columns {
779780
let name = match *name {

‎crates/sqlbuild-rules/src/lint_text/tests/test_lint_text.rs‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const CROSS_JOIN_FILE: &str = "select o.order_id\nfrom orders as o\n-- sqb: igno
3535
const NORMALISE_NAME_MACRO: &str = "MACRO (\n description \"Normalise a name\",\n arguments (column_name VARCHAR),\n returns VARCHAR,\n);\n\nREGEXP_REPLACE(\n TRIM(UPPER(\n -- Collapse repeated spaces\n REGEXP_REPLACE(\n @column_name,\n '[[:space:]]+',\n ' '\n ))),\n '(^| )([A-Z]) ',\n '\\\\1\\\\2'\n)\n";
3636
const ESCAPED_QUOTE_MACRO: &str = "MACRO (arguments (v VARCHAR), returns VARCHAR);\n\nCONCAT(\n @v,\n 'O\\'Brien\n kept indent',\n 'tail'\n)\n";
3737
const ESCAPED_QUOTE_FORMATTED: &str = "MACRO (arguments (v VARCHAR), returns VARCHAR);\n\nCONCAT(@v, 'O\\'Brien\n kept indent', 'tail')\n";
38+
const E_STRING_MACRO: &str = "MACRO (arguments (v VARCHAR), returns VARCHAR);\n\nCONCAT(\n @v,\n E'O\\'Brien\n kept indent',\n 'tail'\n)\n";
39+
const E_STRING_FORMATTED: &str = "MACRO (arguments (v VARCHAR), returns VARCHAR);\n\nCONCAT(@v, E'O\\'Brien\n kept indent', 'tail')\n";
40+
const NESTED_COMMENT_MACRO: &str = "MACRO (arguments (v VARCHAR), returns VARCHAR);\n\nCOALESCE(\n @v, /* outer /* inner */ it's\n kept */\n 'x'\n)\n";
41+
const NESTED_COMMENT_FORMATTED: &str = "MACRO (arguments (v VARCHAR), returns VARCHAR);\n\nCOALESCE(\n @v, /* outer /* inner */ it's\n kept */ 'x'\n)\n";
3842
const BLOCK_COMMENT_MACRO: &str = "MACRO (arguments (v VARCHAR), returns VARCHAR);\n\nCOALESCE(\n @v, /* first\n second */\n 'x'\n)\n";
3943
const BLOCK_COMMENT_FORMATTED: &str = "MACRO (arguments (v VARCHAR), returns VARCHAR);\n\nCOALESCE(\n @v, /* first\n second */ 'x'\n)\n";
4044
const NORMALISE_NAME_FORMATTED: &str = "MACRO (\n description \"Normalise a name\",\n arguments (column_name VARCHAR),\n returns VARCHAR,\n);\n\nREGEXP_REPLACE(\n TRIM(\n UPPER(\n -- Collapse repeated spaces\n REGEXP_REPLACE(@column_name, '[[:space:]]+', ' ')\n )\n ),\n '(^| )([A-Z]) ',\n '\\\\1\\\\2'\n)\n";
@@ -1011,22 +1015,34 @@ fn given_expression_macro_bodies_when_formatting_twice_then_every_dialect_lays_t
10111015
let test_cases = [
10121016
ExpressionMacroFormatTestCase {
10131017
description: "a body with a comment between nested calls",
1014-
dialects: &["duckdb", "snowflake"],
1018+
dialects: &["duckdb", "snowflake", "databricks"],
10151019
contents: NORMALISE_NAME_MACRO.to_string(),
10161020
expected_formatted: NORMALISE_NAME_FORMATTED.to_string(),
10171021
},
10181022
ExpressionMacroFormatTestCase {
10191023
description: "a body nesting fifteen calls, authored flush left",
1020-
dialects: &["duckdb", "snowflake"],
1024+
dialects: &["duckdb", "snowflake", "databricks"],
10211025
contents: nested_macro(15, ""),
10221026
expected_formatted: nested_macro(15, " "),
10231027
},
10241028
ExpressionMacroFormatTestCase {
10251029
description: "a multi-line string after a backslash-escaped quote",
1026-
dialects: &["snowflake"],
1030+
dialects: &["snowflake", "databricks"],
10271031
contents: ESCAPED_QUOTE_MACRO.to_string(),
10281032
expected_formatted: ESCAPED_QUOTE_FORMATTED.to_string(),
10291033
},
1034+
ExpressionMacroFormatTestCase {
1035+
description: "a multi-line E-string after a backslash-escaped quote",
1036+
dialects: &["duckdb"],
1037+
contents: E_STRING_MACRO.to_string(),
1038+
expected_formatted: E_STRING_FORMATTED.to_string(),
1039+
},
1040+
ExpressionMacroFormatTestCase {
1041+
description: "a nested block comment holding an apostrophe",
1042+
dialects: &["duckdb", "databricks"],
1043+
contents: NESTED_COMMENT_MACRO.to_string(),
1044+
expected_formatted: NESTED_COMMENT_FORMATTED.to_string(),
1045+
},
10301046
ExpressionMacroFormatTestCase {
10311047
description: "a block comment with indented lines",
10321048
dialects: &["duckdb", "snowflake"],

‎crates/sqlbuild-sqltext/src/sql_scan/main/dialect_lexical_syntax.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ pub fn dialect_lexical_syntax(dialect: &str) -> LexicalSyntax {
2424
line_comment_prefixes: lines(&["--", "# ", "#!", "//"]),
2525
..LexicalSyntax::default()
2626
},
27-
"databricks" | "duckdb" => LexicalSyntax {
27+
"databricks" => LexicalSyntax {
28+
backslash_escape_quotes: strings(&["'", "\""]),
29+
raw_string_prefix: true,
30+
nested_block_comments: true,
2831
line_comment_prefixes: lines(&["--"]),
2932
..LexicalSyntax::default()
3033
},

0 commit comments

Comments
 (0)