Skip to content

Commit fcb4b67

Browse files
authored
Merge branch 'main' into ci/retry-code-server-install
2 parents 9edf548 + 9d89350 commit fcb4b67

39 files changed

Lines changed: 2353 additions & 100 deletions

‎.github/dependabot.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,28 @@ updates:
3232
directory: '/'
3333
schedule:
3434
interval: 'weekly'
35+
- package-ecosystem: 'pip'
36+
directory: '/docs'
37+
schedule:
38+
interval: 'weekly'
39+
groups:
40+
# The docs toolchain (MkDocs, its theme and plugins, pdoc, Pygments) is
41+
# built and verified as a whole, so bump it in a single PR.
42+
docs:
43+
patterns:
44+
- '*'
45+
ignore:
46+
# MkDocs 2.0 removes the plugin and theme systems that Material for
47+
# MkDocs and our plugins depend on, so a major bump can't be taken as-is.
48+
- dependency-name: 'mkdocs'
49+
update-types: ['version-update:semver-major']
50+
# mkdocs-material 9.8+ requires Python >= 3.11, but Read the Docs builds
51+
# with Python 3.10 (.readthedocs.yaml). Drop this once that is raised.
52+
- dependency-name: 'mkdocs-material'
53+
versions: ['>=9.8']
54+
# pdoc renders the API reference through a custom template
55+
# (pdoc/templates/), and the docs-build CI job doesn't run it, so a major
56+
# bump would land untested. Upgrade pdoc majors by hand with
57+
# `make api-docs`.
58+
- dependency-name: 'pdoc'
59+
update-types: ['version-update:semver-major']

‎.github/workflows/pr.yaml‎

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
vscode: ${{ steps.filter.outputs.vscode }}
2222
lsp: ${{ steps.filter.outputs.lsp }}
2323
ci: ${{ steps.filter.outputs.ci }}
24+
docs: ${{ steps.filter.outputs.docs }}
2425
steps:
2526
- uses: actions/checkout@v7
2627
- uses: dorny/paths-filter@v4
@@ -46,6 +47,10 @@ jobs:
4647
- '.github/**'
4748
- 'Makefile'
4849
- '.pre-commit-config.yaml'
50+
docs:
51+
- 'docs/**'
52+
- 'mkdocs.yml'
53+
- '.readthedocs.yaml'
4954
5055
doc-tests:
5156
needs: changes
@@ -73,6 +78,33 @@ jobs:
7378
source .venv/bin/activate
7479
make doc-test
7580
81+
docs-build:
82+
needs: changes
83+
if:
84+
needs.changes.outputs.docs == 'true' || needs.changes.outputs.ci ==
85+
'true' || github.ref == 'refs/heads/main'
86+
runs-on: ubuntu-latest
87+
env:
88+
UV: '1'
89+
steps:
90+
- uses: actions/checkout@v7
91+
- name: Set up Python
92+
# Match the Python version Read the Docs builds with (.readthedocs.yaml)
93+
uses: actions/setup-python@v7
94+
with:
95+
python-version: '3.10'
96+
- name: Install uv
97+
uses: astral-sh/setup-uv@v7
98+
- name: Install dependencies
99+
run: |
100+
uv venv .venv
101+
source .venv/bin/activate
102+
make install-doc
103+
- name: Build docs
104+
run: |
105+
source .venv/bin/activate
106+
mkdocs build --strict
107+
76108
style-and-cicd-tests:
77109
needs: changes
78110
if:
@@ -403,9 +435,43 @@ jobs:
403435
./.github/scripts/manage-test-db.sh "${{ matrix.engine }}"
404436
"$TEST_DB_NAME" up
405437
- name: Run tests
438+
env:
439+
# Temporary BigQuery diagnostics: since 2026-10-31 the BigQuery runner either shuts
440+
# down or stops responding mid-pytest, and its log is never uploaded. Keep the
441+
# evidence in files, stop pytest before the job limit so the runner can recover,
442+
# and upload the files in the steps below. Remove once fixed.
443+
PYTHONUNBUFFERED: ${{ matrix.engine == 'bigquery' && '1' || '' }}
444+
PYTEST_ADDOPTS: ${{ matrix.engine == 'bigquery' && '-v' || '' }}
406445
run: |
407446
source .venv/bin/activate
408-
make ${{ matrix.engine }}-test
447+
if [ "${{ matrix.engine }}" != "bigquery" ]; then
448+
make ${{ matrix.engine }}-test
449+
exit
450+
fi
451+
mkdir -p test-results
452+
(
453+
while true; do
454+
echo "[resources $(date -u +%T)] $(free -m | awk '/Mem:/{print "mem_used="$3"MB mem_avail="$7"MB"}') $(free -m | awk '/Swap:/{print "swap_used="$3"MB"}') $(df -h / | awk 'NR==2{print "disk_used="$5}')"
455+
ps -eo rss=,args= --sort=-rss | head -4 | awk '{rss=$1; $1=""; printf " rss=%dMB %.120s\n", rss/1024, $0}'
456+
sleep 5
457+
done
458+
) >> test-results/bigquery-resources.log 2>&1 &
459+
trap "kill $! 2>/dev/null || true" EXIT
460+
make engine-bigquery-install
461+
uv pip install -e ".[bigframes]"
462+
# Same commands as the Makefile's bigquery-test target, under a timeout so
463+
# pytest itself (not just make) is stopped before the 25 minute job limit.
464+
set -o pipefail
465+
timeout --kill-after=60s 18m pytest -n auto -m "bigquery" --reruns 3 \
466+
--junitxml=test-results/junit-bigquery.xml 2>&1 | tee test-results/bigquery-pytest.log
467+
- name: Collect BigQuery diagnostics
468+
if: ${{ always() && matrix.engine == 'bigquery' }}
469+
run: |
470+
mkdir -p test-results
471+
sudo dmesg -T | grep -iE 'out of memory|oom|killed process' > test-results/bigquery-dmesg.log || true
472+
echo "== kernel OOM messages"; cat test-results/bigquery-dmesg.log
473+
echo "== last resource samples"; tail -n 60 test-results/bigquery-resources.log || true
474+
echo "== last pytest output"; tail -n 60 test-results/bigquery-pytest.log || true
409475
- name: Tear down test database
410476
if: always()
411477
run:

‎docs/concepts/audits.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ MODEL (
251251
#### at_least_one, at_least_one_non_blocking
252252
Ensures that specified columns contain at least one non-NULL value.
253253

254+
The audit fails when no row has a non-NULL value, including when the table is empty. For `INCREMENTAL_BY_TIME_RANGE` models the audit only sees the interval being processed, so an empty interval also fails. Use `at_least_one_non_blocking` if empty tables or intervals should log a warning instead of stopping the run.
255+
254256
This example asserts that the `zip` column contains at least one non-NULL value:
255257

256258
```sql linenums="1"

‎docs/concepts/macros/sqlmesh_macros.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ would be rendered as:
887887

888888
```sql linenums="1"
889889
SELECT
890-
CASE WHEN a IS NULL AND b IS NULL AND c IS NULL THEN NULL ELSE COALESCE(a, 0) + COALESCE(b, 0) + COALESCE(c, 0) END
890+
CASE WHEN a IS NULL AND b IS NULL AND c IS NULL THEN NULL ELSE (COALESCE(a, 0) + COALESCE(b, 0) + COALESCE(c, 0)) END
891891
FROM foo
892892
```
893893

@@ -906,7 +906,7 @@ would be rendered as:
906906

907907
```sql linenums="1"
908908
SELECT
909-
CASE WHEN a IS NULL AND b IS NULL AND c IS NULL THEN NULL ELSE COALESCE(a, 0) - COALESCE(b, 0) - COALESCE(c, 0) END
909+
CASE WHEN a IS NULL AND b IS NULL AND c IS NULL THEN NULL ELSE (COALESCE(a, 0) - COALESCE(b, 0) - COALESCE(c, 0)) END
910910
FROM foo
911911
```
912912

@@ -925,7 +925,7 @@ would be rendered as:
925925

926926
```sql linenums="1"
927927
SELECT
928-
a / NULLIF(b, 0)
928+
(a / NULLIF(b, 0))
929929
FROM foo
930930
```
931931

‎docs/requirements.txt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
mkdocs==1.4.2
2-
mkdocs-include-markdown-plugin==6.0.6
3-
mkdocs-material==9.0.5
4-
mkdocs-material-extensions==1.1.1
5-
mkdocs-glightbox==0.3.7
1+
mkdocs==1.6.1
2+
mkdocs-include-markdown-plugin==7.3.0
3+
mkdocs-material==9.7.7
4+
mkdocs-material-extensions==1.3.1
5+
mkdocs-glightbox==0.5.3
66
pdoc==14.5.1
7-
pygments==2.19.2 # Temporary pin: 2.20.0 breaks docs build; revisit after the fix
7+
pygments==2.21.0

‎mkdocs.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,16 @@ theme:
149149
palette:
150150
- media: "(prefers-color-scheme: light)"
151151
scheme: default
152-
primary: #3C64E2
153-
accent: #3C64E2
152+
primary: custom
153+
accent: custom
154154
toggle:
155155
icon: material/weather-sunny
156156
name: Switch to dark mode
157157
# Palette toggle for dark mode
158158
- media: "(prefers-color-scheme: dark)"
159159
scheme: slate
160-
primary: #3C64E2
161-
accent: #3C64E2
160+
primary: custom
161+
accent: custom
162162
toggle:
163163
icon: material/weather-night
164164
name: Switch to light mode

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ slack = ["slack_sdk"]
133133
snowflake = [
134134
"cryptography",
135135
"snowflake-connector-python[pandas,secure-local-storage]",
136-
"snowflake-snowpark-python",
136+
"snowflake-snowpark-python>=1.0.0",
137137
]
138138
starrocks = ["pymysql"]
139139
trino = ["trino"]

‎sqlmesh/core/audit/builtin.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,16 @@ def create_non_blocking_copy(audit: Audit) -> Audit:
137137
)
138138

139139
# at_least_one(column=column_name)
140+
# The aggregate is computed over the whole table rather than per group: grouping by the constant
141+
# produces no groups at all when the table is empty or @condition filters out every row, which
142+
# would make the audit pass even though no row has a non-NULL value.
140143
at_least_one_audit = ModelAudit(
141144
name="at_least_one",
142145
defaults={"condition": exp.true()},
143146
query="""
144-
SELECT 1
147+
SELECT COUNT(@column) AS cnt_not_null
145148
FROM @this_model
146149
WHERE @condition
147-
GROUP BY 1
148150
HAVING COUNT(@column) = 0
149151
""",
150152
)

‎sqlmesh/core/config/connection.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,7 @@ def _static_connection_kwargs(self) -> t.Dict[str, t.Any]:
24242424
# https://clickhouse.com/docs/en/operations/settings/settings
24252425
# - below are set to align with dbt-clickhouse
24262426
# - https://github.com/ClickHouse/dbt-clickhouse/blob/44d26308ea6a3c8ead25c280164aa88191f05f47/dbt/adapters/clickhouse/dbclient.py#L77
2427-
settings = self.connection_settings or {}
2427+
settings = dict(self.connection_settings or {})
24282428
# mutations_sync = 2: "The query waits for all mutations [ALTER statements] to complete on all replicas (if they exist)"
24292429
settings["mutations_sync"] = "2"
24302430
# insert_distributed_sync = 1: "INSERT operation succeeds only after all the data is saved on all shards"
@@ -2438,7 +2438,8 @@ def _static_connection_kwargs(self) -> t.Dict[str, t.Any]:
24382438
# - "INSERT succeeds only when ClickHouse manages to correctly write data to the insert_quorum of replicas during
24392439
# the insert_quorum_timeout"
24402440
# - "use majority number (number_of_replicas / 2 + 1) as quorum number"
2441-
settings["insert_quorum"] = "auto"
2441+
# - a value set by the user in connection_settings takes precedence
2442+
settings.setdefault("insert_quorum", "auto")
24422443

24432444
return {
24442445
"compress": compress,

‎sqlmesh/core/context_diff.py‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class ContextDiff(PydanticModel):
8888
"""Environment statements."""
8989
diff_rendered: bool = False
9090
"""Whether the diff should compare raw vs rendered models"""
91+
stored_parent_forward_only: t.Dict[SnapshotId, bool] = {}
92+
"""Whether the earlier versions of the stored parents of new indirectly modified snapshots were
93+
forward-only. A past version doesn't record this, so it is read from the snapshot stored for that
94+
version."""
9195

9296
@classmethod
9397
def create(
@@ -233,6 +237,9 @@ def create(
233237

234238
return ContextDiff(
235239
environment=environment,
240+
stored_parent_forward_only=_get_stored_parent_forward_only(
241+
state_reader, merged_snapshots, new_snapshots, modified_snapshots
242+
),
236243
is_new_environment=is_new_environment,
237244
is_unfinalized_environment=bool(env and not env.finalized_ts),
238245
normalize_environment_name=is_new_environment or bool(env and env.normalize_name),
@@ -491,6 +498,57 @@ def text_diff(self, name: str) -> str:
491498
return ""
492499

493500

501+
def _get_stored_parent_forward_only(
502+
state_reader: StateReader,
503+
snapshots: t.Dict[SnapshotId, Snapshot],
504+
new_snapshots: t.Dict[SnapshotId, Snapshot],
505+
modified_snapshots: t.Dict[str, t.Tuple[Snapshot, Snapshot]],
506+
) -> t.Dict[SnapshotId, bool]:
507+
"""Returns whether the past versions of stored parents were forward-only.
508+
509+
A stored parent already exists in state and is a direct parent of a new indirectly modified snapshot
510+
that also has a new direct parent, but it has changed since that snapshot's previous version. These
511+
are the only snapshots for which the plan builder reads the flags. For each such parent, the earlier
512+
versions in its history (`all_versions`, as used by the plan builder) created after the version the
513+
previous snapshot was built from are returned. Nothing is returned for a parent whose history doesn't
514+
reach back to that version, and versions that can't be found in state are left out.
515+
"""
516+
version_ids: t.Set[SnapshotId] = set()
517+
for snapshot, previous_snapshot in modified_snapshots.values():
518+
if (
519+
snapshot.snapshot_id not in new_snapshots
520+
or not any(parent_id in new_snapshots for parent_id in snapshot.parents)
521+
or not snapshot.is_indirectly_modified(previous_snapshot)
522+
):
523+
continue
524+
previous_parent_ids = {p.name: p for p in previous_snapshot.parents}
525+
for parent_id in snapshot.parents:
526+
parent = snapshots.get(parent_id)
527+
previous_parent_id = previous_parent_ids.get(parent_id.name)
528+
if (
529+
not parent
530+
or parent_id in new_snapshots
531+
or previous_parent_id is None
532+
or previous_parent_id == parent_id
533+
):
534+
continue
535+
# The latest version is the parent itself, whose flag is known.
536+
parent_version_ids: t.List[SnapshotId] = []
537+
for version in reversed(parent.all_versions[:-1]):
538+
version_id = version.snapshot_id(parent.name)
539+
if version_id == previous_parent_id:
540+
version_ids.update(parent_version_ids)
541+
break
542+
parent_version_ids.append(version_id)
543+
544+
if not version_ids:
545+
return {}
546+
return {
547+
snapshot_id: snapshot.is_forward_only
548+
for snapshot_id, snapshot in state_reader.get_snapshots(version_ids).items()
549+
}
550+
551+
494552
def _build_requirements(
495553
provided_requirements: t.Dict[str, str],
496554
excluded_requirements: t.Set[str],

0 commit comments

Comments
 (0)