Skip to content

Commit 2367ef0

Browse files
authored
Merge branch 'main' into main
2 parents f595d3e + d4a3acb commit 2367ef0

File tree

855 files changed

+81245
-43118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

855 files changed

+81245
-43118
lines changed

.circleci/continue_config.yml

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,13 @@ jobs:
9393
- run:
9494
name: Run linters and code style checks
9595
command: make py-style
96-
- run:
97-
name: Exercise the benchmarks
98-
command: make benchmark-ci
96+
- unless:
97+
condition:
98+
equal: ["3.9", << parameters.python_version >>]
99+
steps:
100+
- run:
101+
name: Exercise the benchmarks
102+
command: make benchmark-ci
99103
- run:
100104
name: Run cicd tests
101105
command: make cicd-test
@@ -144,8 +148,11 @@ jobs:
144148
- halt_unless_core
145149
- checkout
146150
- run:
147-
name: Run the migration test
148-
command: ./.circleci/test_migration.sh
151+
name: Run the migration test - sushi
152+
command: ./.circleci/test_migration.sh sushi "--gateway duckdb_persistent"
153+
- run:
154+
name: Run the migration test - sushi_dbt
155+
command: ./.circleci/test_migration.sh sushi_dbt "--config migration_test_config"
149156

150157
ui_style:
151158
docker:
@@ -172,7 +179,7 @@ jobs:
172179

173180
ui_test:
174181
docker:
175-
- image: mcr.microsoft.com/playwright:v1.52.0-jammy
182+
- image: mcr.microsoft.com/playwright:v1.54.1-jammy
176183
resource_class: medium
177184
steps:
178185
- halt_unless_client
@@ -201,39 +208,6 @@ jobs:
201208
name: Run tests
202209
command: npm --prefix web/client run test
203210

204-
trigger_private_tests:
205-
docker:
206-
- image: cimg/python:3.12.0
207-
resource_class: small
208-
steps:
209-
- checkout
210-
- run:
211-
name: Install setuptools scm
212-
command: pip install setuptools_scm
213-
- run:
214-
name: Trigger private tests
215-
command: |
216-
export COMMIT_MESSAGE="$(git log --format=%s -n 1 $CIRCLE_SHA1)"
217-
export FORMATTED_COMMIT_MESSAGE="${COMMIT_MESSAGE//\"/\\\"}"
218-
# returns a version string like 0.1.0.dev11
219-
export PACKAGE_VERSION="$(python ./.circleci/get_scm_version.py)"
220-
curl --request POST \
221-
--url $TOBIKO_PRIVATE_CIRCLECI_URL \
222-
--header "Circle-Token: $TOBIKO_PRIVATE_CIRCLECI_KEY" \
223-
--header "content-type: application/json" \
224-
--data '{
225-
"branch":"main",
226-
"parameters":{
227-
"run_main_pr":false,
228-
"run_sqlmesh_commit":true,
229-
"sqlmesh_branch":"'$CIRCLE_BRANCH'",
230-
"sqlmesh_commit_author":"'$CIRCLE_USERNAME'",
231-
"sqlmesh_commit_hash":"'$CIRCLE_SHA1'",
232-
"sqlmesh_commit_message":"'"$FORMATTED_COMMIT_MESSAGE"'",
233-
"sqlmesh_package_version":"'$PACKAGE_VERSION'"
234-
}
235-
}'
236-
237211
engine_tests_docker:
238212
parameters:
239213
engine:
@@ -270,6 +244,9 @@ jobs:
270244
steps:
271245
- halt_unless_core
272246
- checkout
247+
- run:
248+
name: Install OS-level dependencies
249+
command: ./.circleci/install-prerequisites.sh "<< parameters.engine >>"
273250
- run:
274251
name: Generate database name
275252
command: |
@@ -279,6 +256,8 @@ jobs:
279256
echo "export SNOWFLAKE_DATABASE='$TEST_DB_NAME'" >> "$BASH_ENV"
280257
echo "export DATABRICKS_CATALOG='$TEST_DB_NAME'" >> "$BASH_ENV"
281258
echo "export REDSHIFT_DATABASE='$TEST_DB_NAME'" >> "$BASH_ENV"
259+
echo "export GCP_POSTGRES_DATABASE='$TEST_DB_NAME'" >> "$BASH_ENV"
260+
echo "export FABRIC_DATABASE='$TEST_DB_NAME'" >> "$BASH_ENV"
282261
- run:
283262
name: Create test database
284263
command: ./.circleci/manage-test-db.sh << parameters.engine >> "$TEST_DB_NAME" up
@@ -306,6 +285,7 @@ workflows:
306285
- "3.10"
307286
- "3.11"
308287
- "3.12"
288+
- "3.13"
309289
- cicd_tests_windows
310290
- engine_tests_docker:
311291
name: engine_<< matrix.engine >>
@@ -329,19 +309,14 @@ workflows:
329309
matrix:
330310
parameters:
331311
engine:
332-
- snowflake
312+
#- snowflake
333313
- databricks
334314
- redshift
335315
- bigquery
336316
- clickhouse-cloud
337317
- athena
338-
filters:
339-
branches:
340-
only:
341-
- main
342-
- trigger_private_tests:
343-
requires:
344-
- style_and_cicd_tests
318+
- fabric
319+
- gcp-postgres
345320
filters:
346321
branches:
347322
only:

.circleci/install-prerequisites.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,31 @@ fi
1212

1313
ENGINE="$1"
1414

15-
COMMON_DEPENDENCIES="libpq-dev netcat-traditional"
15+
COMMON_DEPENDENCIES="libpq-dev netcat-traditional unixodbc-dev"
1616
ENGINE_DEPENDENCIES=""
1717

1818
if [ "$ENGINE" == "spark" ]; then
1919
ENGINE_DEPENDENCIES="default-jdk"
20+
elif [ "$ENGINE" == "fabric" ]; then
21+
echo "Installing Microsoft package repository"
22+
23+
# ref: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
24+
curl -sSL -O https://packages.microsoft.com/config/ubuntu/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)/packages-microsoft-prod.deb
25+
sudo dpkg -i packages-microsoft-prod.deb
26+
rm packages-microsoft-prod.deb
27+
28+
ENGINE_DEPENDENCIES="msodbcsql18"
2029
fi
2130

2231
ALL_DEPENDENCIES="$COMMON_DEPENDENCIES $ENGINE_DEPENDENCIES"
2332

2433
echo "Installing OS-level dependencies: $ALL_DEPENDENCIES"
2534

26-
sudo apt-get clean && sudo apt-get -y update && sudo apt-get -y install $ALL_DEPENDENCIES
35+
sudo apt-get clean && sudo apt-get -y update && sudo ACCEPT_EULA='Y' apt-get -y install $ALL_DEPENDENCIES
36+
37+
if [ "$ENGINE" == "spark" ]; then
38+
echo "Using Java version for spark:"
39+
java -version
40+
fi
2741

2842
echo "All done"

.circleci/manage-test-db.sh

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ databricks_init() {
5151

5252
# Note: the cluster doesnt need to be running to create / drop catalogs, but it does need to be running to run the integration tests
5353
echo "Ensuring cluster is running"
54+
# the || true is to prevent the following error from causing an abort:
55+
# > Error: is in unexpected state Running.
5456
databricks clusters start $CLUSTER_ID || true
5557
}
5658

@@ -80,7 +82,11 @@ redshift_down() {
8082
EXIT_CODE=1
8183
ATTEMPTS=0
8284
while [ $EXIT_CODE -ne 0 ] && [ $ATTEMPTS -lt 5 ]; do
83-
redshift_exec "select pg_terminate_backend(procpid) from pg_stat_activity where datname = '$1'"
85+
# note: sometimes this pg_terminate_backend() call can randomly fail with: ERROR: Insufficient privileges
86+
# if it does, let's proceed with the drop anyway rather than aborting and never attempting the drop
87+
redshift_exec "select pg_terminate_backend(procpid) from pg_stat_activity where datname = '$1'" || true
88+
89+
# perform drop
8490
redshift_exec "drop database $1;" && EXIT_CODE=$? || EXIT_CODE=$?
8591
if [ $EXIT_CODE -ne 0 ]; then
8692
echo "Unable to drop database; retrying..."
@@ -109,6 +115,51 @@ clickhouse-cloud_init() {
109115
echo "Clickhouse Cloud instance $CLICKHOUSE_CLOUD_HOST is up and running"
110116
}
111117

118+
# GCP Postgres
119+
gcp-postgres_init() {
120+
# Download and start Cloud SQL Proxy
121+
curl -fsSL -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.linux.amd64
122+
chmod +x cloud-sql-proxy
123+
echo "$GCP_POSTGRES_KEYFILE_JSON" > /tmp/keyfile.json
124+
./cloud-sql-proxy --credentials-file /tmp/keyfile.json $GCP_POSTGRES_INSTANCE_CONNECTION_STRING &
125+
126+
# Wait for proxy to start
127+
sleep 5
128+
}
129+
130+
gcp-postgres_exec() {
131+
PGPASSWORD=$GCP_POSTGRES_PASSWORD psql -h 127.0.0.1 -U $GCP_POSTGRES_USER -c "$1" postgres
132+
}
133+
134+
gcp-postgres_up() {
135+
gcp-postgres_exec "create database $1"
136+
}
137+
138+
gcp-postgres_down() {
139+
gcp-postgres_exec "drop database $1"
140+
}
141+
142+
# Fabric
143+
fabric_init() {
144+
python --version #note: as at 2025-08-20, ms-fabric-cli is pinned to Python >= 3.10, <3.13
145+
pip install ms-fabric-cli
146+
147+
# to prevent the '[EncryptionFailed] An error occurred with the encrypted cache.' error
148+
# ref: https://microsoft.github.io/fabric-cli/#switch-to-interactive-mode-optional
149+
fab config set encryption_fallback_enabled true
150+
151+
echo "Logging in to Fabric"
152+
fab auth login -u $FABRIC_CLIENT_ID -p $FABRIC_CLIENT_SECRET --tenant $FABRIC_TENANT_ID
153+
}
154+
155+
fabric_up() {
156+
fab create "SQLMesh CircleCI.Workspace/$1.Warehouse"
157+
}
158+
159+
fabric_down() {
160+
fab rm -f "SQLMesh CircleCI.Workspace/$1.Warehouse" || true
161+
}
162+
112163
INIT_FUNC="${ENGINE}_init"
113164
UP_FUNC="${ENGINE}_up"
114165
DOWN_FUNC="${ENGINE}_down"

.circleci/test_migration.sh

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
#!/usr/bin/env bash
22
set -ex
33

4-
GATEWAY_NAME="duckdb_persistent"
5-
TMP_DIR=$(mktemp -d)
6-
SUSHI_DIR="$TMP_DIR/sushi"
7-
8-
94
if [[ -z $(git tag --points-at HEAD) ]]; then
105
# If the current commit is not tagged, we need to find the last tag
116
LAST_TAG=$(git describe --tags --abbrev=0)
@@ -14,28 +9,48 @@ else
149
LAST_TAG=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
1510
fi
1611

12+
if [ "$1" == "" ]; then
13+
echo "Usage: $0 <example name> <sqlmesh opts>"
14+
echo "eg $0 sushi '--gateway duckdb_persistent'"
15+
exit 1
16+
fi
17+
18+
19+
TMP_DIR=$(mktemp -d)
20+
EXAMPLE_NAME="$1"
21+
SQLMESH_OPTS="$2"
22+
EXAMPLE_DIR="./examples/$EXAMPLE_NAME"
23+
TEST_DIR="$TMP_DIR/$EXAMPLE_NAME"
24+
25+
echo "Running migration test for '$EXAMPLE_NAME' in '$TEST_DIR' for example project '$EXAMPLE_DIR' using options '$SQLMESH_OPTS'"
26+
1727
git checkout $LAST_TAG
1828

1929
# Install dependencies from the previous release.
2030
make install-dev
2131

22-
cp -r ./examples/sushi $TMP_DIR
32+
cp -r $EXAMPLE_DIR $TEST_DIR
33+
34+
# this is only needed temporarily until the released tag for $LAST_TAG includes this config
35+
if [ "$EXAMPLE_NAME" == "sushi_dbt" ]; then
36+
echo 'migration_test_config = sqlmesh_config(Path(__file__).parent, dbt_target_name="duckdb")' >> $TEST_DIR/config.py
37+
fi
2338

2439
# Run initial plan
25-
pushd $SUSHI_DIR
40+
pushd $TEST_DIR
2641
rm -rf ./data/*
27-
sqlmesh --gateway $GATEWAY_NAME plan --no-prompts --auto-apply
42+
sqlmesh $SQLMESH_OPTS plan --no-prompts --auto-apply
2843
rm -rf .cache
2944
popd
3045

31-
# Switch back to the starting state of the repository
46+
# Switch back to the starting state of the repository
3247
git checkout -
3348

3449
# Install updated dependencies.
3550
make install-dev
3651

3752
# Migrate and make sure the diff is empty
38-
pushd $SUSHI_DIR
39-
sqlmesh --gateway $GATEWAY_NAME migrate
40-
sqlmesh --gateway $GATEWAY_NAME diff prod
41-
popd
53+
pushd $TEST_DIR
54+
sqlmesh $SQLMESH_OPTS migrate
55+
sqlmesh $SQLMESH_OPTS diff prod
56+
popd

.claude/agents/code-reviewer.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
name: code-reviewer
3+
description: Use this agent PROACTIVELY when you need expert code review after writing or modifying code. This agent should be called after completing any coding task to ensure quality, architectural compliance, and catch potential issues. Examples: <example>Context: The user has just implemented a new feature for processing SQLMesh snapshots. user: 'I just added a new method to handle snapshot fingerprinting in the Context class' assistant: 'Let me use the code-reviewer agent to analyze this implementation for potential issues and architectural compliance' <commentary>Since code was just written, use the code-reviewer agent to review the implementation for quality, edge cases, and adherence to SQLMesh patterns.</commentary></example> <example>Context: An agent just generated a database migration script. user: 'Here's the migration I created for adding a new state table' assistant: 'Now I'll have the code-reviewer agent examine this migration for safety and best practices' <commentary>Since a migration was created, use the code-reviewer agent to ensure it follows SQLMesh migration patterns and handles edge cases safely.</commentary></example>
4+
tools: Glob, Grep, LS, Read, NotebookRead, WebFetch, TodoWrite, WebSearch, Bash
5+
model: sonnet
6+
color: blue
7+
---
8+
9+
You are an Expert Code Reviewer, a senior software engineer with deep expertise in code quality, architecture, and best practices. You NEVER write code yourself - your sole focus is providing thorough, insightful code reviews that catch issues other engineers might miss.
10+
11+
Your core responsibilities:
12+
13+
## Analysis Approach
14+
15+
- Examine code for architectural alignment with established patterns and principles
16+
- Identify potential edge cases, race conditions, and error scenarios
17+
- Evaluate performance implications and scalability concerns
18+
- Check for security vulnerabilities and data safety issues
19+
- Assess maintainability, readability, and documentation quality
20+
- Verify adherence to project-specific coding standards and conventions
21+
22+
## Review Methodology
23+
24+
- **Architectural Review**: Does the code follow established patterns? Does it fit well within the existing codebase structure?
25+
- **Logic Analysis**: Are there logical flaws, edge cases, or scenarios that could cause failures?
26+
- **Error Handling**: Is error handling comprehensive and appropriate? Are failure modes considered?
27+
- **Performance Review**: Are there performance bottlenecks, inefficient algorithms, or resource leaks?
28+
- **Security Assessment**: Are there potential security vulnerabilities or data exposure risks?
29+
- **Maintainability Check**: Is the code readable, well-structured, and properly documented?
30+
31+
### Standard Code Review Checklist
32+
33+
- Code is simple and readable
34+
- Functions, classes, and variables are well-named
35+
- No duplicated code
36+
- Proper error handling with specific error types
37+
- No exposed secrets, API keys, or credentials
38+
- Input validation and sanitization implemented
39+
- Good test coverage including edge cases
40+
- Performance considerations addressed
41+
- Security best practices followed
42+
- Documentation updated for significant changes
43+
44+
## Feedback Structure
45+
46+
Organize your reviews into clear categories:
47+
48+
- **Critical Issues**: Problems that could cause failures, security issues, or data corruption
49+
- **Architectural Concerns**: Deviations from established patterns or design principles
50+
- **Edge Cases**: Scenarios that might not be handled properly
51+
- **Performance Considerations**: Potential bottlenecks or inefficiencies
52+
- **Maintainability Improvements**: Suggestions for better code organization or documentation
53+
- **Documentation**: Suggestions to update documentation for significant changes
54+
55+
## Communication Style
56+
57+
- Be constructive and specific in your feedback
58+
- Explain the 'why' behind your suggestions, not just the 'what'
59+
- Prioritize issues by severity and impact
60+
- Acknowledge good practices when you see them
61+
- Provide context for your recommendations
62+
- Ask clarifying questions when code intent is unclear
63+
64+
## Important Constraints
65+
66+
- You NEVER write, modify, or suggest specific code implementations
67+
- You focus purely on analysis and high-level guidance
68+
- You always consider the broader system context and existing codebase patterns
69+
- You escalate concerns about fundamental architectural decisions
70+
- You validate that solutions align with project requirements and constraints
71+
72+
When reviewing code, assume you're looking at recently written code unless explicitly told otherwise. Focus on providing actionable insights that help improve code quality while respecting the existing architectural decisions and project constraints.
73+

0 commit comments

Comments
 (0)