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

Docs Refactor #321

Merged
merged 16 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 3 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
| [Redis](./wrappers/src/fdw/redis_fdw) | A FDW for [Redis](https://redis.io/) | ✅ | ❌ |
| [AWS Cognito](./wrappers/src/fdw/cognito_fdw) | A FDW for [AWS Cognito](https://aws.amazon.com/cognito/) | ✅ | ❌ |
| [Notion](./wrappers/src/fdw/notion_fdw) | A FDW for [Notion](https://www.notion.so/) | ✅ | ❌ |
| [Snowflake](./wasm-wrappers/fdw/snowflake_fdw) | A FDW for [Snowflake](https://www.snowflake.com/) | ✅ | ✅ |
| [Paddle](./wasm-wrappers/fdw/paddle_fdw) | A FDW for [Paddle](https://www.paddle.com/) | ✅ | ✅ |
| [Snowflake](./wasm-wrappers/fdw/snowflake_fdw) | A Wasm FDW for [Snowflake](https://www.snowflake.com/) | ✅ | ✅ |
| [Paddle](./wasm-wrappers/fdw/paddle_fdw) | A Wasm FDW for [Paddle](https://www.paddle.com/) | ✅ | ✅ |

### Warning

Expand Down Expand Up @@ -51,108 +51,7 @@ cargo pgrx install --pg-config [path_to_pg_config] --features stripe_fdw

## Developing a FDW

To develop a FDW using `Wrappers`, you only need to implement the [ForeignDataWrapper](./supabase-wrappers/src/interface.rs) trait.

```rust
pub trait ForeignDataWrapper {
// create a FDW instance
fn new(...) -> Self;

// functions for data scan, e.g. select
fn begin_scan(...);
fn iter_scan(...) -> Option<Row>;
fn end_scan(...);

// functions for data modify, e.g. insert, update and delete
fn begin_modify(...);
fn insert(...);
fn update(...);
fn delete(...);
fn end_modify(...);

// other optional functions
...
}
```

In a minimum FDW, which supports data scan only, `new()`, `begin_scan()`, `iter_scan()` and `end_scan()` are required, all the other functions are optional.

To know more about FDW development, please visit the [Wrappers documentation](https://docs.rs/supabase-wrappers/latest/supabase_wrappers/).

## Basic usage

These steps outline how to use the a demo FDW [HelloWorldFdw](./wrappers/src/fdw/helloworld_fdw), which only outputs a single line of fake data:

1. Clone this repo

```bash
git clone https://github.com/supabase/wrappers.git
```

2. Run it using pgrx with feature:

```bash
cd wrappers/wrappers
cargo pgrx run pg15 --features helloworld_fdw
```

3. Create the extension, foreign data wrapper and related objects:

```sql
-- create extension
create extension wrappers;

-- create foreign data wrapper and enable 'HelloWorldFdw'
create foreign data wrapper helloworld_wrapper
handler hello_world_fdw_handler
validator hello_world_fdw_validator;

-- create server and specify custom options
create server my_helloworld_server
foreign data wrapper helloworld_wrapper
options (
foo 'bar'
);

-- create an example foreign table
create foreign table hello (
id bigint,
col text
)
server my_helloworld_server
options (
foo 'bar'
);
```

4. Run a query to check if it is working:

```sql
wrappers=# select * from hello;
id | col
----+-------------
0 | Hello world
(1 row)
```

## Running tests

In order to run tests in `wrappers`:

```bash
docker-compose -f .ci/docker-compose.yaml up -d
cargo pgrx test --features all_fdws,pg15
```

## Limitations

- Windows is not supported, that limitation inherits from [pgrx](https://github.com/tcdi/pgrx).
- Currently only supports PostgreSQL v14, v15 and v16.
- Generated column is not supported.

## Contribution

All contributions, feature requests, bug report or ideas are welcomed.
Visit [Wrappers Docs](https://supabase.github.io/wrappers/) for more details.

## License

Expand Down
Binary file added docs/assets/fdw-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/google-sheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/query-pushdown-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/wasm-build.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/wrappers-github.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/wrappers-icon_container-3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/wrappers-icon_container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/assets/wrappers-icon_container.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/assets/wrappers-wordmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/assets/wrappers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 28 additions & 5 deletions docs/airtable.md → docs/catalog/airtable.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
source:
documentation:
author: supabase
tags:
- native
- official
---

# Airtable

[Airtable](https://www.airtable.com) is an easy-to-use online platform for creating and sharing relational databases.

The Airtable Wrapper allows you to read data from your Airtable bases/tables within your Postgres database.
Expand Down Expand Up @@ -40,6 +51,7 @@ returning key_id;

We need to provide Postgres with the credentials to connect to Airtable, and any additional options. We can do this using the `create server` command:


=== "With Vault"

```sql
Expand All @@ -56,20 +68,25 @@ We need to provide Postgres with the credentials to connect to Airtable, and any
create server airtable_server
foreign data wrapper airtable_wrapper
options (
api_url 'https://api.airtable.com/v0', -- Airtable API url, optional
api_key '<Airtable API Key or PAT>' -- Airtable API key or Personal Access Token (PAT), required
api_key '<your_api_key>'
);
```

## Creating Foreign Tables

The Airtable Wrapper supports data reads from the Airtable API.

### Records

The Airtable Wrapper supports data reads from Airtable's [Records](https://airtable.com/developers/web/api/list-records) endpoint (_read only_).

#### Operations

| Airtable | Select | Insert | Update | Delete | Truncate |
| -------- | :----: | :----: | :----: | :----: | :------: |
| Records | ✅ | ❌ | ❌ | ❌ | ❌ |

For example:
#### Usage

```sql
create foreign table my_foreign_table (
Expand All @@ -83,7 +100,7 @@ options (
);
```

### Foreign table options
#### Options

The full list of foreign table options are below:

Expand All @@ -99,7 +116,7 @@ This FDW doesn't support query pushdown.

Some examples on how to use Airtable foreign tables.

### Basic example
### Query an Airtable table

This will create a "foreign table" inside your Postgres database called `airtable_table`:

Expand All @@ -124,6 +141,8 @@ You can now fetch your Airtable data from within your Postgres database:
select * from airtable_table;
```

### Query an Airtable view

We can also create a foreign table from an Airtable View called `airtable_view`:

```sql
Expand All @@ -140,6 +159,10 @@ options (
table_id 'tbltiLinE56l3YKfn',
view_id 'viwY8si0zcEzw3ntZ'
);
```

You can now fetch your Airtable data from within your Postgres database:

```sql
select * from airtable_view;
```
20 changes: 15 additions & 5 deletions docs/auth0.md → docs/catalog/auth0.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# [Auth0](https://auth0.com/) is a flexible, drop-in solution to add authentication and authorization services to your applications
---
source:
documentation:
author: supabase
tags:
- native
- official
---

# Auth0

[Auth0](https://auth0.com/) is a flexible, drop-in solution to add authentication and authorization services to your applications

The Auth0 Wrapper allows you to read data from your Auth0 tenant for use within your Postgres database.

Expand Down Expand Up @@ -66,9 +77,9 @@ We need to provide Postgres with the credentials to connect to Airtable, and any

The Auth0 Wrapper supports data reads from Auth0's [Management API List users endpoint](https://auth0.com/docs/api/management/v2/users/get-users) endpoint (_read only_).

| Auth0 | Select | Insert | Update | Delete | Truncate |
| -------- | :----: | :----: | :----: | :----: | :------: |
| Records | ✅ | ❌ | ❌ | ❌ | ❌ |
| Auth0 | Select | Insert | Update | Delete | Truncate |
| ------- | :----: | :----: | :----: | :----: | :------: |
| Records | ✅ | ❌ | ❌ | ❌ | ❌ |

For example:

Expand Down Expand Up @@ -120,4 +131,3 @@ You can now fetch your Auth0 data from within your Postgres database:
```sql
select * from auth0;
```

11 changes: 11 additions & 0 deletions docs/bigquery.md → docs/catalog/bigquery.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
source:
documentation:
author: supabase
tags:
- native
- official
---

# BigQuery

[BigQuery](https://cloud.google.com/bigquery) is a completely serverless and cost-effective enterprise data warehouse that works across clouds and scales with your data, with BI, machine learning and AI built in.

The BigQuery Wrapper allows you to read and write data from BigQuery within your Postgres database.
Expand Down
11 changes: 11 additions & 0 deletions docs/clickhouse.md → docs/catalog/clickhouse.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
source:
documentation:
author: supabase
tags:
- native
- official
---

# ClickHouse

[ClickHouse](https://clickhouse.com/) is a fast open-source column-oriented database management system that allows generating analytical data reports in real-time using SQL queries.

The ClickHouse Wrapper allows you to read and write data from ClickHouse within your Postgres database.
Expand Down
20 changes: 15 additions & 5 deletions docs/cognito.md → docs/catalog/cognito.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
[AWS Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/what-is-amazon-cognito.html) is an identity platform for web and mobile apps.
---
source:
documentation:
author: supabase
tags:
- native
- official
---

# AWS Cognito

[AWS Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/what-is-amazon-cognito.html) is an identity platform for web and mobile apps.

The Cognito wrapper allows you to read data from your Cognito Userpool within your Postgres database.

Expand Down Expand Up @@ -69,9 +80,9 @@ We need to provide Postgres with the credentials to connect to Cognito, and any

The Cognito Wrapper supports data reads from Cognito's [User Records](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html) endpoint (_read only_).

| Cognito | Select | Insert | Update | Delete | Truncate |
| -------- | :----: | :----: | :----: | :----: | :------: |
| Records | ✅ | ❌ | ❌ | ❌ | ❌ |
| Cognito | Select | Insert | Update | Delete | Truncate |
| ------- | :----: | :----: | :----: | :----: | :------: |
| Records | ✅ | ❌ | ❌ | ❌ | ❌ |

For example:

Expand All @@ -92,7 +103,6 @@ The full list of foreign table options are below:

- `object`: type of object we are querying. For now, only `users` is supported


## Query Pushdown Support

This FDW doesn't support query pushdown.
Expand Down
11 changes: 11 additions & 0 deletions docs/firebase.md → docs/catalog/firebase.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
source:
documentation:
author: supabase
tags:
- native
- official
---

# Firebase

[Firebase](https://firebase.google.com/) is an app development platform built around non-relational technologies. The Firebase Wrapper supports connecting to below objects.

1. [Authentication Users](https://firebase.google.com/docs/auth/users) (_read only_)
Expand Down
Loading
Loading