Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime APIs and abstractions #991

Merged
merged 44 commits into from
Oct 12, 2022
Merged

Runtime APIs and abstractions #991

merged 44 commits into from
Oct 12, 2022

Conversation

begelundmuller
Copy link
Contributor

@begelundmuller begelundmuller commented Oct 5, 2022

This PR proposes endpoints and abstractions for the runtime. I'm implementing the endpoints over the next couple of days, but would love some feedback on the API signatures now. These are the main files for feedback at the moment:

  • runtime/api/runtime.proto proposes APIs for the runtime. The APIs are expressed as a gRPC service with a mapping to REST endpoints. There are APIs for file artifacts ("repos"), runtime deployments ("instances"), catalog data, queries, explore APIs (metrics views APIs), and connector metadata (profiling endpoints are still TBD)
  • web-common/src/runtime-client contains a generated svelte-query client for all these APIs

NOTE: The comments in runtime/api/runtime.proto explain most of the concepts/terminology, such as "repos".

Workflows

Below I've tried to list how to deal with metrics views and sources using the proposed APIs. I realise these might not fit perfectly into the existing Node frontend, so let's work to make the ends meet. In addition to any simplifications you can think of, we can also add new/temporary APIs to the runtime to bridge the gap as necessary.

NOTE that for convenience, we can have the runtime automatically create an instance and repo for the current directory and map the keyword local to those – so in the APIs below, you just need to insert local in place of instance_id or repo_id.

Workflow for metrics views:

  1. Compose a CREATE METRICS VIEW and write the artifact to disk using POST /v1/repos/{repo_id}/objects/-/metrics/name.sql
  2. To validate/create the metrics view, submit the statement to POST /v1/instances/{instance_id}/migrate/single
  3. If successful, the metrics view will now be available for querying using the explore APIs
  4. To update the metrics view, repeat steps 1 and 2 – it will overwrite the metrics view if it already exists

Workflow for connectors:

  1. Call /v1/connectors/meta to get list of available connectors and their properties – to generate UI
  2. Compose CREATE SOURCE statement and write the artifact to disk using POST /v1/repos/{repo_id}/objects/-/sources/name.sql
  3. To ingest the source, submit the statement to POST /v1/instances/{instance_id}/migrate/single
  4. If successful, it will materialize the source as a table in the DuckDB with the same name as the source
  5. To refresh the source, call POST /v1/instances/{instance_id}/catalog/{name}/refresh
  6. To update the source, repeat steps 2 and 3 – it will overwrite the source and re-ingest

TODOs

  • Fast track implement endpoints for explore APIs and sources/connectors
  • Describe concepts and how to test/run the code in runtime/README.md
  • Add testing setup to server

(Note: Go CI/CD are failing due to a SQL bug – should get fixed soon.)

@ericpgreen2
Copy link
Contributor

Looks great! One note looking at runtime.proto: in a Connector's Property, we'll need a label that we can use for its form's input element.

@begelundmuller begelundmuller self-assigned this Oct 10, 2022
@begelundmuller begelundmuller marked this pull request as ready for review October 12, 2022 19:46
@begelundmuller begelundmuller merged commit 9aa7607 into main Oct 12, 2022
@begelundmuller begelundmuller deleted the runtime-glue branch October 12, 2022 19:48
djbarnwal pushed a commit that referenced this pull request Aug 3, 2023
* Setup Postgres for metadata and db testing

* Align runtime and cloud server config

* Adds registry, repo, catalog, and olap abstraction

And some minor stuff:
- Removes buf
- Tidies up SQL library download
- Moves server to designated folder

* Propose runtime APIs

* Autogenerate svelte-query client for runtime APIs

* Adding missing API fields

* Add SQL protobufs to runtime

* fix: forgot to commit makefile

* Fix sql deps install in CI

* Add READMEs describing the repo/runtime

* Fix arm sql release script after moving pom.xml

* Run prettier on contributing.md

* Minor improvements to api

* Remove Runtime struct

* Spec initial driver APIs

* Runtime server version

* Implement handlers for instances and repos

* Fix bugs

* Added stubs for registry store functions in sqlite driver

* Adding initial implementation of metrics views API (#1001)

* Adding initial implementation of metrics views API

* Addressing PR comments

* Ad-hoc create source parser

* Implement registry for sqlite

* Implemented repos

* Fix failing tests

* [Runtime] Connectors APIs and support local file, s3 and future connectors (#1013)

* Initial structure

* Adding abstractions for validation and a test for local file

* Addressing a few PR comments

* Addressing some other PR comments

* Integrate connectors

* Implement catalog and migrations handlers

* Add embedded catalog support to duckdb

* Add connectors metadata endpoint

* Move duckdb connector overrides to own file

* Add connection caching to runtime server

* Bugfixes

* Add example usage with curl

* Regenerate runtime client

* Set embed_catalog = true in DuckDBClient

* Add boot queries

* Incorporate small fix for multi-statement queries in duckdb

* Can't use args in multi-statement query

Co-authored-by: Aditya Hegde <[email protected]>
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.

3 participants