Skip to content

Commit 1ba82f5

Browse files
john-sanchez31knassre-bodopre-commit-ci[bot]hadia206
authored
Add support for MySQL databases & dialect in PyDough (#385)
Co-authored-by: knassre-bodo <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: knassre-bodo <[email protected]> Co-authored-by: Hadia Ahmed <[email protected]>
1 parent 00d6c09 commit 1ba82f5

File tree

564 files changed

+14781
-1668
lines changed

Some content is hidden

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

564 files changed

+14781
-1668
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Run MySQL 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+
MYSQL_USERNAME:
12+
required: true
13+
MYSQL_PASSWORD:
14+
required: true
15+
16+
jobs:
17+
mysql-tests:
18+
name: MySQL 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+
mysql:
27+
image: bodoai1/pydough-mysql-tpch:latest
28+
env:
29+
# Set environment variables for MySQL container
30+
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
31+
MYSQL_DATABASE: tpch
32+
ports:
33+
- 3306:3306
34+
env:
35+
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }}
36+
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
37+
MYSQL_DATABASE: tpch
38+
MYSQL_HOST: 127.0.0.1
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Setup Python ${{ matrix.python-version }}
44+
id: setup-python
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
49+
- name: Install uv
50+
uses: astral-sh/setup-uv@v3
51+
with:
52+
version: "0.4.23"
53+
54+
- name: Create virtual environment
55+
run: uv venv
56+
57+
- name: Install dependencies
58+
run: uv pip install -e ".[mysql]"
59+
60+
- name: Wait for MySQL to be ready
61+
run: |
62+
for i in $(seq 1 10); do
63+
mysqladmin ping -h 127.0.0.1 -P 3306 -u root -p${{ env.MYSQL_PASSWORD }} && break
64+
echo "Waiting for MySQL... ($i/10)"
65+
sleep 5
66+
done
67+
mysqladmin ping -h 127.0.0.1 -P 3306 -u root -p${{ env.MYSQL_PASSWORD }} || exit 1
68+
69+
- name: Confirm MySQL connector is installed
70+
run: uv run python -c "import mysql.connector; print('MySQL connector installed')"
71+
72+
- name: Run MySQL Tests
73+
74+
run: uv run pytest -m mysql tests/ -rs

.github/workflows/pr_testing.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ on:
2626
type: boolean
2727
required: false
2828
default: false
29+
run-mysql:
30+
description: "Run MySQL Tests"
31+
type: boolean
32+
required: false
33+
default: false
2934

3035
# Limit CI to cancel previous runs in the same PR
3136
concurrency:
@@ -127,7 +132,7 @@ jobs:
127132
run: uv run ruff check .
128133

129134
- name: Run Tests
130-
run: uv run pytest tests/ -m "not snowflake" -rs
135+
run: uv run pytest tests/ -m "not (snowflake or mysql)" -rs
131136

132137
run-sf-tests:
133138
name: Snowflake Tests
@@ -144,3 +149,18 @@ jobs:
144149
python-versions: ${{ github.event_name == 'workflow_dispatch'
145150
&& needs.get-py-ver-matrix.outputs.matrix
146151
|| '["3.10", "3.11", "3.12"]' }}
152+
153+
run-mysql-tests:
154+
name: MySQL Tests
155+
needs: [get-msg, get-py-ver-matrix]
156+
if: |
157+
(github.event_name == 'pull_request' && contains(needs.get-msg.outputs.commitMsg, '[run mysql]')) ||
158+
(github.event_name == 'workflow_dispatch' && inputs.run-mysql)
159+
uses: ./.github/workflows/mysql_testing.yml # Path to MySQL workflow file
160+
secrets:
161+
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }}
162+
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
163+
with:
164+
python-versions: ${{ github.event_name == 'workflow_dispatch'
165+
&& needs.get-py-ver-matrix.outputs.matrix
166+
|| '["3.10", "3.11", "3.12"]' }}

demos/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ 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.
2627

demos/notebooks/1_introduction.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
"name": "python",
295295
"nbconvert_exporter": "python",
296296
"pygments_lexer": "ipython3",
297-
"version": "3.12.6"
297+
"version": "3.13.5"
298298
}
299299
},
300300
"nbformat": 4,

demos/notebooks/2_pydough_operations.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@
610610
"name": "python",
611611
"nbconvert_exporter": "python",
612612
"pygments_lexer": "ipython3",
613-
"version": "3.12.6"
613+
"version": "3.13.5"
614614
}
615615
},
616616
"nbformat": 4,

0 commit comments

Comments
 (0)