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
7 changes: 3 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ 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"
# protoc 29.5 is the last version with protobuf python v5 which is compatible with protoletariat v3
RUN cd ~ && curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v29.5/protoc-29.5-linux-x86_64.zip && \
unzip protoc-29.5-linux-x86_64.zip -d ~/.local && \
rm protoc-29.5-linux-x86_64.zip
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
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
uvx [email protected] check
- name: Run ruff formatter
run: |
uvx [email protected] format
uvx [email protected] format --check
8 changes: 4 additions & 4 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: v2
plugins:
- protoc_builtin: python
out: src/substrait/gen
- remote: buf.build/community/nipunn1313-mypy:v3.6.0
out: src/substrait/gen
- remote: buf.build/protocolbuffers/python:v33.2
out: src
- remote: buf.build/community/nipunn1313-mypy:v4.0.0
out: src
8 changes: 4 additions & 4 deletions gen_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

set -eou pipefail

namespace=proto
namespace=substrait.gen.proto
submodule_dir=./third_party/substrait
src_dir="$submodule_dir"/proto
tmp_dir=./buf_work_dir
dest_dir=./src/substrait/gen
dest_dir=./src
Comment on lines +5 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was altering the value of namespace and dest_dir necessary? If so, why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's necessary since protoc generates the Python imports following the directory structure. with the changed namespace it generates a directory structure with the namespace within ./buf_work_dir (./buf_work__dir/substrait/gen/proto) which then gets copied over into ./src.

extension_dir=./src/substrait/extensions

# Prefix the protobuf files with a unique configuration to prevent namespace conflicts
# with other substrait packages. Save output to the work dir.
python "$submodule_dir"/tools/proto_prefix.py "$tmp_dir" "$namespace" "$src_dir"

# Remove the old python protobuf files
rm -rf "$dest_dir/proto"
rm -rf "$dest_dir/substrait/gen/proto"

# Generate the new python protobuf files
buf generate
uv run protol --in-place --create-package --python-out "$dest_dir" buf
find "$dest_dir/substrait/gen" -type d -exec touch {}/__init__.py \;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Can we add a comment explaining why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the answer is that protoc doesn't automatically generated __init__.py files in all of the subdirectories, so we have to do it manually. Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, protoc / buf don't generate those automatically and the previous ones get rm'ed


# Remove the old extension files
rm -rf "$extension_dir"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = [{name = "Substrait contributors", email = "[email protected]
license = {text = "Apache-2.0"}
readme = "README.md"
requires-python = ">=3.10,<3.14"
dependencies = ["protobuf >=3.19.1,<6"]
dependencies = ["protobuf >=6.33,<7"]
dynamic = ["version"]

[tool.setuptools_scm]
Expand All @@ -17,7 +17,7 @@ sql = ["sqloxide", "deepdiff"]

[dependency-groups]
dev = ["pytest >= 7.0.0", "antlr4-python3-runtime", "pyyaml", "sqloxide", "deepdiff", "duckdb<=1.2.2", "datafusion"]
gen_proto = ["protobuf >=3.19.1,<6", "protoletariat >= 3.0.0"]
gen_proto = ["protobuf >=6.33,<7"]
gen_extensions = ["datamodel-code-generator"]

[tool.pytest.ini_options]
Expand Down
1 change: 0 additions & 1 deletion src/substrait/builders/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def precision_timestamp_tz(precision: int, nullable=True) -> stt.Type:
)



def struct(types: Iterable[stt.Type], nullable=True) -> stt.Type:
return stt.Type(
struct=stt.Type.Struct(
Expand Down
9 changes: 0 additions & 9 deletions src/substrait/gen/proto/__init__.pyi

This file was deleted.

698 changes: 359 additions & 339 deletions src/substrait/gen/proto/algebra_pb2.py

Large diffs are not rendered by default.

4,972 changes: 2,630 additions & 2,342 deletions src/substrait/gen/proto/algebra_pb2.pyi

Large diffs are not rendered by default.

38 changes: 29 additions & 9 deletions src/substrait/gen/proto/capabilities_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 34 additions & 21 deletions src/substrait/gen/proto/capabilities_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 35 additions & 15 deletions src/substrait/gen/proto/extended_expression_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading