This repository is based on https://github.com/duckdb/extension-template.
MobilityDuck is a binding for DuckDB built on top of MEOS (Mobility Engine, Open Source), a C library that enables the manipulation of temporal and spatiotemporal data based on MobilityDB's data types and functions.
With MobilityDuck, users can use these data types and functions directly in DuckDB queries.
MobilityDuck needs some dependencies(including MEOS) which can be installed through VCPKG. Run the following to enable it:
cd <your-working-dir-not-the-plugin-repo>
git clone https://github.com/Microsoft/vcpkg.git
sh ./vcpkg/scripts/bootstrap.sh -disableMetrics
export VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake
git clone --recurse-submodules https://github.com/nhungoc1508/mobilityduck.git
Note that --recurse-submodules
will ensure DuckDB is pulled which is required to build the extension.
To build the extension, from the root directory (mobilityduck
), run (for first build):
make
For subsequent builds, use ninja
for faster build relying on cache:
GEN=ninja make
The main binaries that will be built are:
./build/release/duckdb
./build/release/test/unittest
./build/release/extension/mobilityduck/mobilityduck.duckdb_extension
duckdb
is the binary for the duckdb shell with the extension code automatically loaded.unittest
is the test runner of duckdb. Again, the extension is already linked into the binary.mobilityduck.duckdb_extension
is the loadable binary as it would be distributed.
To run the extension code, start the shell with ./build/release/duckdb
.
Now we can use the features from the extension directly in DuckDB. Some examples:
D SELECT '100@2025-01-01 10:00:00+05'::TINT as tint;
┌────────────────────────────┐
│ tint │
│ tint │
├────────────────────────────┤
│ 100@2025-01-01 05:00:00+00 │
└────────────────────────────┘
D SELECT duration('{1@2000-01-01, 2@2000-01-02, 1@2000-01-03}'::TINT, true) as duration;
┌──────────┐
│ duration │
│ interval │
├──────────┤
│ 2 days │
└──────────┘
D SELECT tstzspan('[2000-01-01,2000-01-01]') as ts_span;
┌──────────────────────────────────────────────────┐
│ ts_span │
│ span │
├──────────────────────────────────────────────────┤
│ [2000-01-01 00:00:00+00, 2000-01-02 00:00:00+00) │
└──────────────────────────────────────────────────┘
D SELECT timeSpan(tgeompoint('{Point(1 1)@2000-01-01, Point(2 2)@2000-01-02, Point(1 1)@2000-01-03}')) as span;
┌──────────────────────────────────────────────────┐
│ span │
│ span │
├──────────────────────────────────────────────────┤
│ [2000-01-01 00:00:00+00, 2000-01-03 00:00:00+00] │
└──────────────────────────────────────────────────┘
D SELECT * FROM setUnnest(textset('{"highway", "car", "bike"}'));
┌─────────┐
│ unnest │
│ varchar │
├─────────┤
│ bike │
│ car │
│ highway │
└─────────┘
Test files are located in ./test/sql
. These SQL tests can be run using:
make test