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
9 changes: 4 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ jobs:
uses: actions/checkout@v5
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v6
- name: Install uv with python
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python }}
- name: Install package and test dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ".[test]"
uv sync --frozen --extra test
- name: Run tests
run: |
python -m pytest tests
uv run pytest
43 changes: 22 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ git clone --recursive https://github.com/<your-fork>/substrait-python.git
cd substrait-python
```

## Conda env
Create a conda environment with developer dependencies.
## Development environment
Activate environment with uv.
```
conda env create -f environment.yml
conda activate substrait-python-env
uv sync --extra test
```

## Update the substrait submodule locally
Expand All @@ -21,43 +20,45 @@ git submodule update --init --recursive
```


# Upgrade the substrait protocol definition
# Code generation

## a) Use the upgrade script
## Protobuf stubs

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

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

## b) Manual upgrade
## Antlr grammar

### Upgrade the Substrait submodule
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.

```
cd third_party/substrait
git checkout <version>
cd -
git commit . -m "Use submodule <version>"
make antlr
```

### Generate protocol buffers
Generate the protobuf files manually. Requires protobuf `v3.20.1`.
## Extensions stubs

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

```
./gen_proto.sh
make codegen-extensions
```

# Lint & Format

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

# Build
## Python package
Editable installation.
```
pip install -e .
make lint
make format
```

# Test
Run tests in the project's root dir.
```
pytest
uv sync --extra test
uv run pytest
```
14 changes: 0 additions & 14 deletions environment.yml

This file was deleted.

7 changes: 5 additions & 2 deletions tests/builders/plan/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from substrait.builders.plan import read_named_table
import pytest
from substrait.gen.proto.extensions.extensions_pb2 import AdvancedExtension
from google.protobuf import any
from google.protobuf import any_pb2
from google.protobuf.wrappers_pb2 import StringValue

struct = stt.Type.Struct(
Expand Down Expand Up @@ -80,7 +80,10 @@ def test_read_rel_schema_nullable():


def test_read_rel_ae():
extension = AdvancedExtension(optimization=[any.pack(StringValue(value="Opt1"))])
any = any_pb2.Any()
any.Pack(StringValue(value="Opt1"))

extension = AdvancedExtension(optimization=[any])

actual = read_named_table(["example_db", "example_table"], named_struct, extension)(
None
Expand Down
Loading