Skip to content

feat(api): add upload endpoint and align upsert - #21

Merged
redox merged 2 commits into
altertable-ai:mainfrom
albert20260301:fix/upsert-primary-key
Jul 24, 2026
Merged

feat(api): add upload endpoint and align upsert#21
redox merged 2 commits into
altertable-ai:mainfrom
albert20260301:fix/upsert-primary-key

Conversation

@albert20260301

@albert20260301 albert20260301 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add Client.upload for raw CSV, JSON, or Parquet bytes and binary streams
  • expose typed UploadMode values: create, append, and overwrite
  • keep the existing upsert correction: primary_key is required and mode is not sent
  • document upload usage and add request/error regression coverage

Impact analysis

This PR changes the Python Lakehouse client public surface in two places. Client.upsert now requires primary_key, matching the v0.12.0 Lakehouse spec. It also adds Client.upload(catalog, schema, table, mode, content, content_type=None), which sends POST /upload with the required query parameters and optional content type. Callers can pass bytes, a binary file stream, or a byte iterator.

The endpoint contract matches specs/lakehouse/SPEC.md: mode is restricted to create, append, or overwrite; file format is conveyed by Content-Type when known, otherwise inferred by the service. Ruby, Java, and Rust already implement the same upload contract, so this removes the Python SDK divergence. No other SDK changes are needed.

Validation

  • python3 -m py_compile src/altertable_lakehouse/client.py src/altertable_lakehouse/models.py tests/test_client.py
  • git diff --check
  • Added mock-transport coverage for streamed CSV upload, exact query parameters, optional Content-Type, and 400 error handling.
  • Full Ruff, mypy, and pytest could not run locally because Poetry and the repository test dependencies are unavailable in this environment; GitHub CI runs the complete lint/typecheck and Python 3.9–3.14 test matrix.

@albert20260301

Copy link
Copy Markdown
Contributor Author

@leo-altertable could you review this?

I picked you because the affected client and test paths have no non-Albert ownership signal, and your Python stack ownership is the best match. CI is pending; the main review focus is the intentional breaking API correction: primary_key is required and mode is fully removed from the Python upsert surface.

@redox

redox commented Jul 24, 2026

Copy link
Copy Markdown
Member

@albert20260301 you need to implement the new /upload as well

@albert20260301 albert20260301 changed the title fix(api): align upsert query parameters with lakehouse spec feat(api): add upload endpoint and align upsert Jul 24, 2026
@albert20260301

Copy link
Copy Markdown
Contributor Author

@redox Implemented /upload on this PR: typed modes, bytes/binary-stream input, optional Content-Type, README coverage, and request/error tests. Commit 50e63ae updates the PR scope; CI is running.

@redox
redox merged commit 969e54d into altertable-ai:main Jul 24, 2026
11 checks passed
@albert20260301
albert20260301 deleted the fix/upsert-primary-key branch July 24, 2026 07:22
redox pushed a commit that referenced this pull request Jul 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.4.0](altertable-lakehouse-v0.3.1...altertable-lakehouse-v0.4.0)
(2026-07-24)


### Features

* **api:** add upload endpoint and align upsert
([#21](#21))
([969e54d](969e54d))


### Documentation

* sync community documents
([#19](#19))
([4a21043](4a21043))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants