Skip to content

Commit fce10eb

Browse files
committed
Merge branch 'main' into temp_contribution
2 parents aa48c31 + 1354c46 commit fce10eb

File tree

100 files changed

+4400
-2419
lines changed

Some content is hidden

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

100 files changed

+4400
-2419
lines changed

.devcontainer/Dockerfile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
FROM mcr.microsoft.com/vscode/devcontainers/python:3.9-buster
1+
FROM mcr.microsoft.com/vscode/devcontainers/python:3.13
22
USER vscode
33
RUN curl -s "https://get.sdkman.io" | bash
4-
SHELL ["/bin/bash", "-c"]
5-
RUN source "/home/vscode/.sdkman/bin/sdkman-init.sh" && sdk install java 20.0.2-graalce
6-
RUN mkdir -p ~/lib && cd ~/lib && curl -L -O http://www.antlr.org/download/antlr-4.13.1-complete.jar
7-
ENV ANTLR_JAR="~/lib/antlr-4.13.1-complete.jar"
8-
RUN cd ~ && curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protoc-25.1-linux-x86_64.zip && \
9-
unzip protoc-25.1-linux-x86_64.zip -d ~/.local && \
10-
rm protoc-25.1-linux-x86_64.zip
11-
RUN curl -sSL "https://github.com/bufbuild/buf/releases/download/v1.50.0/buf-$(uname -s)-$(uname -m)" -o ~/.local/bin/buf && chmod +x ~/.local/bin/buf
12-
RUN curl -LsSf https://astral.sh/uv/0.7.11/install.sh | sh
4+
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && \
5+
sdk install java 25-graalce"
6+
RUN mkdir -p ~/lib && cd ~/lib && curl -L -O http://www.antlr.org/download/antlr-4.13.2-complete.jar
7+
ENV ANTLR_JAR="~/lib/antlr-4.13.2-complete.jar"
8+
# protoc 29.5 is the last version with protobuf python v5 which is compatible with protoletariat v3
9+
RUN cd ~ && curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v29.5/protoc-29.5-linux-x86_64.zip && \
10+
unzip protoc-29.5-linux-x86_64.zip -d ~/.local && \
11+
rm protoc-29.5-linux-x86_64.zip
12+
RUN curl -sSL "https://github.com/bufbuild/buf/releases/download/v1.58.0/buf-$(uname -s)-$(uname -m)" -o ~/.local/bin/buf && chmod +x ~/.local/bin/buf
13+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
1314
USER root

.devcontainer/devcontainer.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,21 @@
1414
// "forwardPorts": [],
1515

1616
// Use 'postCreateCommand' to run commands after the container is created.
17-
// "postCreateCommand": "poetry install"
17+
"postCreateCommand": "uv venv --clear && uv sync --extra test --extra gen_proto",
1818

1919
// Configure tool-specific properties.
20-
// "customizations": {},
20+
"customizations": {
21+
"vscode": {
22+
"settings": {
23+
"python.testing.pytestArgs": [
24+
"tests"
25+
],
26+
"python.testing.unittestEnabled": false,
27+
"python.testing.pytestEnabled": true
28+
},
29+
"extensions": []
30+
}
31+
}
2132

2233
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
2334
// "remoteUser": "root"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Code Generation Check
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
codegen-check:
11+
name: Verify Code Generation
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v5
16+
with:
17+
submodules: recursive
18+
19+
- name: Run code generation in devcontainer
20+
uses: devcontainers/[email protected]
21+
with:
22+
runCmd: |
23+
# Ensure dependencies are installed
24+
uv sync --extra test --extra gen_proto
25+
# Run all code generation steps
26+
make antlr
27+
./gen_proto.sh
28+
make codegen-extensions
29+
30+
- name: Check for uncommitted changes
31+
run: |
32+
# Check for diffs, ignoring timestamp lines
33+
if ! git diff --quiet --exit-code src/substrait/gen/; then
34+
echo "Code generation produced changes. Generated code is out of sync!"
35+
echo ""
36+
git diff src/substrait/gen/
37+
echo ""
38+
echo "To fix this, run:"
39+
echo " make antlr"
40+
echo " ./gen_proto.sh"
41+
echo " make codegen-extensions"
42+
echo "Then commit the changes."
43+
exit 1
44+
fi

.github/workflows/example.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Run examples
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
example:
13+
name: Run ${{ matrix.example }}
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
example:
18+
- builder_example.py
19+
- duckdb_example.py
20+
- adbc_example.py
21+
- pyarrow_example.py
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v5
25+
with:
26+
submodules: recursive
27+
- name: Install uv with python
28+
uses: astral-sh/setup-uv@v7
29+
with:
30+
python-version: "3.10"
31+
- name: Install package dependencies
32+
run: |
33+
uv sync --frozen --extra extensions
34+
- name: Run ${{ matrix.example }}
35+
run: |
36+
uv run examples/${{ matrix.example }}

.github/workflows/pr_title.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: PR title / description conforms to semantic-release
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/setup-node@v5
11+
- uses: actions/setup-node@v6
1212
with:
1313
node-version: "18"
1414
- run: npm install @commitlint/config-conventional

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: |
3030
python -m build
3131
- name: Upload package
32-
uses: actions/upload-artifact@v4
32+
uses: actions/upload-artifact@v5
3333
with:
3434
name: dist
3535
path: dist/
@@ -41,7 +41,7 @@ jobs:
4141
if: startsWith(github.ref, 'refs/tags/v')
4242
steps:
4343
- name: Download artifact
44-
uses: actions/download-artifact@v5
44+
uses: actions/download-artifact@v6
4545
with:
4646
name: dist
4747
path: dist/
@@ -57,7 +57,7 @@ jobs:
5757
needs: release
5858
steps:
5959
- name: Download artifact
60-
uses: actions/download-artifact@v5
60+
uses: actions/download-artifact@v6
6161
with:
6262
name: dist
6363
path: dist/

.github/workflows/ruff.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest]
18-
python: ["3.9"]
18+
python: ["3.10"]
1919
runs-on: ${{ matrix.os }}
2020
steps:
2121
- name: Checkout code
2222
uses: actions/checkout@v5
2323
with:
2424
submodules: recursive
2525
- name: Install uv with python
26-
uses: astral-sh/setup-uv@v6
26+
uses: astral-sh/setup-uv@v7
2727
with:
2828
python-version: ${{ matrix.python }}
2929
- name: Run ruff linter

.github/workflows/test.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [macos-latest, ubuntu-latest, windows-latest]
18-
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
18+
python: ["3.10", "3.11", "3.12", "3.13"]
1919
runs-on: ${{ matrix.os }}
2020
steps:
2121
- name: Checkout code
2222
uses: actions/checkout@v5
2323
with:
2424
submodules: recursive
25-
- name: Set up Python
26-
uses: actions/setup-python@v6
25+
- name: Install uv with python
26+
uses: astral-sh/setup-uv@v7
2727
with:
2828
python-version: ${{ matrix.python }}
2929
- name: Install package and test dependencies
3030
run: |
31-
python -m pip install --upgrade pip
32-
python -m pip install ".[test]"
31+
uv sync --frozen --extra test
3332
- name: Run tests
3433
run: |
35-
python -m pytest tests
34+
uv run pytest

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "third_party/substrait"]
22
path = third_party/substrait
33
url = https://github.com/substrait-io/substrait
4-
[submodule "third_party/substrait-cpp"]
5-
path = third_party/substrait-cpp
6-
url = https://github.com/substrait-io/substrait-cpp

CONTRIBUTING.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ git clone --recursive https://github.com/<your-fork>/substrait-python.git
66
cd substrait-python
77
```
88

9-
## Conda env
10-
Create a conda environment with developer dependencies.
9+
## Development environment
10+
Activate environment with uv.
1111
```
12-
conda env create -f environment.yml
13-
conda activate substrait-python-env
12+
uv sync --extra test
1413
```
1514

1615
## Update the substrait submodule locally
@@ -21,43 +20,45 @@ git submodule update --init --recursive
2120
```
2221

2322

24-
# Upgrade the substrait protocol definition
23+
# Code generation
2524

26-
## a) Use the upgrade script
25+
## Protobuf stubs
2726

2827
Run the upgrade script to upgrade the submodule and regenerate the protobuf stubs.
2928

3029
```
31-
./update_proto.sh <version>
30+
uv sync --extra gen_proto
31+
uv run ./update_proto.sh <version>
3232
```
3333

34-
## b) Manual upgrade
34+
## Antlr grammar
3535

36-
### Upgrade the Substrait submodule
36+
Substrait uses antlr grammar to derive output types of extension functions. Make sure java is installed and ANTLR_JAR environment variable is set. Take a look at .devcontainer/Dockerfile for example setup.
3737

3838
```
39-
cd third_party/substrait
40-
git checkout <version>
41-
cd -
42-
git commit . -m "Use submodule <version>"
39+
make antlr
4340
```
4441

45-
### Generate protocol buffers
46-
Generate the protobuf files manually. Requires protobuf `v3.20.1`.
42+
## Extensions stubs
43+
44+
Substrait uses jsonschema to describe the data model for extension files.
45+
4746
```
48-
./gen_proto.sh
47+
make codegen-extensions
4948
```
5049

50+
# Lint & Format
51+
52+
Run the following make commands to lint and format with ruff.
5153

52-
# Build
53-
## Python package
54-
Editable installation.
5554
```
56-
pip install -e .
55+
make lint
56+
make format
5757
```
5858

5959
# Test
6060
Run tests in the project's root dir.
6161
```
62-
pytest
62+
uv sync --extra test
63+
uv run pytest
6364
```

0 commit comments

Comments
 (0)