Search Shortcut cmd + k | ctrl + k
laterite_ags4

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 TYPE row (2DPDOUBLE, IDVARCHAR, 0DPBIGINT, YNBOOLEAN, …).
  • Deterministic content-addressed keys — every row carries _id and _parent_id (UUIDv8 of the row's spec key-chain). child._parent_id == parent._id by construction, so groups join across independent read_ags(...) calls with no shared state.
  • Self-describing metadataags_groups, ags_headings, ags_dictionary, ags_relationships expose the file's structure and the embedded AGS dictionary.
  • Opt-in validationvalidate_ags(path[, dict_version := '4.2']) runs a clean-room AGS4 rule check (error-only by default; warnings := true / fyi := true add the lower tiers); never a gate on reads.
  • Persistenceload_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):// and s3:// (with LOAD httpfs) all work on one code path.

Functions

function returns
read_ags(path, group) one group as a typed table — _id, _parent_id, then one column per heading (typed from the file's TYPE row). Reads local / http(s):// / s3://.
read_ags_text(content, group) the same typed table, from an inline AGS4 string (no filesystem).
ags_groups(path) (group, n_rows, n_headings, parent) — the file's group list.
ags_headings(path) (group, heading, unit, ags_type, sql_type, status, is_key, ordinal) — the per-heading schema, enriched with the dictionary's KEY status.
ags_dictionary() the embedded standard AGS dictionary as a table (group, heading, status, ags_type, unit, description, …).
ags_relationships() (child, parent, shared_keys) — the spec parent→child graph that _parent_id follows.
validate_ags(path[, dict_version := '4.2'][, warnings := true][, fyi := true]) (rule, line, group, severity, desc) — a clean-room AGS4 rule check; the edition auto-detects from TRAN_AGS unless forced, and only error-severity findings show unless the warnings / fyi tiers are opted in.
certify_ags(path[, dict_version := '4.2']) validate, then mint a sibling .ags.idx certificate; returns a one-row status (certified, groups/errors/warnings/fyi counts, dict_version, message).
load_ags_script(path) (seq, stmt) — CREATE-TABLE DDL to materialise every group into an indexed, repeat-/remote-queryable store.

Readers stream lazily (≈2048-row vector chunks); a non-conforming numeric cell becomes NULL, never an error (the born-typed behaviour). Optional arguments are named (dict_version := '4.2', warnings := true), the rest positional. There is no repair surface — mutation stays in the lat-check CLI / the laterite library.

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  
certify_ags 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.