feat(python/sedonadb-expr): Add Python documentation sources based on SQL documentation#862
Open
paleolimbot wants to merge 29 commits into
Open
feat(python/sedonadb-expr): Add Python documentation sources based on SQL documentation#862paleolimbot wants to merge 29 commits into
paleolimbot wants to merge 29 commits into
Conversation
15e28b5 to
c511c2d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an optional, build-time-generated Python package (sedonadb-expr) that exposes SQL-function documentation and geometry/geography accessor helpers (.geo) for improved IDE completion and inline docs, while keeping the core sedonadb import/load cost low for non-interactive usage.
Changes:
- Introduces new
sedonadb-exprPython package with Hatch build hook + codegen fromdocs/reference/sql/*.qmd. - Adds
.geoaccessors onExpr,Literal, andFunctionsto route calls through generatedGeoMethods/GeoFunctions. - Updates CI to install and test
sedonadb-expralongsidesedonadb.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| python/sedonadb/tests/expr/test_function_expression.py | Adds tests for piped expressions and new .geo accessors. |
| python/sedonadb/python/sedonadb/functions/init.py | Adds Functions.geo property exposing generated geo functions. |
| python/sedonadb/python/sedonadb/expr/literal.py | Adds Literal.geo and internal _call used by generated accessors. |
| python/sedonadb/python/sedonadb/expr/expression.py | Adds Expr.geo and internal _call used by generated accessors. |
| python/sedonadb-expr/tests/test_codegen.py | Tests doc/code generation helpers and validates generated sources compile. |
| python/sedonadb-expr/tests/init.py | Initializes test package (license header only). |
| python/sedonadb-expr/README.md | Adds initial package README and installation snippet. |
| python/sedonadb-expr/python/sedonadb_expr/utils.py | Adds MISSING sentinel + trailing-missing argument filtering helper. |
| python/sedonadb-expr/python/sedonadb_expr/_codegen.py | Implements parsing of SQL docs and generation of accessor modules + docstrings. |
| python/sedonadb-expr/python/sedonadb_expr/init.py | Exposes GeoFunctions / GeoMethods from generated modules. |
| python/sedonadb-expr/pyproject.toml | Defines new package metadata and Hatch build hook configuration. |
| python/sedonadb-expr/hatch_build.py | Adds Hatch build hook to generate _version.py and _generated/ sources at build time. |
| python/sedonadb-expr/.gitignore | Ignores build-generated files and common Python artifacts. |
| python/sedonadb-expr/_version.py | Provides Hatch version source reading from workspace Cargo.toml. |
| .github/workflows/python.yml | Installs/tests sedonadb-expr and adjusts test/doctest working directories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+133
to
+143
| def test_geo_methods_accessor(con): | ||
| pytest.importorskip("sedonadb_expr") | ||
|
|
||
| # Check piped function from literal via .geo accessor | ||
| e = con.lit(shapely.Point(0, 1)).geo.as_text() | ||
| e = con.lit("POINT (0 1)").funcs.st_geomfromwkt() | ||
| assert repr(e) == 'Expr(st_geomfromwkt(Utf8("POINT (0 1)")))' | ||
|
|
||
| # Check piped function from Expr via .geo accessor | ||
| e = con.col("foofy").geo.as_text() | ||
| assert repr(e) == "Expr(st_astext(foofy))" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Like #851 but for Python.
This PR generates a package, sedonadb-expr, dynamically at build time based on the SQL documentation. This allows function documentation inline. Because it's a separate package, users that don't need this don't have to pay the cost of loading it (non trivial, given that there are hundreds of functions and thousands of lines of functions + docs).
The pattern here is the "accessor" pattern, which both Pandas and CUDF and ESRI use to get nice type completion (I think this was invented slightly after GeoPandas subclassed the GeoSeries).