Skip to content

Commit 414d538

Browse files
Add support for PostgreSQL dialect (#400)
Co-authored-by: john-sanchez31 <[email protected]>
1 parent 1222915 commit 414d538

File tree

286 files changed

+8984
-385
lines changed

Some content is hidden

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

286 files changed

+8984
-385
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Run Postgres Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-versions:
7+
description: "JSON string of Python versions"
8+
type: string
9+
required: true
10+
secrets:
11+
POSTGRES_USER:
12+
required: true
13+
POSTGRES_PASSWORD:
14+
required: true
15+
16+
jobs:
17+
postgres-test:
18+
name: Postgres Tests (Python ${{ matrix.python-version }})
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
python-version: ${{ fromJSON(inputs.python-versions) }}
23+
24+
# Define services here to run Docker containers alongside your job
25+
services:
26+
postgres:
27+
image: bodoai1/pydough-postgres-tpch:latest
28+
env:
29+
# Set environment variables for Postgres container
30+
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
31+
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
32+
POSTGRES_DB: "pydough_test"
33+
ports:
34+
- 5432:5432
35+
env:
36+
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
37+
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
38+
POSTGRES_DB: pydough_test
39+
POSTGRES_HOST: 127.0.0.1
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Setup Python ${{ matrix.python-version }}
45+
id: setup-python
46+
uses: actions/setup-python@v4
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v3
52+
with:
53+
version: "0.4.23"
54+
55+
- name: Create virtual environment
56+
run: uv venv
57+
58+
- name: Install dependencies
59+
run: uv pip install -e ".[postgres]"
60+
61+
- name: Wait for Postgres to be ready
62+
run: |
63+
for i in $(seq 1 240); do
64+
pg_isready -h ${{ env.POSTGRES_HOST }} -U ${{ env.POSTGRES_USER }} -d ${{ env.POSTGRES_DB }} && break || sleep 2;
65+
done
66+
pg_isready -h ${{ env.POSTGRES_HOST }} -U ${{ env.POSTGRES_USER }} -d ${{ env.POSTGRES_DB }} && echo "PostgreSQL is running" || exit 1;
67+
- name: Confirm Postgres connector is installed
68+
run: uv run python -c "import psycopg2; print('Postgres connector installed')"
69+
70+
- name: Run Postgres Tests
71+
run: uv run pytest -m postgres tests/ -rs

.github/workflows/pr_testing.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ on:
3636
type: boolean
3737
required: false
3838
default: false
39+
run-postgres:
40+
description: "Run Postgres Tests"
41+
type: boolean
42+
required: false
43+
default: false
3944

4045
# Limit CI to cancel previous runs in the same PR
4146
concurrency:
@@ -138,7 +143,7 @@ jobs:
138143
run: uv run ruff check .
139144

140145
- name: Run Tests
141-
run: uv run pytest tests/ -m "not (snowflake or mysql)" -rs
146+
run: uv run pytest tests/ -m "not (snowflake or mysql or postgres)" -rs
142147

143148
run-sf-tests:
144149
name: Snowflake Tests
@@ -164,11 +169,27 @@ jobs:
164169
(github.event_name == 'pull_request' && contains(needs.get-msg.outputs.commitMsg, '[run all]')) ||
165170
(github.event_name == 'pull_request' && contains(needs.get-msg.outputs.commitMsg, '[run mysql]')) ||
166171
(github.event_name == 'workflow_dispatch' && (inputs.run-all || inputs.run-mysql))
167-
uses: ./.github/workflows/mysql_testing.yml # Path to MySQL workflow file
172+
uses: ./.github/workflows/mysql_testing.yml
168173
secrets:
169174
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }}
170175
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
171176
with:
172177
python-versions: ${{ github.event_name == 'workflow_dispatch'
173178
&& needs.get-py-ver-matrix.outputs.matrix
174179
|| '["3.10", "3.11", "3.12"]' }}
180+
181+
run-postgres-tests:
182+
name: Postgres Tests
183+
needs: [get-msg, get-py-ver-matrix]
184+
if: |
185+
(github.event_name == 'pull_request' && contains(needs.get-msg.outputs.commitMsg, '[run all]')) ||
186+
(github.event_name == 'pull_request' && contains(needs.get-msg.outputs.commitMsg, '[run postgres]')) ||
187+
(github.event_name == 'workflow_dispatch' && (inputs.run-all || inputs.run-postgres))
188+
uses: ./.github/workflows/postgres_testing.yml
189+
secrets:
190+
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
191+
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
192+
with:
193+
python-versions: ${{ github.event_name == 'workflow_dispatch'
194+
&& needs.get-py-ver-matrix.outputs.matrix
195+
|| '["3.10", "3.11", "3.12"]' }}

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,26 @@ To run **MySQL CI tests**, add the flag `[run mysql]` to your commit message.
141141
export MYSQL_USERNAME="your_username"
142142
export MYSQL_PASSWORD="your_password"
143143
144+
## Running Postgres Tests on CI
145+
To run **Postgres CI tests**, add the flag `[run postgres]` to your commit message.
146+
147+
**Running Postgres tests locally:**
148+
149+
1. Make sure you have [**Docker Desktop**](https://www.docker.com/get-started/)
150+
installed and running.
151+
152+
2. Install the Postgres Connector for Python
153+
```bash
154+
pip install psycopg2-binary
155+
```
156+
157+
3. Set your Postgres credentials as environment variables:
158+
```bash
159+
export POSTGRES_DB="your_database"
160+
export POSTGRES_USER="your_username"
161+
export POSTGRES_PASSWORD="your_password"
162+
```
163+
144164
## Runtime Dependencies
145165

146166
PyDough requires having the following Python modules installed to use

demos/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Once the introduction notebook is complete, you can explore the other notebooks:
2323
- [3_exploration.ipynb](notebooks/3_exploration.ipynb) shows how to use several user APIs for exploring PyDough.
2424
- [4_tpch.ipynb](notebooks/4_tpch.ipynb) provides PyDough translations for most of the TPC-H benchmark queries.
2525
- [5_what_if.ipynb](notebooks/5_what_if.ipynb) demonstrates how to do WHAT-IF analysis with PyDough.
26-
- [MySQL_TPCH.ipynb](notebooks/MySQL_TPCH.ipynb) demonstrates how to connect a MySQL database with PyDough.
2726
- [SF_TPCH_q1.ipynb](notebooks/SF_TPCH_q1.ipynb) demonstrates how to connect a Snowflake database with PyDough.
27+
- [MySQL_TPCH.ipynb](notebooks/MySQL_TPCH.ipynb) demonstrates how to connect a MySQL database with PyDough.
28+
- [PG_TPCH.ipynb](notebooks/PG_TPCH.ipynb) demonstrates how to connect a Postgres database with PyDough.
2829

0 commit comments

Comments
 (0)