Skip to content

feat!: three-surface API for v1.2.0 (Surface 2 dunders + .to_arrow_table() escape + empty allowlist)#62

Merged
prantogg merged 12 commits intomainfrom
pranav/feature/pythonic-wkl
May 2, 2026
Merged

feat!: three-surface API for v1.2.0 (Surface 2 dunders + .to_arrow_table() escape + empty allowlist)#62
prantogg merged 12 commits intomainfrom
pranav/feature/pythonic-wkl

Conversation

@prantogg
Copy link
Copy Markdown
Member

@prantogg prantogg commented Apr 24, 2026

Summary

Ship the three-surface API for wkls v1.2.0:

  • Surface 1 (dot-chain navigation) — unchanged, remains primary identity
  • Surface 2 (Python collection protocol) — len(), iter(), [], in, bool()
  • Surface 3 (Arrow escape) — to_arrow_table() returns pyarrow.Table with GeoArrow WKB geometry

Breaking changes

  • resolve() removed — use to_arrow_table() instead
  • svg() and hexwkb() removed (were NotImplementedError stubs)
  • __getattr__ passthrough removed — .count(), .head(), .show(), .filter() etc. now raise AttributeError with priority-ordered redirects pointing at the correct Surface
  • to_dicts() is metadata-only by contract (no geometry)

Commits

  1. feat!: remove unimplemented svg() and hexwkb() methods
  2. refactor: rename Wkl.resolve to private _resolve
  3. feat!: add Wkl.to_arrow_table() with direct Overture query
  4. feat!: empty __getattr__ allowlist with priority-ordered redirects
  5. docs: README + CHANGELOG for v1.2.0

@prantogg prantogg force-pushed the pranav/feature/pythonic-wkl branch from 4022dd8 to 6d692de Compare April 27, 2026 17:27
…ins, bool)

Implements Phase 3 Surface 2 per docs/design/pythonic-wkl.md. Wkl now
behaves like a stdlib collections.abc.Sequence on the rows of the
resolved result set:

  len(wkl)           # row count
  for row in wkl     # iterate; each row is itself a single-row Wkl
  wkl[0], wkl[-1]    # positional index (negatives supported)
  wkl[:5]            # slice; returns a multi-row Wkl
  bool(wkl)          # True iff non-empty
  uuid in wkl        # membership check against the id column

Iteration is backed by a cached pyarrow Table (_arrow_table) so
len/iter/getitem don't fire one sedona round-trip per row. Per-row
Wkls are constructed by slicing the table and re-wrapping via
sedona.create_data_frame — no SQL per step.

Also in this commit:

- Narrowed __getattr__ passthrough on result-mode Wkl to the explicit
  _DIR_DATAFRAME_METHODS allowlist. Anything outside it (e.g. .filter,
  .select, .group_by) now raises AttributeError with a pointer at
  .resolve() instead of silently forwarding to sedona.
- .head(n) / .limit(n) now return a Wkl (was: sedona DataFrame). Fixes
  the .head(3).to_dicts() trap from the Copilot usability review.
- Replaced the bracket-access deprecation shim. String subscripts now
  raise TypeError pointing at dot access / .search() / .resolve();
  list subscripts and other key types raise TypeError as well.
  DeprecationWarning was the v1.2 behavior; v1.3 enforces.

Module docstring updated to teach the new Sequence idioms in the
Inspection paragraph.

__repr__ is intentionally unchanged — see docs/architecture/three-surface-api.md
"Changing the repr (considered, deferred)".
New tests/test_pythonic.py exercises the v1.3 Surface 2 contract end
to end: len/bool/iter/getitem/contains across chain-mode, result-mode,
empty, and root Wkl edge cases; head(n)/limit(n) returning Wkl; the
.head(3).to_dicts() chain that used to fail; the narrowed __getattr__
raising AttributeError with .resolve() pointers; row-Wkl integration
(.wkt, .path, .parent on a yielded row).

tests/test_deprecation.py rewritten: the bracket-access shim is gone,
so the file now asserts the v1.3 TypeError replacement (matching the
"considered, deferred" deprecation policy).

tests/test_errors.py: removed the obsolete companion test that
exercised Wkl()["..."] hint rendering via the shim. TypeError
coverage lives in test_deprecation.py now.

tests/conftest.py: dropped the unused ignore_bracket_deprecation
fixture (no remaining callers).
@prantogg prantogg force-pushed the pranav/feature/pythonic-wkl branch from 6d692de to 6f35ef3 Compare April 27, 2026 19:16
@prantogg prantogg changed the title feat: Wkl Python collection protocol (Surface 2) + narrowed passthrough feat!: three-surface API for v1.2.0 (Surface 2 dunders + .to_arrow_table() escape + empty allowlist) Apr 29, 2026
@prantogg prantogg force-pushed the pranav/feature/pythonic-wkl branch from b41c60b to 25ba113 Compare May 1, 2026 22:09
@prantogg prantogg force-pushed the pranav/feature/pythonic-wkl branch 5 times, most recently from 4c7b43c to cff639a Compare May 2, 2026 04:37
prantogg added 3 commits May 1, 2026 21:50
Remove silent DataFrame passthrough from result-mode Wkls. Every
unknown attribute now raises AttributeError with a priority-ordered
redirect (Surface 1 > Surface 2 > Surface 3). Migrate all tests
from .count()/.head()/.show() to len()/[:n] equivalents.
@prantogg prantogg force-pushed the pranav/feature/pythonic-wkl branch from cff639a to 21ddb37 Compare May 2, 2026 04:51
@prantogg prantogg marked this pull request as ready for review May 2, 2026 05:59
@prantogg prantogg merged commit bd7741a into main May 2, 2026
7 checks passed
@prantogg prantogg deleted the pranav/feature/pythonic-wkl branch May 2, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant