Skip to content

Commit 6dece2f

Browse files
authored
docs: Polish README (#15)
1 parent 6ad20cb commit 6dece2f

5 files changed

Lines changed: 63 additions & 13 deletions

File tree

README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
## Features
88

99
- Foreign Data Wrapper: `lance_fdw`
10-
- Auto schema discovery + DDL: `lance_import(server, schema, table, uri, batch_size)`
10+
- Auto schema discovery + DDL: `lance_import(server, schema, table, uri, batch_size => NULL)`
1111
- Native-first type mapping:
1212
- Scalars map to native PostgreSQL scalar types where possible
1313
- `list<T>` maps to `T[]` when possible
@@ -59,7 +59,7 @@ SELECT lance_import(
5959
'public',
6060
'my_lance_table',
6161
'/path/to/your/lance/table',
62-
NULL
62+
batch_size => NULL
6363
);
6464
```
6565

@@ -68,10 +68,6 @@ SELECT lance_import(
6868
- The foreign table `public.my_lance_table`
6969
- Composite types for nested `struct` fields, e.g. `public.lance_my_lance_table_meta`
7070

71-
Why not `IMPORT FOREIGN SCHEMA`?
72-
73-
- PostgreSQL's `IMPORT FOREIGN SCHEMA` callback can only emit `CREATE FOREIGN TABLE` statements, so it cannot also create composite types for nested `struct` columns. `lance_import` performs both type and table DDL in one step.
74-
7571
### 3) Query like a regular table
7672

7773
```sql
@@ -80,6 +76,35 @@ SELECT count(*) FROM public.my_lance_table;
8076
SELECT * FROM public.my_lance_table LIMIT 10;
8177
```
8278

79+
### 4) Attach and sync a Lance namespace
80+
81+
```sql
82+
-- Plan only (no DDL).
83+
SELECT *
84+
FROM lance_attach_namespace('lance_srv', dry_run => true);
85+
86+
-- Attach a namespace subtree into local schemas/tables.
87+
SELECT *
88+
FROM lance_attach_namespace(
89+
'lance_srv',
90+
root_namespace_id => ARRAY[]::text[],
91+
schema_prefix => 'lance',
92+
batch_size => NULL,
93+
limit_per_list_call => 1000,
94+
dry_run => false
95+
);
96+
97+
-- Reconcile local objects with the remote namespace.
98+
SELECT *
99+
FROM lance_sync_namespace(
100+
'lance_srv',
101+
schema_prefix => 'lance',
102+
drop_missing => false,
103+
recreate_changed => false,
104+
dry_run => true
105+
);
106+
```
107+
83108
## Type Mapping (native-first)
84109

85110
| Arrow/Lance Type | PostgreSQL Type |

tests/sql/00_smoke.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Basic smoke test for lance FDW.
22

33
statement ok
4-
SELECT lance_import('${SERVER}', '${SCHEMA}', 't_fdw', '${LANCE_URI}', NULL);
4+
SELECT lance_import('${SERVER}', '${SCHEMA}', 't_fdw', '${LANCE_URI}', batch_size => NULL);
55

66
query I
77
SELECT count(*) FROM t_fdw;

tests/sql/01_type_mapping.slt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Ensure declared type mapping matches runtime value conversion.
22

33
statement ok
4-
SELECT lance_import('${SERVER}', '${SCHEMA}', 't_misc', '${LANCE_URI_MISC}', NULL);
4+
SELECT lance_import(
5+
'${SERVER}',
6+
'${SCHEMA}',
7+
't_misc',
8+
'${LANCE_URI_MISC}',
9+
batch_size => NULL
10+
);
511

612
query T
713
SELECT atttypid::regtype::text
@@ -34,4 +40,3 @@ query T
3440
SELECT (dec IS NULL) AND (dict IS NULL) FROM t_misc WHERE u16 = 2;
3541
----
3642
t
37-

tests/sql/02_namespace_attach.slt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ CREATE SERVER ${SERVER} FOREIGN DATA WRAPPER lance_fdw
1010
statement ok
1111
CREATE TEMP TABLE attach_result AS
1212
SELECT local_schema, local_table, status, detail
13-
FROM lance_attach_namespace('${SERVER}', ARRAY[]::text[], '${SCHEMA}', NULL, 1000, false);
13+
FROM lance_attach_namespace(
14+
'${SERVER}',
15+
root_namespace_id => ARRAY[]::text[],
16+
schema_prefix => '${SCHEMA}',
17+
batch_size => NULL,
18+
limit_per_list_call => 1000,
19+
dry_run => false
20+
);
1421

1522
query I
1623
SELECT count(*) FROM attach_result;

tests/sql/05_namespace_sync.slt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ CREATE FOREIGN TABLE ${SCHEMA}.ghost(id int4)
1919

2020
query TTT
2121
SELECT local_table, action, status
22-
FROM lance_sync_namespace('${SERVER}', ARRAY[]::text[], '${SCHEMA}', false, false, false)
22+
FROM lance_sync_namespace(
23+
'${SERVER}',
24+
root_namespace_id => ARRAY[]::text[],
25+
schema_prefix => '${SCHEMA}',
26+
drop_missing => false,
27+
recreate_changed => false,
28+
dry_run => false
29+
)
2330
ORDER BY local_table, action, status;
2431
----
2532
ghost drift ok
@@ -28,7 +35,14 @@ train create_table ok
2835

2936
query TTT
3037
SELECT local_table, action, status
31-
FROM lance_sync_namespace('${SERVER}', ARRAY[]::text[], '${SCHEMA}', true, true, false)
38+
FROM lance_sync_namespace(
39+
'${SERVER}',
40+
root_namespace_id => ARRAY[]::text[],
41+
schema_prefix => '${SCHEMA}',
42+
drop_missing => true,
43+
recreate_changed => true,
44+
dry_run => false
45+
)
3246
ORDER BY local_table, action, status;
3347
----
3448
ghost drop_table ok
@@ -49,4 +63,3 @@ query T
4963
SELECT to_regclass('${SCHEMA}.ghost') IS NULL;
5064
----
5165
t
52-

0 commit comments

Comments
 (0)