|
1 | | -# Mooncake |
| 1 | +# duckdb_mooncake |
2 | 2 |
|
3 | | -This repository is based on https://github.com/duckdb/extension-template, check it out if you want to build and ship your own DuckDB extension. |
| 3 | +duckdb_mooncake is a DuckDB extension to read Iceberg tables written by [moonlink][moonlink-link] in real time. |
4 | 4 |
|
5 | | ---- |
| 5 | +## Installation |
6 | 6 |
|
7 | | -This extension, Mooncake, allow you to ... <extension_goal>. |
8 | | - |
9 | | - |
10 | | -## Building |
11 | | -### Managing dependencies |
12 | | -DuckDB extensions uses VCPKG for dependency management. Enabling VCPKG is very simple: follow the [installation instructions](https://vcpkg.io/en/getting-started) or just run the following: |
13 | | -```shell |
14 | | -git clone https://github.com/Microsoft/vcpkg.git |
15 | | -./vcpkg/bootstrap-vcpkg.sh |
16 | | -export VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake |
| 7 | +duckdb_mooncake can be installed using the `INSTALL` command: |
| 8 | +```sql |
| 9 | +INSTALL duckdb_mooncake FROM community; |
17 | 10 | ``` |
18 | | -Note: VCPKG is only required for extensions that want to rely on it for dependency management. If you want to develop an extension without dependencies, or want to do your own dependency management, just skip this step. Note that the example extension uses VCPKG to build with a dependency for instructive purposes, so when skipping this step the build may not work without removing the dependency. |
19 | 11 |
|
20 | | -### Build steps |
21 | | -Now to build the extension, run: |
22 | | -```sh |
23 | | -make |
24 | | -``` |
25 | | -The main binaries that will be built are: |
26 | | -```sh |
27 | | -./build/release/duckdb |
28 | | -./build/release/test/unittest |
29 | | -./build/release/extension/mooncake/mooncake.duckdb_extension |
30 | | -``` |
31 | | -- `duckdb` is the binary for the duckdb shell with the extension code automatically loaded. |
32 | | -- `unittest` is the test runner of duckdb. Again, the extension is already linked into the binary. |
33 | | -- `mooncake.duckdb_extension` is the loadable binary as it would be distributed. |
| 12 | +## Usage |
34 | 13 |
|
35 | | -## Running the extension |
36 | | -To run the extension code, simply start the shell with `./build/release/duckdb`. |
| 14 | +Mooncake databases can be attached using the `ATTACH` command, after which tables can be queried using standard SQL. |
37 | 15 |
|
38 | | -Now we can use the features from the extension directly in DuckDB: |
39 | | -``` |
40 | | -D ATTACH DATABASE 'mooncake' (TYPE mooncake, URI '/var/lib/postgresql/data/pg_mooncake/moonlink.sock'); |
41 | | -D USE mooncake; |
42 | | -D SELECT * FROM "5.16401"; |
| 16 | +The example below attaches to the moonlink database `'postgres'`, from a moonlink instance listening at `'/var/lib/postgresql/data/pg_mooncake/moonlink.sock'`. This moonlink instance comes prepopulated with a table named `public.c`: |
| 17 | +```sql |
| 18 | +D ATTACH DATABASE 'mooncake' (TYPE mooncake, URI '/var/lib/postgresql/data/pg_mooncake/moonlink.sock', DATABASE 'postgres'); |
| 19 | +D SELECT * FROM mooncake.public.c; |
43 | 20 | ┌───────┬─────────┐ |
44 | | -│ a │ b │ |
| 21 | +│ id │ val │ |
45 | 22 | │ int32 │ varchar │ |
46 | 23 | ├───────┼─────────┤ |
47 | | -│ 1 │ a │ |
48 | | -│ 2 │ b │ |
49 | | -│ 3 │ c │ |
| 24 | +│ 1 │ Hello │ |
| 25 | +│ 2 │ World │ |
50 | 26 | └───────┴─────────┘ |
51 | 27 | ``` |
52 | 28 |
|
53 | | -## Running the tests |
54 | | -Different tests can be created for DuckDB extensions. The primary way of testing DuckDB extensions should be the SQL tests in `./test/sql`. These SQL tests can be run using: |
55 | | -```sh |
56 | | -make test |
57 | | -``` |
58 | | - |
59 | | -### Installing the deployed binaries |
60 | | -To install your extension binaries from S3, you will need to do two things. Firstly, DuckDB should be launched with the |
61 | | -`allow_unsigned_extensions` option set to true. How to set this will depend on the client you're using. Some examples: |
| 29 | +## Building |
62 | 30 |
|
63 | | -CLI: |
64 | | -```shell |
65 | | -duckdb -unsigned |
| 31 | +To build, type: |
66 | 32 | ``` |
67 | | - |
68 | | -Python: |
69 | | -```python |
70 | | -con = duckdb.connect(':memory:', config={'allow_unsigned_extensions' : 'true'}) |
| 33 | +git submodule update --init --recursive |
| 34 | +GEN=ninja make |
71 | 35 | ``` |
72 | 36 |
|
73 | | -NodeJS: |
74 | | -```js |
75 | | -db = new duckdb.Database(':memory:', {"allow_unsigned_extensions": "true"}); |
| 37 | +To run, run the bundled `duckdb` shell: |
76 | 38 | ``` |
77 | | - |
78 | | -Secondly, you will need to set the repository endpoint in DuckDB to the HTTP url of your bucket + version of the extension |
79 | | -you want to install. To do this run the following SQL query in DuckDB: |
80 | | -```sql |
81 | | -SET custom_extension_repository='bucket.s3.eu-west-1.amazonaws.com/<your_extension_name>/latest'; |
| 39 | +./build/release/duckdb |
82 | 40 | ``` |
83 | | -Note that the `/latest` path will allow you to install the latest extension version available for your current version of |
84 | | -DuckDB. To specify a specific version, you can pass the version instead. |
85 | 41 |
|
86 | | -After running these steps, you can install and load your extension using the regular INSTALL/LOAD commands in DuckDB: |
87 | | -```sql |
88 | | -INSTALL mooncake |
89 | | -LOAD mooncake |
90 | | -``` |
| 42 | +[moonlink-link]: https://github.com/Mooncake-Labs/moonlink |
0 commit comments