Skip to content

Commit f7c5f75

Browse files
committed
fix: swap truncate logic
1 parent ed8b404 commit f7c5f75

File tree

3 files changed

+101
-9
lines changed

3 files changed

+101
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from setuptools_scm import get_version
22

3-
version = get_version(root='../', relative_to=__file__)
3+
version = get_version(root='../../', relative_to=__file__)
44
print(version.split('+')[0])
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Private Repo Testing
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: 'private-test-${{ github.event.pull_request.number }}'
10+
cancel-in-progress: true
11+
12+
jobs:
13+
trigger-private-test:
14+
runs-on: ubuntu-latest
15+
if: github.event.pull_request.head.repo.full_name == github.repository
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v6
28+
- name: Set up Node.js for UI build
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
- name: Install pnpm
33+
uses: pnpm/action-setup@v4
34+
with:
35+
version: latest
36+
- name: Install UI dependencies
37+
run: pnpm install
38+
- name: Build UI
39+
run: pnpm --prefix web/client run build
40+
- name: Install Python dependencies
41+
run: |
42+
python -m venv .venv
43+
source .venv/bin/activate
44+
pip install build twine setuptools_scm
45+
- name: Generate development version
46+
id: version
47+
run: |
48+
source .venv/bin/activate
49+
# Generate a development version using existing script
50+
DEV_VERSION=$(python .github/scripts/get_scm_version.py)
51+
echo "version=$DEV_VERSION" >> $GITHUB_OUTPUT
52+
echo "Generated development version: $DEV_VERSION"
53+
- name: Build package
54+
run: |
55+
source .venv/bin/activate
56+
python -m build
57+
- name: Configure PyPI for private repository
58+
run: |
59+
cat > ~/.pypirc << EOF
60+
[distutils]
61+
index-servers = tobiko-private
62+
[tobiko-private]
63+
repository = ${{ secrets.TOBIKO_PRIVATE_PYPI_URL }}
64+
username = _json_key_base64
65+
password = ${{ secrets.TOBIKO_PRIVATE_PYPI_KEY }}
66+
EOF
67+
- name: Publish to private PyPI
68+
run: |
69+
source .venv/bin/activate
70+
python -m twine upload -r tobiko-private dist/*
71+
- name: Get commit information
72+
id: commit
73+
run: |
74+
echo "author=$(git log -1 --format='%an')" >> $GITHUB_OUTPUT
75+
echo "hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
76+
echo "message=$(git log -1 --format='%s')" >> $GITHUB_OUTPUT
77+
- name: Trigger private repository workflow
78+
uses: convictional/[email protected]
79+
with:
80+
owner: ${{ secrets.PRIVATE_REPO_OWNER }}
81+
repo: ${{ secrets.PRIVATE_REPO_NAME }}
82+
github_token: ${{ secrets.PRIVATE_REPO_TOKEN }}
83+
workflow_file_name: ${{ secrets.PRIVATE_WORKFLOW_FILE }}
84+
client_payload: |
85+
{
86+
"package_version": "${{ steps.version.outputs.version }}",
87+
"python_version": "3.12",
88+
"author": "${{ steps.commit.outputs.author }}",
89+
"hash": "${{ steps.commit.outputs.hash }}",
90+
"message": "${{ steps.commit.outputs.message }}",
91+
"pr_number": "${{ github.event.pull_request.number }}"
92+
}

sqlmesh/core/engine_adapter/base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,21 +1762,19 @@ def remove_managed_columns(
17621762
# Historical Records that Do Not Change
17631763
.with_(
17641764
"static",
1765-
existing_rows_query.where(valid_to_col.is_(exp.Null()).not_())
1766-
if truncate
1767-
else existing_rows_query.where(
1765+
existing_rows_query.where(
17681766
exp.and_(
17691767
valid_to_col.is_(exp.Null().not_()),
17701768
valid_to_col < cleanup_ts,
17711769
),
1772-
),
1770+
)
1771+
if truncate
1772+
else existing_rows_query.where(valid_to_col.is_(exp.Null()).not_()),
17731773
)
17741774
# Latest Records that can be updated
17751775
.with_(
17761776
"latest",
1777-
existing_rows_query.where(valid_to_col.is_(exp.Null()))
1778-
if truncate
1779-
else exp.select(
1777+
exp.select(
17801778
*(
17811779
to_time_column(
17821780
exp.null(), time_data_type, self.dialect, nullable=True
@@ -1796,7 +1794,9 @@ def remove_managed_columns(
17961794
valid_to_col >= cleanup_ts,
17971795
),
17981796
)
1799-
),
1797+
)
1798+
if truncate
1799+
else existing_rows_query.where(valid_to_col.is_(exp.Null())),
18001800
)
18011801
# Deleted records which can be used to determine `valid_from` for undeleted source records
18021802
.with_(

0 commit comments

Comments
 (0)