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(airtable): add comprehensive data type support documentation #388

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 3 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
78 changes: 78 additions & 0 deletions docs/catalog/airtable.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,83 @@ options (

This FDW doesn't support query pushdown.

## Supported Data Types

The Airtable FDW supports the following PostgreSQL data types:

| PostgreSQL Type | Notes |
| -------------- | ----- |
| `boolean` | Maps to Airtable checkbox fields |
| `smallint`, `integer`, `bigint` | Maps to Airtable number fields |
| `real`, `double precision`, `numeric` | Maps to Airtable number fields |
| `text` | Maps to Airtable single line text, long text, URL, email, and phone fields |
| `date` | Maps to Airtable date fields |
| `timestamp` | Maps to Airtable date fields |
| `timestamp with time zone` | Maps to Airtable date fields |
| `jsonb` | Maps to Airtable array fields, linked records, and other complex types |

### Array and Complex Types

Arrays and linked records are supported through the `jsonb` type:

```sql
create foreign table airtable.complex_types (
linked_records jsonb, -- For Airtable linked records
attachments jsonb, -- For Airtable attachments
multiselect jsonb -- For Airtable multiple select fields
)
server airtable_server
options (
base_id 'appXXXX',
table_id 'tblXXXX'
);
```

### Column Naming Rules

1. Column names are case-insensitive
2. Column names containing spaces must be quoted:
```sql
create foreign table airtable.my_table (
"Business Name" text, -- Column with spaces must be quoted
city text, -- Simple column names don't need quotes
"ZIP Code" text -- Another column with spaces
)
server airtable_server
options (
base_id 'appXXXX',
table_id 'tblXXXX'
);
```

### Handling Complex Data Types

Here's an example of querying a table with linked records and arrays:

```sql
create foreign table airtable.contacts (
name text,
"Phone Numbers" jsonb, -- Array of phone numbers
"Related Companies" jsonb, -- Linked records
tags jsonb -- Multiple select field
)
server airtable_server
options (
base_id 'appXXXX',
table_id 'tblXXXX'
);

-- Query the complex types
select
name,
"Phone Numbers"->0 as primary_phone, -- Access first phone number
jsonb_array_length("Related Companies") as company_count,
tags
from airtable.contacts;
```

Note: Null values in Airtable fields are returned as SQL NULL values.

## Limitations

This section describes important limitations and considerations when using this FDW:
Expand All @@ -141,6 +218,7 @@ This section describes important limitations and considerations when using this
- No support for Airtable's block features
- Materialized views using these foreign tables may fail during logical backups
kiwicopple marked this conversation as resolved.
Show resolved Hide resolved


kiwicopple marked this conversation as resolved.
Show resolved Hide resolved
## Examples

### Query an Airtable table
Expand Down
Loading