Skip to content

feat: Query API for SQL over extracted entities (sync spec v0.7.15) - #73

Open
kdr wants to merge 2 commits into
mainfrom
kdr-query
Open

feat: Query API for SQL over extracted entities (sync spec v0.7.15)#73
kdr wants to merge 2 commits into
mainfrom
kdr-query

Conversation

@kdr

@kdr kdr commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Syncs the SDK to spec v0.7.15 (cloudglue/cloudglue-api-spec#107) and bumps the package to 0.7.20.

The headline is the new Query API — read-only SQL (or natural language) over the structured data extracted from collections, against the files/entities/segment_entities virtual tables — plus query-call output items on the Response API and an ephemeral thumbnail_url on data-connector file listings.

Generated (cloudglue/sdk)

  • New QueryApi: run_query, list_queries, get_query_schema, get_query, cancel_query_export + all Query models
  • Response.output items: oneOf message | function_call | query_call
  • DataConnectorFile.thumbnail_url (nullable, ephemeral signed provider preview)

Wrapper (cloudglue/client)

  • New cg.query resource: run (sql or natural-language), get_schema(collections) (joins IDs into the comma-separated param), list, get, cancel, and wait_for_ready for background exports — registered in client/main.py and resources/__init__

Test plan

  • Package imports clean; cg.query wired with all six methods
  • Live battery against staging12/12 (evidence in ~/Downloads/cloudglue-v0.7.15-sdk-test-results.md): schema introspection lists the three virtual tables + per-collection fields; SQL SELECT COUNT(*) returns inline rows with scan-stat usage; natural-language query returns the compiled SQL; dry_run validates without rows; non-SELECT and face-analysis-collection requests 400; list omits rows while get replays them; background CSV export cancels cleanly; gong/recall listings parse with the optional thumbnail_url

Note

Low Risk
Mostly additive OpenAPI regeneration plus a thin client wrapper; no auth or breaking changes to existing resources.

Overview
Regenerates the Python SDK for OpenAPI 0.7.15 and exposes structured querying on the high-level Cloudglue client via cg.query.

Query API adds read-only SQL (or natural-language questions compiled to SQL) over collection extraction virtual tables (files, entities, segment_entities), with schema introspection, stored runs, list/get, background exports (cancel + poll), and dry-run. The hand-written Query resource mirrors the generated QueryApi with run, get_schema, list, get, cancel, and wait_for_ready, wired through client/main.py.

Smaller spec-driven updates: Response.output can include query_call (and related models) alongside messages and function calls; DataConnectorFile gains optional ephemeral thumbnail_url; sync_file_source_metadata docs note iconik poster keyframe thumbnail backfill when missing.

Reviewed by Cursor Bugbot for commit 464c047. Bugbot is set up for automated code reviews on this repo. Configure here.

Regenerated from spec v0.7.15 (cloudglue/cloudglue-api-spec#107) and
bumped to 0.7.20.

Generated (cloudglue/sdk):
- New QueryApi: run_query, list_queries, get_query_schema, get_query,
  cancel_query_export with RunQueryRequest/QueryResult/QueryListItem/
  QueryListResponse/QuerySchema(+Table/Collection)/QueryUsage models
- Response.output items are now a oneOf of message, function_call, and
  query_call
- DataConnectorFile gains nullable thumbnail_url (ephemeral provider
  preview URL); /files/{file_id}/sync description refreshed

Wrapper (cloudglue/client):
- New Query resource (cg.query): run (sql or natural-language),
  get_schema(collections) joining IDs into the comma-separated param,
  list, get, cancel, and wait_for_ready for background exports —
  registered in client/main.py and resources/__init__

Verified against the STAGING API (12/12): schema introspection over the
seeded entities collection; SQL and natural-language queries (compiled
SQL returned); dry_run; non-SELECT and face-analysis rejections; stored
run list/replay; background export cancel; connector listings parse with
optional thumbnail_url.
@kdr
kdr requested a review from amyxst July 29, 2026 01:37

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4dcc3be. Configure here.

Comment thread cloudglue/client/resources/query.py Outdated
query.wait_for_ready now returns the final QueryResult for failed runs
instead of raising with only the query ID, preserving the fetched error
payload (code/message) — matching the other wait helpers in this client
(e.g. extract.run) which return terminal objects for inspection.
@kdr

kdr commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Addressed Bugbot's finding in 464c047: query.wait_for_ready now returns the final QueryResult for failed runs instead of raising with only the query ID — the fetched error payload (code/message) is preserved for inspection, matching this client's other wait helpers (e.g. extract.run), and the docstring documents the new contract.

Follow-up verification: the new Response.output items were also confirmed live against staging — a nimbus-002-preview response with entity_backed_knowledge produced three completed cloudglue_query_call items, and the raw payload parses through Response.from_dict with all three accessible via actual_instance. Evidence added to the test-results doc.

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