Read AGS4 geotechnical data files as typed, UUID-keyed tables directly from SQL — born-typed columns, deterministic content-addressed keys that join across groups by construction, embedded AGS dictionary, and opt-in validation. Local, http(s):// and s3:// (with httpfs).
Maintainer(s):
niko86
Installing and Loading
INSTALL laterite_ags4 FROM community;
LOAD laterite_ags4;
Example
-- Read a group as a typed table (columns typed from the file's own TYPE row):
SELECT loca_id, loca_gl
FROM read_ags('site.ags', 'LOCA')
WHERE loca_gl > 50.0;
-- Join across groups on the deterministic keys — no shared state, joins by
-- construction (every SAMP row's _parent_id equals its LOCA's _id):
SELECT l.loca_id, s.samp_ref, s.samp_top
FROM read_ags('site.ags', 'SAMP') s
JOIN read_ags('site.ags', 'LOCA') l ON s._parent_id = l._id;
-- Inspect structure + the embedded AGS dictionary:
SELECT "group", n_rows, parent FROM ags_groups('site.ags') ORDER BY n_rows DESC;
SELECT child, parent, shared_keys FROM ags_relationships() WHERE parent = 'LOCA';
-- Opt-in validation (auto-detects the edition from TRAN_AGS):
SELECT rule, line, "group", severity, "desc" FROM validate_ags('site.ags');
-- Remote, lazily (with httpfs):
-- LOAD httpfs;
-- SELECT loca_id FROM read_ags('s3://bucket/site.ags', 'LOCA');
About laterite_ags4
laterite_ags4 reads AGS4 geotechnical & geoenvironmental
data files as first-class DuckDB tables — no conversion step, no bundled engine.
Written in 🦀 Rust on DuckDB's C Extension API (zero C++).
What it gives you
- Born-typed columns — each heading is typed from the file's own
TYPErow (2DP→DOUBLE,ID→VARCHAR,0DP→BIGINT,YN→BOOLEAN, …). - Deterministic content-addressed keys — every row carries
_idand_parent_id(UUIDv8 of the row's spec key-chain).child._parent_id == parent._idby construction, so groups join across independentread_ags(...)calls with no shared state. - Self-describing metadata —
ags_groups,ags_headings,ags_dictionary,ags_relationshipsexpose the file's structure and the embedded AGS dictionary. - Opt-in validation —
validate_ags(path[, edition := '4.2'])runs a clean-room AGS4 rule check; never a gate on reads. - Persistence —
load_ags_script(path)emits CREATE-TABLE DDL for an indexed, repeat-/remote-query store. - Local or remote — reads go through DuckDB's virtual filesystem, so local paths,
http(s)://ands3://(withLOAD httpfs) all work on one code path.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| ags_dictionary | table | NULL | NULL | |
| ags_groups | table | NULL | NULL | |
| ags_headings | table | NULL | NULL | |
| ags_relationships | table | NULL | NULL | |
| load_ags_script | table | NULL | NULL | |
| read_ags | table | NULL | NULL | |
| read_ags_text | table | NULL | NULL | |
| validate_ags | table | NULL | NULL |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
This extension does not add any settings.