Skip to content

Commit

Permalink
Update duckdb connector to v0.1.3 (#428)
Browse files Browse the repository at this point in the history
This PR updates the duckdb connector metadata to version 0.1.3.

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
TristenHarr and actions-user authored Jan 8, 2025
1 parent 2438767 commit eb02cfb
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 57 deletions.
148 changes: 92 additions & 56 deletions registry/hasura/duckdb/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# Hasura DuckDB Connector

<a href="https://duckdb.org/"><img src="https://github.com/hasura/ndc-duckdb/blob/main/docs/logo.svg" align="right" width="200"></a>

[![Docs](https://img.shields.io/badge/docs-v3.x-brightgreen.svg?style=flat)](https://hasura.io/connectors/duckdb)
[![ndc-hub](https://img.shields.io/badge/ndc--hub-duckdb-blue.svg?style=flat)](https://hasura.io/connectors/duckdb)
[![License](https://img.shields.io/badge/license-Apache--2.0-purple.svg?style=flat)](https://github.com/hasura/ndc-duckdb/blob/main/LICENSE.txt)
[![Status](https://img.shields.io/badge/status-alpha-yellow.svg?style=flat)](https://github.com/hasura/ndc-duckdb/blob/main/README.md)

The Hasura DuckDB Connector allows for connecting to a DuckDB database or a MotherDuck hosted DuckDB database to give
you an instant GraphQL API on top of your DuckDB data.
The Hasura DuckDB Connector allows for connecting to a DuckDB database or a MotherDuck hosted DuckDB database to give you an instant GraphQL API on top of your DuckDB data.

This connector is built using the [Typescript Data Connector SDK](https://github.com/hasura/ndc-sdk-typescript) and
implements the [Data Connector Spec](https://github.com/hasura/ndc-spec).
This connector is built using the [Typescript Data Connector SDK](https://github.com/hasura/ndc-sdk-typescript) and implements the [Data Connector Spec](https://github.com/hasura/ndc-spec).

- [See the listing in the Hasura Hub](https://hasura.io/connectors/duckdb)
- [Hasura V3 Documentation](https://hasura.io/docs/3.0/index/)
Expand All @@ -22,74 +19,113 @@ Below, you'll find a matrix of all supported features for the DuckDB connector:

| Feature | Supported | Notes |
| ------------------------------- | --------- | ----- |
| Native Queries + Logical Models || |
| Simple Object Query || |
| Filter / Search || |
| Simple Aggregation || |
| Sort || |
| Paginate || |
| Table Relationships || |
| Views || |
| Distinct || |
| Remote Relationships || |
| Custom Fields || |
| Mutations || |

## Prerequisites

1. Create a [Hasura Cloud account](https://console.hasura.io)
2. Please ensure you have the [DDN CLI](https://hasura.io/docs/3.0/cli/installation) and
[Docker](https://docs.docker.com/engine/install/) installed
3. [Create a supergraph](https://hasura.io/docs/3.0/getting-started/init-supergraph)
4. [Create a subgraph](https://hasura.io/docs/3.0/getting-started/init-subgraph)
5. Have a [MotherDuck](https://motherduck.com/) hosted DuckDB database, or a persitent DuckDB database file — for
supplying data to your API.

The steps below explain how to initialize and configure a connector on your local machine (typically for development
purposes).You can learn how to deploy a connector to Hasura DDN — after it's been configured —
[here](https://hasura.io/docs/3.0/getting-started/deployment/deploy-a-connector).
| Native Queries + Logical Models || |
| Simple Object Query || |
| Filter / Search || |
| Simple Aggregation || |
| Sort || |
| Paginate || |
| Table Relationships || |
| Views || |
| Distinct || |
| Remote Relationships || |
| Custom Fields || |
| Mutations || |

## Before you get Started

1. The [DDN CLI](https://hasura.io/docs/3.0/cli/installation) and [Docker](https://docs.docker.com/engine/install/) installed
2. A [supergraph](https://hasura.io/docs/3.0/getting-started/init-supergraph)
3. A [subgraph](https://hasura.io/docs/3.0/getting-started/init-subgraph)
4. Have a [MotherDuck](https://motherduck.com/) hosted DuckDB database, or a persitent DuckDB database file — for supplying data to your API.

The steps below explain how to Initialize and configure a connector for local development. You can learn how to deploy a
connector — after it's been configured — [here](https://hasura.io/docs/3.0/getting-started/deployment/deploy-a-connector).

## Using the DuckDB connector

With the [context set](https://hasura.io/docs/3.0/cli/commands/ddn_context_set/) for an existing subgraph, initialize
the connector:
### Step 1: Authenticate your CLI session

```bash
ddn auth login
```

### Step 2: Configure the connector

Once you have an initialized supergraph and subgraph, run the initialization command in interactive mode while providing a name for the connector in the prompt:

```bash
ddn connector init duckdb -i
```

#### Step 2.1: Choose the `hasura/duckdb` option from the list

#### Step 2.2: Choose a port for the connector

The CLI will ask for a specific port to run the connector on. Choose a port that is not already in use or use the default suggested port.

#### Step 2.3: Provide the env var(s) for the connector

| Name | Description |
|-|-|
| DUCKDB_URL | The connection string for the DuckDB database, or the file path to the DuckDB database file |

```sh
ddn connector init -i
You'll find the environment variables in the `.env` file and they will be in the format:

`<SUBGRAPH_NAME>_<CONNECTOR_NAME>_<VARIABLE_NAME>`

Here is an example of what your `.env` file might look like:

```
APP_DUCKDB_AUTHORIZATION_HEADER="Bearer SPHZWfL7P3Jdc9mDMF9ZNA=="
APP_DUCKDB_DUCKDB_URL="md:?motherduck_token=ey..."
APP_DUCKDB_HASURA_SERVICE_TOKEN_SECRET="SPHZWfL7P3Jdc9mDMF9ZNA=="
APP_DUCKDB_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://local.hasura.dev:4317"
APP_DUCKDB_OTEL_SERVICE_NAME="app_duckdb"
APP_DUCKDB_READ_URL="http://local.hasura.dev:7525"
APP_DUCKDB_WRITE_URL="http://local.hasura.dev:7525"
```

If you are attaching to a local DuckDB file, first make sure that the file is located inside the connector directory. For example, if you had a `data.duckdb` file you could place it at `/app/connector/duckdb/data.duckdb`. Files in the connector directory get mounted to `/etc/connector/`.

In this instance, you would set the `DUCKDB_URL=/etc/connector/data.duckdb`. Now your `.env` might look like this:

```
APP_DUCKDB_AUTHORIZATION_HEADER="Bearer SPHZWfL7P3Jdc9mDMF9ZNA=="
APP_DUCKDB_DUCKDB_URL="/etc/connector/data.duckdb"
APP_DUCKDB_HASURA_SERVICE_TOKEN_SECRET="SPHZWfL7P3Jdc9mDMF9ZNA=="
APP_DUCKDB_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="http://local.hasura.dev:4317"
APP_DUCKDB_OTEL_SERVICE_NAME="app_duckdb"
APP_DUCKDB_READ_URL="http://local.hasura.dev:7525"
APP_DUCKDB_WRITE_URL="http://local.hasura.dev:7525"
```

When the wizard runs, you'll be prompted to enter the following env vars necessary for your connector to function:
Your experience mounting files may vary, and while useful to explore a file locally, it's not recommended to attempt to deploy a connector using a locally mounted file.

| Name | Description |
| ---------- | ------------------------------------------------------------------------------------------- |
| DUCKDB_URL | The connection string for the DuckDB database, or the file path to the DuckDB database file |
### Step 3: Introspect the connector

If you are attaching to a local DuckDB file, first make sure that the file is located inside the connector directory.
For example, if you had a `data.duckdb` file you could place it at `/app/connector/duckdb/data.duckdb`. Files in the
connector directory get mounted to `/etc/connector/`.
Introspecting the connector will generate a `config.json` file and a `duckdb.hml` file.

**Your experience mounting files may vary, and while useful to explore a file locally, it's not recommended to attempt
to deploy a connector using a locally mounted file.**
```bash
ddn connector introspect duckdb
```

### Step 4: Add your resources

After the CLI initializes the connector, you'll need to:
You can add the models, commands, and relationships to your API by tracking them which generates the HML files.

- [Introspect](https://hasura.io/docs/3.0/cli/commands/ddn_connector_introspect) the source.
- Add your [models](https://hasura.io/docs/3.0/cli/commands/ddn_model_add),
[commands](https://hasura.io/docs/3.0/cli/commands/ddn_command_add), and
[relationships](https://hasura.io/docs/3.0/cli/commands/ddn_relationship_add).
- Create a [new build](https://hasura.io/docs/3.0/cli/commands/ddn_supergraph_build_local).
- Test it by [running your project along with the connector](https://hasura.io/docs/3.0/cli/commands/ddn_run#examples).
```bash
ddn connector-link add-resources duckdb
```

## Documentation

View the full documentation for the DuckDB connector
[here](https://github.com/hasura/ndc-duckdb/blob/main/docs/index.md).
View the full documentation for the DuckDB connector [here](https://github.com/hasura/ndc-duckdb/blob/main/docs/index.md).

## Contributing

Check out our [contributing guide](https://github.com/hasura/ndc-duckdb/blob/main/docs/contributing.md) for more
details.
Check out our [contributing guide](https://github.com/hasura/ndc-duckdb/blob/main/docs/contributing.md) for more details.

## License

The DuckDB connector is available under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
The DuckDB connector is available under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
7 changes: 6 additions & 1 deletion registry/hasura/duckdb/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"tags": [
"database"
],
"latest_version": "v0.1.2"
"latest_version": "v0.1.3"
},
"author": {
"support_email": "Community Supported",
Expand All @@ -34,6 +34,11 @@
"tag": "v0.1.2",
"hash": "97b4ebdc58870ba4aaa6b30f154e8a15ed2b4040",
"is_verified": false
},
{
"tag": "v0.1.3",
"hash": "77ee12cef21cd4231c3f6a6433d9249da180e59e",
"is_verified": false
}
]
}
Expand Down
11 changes: 11 additions & 0 deletions registry/hasura/duckdb/releases/v0.1.3/connector-packaging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.1.3",
"uri": "https://github.com/hasura/ndc-duckdb/releases/download/v0.1.3/connector-definition.tgz",
"checksum": {
"type": "sha256",
"value": "28c88754f42de46154357ace1d97fef4e96ea4c0c6a2d84671a1872e8b27070a"
},
"source": {
"hash": "77ee12cef21cd4231c3f6a6433d9249da180e59e"
}
}

0 comments on commit eb02cfb

Please sign in to comment.