|
| 1 | +# datalake_fdw |
| 2 | + |
| 3 | +`datalake_fdw` is a skeleton of Apache Iceberg lake-table support for Apache |
| 4 | +Cloudberry, built as an ordinary extension: no kernel changes, no new grammar. |
| 5 | +A lake table is a regular `CREATE TABLE ... USING iceberg`, and its binding to a |
| 6 | +catalog and a storage volume travels in reloptions that point at foreign servers. |
| 7 | + |
| 8 | +This first drop wires up the whole DDL path against a stub metadata engine, so |
| 9 | +`CREATE TABLE` and `DROP TABLE` work end to end with no external dependency -- |
| 10 | +no catalog service, no object store, no Arrow, no JVM. Everything that would |
| 11 | +touch data reports a clean not-supported error. The interfaces the later work |
| 12 | +plugs into (metadata engine vtable, format reader/writer, storage facade) ship |
| 13 | +here in full so they can be reviewed before there is an implementation behind |
| 14 | +them. |
| 15 | + |
| 16 | +## Build and configuration |
| 17 | + |
| 18 | +```sh |
| 19 | +make USE_PGXS=1 install |
| 20 | +``` |
| 21 | + |
| 22 | +The extension installs hooks from `_PG_init`, so it must be preloaded: |
| 23 | + |
| 24 | +```conf |
| 25 | +shared_preload_libraries = 'datalake_fdw' |
| 26 | +``` |
| 27 | + |
| 28 | +```sh |
| 29 | +gpconfig -c shared_preload_libraries -v datalake_fdw && gpstop -ar |
| 30 | +``` |
| 31 | + |
| 32 | +## Example |
| 33 | + |
| 34 | +```sql |
| 35 | +CREATE EXTENSION datalake_fdw; |
| 36 | + |
| 37 | +-- Where the table metadata lives. |
| 38 | +CREATE SERVER hive_cat FOREIGN DATA WRAPPER iceberg_catalog_fdw |
| 39 | + OPTIONS (type 'hive', uri 'thrift://metastore:9083'); |
| 40 | + |
| 41 | +-- Where the data files live. |
| 42 | +CREATE SERVER s3_vol FOREIGN DATA WRAPPER iceberg_volume_fdw |
| 43 | + OPTIONS (base_path 's3://bucket/prefix', endpoint 'http://minio:9000', |
| 44 | + region 'us-east-1'); |
| 45 | + |
| 46 | +-- Credentials are optional: without a user mapping the storage backend falls |
| 47 | +-- back to ambient credentials (instance role, environment, and so on). |
| 48 | +CREATE USER MAPPING FOR CURRENT_USER SERVER s3_vol |
| 49 | + OPTIONS (access_key '...', secret_key '...'); |
| 50 | + |
| 51 | +CREATE TABLE t (a int, b text) |
| 52 | + USING iceberg |
| 53 | + WITH (catalog = 'hive_cat', volume = 's3_vol'); |
| 54 | + |
| 55 | +DROP TABLE t; |
| 56 | +``` |
| 57 | + |
| 58 | +Both servers are recorded as dependencies of the table, so `DROP SERVER` is |
| 59 | +refused while lake tables reference it, and `DROP SERVER ... CASCADE` removes |
| 60 | +them together. Creating a table requires `USAGE` on both servers. |
| 61 | + |
| 62 | +`iceberg.default_catalog` and `iceberg.default_volume` supply the binding when |
| 63 | +`WITH` omits it. |
| 64 | + |
| 65 | +Table metadata always goes through one metadata engine, the Java agent, and |
| 66 | +nothing selects between implementations -- no option, no setting. The engine |
| 67 | +sits behind a vtable so that the implementation can change (an in-process C++ |
| 68 | +one is the expected next step), but that is a property of the build, never of a |
| 69 | +table or a session, so an existing table can never be reinterpreted by a |
| 70 | +configuration change. |
| 71 | + |
| 72 | +## What this skeleton does |
| 73 | + |
| 74 | +| Works | Behaviour | |
| 75 | +| --- | --- | |
| 76 | +| `CREATE TABLE ... USING iceberg` | Binding validated, distribution forced to random, stub engine reports the create | |
| 77 | +| `DROP TABLE` | Stub engine reports the drop; dependencies removed on every segment | |
| 78 | +| `ANALYZE`, `VACUUM` | Succeed as no-ops, so database-wide maintenance is never blocked by a lake table | |
| 79 | +| Catalog and volume validators | Per-context option allowlists; credentials are refused on servers and belong in user mappings | |
| 80 | + |
| 81 | +| Rejected for now | | |
| 82 | +| --- | --- | |
| 83 | +| `SELECT`, `INSERT`, `UPDATE`, `DELETE`, `COPY` | Data paths land in a later change | |
| 84 | +| `CREATE INDEX`, `TABLESAMPLE`, `TRUNCATE`, `CLUSTER`, `VACUUM FULL` | Not meaningful, or unsafe, without the data path | |
| 85 | +| Every `ALTER` form on a lake table, and on servers a lake table references | Schema evolution and identity tracking land in a later change | |
| 86 | +| `CREATE TABLE AS`, materialized views, partitioning, inheritance, typed tables, `TEMP`, `UNLOGGED`, `ON COMMIT`, explicit `TABLESPACE` | Out of scope for the skeleton | |
| 87 | + |
| 88 | +## Running the tests |
| 89 | + |
| 90 | +Against a running cluster with the library preloaded: |
| 91 | + |
| 92 | +```sh |
| 93 | +make USE_PGXS=1 installcheck |
| 94 | +``` |
| 95 | + |
| 96 | +The suite covers the DDL path (including per-segment catalog state), the |
| 97 | +rejection matrices, and the privilege model. |
| 98 | + |
| 99 | +## Layout |
| 100 | + |
| 101 | +| Directory | Contents | |
| 102 | +| --- | --- | |
| 103 | +| `src/am_iceberg/` | Table access method, utility and object-access hooks, binding resolution, GUCs | |
| 104 | +| `src/iceberg_catalog_fdw/`, `src/iceberg_volume_fdw/` | Foreign-data-wrapper validators for the two server kinds | |
| 105 | +| `src/meta/` | `IcebergMetaEngine` vtable, registry with capability checking, stub engine | |
| 106 | +| `src/format/` | `FormatReader` / `FormatWriter` interfaces and their registry | |
| 107 | +| `src/common/` | Storage facade, canonical location type, C/C++ exception boundary macros | |
0 commit comments