Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
FROM mcr.microsoft.com/vscode/devcontainers/python:3.13
USER vscode
RUN curl -s "https://get.sdkman.io" | bash
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && \
sdk install java 25-graalce"
RUN mkdir -p ~/lib && cd ~/lib && curl -L -O http://www.antlr.org/download/antlr-4.13.2-complete.jar
ENV ANTLR_JAR="~/lib/antlr-4.13.2-complete.jar"
RUN cd ~ && curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v33.2/protoc-33.2-linux-x86_64.zip && \
unzip protoc-33.2-linux-x86_64.zip -d ~/.local && \
rm protoc-33.2-linux-x86_64.zip
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
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
USER root
RUN curl -fsSL https://pixi.sh/install.sh | sh
ENV PATH=~/.pixi/bin:$PATH
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "uv venv --clear && uv sync --group gen_proto",
"postCreateCommand": "uv venv --clear && uv sync",

// Configure tool-specific properties.
"customizations": {
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
src/substrait/gen/** linguist-generated=true
src/substrait/extensions/** linguist-generated=true
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
28 changes: 10 additions & 18 deletions .github/workflows/codegen-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,17 @@ jobs:
with:
submodules: recursive

- name: Run code generation in devcontainer
uses: devcontainers/ci@v0.3
- uses: prefix-dev/setup-pixi@v0.9.3
with:
runCmd: |
# fetch submodule tags since actions/checkout does not
git submodule foreach 'git fetch --unshallow || true'
# Run all code generation steps
make codegen
pixi-version: v0.62.2

- name: Run code generation
run: |
# fetch submodule tags since actions/checkout does not
git submodule foreach 'git fetch --unshallow || true'
# Run all code generation steps
pixi run codegen

- name: Check for uncommitted changes
run: |
# Check for diffs, ignoring timestamp lines
if ! git diff --quiet --exit-code src/substrait/gen/; then
echo "Code generation produced changes. Generated code is out of sync!"
echo ""
git diff src/substrait/gen/
echo ""
echo "To fix this, run:"
echo " make codegen"
echo "Then commit the changes."
exit 1
fi
pixi run check-codegen
10 changes: 4 additions & 6 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.10"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Install uv with python
uses: astral-sh/setup-uv@v7
- uses: prefix-dev/setup-pixi@v0.9.3
with:
python-version: ${{ matrix.python }}
pixi-version: v0.62.2
- name: Run ruff linter
run: |
uvx ruff@0.11.11 check
pixi run lint
- name: Run ruff formatter
run: |
uvx ruff@0.11.11 format --check
pixi run format --check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,6 @@ src/substrait/_version.py
.directory
.gdb_history
.DS_Store
# pixi environments
.pixi/*
!.pixi/config.toml
35 changes: 19 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,61 @@ uv sync --extra test
```

## Update the substrait submodule locally
You can run update-submodule task to pull in latest substrait from upstream.
```
pixi run update-submodule <version>
```

Or you can update submodule and run code generation at the same time with
```
pixi run update-substrait
```

This might be necessary if you are updating an existing checkout.
```
git submodule sync --recursive
git submodule update --init --recursive
```


# Code generation

You can run the full code generation using the following command or use the individual commands to selectively regenerate the generated code. This does not update the Substrait Git submodule.
You can run the full code generation using the following command or use the individual commands to selectively regenerate the generated code. This does not update the Substrait Git submodule. You can use pixi environment defined in pyproject.toml which contains all dependencies needed for code generation.

```
make codegen
pixi run codegen
```

## Protobuf stubs

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

```
uv run --group gen_proto ./update_proto.sh <version>
```

Or run the proto codegen without updating the Substrait Git submodule:
Run the proto codegen only:

```
make codegen-proto
pixi run codegen-proto
```

## Antlr grammar

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.

```
make antlr
pixi run antlr
```

## Extensions stubs

Substrait uses jsonschema to describe the data model for extension files.

```
make codegen-extensions
pixi run codegen-extensions
```

# Lint & Format

Run the following make commands to lint and format with ruff.
Run the following pixi tasks to lint and format with ruff.

```
make lint
make format
pixi run lint
pixi run format
```

# Test
Expand Down
34 changes: 0 additions & 34 deletions Makefile

This file was deleted.

11 changes: 11 additions & 0 deletions check_codegen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
if ! git diff --quiet --exit-code src/substrait/gen/; then
echo "Code generation produced changes. Generated code is out of sync!"
echo ""
git diff src/substrait/gen/
echo ""
echo "To fix this, run:"
echo " pixi run codegen"
echo "Then commit the changes."
exit 1
fi
Loading
Loading