Search Shortcut cmd + k | ctrl + k

anofox_similarity

Multi-modal product similarity search for manufacturing supply chain planning. Find similar materials by BOM component overlap (Jaccard), graph-structural similarity (Weisfeiler-Lehman kernel), text embeddings, and transactional patterns, with predecessor detection and cold-start analog matching for demand forecasting. Requirements coverage matching: direction-aware value checks with units (EN/DE), property trees from JSON, a traced coverage kernel with gap lists, catalogue classification with your own vectors, vocabulary review, evaluation, and MinHash/LSH recall. Asset Administration Shell (AAS v3): read JSON/XML/AASX, match on ECLASS / IEC CDD ids, check data quality, and write results back as AAS.

Maintainer(s): jrosskopf

Compatibility Matrix

This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.

Platform 1.5.5 1.5.6 2.0.0 2.0.1
Linux AMD64
Linux ARM64
macOS AMD64
macOS ARM64
Windows AMD64
Windows ARM64
WebAssembly

Installing and Loading

INSTALL anofox_similarity FROM community;
LOAD anofox_similarity;

Example

-- Components (BOM) for each product
CREATE TABLE bom_items (parent_id VARCHAR, child_id VARCHAR);
INSERT INTO bom_items VALUES
  ('PUMP-A', 'SEAL-001'), ('PUMP-A', 'BEARING-X'), ('PUMP-A', 'MOTOR-M1'),
  ('PUMP-B', 'SEAL-001'), ('PUMP-B', 'BEARING-X'), ('PUMP-B', 'MOTOR-M1'), ('PUMP-B', 'GASKET-Y'),
  ('PUMP-C', 'FILTER-F1'), ('PUMP-C', 'VALVE-V2');

-- Find the 3 materials most similar to PUMP-A by shared components
SELECT material_id, similarity, shared_components, total_components
FROM find_similar_materials_jaccard('PUMP-A', 3, bom_table := 'bom_items')
ORDER BY similarity DESC;
-- PUMP-B   0.75  3  4   (PUMP-C shares nothing and is left out; min_similarity := 0 keeps it)

-- Structural similarity that also weighs BOM topology, not just component sets
SELECT wl_kernel_similarity('PUMP-A', 'PUMP-B', iterations := 3, bom_table := 'bom_items');

About anofox_similarity

anofox_similarity helps manufacturers answer "which existing product is this new one most like?" directly against ERP master data (SAP, Microsoft Dynamics 365, or a plain bom_items table), which is the key input for cold-start demand forecasting, predecessor detection, and analog-based planning for products with no sales history yet.

Similarity signals compose across several table functions:

  • find_similar_materials_jaccard ranks materials by BOM component overlap.
  • wl_kernel_similarity / find_similar_materials_wl_kernel use a Weisfeiler-Lehman graph kernel to capture BOM topology, not just which components are shared but how they're structurally arranged.
  • infer_predecessors detects predecessor/successor relationships from structural similarity plus temporal anti-correlation in goods-movement history (an old part's usage declining as a new part's usage rises).
  • cold_start_analogs finds established products to seed a forecast for a brand-new material with no history at all.
  • compute_fused_embeddings combines structural, transactional, and text embedding signals into one fusable vector, indexable with DuckDB's vss extension via the bundled HNSW index helpers.

SAP (MARA/MAKT/MAST/STKO/STPO/STAS) and Dynamics 365 (BOMVersion, BOM lines) readers (sap_to_bom_items, dynamics365_to_bom_header, …) turn ERP exports into the BOM/material schema the rest of the extension expects, applying BOM categories, alternatives, versions on a reference date and deletion flags, so integration is mostly SELECT * FROM sap_to_bom_items(...).

Requirements coverage matching answers "which past programme or supplier offer covers this request, and what is missing": tree_coverage scores property trees with unit- and direction-aware value checks and returns a gap list. Supplier offers and requests can come straight from Asset Administration Shells (aas_to_trees, aas_issues, aas_quality), and a match can be written back as an AAS CoverageResult submodel.

A Claude Code plugin with six skills (in the repository) teaches an AI assistant to write correct SQL for the extension.

All table functions accept a fully qualified read-only DuckDB database and degrade gracefully when optional companion extensions (anofox_forecast for time-series features, duckpgq for property-graph BOM queries) are not loaded.

The extension collects anonymous usage telemetry (an envelope-only extension_loaded event; never table names, keys, or SQL). Disable with SET anofox_telemetry_enabled = false or DATAZOO_DISABLE_TELEMETRY=1; see TELEMETRY.md in the repository.

Added Functions

function_name function_type description comment examples
aas_class_hierarchy scalar The capability class hierarchy of IDTA-02020 CapabilityGeneralizedBy relations: LIST of STRUCT(class_id, parent_class_id), class ids as in aas_to_trees (the second element may also be an external ontology IRI). Store it as a table and pass it to tree_coverage as class_hierarchy: an offer of a subclass then fully meets a requirement of its superclass (is-a), and with a generalization_credit c a superclass offer gets c^d for a subclass requirement. Unresolvable references are in aas_issues (unresolved_relation). NULL [SELECT unnest(aas_class_hierarchy(content), recursive := true) FROM read_blob('taxonomy.aasx');]
aas_class_hierarchy scalar The capability class hierarchy of IDTA-02020 CapabilityGeneralizedBy relations: LIST of STRUCT(class_id, parent_class_id), class ids as in aas_to_trees (the second element may also be an external ontology IRI). Store it as a table and pass it to tree_coverage as class_hierarchy: an offer of a subclass then fully meets a requirement of its superclass (is-a), and with a generalization_credit c a superclass offer gets c^d for a subclass requirement. Unresolvable references are in aas_issues (unresolved_relation). NULL [SELECT unnest(aas_class_hierarchy(content), recursive := true) FROM read_text('capability_taxonomy.aas.json');]
aas_coverage_result table The rankings of a tree_coverage_trace result as AAS: one row per query and candidate with aas_json, a 'CoverageResult' Submodel (coverage_result_to_aas), and aas_environment, the same wrapped as an Environment ready to upload. coverage is the mean requirement score of the trace, i.e. tree_coverage's coverage. The submodel id is id_prefix (default https://anofox.com/aas/results/) plus the base64url-encoded query and candidate ids. NULL [CREATE TABLE trace AS SELECT * FROM tree_coverage_trace('RFQ-2026-117', candidates := ['OFF-A']);, SELECT aas_json FROM aas_coverage_result('trace');]
aas_export table Exports property trees as AAS: one row per tree with tree_id and aas_json, an AAS v3 Environment (Part 1 JSON) as trees_to_aas writes it. Trees come from nodes_table / attrs_table (default 'tree_nodes' / 'tree_attributes'), tree_ids selects some; catalogue_table (class_id[, label | name][, definition]) adds ConceptDescriptions for the classes. NULL [SELECT tree_id, aas_json FROM aas_export(tree_ids := ['RFQ-2026-117']);]
aas_id_b64url scalar An AAS identifier encoded for an AAS Part 2 REST path: base64url (RFC 4648 §5) without padding, as in GET /submodels/{submodelIdentifier}. Use it with read_text over httpfs to load a submodel from an AAS repository (BaSyx, FA³ST). NULL [SELECT aas_to_trees(content) FROM read_text('http://localhost:8081/submodels/' || aas_id_b64url('https://example.com/ids/sm/TechnicalData'));]
aas_issues scalar Findings of aas_to_trees about the input: LIST of STRUCT(tree_id, path, issue, severity, detail). It never raises on malformed input: a broken file gives one parse_error row with the reader's message, so SELECT filename, unnest(aas_issues(content)) FROM read_blob('offers/*') audits a folder. See the API page for the issue codes (bad_value, empty_value, decimal_comma, missing_concept_description, ambiguous_concept_description, unknown_unit_id, unknown_unit, assumed_dimensionless, duplicate_id_short, …). A unit slip across files (0.55 W against max. 0.75 kW) needs the other values: validate_trees over the loaded trees reports it as magnitude_outlier. path is the idShort path, submodel first. Same arguments as aas_to_trees. NULL [SELECT aas_issues(content) FROM read_blob('offers/*.aasx');]
aas_issues scalar Findings of aas_to_trees about the input: LIST of STRUCT(tree_id, path, issue, severity, detail). It never raises on malformed input: a broken file gives one parse_error row with the reader's message, so SELECT filename, unnest(aas_issues(content)) FROM read_blob('offers/*') audits a folder. See the API page for the issue codes (bad_value, empty_value, decimal_comma, missing_concept_description, ambiguous_concept_description, unknown_unit_id, unknown_unit, assumed_dimensionless, duplicate_id_short, …). A unit slip across files (0.55 W against max. 0.75 kW) needs the other values: validate_trees over the loaded trees reports it as magnitude_outlier. path is the idShort path, submodel first. Same arguments as aas_to_trees. NULL [SELECT aas_issues(content) FROM read_text('offers/*.json');]
aas_issues scalar Findings of aas_to_trees about the input: LIST of STRUCT(tree_id, path, issue, severity, detail). It never raises on malformed input: a broken file gives one parse_error row with the reader's message, so SELECT filename, unnest(aas_issues(content)) FROM read_blob('offers/*') audits a folder. See the API page for the issue codes (bad_value, empty_value, decimal_comma, missing_concept_description, ambiguous_concept_description, unknown_unit_id, unknown_unit, assumed_dimensionless, duplicate_id_short, …). A unit slip across files (0.55 W against max. 0.75 kW) needs the other values: validate_trees over the loaded trees reports it as magnitude_outlier. path is the idShort path, submodel first. Same arguments as aas_to_trees. NULL [SELECT aas_issues(content, 'OFF-A') FROM read_blob('offer_a.aasx');]
aas_issues scalar Findings of aas_to_trees about the input: LIST of STRUCT(tree_id, path, issue, severity, detail). It never raises on malformed input: a broken file gives one parse_error row with the reader's message, so SELECT filename, unnest(aas_issues(content)) FROM read_blob('offers/*') audits a folder. See the API page for the issue codes (bad_value, empty_value, decimal_comma, missing_concept_description, ambiguous_concept_description, unknown_unit_id, unknown_unit, assumed_dimensionless, duplicate_id_short, …). A unit slip across files (0.55 W against max. 0.75 kW) needs the other values: validate_trees over the loaded trees reports it as magnitude_outlier. path is the idShort path, submodel first. Same arguments as aas_to_trees. NULL [SELECT aas_issues(content, 'OFF-A') FROM read_text('offer_a.xml');]
aas_issues scalar Findings of aas_to_trees about the input: LIST of STRUCT(tree_id, path, issue, severity, detail). It never raises on malformed input: a broken file gives one parse_error row with the reader's message, so SELECT filename, unnest(aas_issues(content)) FROM read_blob('offers/*') audits a folder. See the API page for the issue codes (bad_value, empty_value, decimal_comma, missing_concept_description, ambiguous_concept_description, unknown_unit_id, unknown_unit, assumed_dimensionless, duplicate_id_short, …). A unit slip across files (0.55 W against max. 0.75 kW) needs the other values: validate_trees over the loaded trees reports it as magnitude_outlier. path is the idShort path, submodel first. Same arguments as aas_to_trees. NULL [SELECT aas_issues(content, NULL, (SELECT list(u) FROM eclass_units u)) FROM read_blob('offer_a.aasx');]
aas_issues scalar Findings of aas_to_trees about the input: LIST of STRUCT(tree_id, path, issue, severity, detail). It never raises on malformed input: a broken file gives one parse_error row with the reader's message, so SELECT filename, unnest(aas_issues(content)) FROM read_blob('offers/*') audits a folder. See the API page for the issue codes (bad_value, empty_value, decimal_comma, missing_concept_description, ambiguous_concept_description, unknown_unit_id, unknown_unit, assumed_dimensionless, duplicate_id_short, …). A unit slip across files (0.55 W against max. 0.75 kW) needs the other values: validate_trees over the loaded trees reports it as magnitude_outlier. path is the idShort path, submodel first. Same arguments as aas_to_trees. NULL [SELECT aas_issues(content, NULL, (SELECT list(u) FROM eclass_units u)) FROM read_text('offer_a.json');]
aas_quality scalar Data quality of an AAS input per submodel, without the coverage kernel: LIST of STRUCT(tree_id, submodel_id, submodel, kind, n_values (Property, Range, MultiLanguageProperty), n_with_semantic_id, semantic_id_share, n_missing_concept_description, n_unresolved_units (numbers whose unit is unknown), n_unparseable (bad_value), n_mixed_releases (concepts referenced in more than one dictionary release in the input), n_issues (aas_issues findings except unmapped_text, which n_values - n_with_semantic_id already counts)). The counts come from the same reading as aas_to_trees and aas_issues. unit_table as in parse_quantity. NULL [SELECT filename, unnest(aas_quality(content), recursive := true) FROM read_blob('offers/*');]
aas_quality scalar Data quality of an AAS input per submodel, without the coverage kernel: LIST of STRUCT(tree_id, submodel_id, submodel, kind, n_values (Property, Range, MultiLanguageProperty), n_with_semantic_id, semantic_id_share, n_missing_concept_description, n_unresolved_units (numbers whose unit is unknown), n_unparseable (bad_value), n_mixed_releases (concepts referenced in more than one dictionary release in the input), n_issues (aas_issues findings except unmapped_text, which n_values - n_with_semantic_id already counts)). The counts come from the same reading as aas_to_trees and aas_issues. unit_table as in parse_quantity. NULL [SELECT filename, unnest(aas_quality(content), recursive := true) FROM read_text('offers/*.json');]
aas_quality scalar Data quality of an AAS input per submodel, without the coverage kernel: LIST of STRUCT(tree_id, submodel_id, submodel, kind, n_values (Property, Range, MultiLanguageProperty), n_with_semantic_id, semantic_id_share, n_missing_concept_description, n_unresolved_units (numbers whose unit is unknown), n_unparseable (bad_value), n_mixed_releases (concepts referenced in more than one dictionary release in the input), n_issues (aas_issues findings except unmapped_text, which n_values - n_with_semantic_id already counts)). The counts come from the same reading as aas_to_trees and aas_issues. unit_table as in parse_quantity. NULL [SELECT unnest(aas_quality(content, (SELECT list(u) FROM eclass_units u)), recursive := true) FROM read_blob('offer.aasx');]
aas_quality scalar Data quality of an AAS input per submodel, without the coverage kernel: LIST of STRUCT(tree_id, submodel_id, submodel, kind, n_values (Property, Range, MultiLanguageProperty), n_with_semantic_id, semantic_id_share, n_missing_concept_description, n_unresolved_units (numbers whose unit is unknown), n_unparseable (bad_value), n_mixed_releases (concepts referenced in more than one dictionary release in the input), n_issues (aas_issues findings except unmapped_text, which n_values - n_with_semantic_id already counts)). The counts come from the same reading as aas_to_trees and aas_issues. unit_table as in parse_quantity. NULL [SELECT unnest(aas_quality(content, (SELECT list(u) FROM eclass_units u)), recursive := true) FROM read_text('offer.json');]
aas_to_trees scalar Reads Asset Administration Shell data (AAS v3.x: Part 1 JSON or XML, an AASX package, a single Submodel or a Part 2 paged result) into property trees: a LIST of the node STRUCTs of tree_from_json with their attributes. One tree per shell (tree_id: the shell id, or the tree_id argument), submodels and collections as nodes; a collection that directly holds values is an item (class_id: its semanticId), otherwise a container. Property and Range give attributes: attr_key is the semanticId (the supplementalSemanticId for IDTA-02020 property types), the unit comes from the IEC 61360 data specification (unitId first, then unit) and values are converted to base units. An IDTA-02020 CapabilityContainer is an item whose class is the Capability's supplementalSemanticId and whose attributes come from its PropertySets; the CapabilityRoleQualifier gives role. Pass read_blob(…) for AASX packages. Findings about the input are in aas_issues(). unit_table as in parse_quantity. NULL [SELECT aas_to_trees(content) FROM read_blob('offers/*.aasx');]
aas_to_trees scalar Reads Asset Administration Shell data (AAS v3.x: Part 1 JSON or XML, an AASX package, a single Submodel or a Part 2 paged result) into property trees: a LIST of the node STRUCTs of tree_from_json with their attributes. One tree per shell (tree_id: the shell id, or the tree_id argument), submodels and collections as nodes; a collection that directly holds values is an item (class_id: its semanticId), otherwise a container. Property and Range give attributes: attr_key is the semanticId (the supplementalSemanticId for IDTA-02020 property types), the unit comes from the IEC 61360 data specification (unitId first, then unit) and values are converted to base units. An IDTA-02020 CapabilityContainer is an item whose class is the Capability's supplementalSemanticId and whose attributes come from its PropertySets; the CapabilityRoleQualifier gives role. Pass read_blob(…) for AASX packages. Findings about the input are in aas_issues(). unit_table as in parse_quantity. NULL [SELECT aas_to_trees(content) FROM read_text('offers/*.json');]
aas_to_trees scalar Reads Asset Administration Shell data (AAS v3.x: Part 1 JSON or XML, an AASX package, a single Submodel or a Part 2 paged result) into property trees: a LIST of the node STRUCTs of tree_from_json with their attributes. One tree per shell (tree_id: the shell id, or the tree_id argument), submodels and collections as nodes; a collection that directly holds values is an item (class_id: its semanticId), otherwise a container. Property and Range give attributes: attr_key is the semanticId (the supplementalSemanticId for IDTA-02020 property types), the unit comes from the IEC 61360 data specification (unitId first, then unit) and values are converted to base units. An IDTA-02020 CapabilityContainer is an item whose class is the Capability's supplementalSemanticId and whose attributes come from its PropertySets; the CapabilityRoleQualifier gives role. Pass read_blob(…) for AASX packages. Findings about the input are in aas_issues(). unit_table as in parse_quantity. NULL [SELECT aas_to_trees(content, 'OFF-A') FROM read_blob('offer_a.aasx');]
aas_to_trees scalar Reads Asset Administration Shell data (AAS v3.x: Part 1 JSON or XML, an AASX package, a single Submodel or a Part 2 paged result) into property trees: a LIST of the node STRUCTs of tree_from_json with their attributes. One tree per shell (tree_id: the shell id, or the tree_id argument), submodels and collections as nodes; a collection that directly holds values is an item (class_id: its semanticId), otherwise a container. Property and Range give attributes: attr_key is the semanticId (the supplementalSemanticId for IDTA-02020 property types), the unit comes from the IEC 61360 data specification (unitId first, then unit) and values are converted to base units. An IDTA-02020 CapabilityContainer is an item whose class is the Capability's supplementalSemanticId and whose attributes come from its PropertySets; the CapabilityRoleQualifier gives role. Pass read_blob(…) for AASX packages. Findings about the input are in aas_issues(). unit_table as in parse_quantity. NULL [SELECT aas_to_trees(content, 'OFF-A') FROM read_text('offer_a.xml');]
aas_to_trees scalar Reads Asset Administration Shell data (AAS v3.x: Part 1 JSON or XML, an AASX package, a single Submodel or a Part 2 paged result) into property trees: a LIST of the node STRUCTs of tree_from_json with their attributes. One tree per shell (tree_id: the shell id, or the tree_id argument), submodels and collections as nodes; a collection that directly holds values is an item (class_id: its semanticId), otherwise a container. Property and Range give attributes: attr_key is the semanticId (the supplementalSemanticId for IDTA-02020 property types), the unit comes from the IEC 61360 data specification (unitId first, then unit) and values are converted to base units. An IDTA-02020 CapabilityContainer is an item whose class is the Capability's supplementalSemanticId and whose attributes come from its PropertySets; the CapabilityRoleQualifier gives role. Pass read_blob(…) for AASX packages. Findings about the input are in aas_issues(). unit_table as in parse_quantity. NULL [SELECT aas_to_trees(content, NULL, (SELECT list(u) FROM eclass_units u)) FROM read_blob('offer_a.aasx');]
aas_to_trees scalar Reads Asset Administration Shell data (AAS v3.x: Part 1 JSON or XML, an AASX package, a single Submodel or a Part 2 paged result) into property trees: a LIST of the node STRUCTs of tree_from_json with their attributes. One tree per shell (tree_id: the shell id, or the tree_id argument), submodels and collections as nodes; a collection that directly holds values is an item (class_id: its semanticId), otherwise a container. Property and Range give attributes: attr_key is the semanticId (the supplementalSemanticId for IDTA-02020 property types), the unit comes from the IEC 61360 data specification (unitId first, then unit) and values are converted to base units. An IDTA-02020 CapabilityContainer is an item whose class is the Capability's supplementalSemanticId and whose attributes come from its PropertySets; the CapabilityRoleQualifier gives role. Pass read_blob(…) for AASX packages. Findings about the input are in aas_issues(). unit_table as in parse_quantity. NULL [SELECT aas_to_trees(content, NULL, (SELECT list(u) FROM eclass_units u)) FROM read_text('offer_a.json');]
aggregate_material_components table_macro Groups a BOM edge list into one row per parent material with its child components as a sorted list — the shape the Jaccard and cold-start functions expect. 'material_filter' restricts the result to the listed parents; NULL means all of them. NULL [SELECT * FROM aggregate_material_components(bom_table := 'bom_items')]
apply_vocabulary_review table Applies a review (wording, class_id[, source, reviewed_by, reviewed_at]) to the overrides (default 'vocabulary_overrides' when that table exists; NULL for none): one entry per wording and source, the review wins. Returns the new overrides table; table functions cannot write, so store it: CREATE OR REPLACE TABLE vocabulary_overrides AS SELECT * FROM apply_vocabulary_review('review'). NULL [CREATE OR REPLACE TABLE vocabulary_overrides AS SELECT * FROM apply_vocabulary_review('review');]
attrs_satisfying table Which attributes satisfy a requirement: every row of attrs_table (default 'tree_attributes') whose attr_key equals attr_key after semantic_key (any release, IRDI or ECLASS IRI; rows without attr_key match by name, case-insensitively), checked with value_satisfies against requirement (a STRUCT such as parse_quantity('mindestens 7637,1 mA')): direction (at_least, at_most, within, equals), units and the dimension gate (5 V never satisfies 5 A). Returns tree_id, node_id, attr_id, name, attr_key, value (the offered value in base units), score, distance, rule and satisfied (score 1), best first. tol, soft_band, scale and default_bound as in value_satisfies; tol := 0, soft_band := 0 for hard limits. A unit- and direction-aware query over AAS data that the AAS Query Language does not offer. NULL [SELECT tree_id, node_id, value FROM attrs_satisfying('0173-1#02-BAA120#008', parse_quantity('mindestens 7637,1 mA', 'de')) WHERE satisfied;]
bhattacharyya scalar Bhattacharyya coefficient of two class distributions MAP(class, probability): Σ √(p_k q_k). 1 for identical distributions, 0 for disjoint ones; the soft label agreement L(q, c) of the coverage kernel. Distributions are used as given (tree_coverage normalises them). Negative values are an error; NULL gives NULL. NULL [SELECT bhattacharyya(MAP {'heating': 0.6, 'ventilation': 0.4}, MAP {'heating': 0.5, 'ventilation': 0.5}); – 0.9949]
bom_common_components table_macro Components that appear in the BOMs of both given materials – the overlap used to judge how interchangeable two assemblies are. NULL [SELECT * FROM bom_common_components(material_1 := 'PUMP-A', material_2 := 'PUMP-B')]
bom_dfs_neighborhood table_macro All descendant components of a root material within a depth limit, as a reusable depth-first BOM traversal over a (parent_id, child_id) edge table. NULL [SELECT * FROM bom_dfs_neighborhood(root_material_id := 'PUMP-A', max_depth := 3)]
bom_explosion_1level table_macro Direct children of one parent material: returns (parent_material_id, child_material_id, quantity_per) for the immediate level only. 'header_table' and 'component_table' name the tables to read, so the macro works on any schema matching the universal BOM shape. NULL [SELECT * FROM bom_explosion_1level(query_material_id := 'PUMP-A')]
bom_explosion_multilevel table_macro Full multi-level BOM explosion under one parent, to 'max_depth' levels: every reachable edge (parent_material_id, child_material_id, quantity_per) once, with no depth column and no rolled-up quantity (multiply quantity_per along the path yourself). Uses UNION rather than UNION ALL so a shared subassembly reached by many paths is expanded once – no exponential blow-up on diamond BOMs – and the depth gate is clamped to a hard ceiling of 64 so a cyclic BOM cannot iterate unbounded. NULL [SELECT * FROM bom_explosion_multilevel(query_material_id := 'PUMP-A', max_depth := 5)]
bom_to_items table_macro Flattens the universal bom_header + bom_component pair into the flat (parent_id, child_id, quantity) bom_items shape that the similarity algorithms expect. NULL [SELECT * FROM bom_to_items(header_table := 'bom_header', component_table := 'bom_component')]
bom_where_used table_macro Reverse BOM lookup: every parent material that consumes a given child, with the quantity each one uses. NULL [SELECT * FROM bom_where_used(child_material_id := 'SEAL-001')]
bootstrap_ci table Cluster bootstrap intervals: resamples the clusters (cluster_col) with replacement n times (default 1000, seeded) and reports per metric the pooled mean (estimate) and the percentile interval lo/hi at level (default 0.95), with n_boot and n_clusters. metrics defaults to every other numeric column. NULL [SELECT * FROM bootstrap_ci('per_request', 'maker', metrics := ['hit', 'regret']);]
calibrated_cosine scalar Cosine rescaled above a corpus floor: clip((cos - floor) / (1 - floor), 0, 1). Small sentence encoders give unrelated texts a cosine around 0.85; estimate the floor with cosine_floor. floor must be in [0, 1); NULL gives NULL. NULL [SELECT calibrated_cosine([1.0, 0.0], [0.8, 0.6], 0.5); – 0.6]
check_anofox_forecast_available macro Returns true when anofox_forecast is loaded with the aggregate anofox_fcst_ts_features_agg, which the transactional embeddings need. anofox_forecast is an optional soft dependency and is never auto-installed. NULL [SELECT check_anofox_forecast_available()]
check_duckpgq_available macro Returns true when the DuckPGQ extension is loaded, so a caller can choose the graph-based BOM traversal path over the SQL fallback. DuckPGQ is an optional soft dependency and is never auto-installed. NULL [SELECT check_duckpgq_available()]
check_statistics_freshness table Returns a single-row summary of the transactional_embedding_statistics table including stat_count, max_samples, current_version, last_updated, and is_fresh. is_fresh is TRUE when >= 30 statistics rows exist and the newest was updated within 7 days. last_updated is NULL when there are no statistics (also on a read-only database, where the table is not created). NULL [SELECT * FROM check_statistics_freshness();]
classify_to_catalogue table Pivot classifier: maps every item onto the catalogue as a distribution p(class). Steps: per-source mean-centring of the item vectors (center_by_source, centroid mode; a source with fewer than min_source_items items, default 10, is centred with the batch mean when the whole batch has at least min_source_items items, and not centred otherwise); cosine to the class vector, or maxsim(tokens, exemplar_tokens) in mode 'late_interaction'; z-score across the catalogue; plus attr_bonus x the attribute-template match (mean over the item's attributes of the best same-dimension template, name similarity by calibrated cosine of name_vectors, or 1 without vectors); softmax with temperature; margin = p1 - p2. Reviewed wordings (overrides_table: wording, source, class_id; matched on the item's label) and per-item decisions (answers_table: tree_id, node_id, class_id) give a one-hot p and overridden = true. items_table: node_id, vec[, tree_id, source, label, tokens]; catalogue_table: class_id, vec[, exemplar_tokens]; attrs_table: [tree_id,] node_id, name, dimension; templates_table: class_id, dimension[, name, name_en, name_de]. Returns tree_id, node_id, source, class_id, p, rank, margin, overridden; tree_id, node_id, class_id and p make it a label_table for tree_coverage. NULL [SELECT * FROM classify_to_catalogue(items_table := 'request_items', catalogue_table := 'catalogue', top := 3);, SELECT * FROM classify_to_catalogue(items_table := 'unseen', catalogue_table := 'catalogue', mode := 'late_interaction', top := 1);]
cluster_matches table Entity clustering: a C++ union-find over the pairs whose score (score_col, default 'score') is at or above threshold (default 0.8). Returns entity_id, cluster_id (the smallest member id) and cluster_size for every entity in the pairs table (left_col/right_col, default 'a'/'b'); entities without a pair above the threshold form their own cluster. For a graph view, see the DuckPGQ recipe in the extension documentation (LSH and clustering). NULL [SELECT * FROM cluster_matches('customer_pairs', threshold := 0.85);]
cold_start_analogs table Finds structural analogs for a cold-start material (one with little or no demand history). Returns established materials that are structurally similar and have at least min_history_months of goods movement data, enabling surrogate forecasting. History is consumption (weeks with a positive net quantity, so a late return does not extend it); movement_weeks counts those weeks and breaks ties of similarity (denser first). Without min_similarity, materials scoring 0 are left out; min_similarity := 0 keeps them. Batch form: cold_start_analogs(k, materials_table := 'tbl') runs the search for every material_id of the table in one query, k per material, and returns query_id (the material searched for) in front of the same columns. NULL [SELECT * FROM cold_start_analogs('NEW-PART', 5);, SELECT * FROM cold_start_analogs('NEW-PART', 10, min_history_months := 12, min_similarity := 0.4);]
cold_start_analogs table Finds structural analogs for a cold-start material (one with little or no demand history). Returns established materials that are structurally similar and have at least min_history_months of goods movement data, enabling surrogate forecasting. History is consumption (weeks with a positive net quantity, so a late return does not extend it); movement_weeks counts those weeks and breaks ties of similarity (denser first). Without min_similarity, materials scoring 0 are left out; min_similarity := 0 keeps them. Batch form: cold_start_analogs(k, materials_table := 'tbl') runs the search for every material_id of the table in one query, k per material, and returns query_id (the material searched for) in front of the same columns. NULL [SELECT * FROM cold_start_analogs(5, materials_table := 'new_products', min_history_months := 12);]
compat_score macro Compatibility of a provided category with a required one for an ordinal or categorical dimension (protection class, certification level, qualifier), looked up in a curated rules table (dimension, required, provided, score). Without a rule: 1 if equal, else 0. Text similarity is never used. NULL [SELECT compat_score('protection_class', 'IP54', 'IP65'), SELECT compat_score('cert_level', 'silver', 'gold', rules_table := 'my_rules')]
compute_domain_specific_statistics table_macro Statistics of the six ERP features of the transactional embedding (positions 92-97): share of movement type 261, share of reversals (262, 602), weekend share, weekday concentration, lifecycle trend strength and growth. Counts movements of either sign; movement_type is optional (shares 0 without it). Part of recompute_embedding_statistics. Needs anofox_forecast for the lifecycle features. NULL [SELECT * FROM compute_domain_specific_statistics(movements_table := 'goods_movements')]
compute_fused_embeddings table_macro Combines the structural, textual and transactional embedding of every material in material_embeddings into one fused vector, returning (material_id, combined_embedding, fusion_weights). Weights are normalised to sum to 1, matching what fuse_embeddings applies internally, and a modality's vector is only required when its weight is above zero. NULL [SELECT * FROM compute_fused_embeddings(weights_structural := 0.6, weights_textual := 0.4)]
compute_jaccard_embeddings table Computes and RETURNS 128-dimensional MinHash embeddings (one row per material/seed, minhash_value FLOAT in [0, 1)) from BOM component sets; it does not write to material_embeddings: aggregate them in seed order into the FLOAT[128] jaccard_embedding yourself. minhash_similarity of two such arrays estimates the Jaccard index. Each material's embedding is derived from its set of direct child components. Requires bom_table with columns parent_id and child_id. NULL [SELECT * FROM compute_jaccard_embeddings();, SELECT * FROM compute_jaccard_embeddings(bom_table := 'sap_stpo');]
compute_textual_embeddings table_macro Generates an embedding per material from its description text, returning (material_id, textual_embedding). In the released build every provider returns a deterministic hash PLACEHOLDER, not a semantic embedding. Reads descriptions from 'makt_table' in the given 'language' (SAP key 'E' or ISO 'EN', either form matches; default 'E'; clients are merged, so filter MAKT to one client first) and embeds them with 'provider'; 'provider_config' is accepted but not read yet (do not put API keys in it). NULL [SELECT * FROM compute_textual_embeddings(makt_table := 'sap_makt', language := 'E')]
compute_transactional_embeddings table Computes 128-dimensional transactional embeddings from goods movements (material_id, movement_date, quantity[, movement_type]) and returns them (it does not write to material_embeddings): 30 time-series features of the weekly series (positions 0-29, from anofox_forecast) and six ERP features (92-97), each a z-score against transactional_embedding_statistics (fill it with recompute_embedding_statistics), then scaled to length 1; the other positions are 0. Needs anofox_forecast (INSTALL/LOAD anofox_forecast FROM community). Volume features count: the same pattern at another volume is not close. Supports batched computation via batch_size and batch_offset. NULL [SELECT * FROM compute_transactional_embeddings();, SELECT * FROM compute_transactional_embeddings(movements_table := 'sap_mseg', time_window_days := 365);, SELECT * FROM compute_transactional_embeddings(batch_size := 1000, batch_offset := 0);]
connected_components scalar Union-find over a LIST of pairs STRUCT(a, b): returns LIST(STRUCT(entity_id, cluster_id)), one entry per entity sorted by id; cluster_id is the smallest entity id of its connected component. NULL ids are ignored. The building block of cluster_matches. NULL [SELECT connected_components([{'a': 'x', 'b': 'y'}, {'a': 'y', 'b': 'z'}]);]
containment scalar Share of the query set contained in the candidate set: |q∩c| / |q|. Directional: a richer candidate is not penalised. Duplicates collapse. NULL in gives NULL; an empty query gives NULL. NULL [SELECT containment(['a','b'], ['a','b','c','d']); – 1.0, SELECT containment(['a','b','c'], ['b','c','d']); – 0.6667]
cosine_floor table Estimates the cosine floor b of a vector corpus: the median cosine of pairs of distinct vectors. With at most sample pairs (default 10 000) all pairs count; otherwise sample pairs are drawn deterministically from seed (default 7). Returns floor and n_pairs. Use the floor with calibrated_cosine or as name_floor. NULL [SET VARIABLE name_floor = (SELECT floor FROM cosine_floor('name_vectors', 'vec'));]
coverage_kernel scalar The stage-2 coverage kernel over two packed trees (LIST of STRUCT(node_id, parent_id, node_kind, edge_type, class_id, reviewed, count, probs MAP, attrs LIST(STRUCT(attr_id, name, dimension, unit, lo, hi, bound, category, default_bound, bound_policy, scale, source_unit, name_vec)))) with an options STRUCT (labels, assignment, label_weight, mu, partition_gate, count_gate, name_floor, tol, soft_band, trace, rules). Returns STRUCT(coverage, n_requirements, n_gaps, reviewed, assignment_used, trace). tree_coverage and tree_coverage_trace build its inputs; use it directly for custom pipelines. NULL [SELECT coverage_kernel(q.nodes, c.nodes, struct_pack(labels := 'hard')).coverage FROM q, c;]
coverage_recall table Stage-1 recall over class multisets: the top-k candidate trees per query with score, containment, jaccard, reviewed, mode_used and rank. mode 'auto' uses containment when every candidate tree is reviewed and weighted jaccard otherwise. query_tree_id is a tree id or a LIST of ids. Trees come from nodes_table (default 'tree_nodes'); candidates from candidate_nodes_table (default: the same table). Classes resolve class_id -> overrides_table (reviewed vocabulary) -> label_table (classifier). Stage 1 ranks candidates by containment (+ tie_break x jaccard) when every candidate tree is reviewed, else by weighted jaccard (mode 'auto'). candidate_multiset_table: a precomputed index of the candidate class multisets (tree_class_multiset output: entity_id, feature_id, weight[, reviewed]) makes stage 1 skip resolving every candidate tree. NULL [SELECT * FROM coverage_recall('R01', k := 20, candidate_nodes_table := 'programme_nodes');]
coverage_result_to_aas scalar The explanation of one ranking as an AAS Submodel (Part 1 JSON) 'CoverageResult': Query, Candidate, Coverage, GapCount and a list of Requirements with matched node and path, label similarity and rule, counts, score, IsGap and per attribute the required and offered value, rule and score. semanticIds in the https://anofox.com/aas/CoverageResult/ namespace. rows are tree_coverage_trace rows (STRUCTs); aas_coverage_result builds them from a trace table. NULL [SELECT * FROM aas_coverage_result('trace');]
coverage_result_to_aas scalar The explanation of one ranking as an AAS Submodel (Part 1 JSON) 'CoverageResult': Query, Candidate, Coverage, GapCount and a list of Requirements with matched node and path, label similarity and rule, counts, score, IsGap and per attribute the required and offered value, rule and score. semanticIds in the https://anofox.com/aas/CoverageResult/ namespace. rows are tree_coverage_trace rows (STRUCTs); aas_coverage_result builds them from a trace table. NULL [SELECT * FROM aas_coverage_result('trace', id_prefix := 'urn:acme:results:');]
create_bom_property_graph table_macro Summarises the BOM graph for one source system as (graph_name, source, num_nodes, num_edges BIGINT): num_nodes counts distinct parent materials, num_edges their components. Reads the tables named bom_header (with source_system) and bom_component; the default source_system is 'TEST', so pass yours. NULL [SELECT * FROM create_bom_property_graph(source_system := 'SAP')]
dynamics365_to_bom_component table Maps Dynamics 365 BOM lines (BOMId, ItemId, BOMQty; optional BOMQtySerie, UnitId, LineNum, FromDate, ToDate, BOMType, BOMConsump, ScrapVar, OprNum, DataAreaId) of the BOMs that dynamics365_to_bom_header chooses (same bom_version and reference_date) to the universal bom_component shape. quantity_per = BOMQty / BOMQtySerie (per one parent), lines valid on reference_date only, one row per BOM, child, unit and consumption type (the quantities of a child's lines are added; constant and variable lines stay apart), company the lower-cased DataAreaId. bom_to_items over the two gives one edge per component row (constant and variable lines of a child are two edges; sum them for one) and has no company column: filter one company first. NULL [SELECT * FROM dynamics365_to_bom_component(bom_lines := 'BOM', bom_version := 'BOMVersion');]
dynamics365_to_bom_header table Maps Dynamics 365 BOMVersion (ItemId, BOMId; optional FromDate, ToDate, Active, Approved, DataAreaId) to the universal bom_header shape: one header per company and manufactured item, the version valid on reference_date (YYYY-MM-DD or YYYYMMDD, default 9999-12-31; ToDate empty or 1900-01-01 = open), active first, approved first, newest FromDate, lowest BOMId. bom_id is '/' ('//' with DataAreaId; a backslash or '/' inside a segment gets a backslash in front), source_bom_id the BOMId, company the lower-cased DataAreaId. bom_table (BOMTable, optional) gives plant_id from SiteId. NULL [SELECT * FROM dynamics365_to_bom_header(bom_version := 'BOMVersion', bom_table := 'BOMTable');, SELECT * FROM dynamics365_to_bom_header(bom_version := 'BOMVersion', reference_date := '2024-06-30');]
dynamics365_to_materials table Maps a Dynamics 365 InventTable to the universal materials shape, one row per company and item. Needs ItemId; uses ItemName (or NameAlias), ItemGroupId, ItemType (0 Item, 1 BOM, 2 Service, or the enum names) and DataAreaId (the company column, lower case) when present. Columns not in D365 are typed NULLs. NULL [SELECT * FROM dynamics365_to_materials('InventTable');]
embed_text macro Embeds a single piece of text with the default local backend — shorthand for embedding_backend(description, 'gemma-local', ''). NULL [SELECT embed_text('centrifugal pump seal kit')]
embedding_backend scalar Generates a 384-dimensional text embedding (FLOAT[384] array) for the given text. provider (gemma-local, openai, anthropic or cohere, case-insensitive; anything else is an error) selects the backend. provider_config is accepted but not read yet; do not put API keys in it. NOTE: unless the extension is built with a local OpenVINO model or a real API backend is configured, all providers return a deterministic, hash-based PLACEHOLDER embedding (useful for wiring and tests, not semantic search). NULL [SELECT embedding_backend('diesel pump', 'gemma-local', '{}');, SELECT embedding_backend('valve seat', 'openai', '');]
eval_calibration table Calibration of the predicted coverage (score_col, default 'coverage') against gold true_coverage over the pairs in both tables: n_pairs, mae, bias (predicted - true), pearson, spearman (average ranks for ties); correlations are NULL for a constant input. NULL [SELECT * FROM eval_calibration('results', 'gold');]
eval_ranking table Ranking quality against gold coverage. results: query_id, candidate_id and a rank (rank_col, default 'rank') or a score (score_col, default 'coverage', highest first); gold: query_id, candidate_id, true_coverage. The best candidates of a query are all gold candidates within 1e-9 of its gold best; a ranked candidate without gold counts as 0. Per k (default 1, 5, 10, 20): n_queries, top_k_accuracy (share of queries with a best candidate in the top k, BRD 'recall@k of the best candidate'), recall_at_k (share of each query's best candidates in the top k), mrr (cut at k), mean_regret and share_regret_le_005 of the top pick. NULL [SELECT * FROM eval_ranking('results', 'gold', k := [1, 20]);]
extract_material_descriptions table_macro Extracts material descriptions from a SAP MAKT table for one language ('E' or 'EN', either form matches; default 'E'); clients (mandt) are merged, so filter MAKT to one client first. Returns (material_id, full_text): the description (MAKTX) and the search text (MAKTG) joined by a space, one row per material. NULL [SELECT * FROM extract_material_descriptions(makt_table := 'sap_makt', language := 'E')]
extract_ts_features table_macro The 30 time-series features of the transactional embedding per material, from anofox_forecast's anofox_fcst_ts_features_agg over the weekly series of positive quantities (zero-filled between the first and last week in the window). Returns (material_id, features STRUCT) with stable field names; NaN and infinite values (short histories) are NULL. A material needs min_observations movements. 'batch_size' and 'batch_offset' page through large material sets; NULL batch_size means all of them. Needs anofox_forecast (INSTALL/LOAD anofox_forecast FROM community). NULL [SELECT * FROM extract_ts_features(movements_table := 'goods_movements', time_window_days := 365)]
filter_recent_movements table_macro Filters a goods-movement table to a recent window and a minimum quantity. The window is anchored on the most recent movement date IN THE DATA rather than wall-clock today, which works without the ICU extension, is deterministic for tests, and is what planners want on historical ERP extracts where 'today' may be years after the last movement. NULL [SELECT * FROM filter_recent_movements(movements_table := 'goods_movements', time_window_days := 180)]
find_covering_entities table Ranks the entities of an (entity, feature, weight) table by how well they cover a query entity of the same table: weighted containment Σmin/Σq by default, so a richer candidate is not penalised, with weighted Jaccard as tie-break so the leanest full cover comes first. Returns entity_id, score, containment, jaccard, shared_weight, query_weight, candidate_weight, surplus_weight. Named parameters: mode ('containment' | 'jaccard' | 'tversky'), alpha, beta (Tversky weights, used in mode 'tversky' only), weighted (use the weight column, default true), tie_break (weight of Jaccard added to the score in modes 'containment' and 'tversky', default 0.01), min_score (threshold on the measure itself), feature_table (default 'feature_multiset'), entity_col, feature_col, weight_col (NULL for unit weights). NULL [SELECT * FROM find_covering_entities('P-100', 10);, SELECT * FROM find_covering_entities('F-100', 5, feature_table := 'frame_bom', entity_col := 'frame_no', feature_col := 'part_no', weight_col := 'quantity_per');]
find_covering_entities_for table Like find_covering_entities, for a query that is not in the table: query is a MAP(feature, weight), e.g. the class multiset of a new specification. The argument must be constant (a literal or getvariable(…)). Named parameters: mode ('containment' | 'jaccard' | 'tversky'), alpha, beta (Tversky weights, used in mode 'tversky' only), weighted (use the weight column, default true), tie_break (weight of Jaccard added to the score in modes 'containment' and 'tversky', default 0.01), min_score (threshold on the measure itself), feature_table (default 'feature_multiset'), entity_col, feature_col, weight_col (NULL for unit weights). NULL [SELECT * FROM find_covering_entities_for(MAP {'seat_heating': 2, 'massage': 4}, 10);, SELECT * FROM find_covering_entities_for(getvariable('request'), 20, mode := 'jaccard');]
find_covering_entities_lsh table Sub-linear candidate search over a minhash_index (LSH-Ensemble style). queries_table holds (query_id, feature_id[, weight]) multisets. threshold (default 0.5) is a containment threshold in mode 'containment' (default): per query and size partition it is turned into the Jaccard threshold for the partition's largest set; in mode 'jaccard' it is the Jaccard threshold itself. The rows per band are chosen so that the LSH S-curve passes below it; candidates share a band, so fewer than k rows can come back. threshold sets recall, it does not filter the results. Ranked by the estimate: containment = J (|q| + |c|) / ((1 + J) |q|) (capped at 1) or J (mode 'jaccard'). Returns query_id, entity_id, estimate, jaccard_estimate, rank (top k, default 20) and n_candidates (scored per query). An approximate accelerator: exact find_covering_entities stays the reference. Without bands_table the index's band hashes are unnested on every call (linear in the index size); store minhash_bands(index) once and pass it as bands_table for a hash-join (sub-linear) search. NULL [SELECT * FROM find_covering_entities_lsh('request_multisets', 'programme_index', k := 20);]
find_similar_materials_jaccard table Finds the k most structurally similar materials to a query material using exact Jaccard similarity on BOM component sets. Returns material_id, similarity, shared_components, and total_components. Rows below min_similarity are left out; without it, rows scoring 0 (no shared component) are left out, and min_similarity := 0 keeps them. mode := 'containment' ranks by the share of the query's components each material contains instead (default 'jaccard'). Batch form: find_similar_materials_jaccard(k, materials_table := 'tbl') runs the search for every material_id of the table in one query, k per material, and returns query_id (the material searched for) in front of the same columns. NULL [SELECT * FROM find_similar_materials_jaccard('MAT-001', 10);, SELECT * FROM find_similar_materials_jaccard('MAT-001', 20, min_similarity := 0.3);, SELECT * FROM find_similar_materials_jaccard('MAT-001', 10, mode := 'containment');]
find_similar_materials_jaccard table Finds the k most structurally similar materials to a query material using exact Jaccard similarity on BOM component sets. Returns material_id, similarity, shared_components, and total_components. Rows below min_similarity are left out; without it, rows scoring 0 (no shared component) are left out, and min_similarity := 0 keeps them. mode := 'containment' ranks by the share of the query's components each material contains instead (default 'jaccard'). Batch form: find_similar_materials_jaccard(k, materials_table := 'tbl') runs the search for every material_id of the table in one query, k per material, and returns query_id (the material searched for) in front of the same columns. NULL [SELECT * FROM find_similar_materials_jaccard(5, materials_table := 'new_products');]
find_similar_materials_wl_kernel table Finds the k most structurally similar materials by BOM depth fingerprints (a kernel of the Weisfeiler-Lehman family, not WL relabelling): each component weighted by the number of depths 1..iterations at which it is reachable, compared by weighted Jaccard. It sees multi-level structure beyond direct components, but not quantities or which subassembly a part sits in. iterations is the depth (default 3; exact up to 5). Without min_similarity, rows scoring 0 are left out; min_similarity := 0 keeps them. Batch form: find_similar_materials_wl_kernel(k, materials_table := 'tbl') runs the search for every material_id of the table in one query, k per material, and returns query_id (the material searched for) in front of the same columns. NULL [SELECT * FROM find_similar_materials_wl_kernel('MAT-001', 10);, SELECT * FROM find_similar_materials_wl_kernel('MAT-001', 10, iterations := 3, min_similarity := 0.2);]
find_similar_materials_wl_kernel table Finds the k most structurally similar materials by BOM depth fingerprints (a kernel of the Weisfeiler-Lehman family, not WL relabelling): each component weighted by the number of depths 1..iterations at which it is reachable, compared by weighted Jaccard. It sees multi-level structure beyond direct components, but not quantities or which subassembly a part sits in. iterations is the depth (default 3; exact up to 5). Without min_similarity, rows scoring 0 are left out; min_similarity := 0 keeps them. Batch form: find_similar_materials_wl_kernel(k, materials_table := 'tbl') runs the search for every material_id of the table in one query, k per material, and returns query_id (the material searched for) in front of the same columns. NULL [SELECT * FROM find_similar_materials_wl_kernel(5, materials_table := 'new_products');]
fit_coverage_weights table Fits the kernel weights on reviewed matches: for every grid point of label_weights (lambda, default 0, 0.1, 0.2, 0.3, 0.5) x mus (default 0, 0.1, 0.2, 0.3), the mean absolute error of the kernel's coverage against reviewed_matches (query_id, candidate_id, true_coverage), with n_pairs, n_unresolved (reviewed pairs whose trees are missing) and rank (best first). At most 20 values per axis. The trees and options are given as for tree_coverage. The classifier's attr_bonus and temperature are tuned with classify_to_catalogue and eval_ranking instead. NULL [SELECT * FROM fit_coverage_weights('reviewed_matches', candidate_nodes_table := 'programme_nodes', candidate_attrs_table := 'programme_attributes') LIMIT 3;]
fuse_embeddings scalar Fuses structural (FLOAT[256]), textual (FLOAT[384]) and transactional (FLOAT[128]) embeddings into one FLOAT[768] array by weighted concatenation, each part scaled by sqrt(weight). Weights are normalised to sum to 1; a modality with weight 0 may be NULL. Lists cast to the array types (a list of another length is an error). NULL [SELECT fuse_embeddings(structural_embedding, textual_embedding, transactional_embedding, {'structural':0.5,'textual':0.5,'transactional':0.0}) FROM material_embeddings;]
hnsw_compact_index pragma NULL NULL  
hnsw_index_scan table NULL NULL  
infer_predecessors table Identifies predecessor (superseded) materials for a given successor by combining BOM structural similarity with anti-correlated consumption patterns. Returns predecessor candidates ranked by confidence score along with correlation, similarity, and temporal overlap data. Usage is consumption: first and last usage and the correlated weeks come from weeks with a positive net quantity, so a late return or a reversal alone does not move them. lookback_months bounds how far before the successor's start candidate rows are read (and so predecessor_first_usage). Useful for lifecycle transition planning and inventory run-down. Batch form: infer_predecessors(materials_table := 'tbl') infers them for every material_id of the table in one query and returns query_id (the successor) in front of the same columns. NULL [SELECT * FROM infer_predecessors('NEW-PART');, SELECT * FROM infer_predecessors('NEW-PART', lookback_months := 24, min_similarity := 0.5, min_confidence := 0.6, lag_weeks := 4);]
infer_predecessors table Identifies predecessor (superseded) materials for a given successor by combining BOM structural similarity with anti-correlated consumption patterns. Returns predecessor candidates ranked by confidence score along with correlation, similarity, and temporal overlap data. Usage is consumption: first and last usage and the correlated weeks come from weeks with a positive net quantity, so a late return or a reversal alone does not move them. lookback_months bounds how far before the successor's start candidate rows are read (and so predecessor_first_usage). Useful for lifecycle transition planning and inventory run-down. Batch form: infer_predecessors(materials_table := 'tbl') infers them for every material_id of the table in one query and returns query_id (the successor) in front of the same columns. NULL [SELECT * FROM infer_predecessors(materials_table := 'new_products');]
items_to_bom_component table_macro One universal bom_component row per edge of a flat bom_items edge list, numbered per parent, quantity_per from quantity as DECIMAL(18,6): a NULL quantity counts as 1, a non-zero quantity that rounds to 0 at 6 decimals is an error, and quantities of 1e12 or more do not fit. Store it and items_to_bom_header as tables; bom_to_items over them gives the edges back. items_table needs parent_id, child_id and quantity (for an edge list without one: SELECT *, NULL::DOUBLE AS quantity FROM …). NULL [SELECT * FROM items_to_bom_component(items_table := 'bom_items')]
items_to_bom_header table_macro One universal bom_header row per parent of a flat bom_items edge list (bom_id 'BOM_' || parent_id), tagged with source_system. With items_to_bom_component it is the inverse of bom_to_items. items_table needs parent_id and child_id. NULL [SELECT * FROM items_to_bom_header(items_table := 'bom_items', source_system := 'MIGRATED')]
items_to_materials table_macro The materials of a flat bom_items edge list (every parent and child, once), in the columns and types of the universal materials table, tagged with source_system. items_table needs parent_id and child_id. NULL [SELECT * FROM items_to_materials(items_table := 'bom_items', source_system := 'MIGRATED')]
jaccard_similarity scalar Computes the Jaccard similarity coefficient between two lists treated as sets. Returns a value in [0.0, 1.0] equal to |intersection| / |union|. Duplicates within each list are deduplicated before comparison. Returns NULL if either argument is NULL; returns 0.0 if both lists are empty. NULL [SELECT jaccard_similarity(['A','B','C'], ['B','C','D']); – 0.5, SELECT jaccard_similarity([1,2,3,4], [3,4,5,6]); – 0.3333]
lsh_bands scalar LSH band hashes of a MinHash signature: one hash per band of len(signature) / bands rows. Two multisets with Jaccard J share at least one band with probability 1 - (1 - J^rows)^bands. NULL [SELECT lsh_bands(weighted_minhash(MAP {'a': 1.0}, 64), 16);]
maxsim scalar Late-interaction score (ColBERT-style MaxSim): each query token takes its maximum cosine over the document tokens, and the maxima are averaged. Asymmetric. Token vectors must share one dimension; a zero token has cosine 0. NULL or an empty list gives NULL. NULL [SELECT maxsim([[1.0, 0.0], [0.0, 1.0]], [[1.0, 0.0], [0.6, 0.8]]); – 0.9]
minhash_bands table The band hashes of a minhash_index in long form (entity_id, part, r, j, h, num_hashes, seed): one row per entity, rows per band (1, 2, 4, 8) and band. Store it and pass it to find_covering_entities_lsh as bands_table, so the search joins on the band hash instead of unnesting the index. NULL [CREATE TABLE programme_bands AS SELECT * FROM minhash_bands('programme_index');]
minhash_index table Builds a weighted-MinHash index of a feature multiset (feature_table, default 'feature_multiset'; entity_col/feature_col/weight_col as in find_covering_entities; weight_col := NULL for unit weights, where duplicate rows count once): one row per entity with total_weight, its size partition (partitions quantiles, default 4), signature (num_hashes, a multiple of 8, default 128; seed default 7), band_hashes for 1, 2, 4 and 8 rows per band (concatenated), num_hashes and seed. Store it as a table; find_covering_entities_lsh searches it. NULL [CREATE TABLE programme_index AS SELECT * FROM minhash_index(feature_table := 'programme_class_multiset');]
minhash_similarity scalar Share of equal positions of two MinHash signatures of the same length: the estimate of their (weighted) Jaccard similarity. Takes UBIGINT[] signatures (weighted_minhash) or the FLOAT[n] MinHash jaccard_embedding of compute_jaccard_embeddings (on other embeddings, such as textual or fused ones, the result is meaningless). In a FLOAT[n] array a NULL element counts as unequal; in a UBIGINT[] signature a NULL element is an error (a corrupt signature). NULL [SELECT minhash_similarity([0.1, 0.2, 0.3]::FLOAT[3], [0.1, 0.5, 0.3]::FLOAT[3]); – 0.667]
minhash_similarity scalar Share of equal positions of two MinHash signatures of the same length: the estimate of their (weighted) Jaccard similarity. Takes UBIGINT[] signatures (weighted_minhash) or the FLOAT[n] MinHash jaccard_embedding of compute_jaccard_embeddings (on other embeddings, such as textual or fused ones, the result is meaningless). In a FLOAT[n] array a NULL element counts as unequal; in a UBIGINT[] signature a NULL element is an error (a corrupt signature). NULL [SELECT minhash_similarity(weighted_minhash(MAP {'a': 1.0}, 64), weighted_minhash(MAP {'a': 1.0, 'b': 1.0}, 64)); – about 0.5]
normalize_quantity scalar Converts a value in a unit to the base unit of its dimension: STRUCT(value, unit, dimension). An unknown unit is never guessed: value and unit come back unchanged with dimension NULL. Currencies keep their value (same-currency comparison only). unit is a symbol, an alias or a unit identifier (UN/ECE Rec 20 code such as 'AMP', or a unit_id from unit_table such as an ECLASS unit IRDI, compared with semantic_key). unit_table extends the seed as in parse_quantity; an entry with only symbol and unit_id attaches identifiers to a known unit. NULL [SELECT normalize_quantity(2500, 'mA'); – 2.5 A]
normalize_quantity scalar Converts a value in a unit to the base unit of its dimension: STRUCT(value, unit, dimension). An unknown unit is never guessed: value and unit come back unchanged with dimension NULL. Currencies keep their value (same-currency comparison only). unit is a symbol, an alias or a unit identifier (UN/ECE Rec 20 code such as 'AMP', or a unit_id from unit_table such as an ECLASS unit IRDI, compared with semantic_key). unit_table extends the seed as in parse_quantity; an entry with only symbol and unit_id attaches identifiers to a known unit. NULL [SELECT normalize_quantity(3, 'lanes', (SELECT list(u) FROM my_units u));]
parse_quantity scalar Parses a quantity written in English or German ('max. 38 dB(A)', 'mindestens 24 cm', '6–18 V', 'zwischen 15 und 25 mm/s', '220 N ± 2 %', 'IP54 or better') into STRUCT(lo, hi, unit, dimension, bound, raw, source_unit, category). lo/hi are in the base unit of the dimension (unit); bound is at_least, at_most, within, equals or NULL when the text states none. A nominal with a tolerance ('220 N ± 2 %', '20 kg ± 1 kg') is equals with lo and hi at the ends it allows; a tolerance alone ('± 0,05 mm') is at_most its half-width. lang ('en', 'de' or a list, first entry decides ambiguous separators such as '2.500') defaults to ['en', 'de']. unit_table is a LIST of STRUCT(symbol, alias, unit_id, dimension, factor, offset) that extends or overrides the seed (see quantity_units()). A space between groups of three digits is a thousands separator ('1 000 N'). A bare number is a count; an unknown unit keeps the number and has dimension NULL; with another number after it ('3.1 acc. to EN 10204', '420 x 310 x 180 mm') the result is empty. Pass lang before unit_table (DuckDB 1.5.6 binds by position). NULL [SELECT parse_quantity('2.500 mA', ['de', 'en']);]
parse_quantity scalar Parses a quantity written in English or German ('max. 38 dB(A)', 'mindestens 24 cm', '6–18 V', 'zwischen 15 und 25 mm/s', '220 N ± 2 %', 'IP54 or better') into STRUCT(lo, hi, unit, dimension, bound, raw, source_unit, category). lo/hi are in the base unit of the dimension (unit); bound is at_least, at_most, within, equals or NULL when the text states none. A nominal with a tolerance ('220 N ± 2 %', '20 kg ± 1 kg') is equals with lo and hi at the ends it allows; a tolerance alone ('± 0,05 mm') is at_most its half-width. lang ('en', 'de' or a list, first entry decides ambiguous separators such as '2.500') defaults to ['en', 'de']. unit_table is a LIST of STRUCT(symbol, alias, unit_id, dimension, factor, offset) that extends or overrides the seed (see quantity_units()). A space between groups of three digits is a thousands separator ('1 000 N'). A bare number is a count; an unknown unit keeps the number and has dimension NULL; with another number after it ('3.1 acc. to EN 10204', '420 x 310 x 180 mm') the result is empty. Pass lang before unit_table (DuckDB 1.5.6 binds by position). NULL [SELECT parse_quantity('3 Stk.', 'de', (SELECT list(u) FROM my_units u));]
parse_quantity scalar Parses a quantity written in English or German ('max. 38 dB(A)', 'mindestens 24 cm', '6–18 V', 'zwischen 15 und 25 mm/s', '220 N ± 2 %', 'IP54 or better') into STRUCT(lo, hi, unit, dimension, bound, raw, source_unit, category). lo/hi are in the base unit of the dimension (unit); bound is at_least, at_most, within, equals or NULL when the text states none. A nominal with a tolerance ('220 N ± 2 %', '20 kg ± 1 kg') is equals with lo and hi at the ends it allows; a tolerance alone ('± 0,05 mm') is at_most its half-width. lang ('en', 'de' or a list, first entry decides ambiguous separators such as '2.500') defaults to ['en', 'de']. unit_table is a LIST of STRUCT(symbol, alias, unit_id, dimension, factor, offset) that extends or overrides the seed (see quantity_units()). A space between groups of three digits is a thousands separator ('1 000 N'). A bare number is a count; an unknown unit keeps the number and has dimension NULL; with another number after it ('3.1 acc. to EN 10204', '420 x 310 x 180 mm') the result is empty. Pass lang before unit_table (DuckDB 1.5.6 binds by position). NULL [SELECT parse_quantity('3 Stk.', ['de'], (SELECT list(u) FROM my_units u));]
parse_quantity scalar Parses a quantity written in English or German ('max. 38 dB(A)', 'mindestens 24 cm', '6–18 V', 'zwischen 15 und 25 mm/s', '220 N ± 2 %', 'IP54 or better') into STRUCT(lo, hi, unit, dimension, bound, raw, source_unit, category). lo/hi are in the base unit of the dimension (unit); bound is at_least, at_most, within, equals or NULL when the text states none. A nominal with a tolerance ('220 N ± 2 %', '20 kg ± 1 kg') is equals with lo and hi at the ends it allows; a tolerance alone ('± 0,05 mm') is at_most its half-width. lang ('en', 'de' or a list, first entry decides ambiguous separators such as '2.500') defaults to ['en', 'de']. unit_table is a LIST of STRUCT(symbol, alias, unit_id, dimension, factor, offset) that extends or overrides the seed (see quantity_units()). A space between groups of three digits is a thousands separator ('1 000 N'). A bare number is a count; an unknown unit keeps the number and has dimension NULL; with another number after it ('3.1 acc. to EN 10204', '420 x 310 x 180 mm') the result is empty. Pass lang before unit_table (DuckDB 1.5.6 binds by position). NULL [SELECT parse_quantity('65.000 Zyklen', 'de');]
parse_quantity scalar Parses a quantity written in English or German ('max. 38 dB(A)', 'mindestens 24 cm', '6–18 V', 'zwischen 15 und 25 mm/s', '220 N ± 2 %', 'IP54 or better') into STRUCT(lo, hi, unit, dimension, bound, raw, source_unit, category). lo/hi are in the base unit of the dimension (unit); bound is at_least, at_most, within, equals or NULL when the text states none. A nominal with a tolerance ('220 N ± 2 %', '20 kg ± 1 kg') is equals with lo and hi at the ends it allows; a tolerance alone ('± 0,05 mm') is at_most its half-width. lang ('en', 'de' or a list, first entry decides ambiguous separators such as '2.500') defaults to ['en', 'de']. unit_table is a LIST of STRUCT(symbol, alias, unit_id, dimension, factor, offset) that extends or overrides the seed (see quantity_units()). A space between groups of three digits is a thousands separator ('1 000 N'). A bare number is a count; an unknown unit keeps the number and has dimension NULL; with another number after it ('3.1 acc. to EN 10204', '420 x 310 x 180 mm') the result is empty. Pass lang before unit_table (DuckDB 1.5.6 binds by position). NULL [SELECT parse_quantity('max. 38 dB(A)');]
pragma_hnsw_index_info table NULL NULL  
quantity_units table The built-in, read-only units seed of the quantity layer: symbol, alias (list), unit_id (UN/ECE Rec 20 codes; no ECLASS content), dimension, factor, offset (base = value * factor + offset) and base_unit. Currencies have factor NULL and are never converted. Copy it into a table to extend it and pass (SELECT list(u) FROM my_units u) as unit_table. NULL [SELECT * FROM quantity_units() WHERE dimension = 'length';, CREATE TABLE my_units AS SELECT symbol, alias, unit_id, dimension, factor, "offset" FROM quantity_units();]
recompute_embedding_statistics table_macro Recomputes the statistics compute_transactional_embeddings normalises with: one row per feature it reads (positions 0-29 from extract_ts_features, 92-97 from compute_domain_specific_statistics), mean and standard deviation over the finite values. Store them: INSERT OR REPLACE INTO transactional_embedding_statistics SELECT *, now(), 1 FROM recompute_embedding_statistics(). 'time_window_days' is the historical window and 'min_observations' the minimum movements a material needs. Needs anofox_forecast. NULL [SELECT * FROM recompute_embedding_statistics(time_window_days := 365, min_observations := 3)]
sap_to_bom_items table Converts SAP MAST/STKO/STPO (and optionally STAS) into flat BOM edges (bom_id, parent_id, child_id, qty, unit, valid_from, valid_to, bom_version, client). Needs MAST matnr, stlnr; STKO stlnr, stlal; STPO stlnr, idnrk, menge, meins. Each further SAP column is used when the table has it: stlty keeps material BOMs (M) only; MAST.stlal must equal bom_alternative (default '01', also matched on STKO.stlal); datuv picks the STKO header and, per STPO item node stlkn, the item version valid on reference_date (YYYYMMDD or a date, default 9999-12-31), stkoz / stpoz breaking ties; a header version with lkenz or loekz set and an item version with lkenz set are dropped. bom_usage filters MAST.stlan. stas_table := 'STAS' applies the item selection: an item is kept only when its newest STAS row for the alternative on reference_date exists and is not deleted (lkenz). With stlty on STKO, STPO (and STAS) need it too; with mandt in every table, clients are kept apart. Each (parent_id, child_id) edge comes once: without bom_usage every usage and BOM number of a material is read, and an edge is taken from the lowest usage, then the lowest BOM number, per SAP client (the client column is MANDT when every table has it, else NULL; filter one client before searching, the searches do not see it), with the quantities of that BOM's positions of the child added per unit (pass bom_usage, e.g. '1' for production, to compare one usage). qty is the sum of MENGE (a DECIMAL MENGE becomes DECIMAL(38, scale)). NULL [SELECT * FROM sap_to_bom_items('MAST', 'STKO', 'STPO');, SELECT * FROM sap_to_bom_items('MAST', 'STKO', 'STPO', stas_table := 'STAS', reference_date := '2024-01-01', bom_usage := '1');]
sap_to_materials table_macro Extracts materials from a SAP MARA table into the universal materials shape. Requires MARA columns matnr, mtart, matkl, ersda and lvorm; rows flagged deleted via lvorm are excluded. The last column, client, is MARA's mandt (NULL without it), so a multi-client extract keeps one row per client and material. The description column is always empty here – use sap_to_materials_with_desc to populate it from MAKT; the makt_table and language parameters are accepted for compatibility and ignored. NULL [SELECT * FROM sap_to_materials('MARA')]
sap_to_materials_with_desc table_macro Like sap_to_materials, but joins MAKT to populate the description column in the requested 'language': SAP's one-character key ('E', 'D') or the two-letter ISO code ('EN', 'DE'); MAKT rows in either form match. With mandt in MAKT, each client gets its own client's text. NULL [SELECT * FROM sap_to_materials_with_desc('MARA', 'MAKT', language := 'E')]
semantic_key scalar Canonical join key for an AAS semanticId. An ECLASS or IEC CDD IRDI ('0173-1#02-AAC895#008', '0112/2///61360_4#AAA001#001') and the ECLASS IRI form ('https://api.eclass-cdp.com/0173-1-02-AAC895-008') give the same key: the upper-cased IRDI without its version suffix. keep_version (default false) keeps the version; use it when a dictionary release changed the meaning of a property. Other URIs pass through with scheme and host lower-cased, any other text is only trimmed, and NULL or a blank give NULL (no key). NULL [SELECT semantic_key('0173-1#02-AAC895#008', true); – 0173-1#02-AAC895#008]
semantic_key scalar Canonical join key for an AAS semanticId. An ECLASS or IEC CDD IRDI ('0173-1#02-AAC895#008', '0112/2///61360_4#AAA001#001') and the ECLASS IRI form ('https://api.eclass-cdp.com/0173-1-02-AAC895-008') give the same key: the upper-cased IRDI without its version suffix. keep_version (default false) keeps the version; use it when a dictionary release changed the meaning of a property. Other URIs pass through with scheme and host lower-cased, any other text is only trimmed, and NULL or a blank give NULL (no key). NULL [SELECT semantic_key('https://api.eclass-cdp.com/0173-1-02-AAC895-008'); – 0173-1#02-AAC895]
suggest_semantic_id table Suggests dictionary ids (ECLASS or your own catalogue) for uncoded attribute names or capability labels, as a review queue in the shape of vocabulary_review_queue: wording, source, n_occurrences, n_trees_affected, top1, p1, top2, p2, margin, similarity (the raw maxsim or cosine of top1: an absolute fit, since p is relative to the dictionary and the best of poor candidates looks certain), fits (similarity >= min_similarity, NULL without one) and impact = n_trees_affected x (1 - margin), or n_trees_affected when fits is false, highest impact first. It runs classify_to_catalogue: items_table (node_id, vec[, tree_id, source, label, tokens]; the wording is label, else node_id) against dictionary_table (class_id = the dictionary id, vec[, exemplar_tokens]). mode 'late_interaction' (default; maxsim of the wording's tokens over example phrasings, the strongest signal) or 'centroid'; temperature default 0.1; center_by_source default false. Wordings in overrides_table (wording[, source], class_id) are reviewed and leave the queue. Confirm suggestions with apply_vocabulary_review and use the result as attr_key or as overrides_table. No dictionary content ships with the extension: bring your own vectors. NULL [SELECT wording, top1, p1, margin FROM suggest_semantic_id('uncoded_names', 'eclass_examples') LIMIT 20;]
threshold_at_precision table The auto-accept threshold: over the top-1 picks, the lowest score threshold whose precision (share of picks with true coverage >= good, default 0.9) reaches target_precision (default 0.95; 'target' is a reserved word). Returns threshold (NULL when unreachable), precision, accepted_share, n_queries and the precision curve (threshold, precision, share). NULL [SELECT threshold, precision, accepted_share FROM threshold_at_precision('results', 'gold', target_precision := 0.95);]
tree_anchors table Flattens property trees: one row per item node (containers are transparent) with its resolved class, depth, anchor_path (ancestor ids from the root), variant_path (the nodes with an OR edge on the way, i.e. the alternatives chosen), effective_count (product of the counts along the path) and n_attributes. Works at any depth. NULL [SELECT * FROM tree_anchors('tree_nodes', 'tree_attributes');, SELECT * FROM tree_anchors('tree_nodes', tree_ids := ['M1']);]
tree_class_multiset table The class multiset per tree for stage-1 recall: entity_id (tree), feature_id (class), weight (summed counts, maximum across OR alternatives), reviewed (every item's class came from class_id or the reviewed vocabulary). Classes resolve in the order class_id, overrides_table (wording, source, class_id), label_table (classifier arg-max). NULL [SELECT * FROM tree_class_multiset('tree_nodes');, SELECT * FROM tree_class_multiset('tree_nodes', overrides_table := 'vocabulary_overrides');]
tree_coverage table Stage-2 coverage: ranks candidate trees by the share of the request they cover. Per request item q and candidate item c: score = label_weightL + (1-label_weight)La, with L the label agreement (Bhattacharyya of soft labels, or 0/1) and a the mean over q's attributes of the best (muname_sim + 1-mu)*value_satisfies (mu counts only for name-vector agreement; without name_vectors names pick the value but do not discount it); counts are summed over compatible items (never across OR alternatives). alternatives 'joint' (default) holds the request to one alternative per candidate OR group (one configuration), 'per_requirement' lets each requirement pick its own. class_hierarchy (class_id, parent_class_id) makes a subclass offer meet a superclass requirement; generalization_credit c gives a superclass offer c^distance. assignment 'partition' gives each candidate item one requirement block (no substitution), 'best_match' lets requirements share, 'auto' uses partition when both the query and the candidate trees are reviewed. Returns query_id, candidate_id, coverage, stage1_score, rank_score (coverage + stage1_weight x stage1_score), rank, n_requirements, n_gaps, reviewed, assignment_used. default_bounds := 'catalogue' gives unqualified values the bound of their template (templates_table); a template row with bound_policy 'override' also replaces a stated at_least/at_most on one value (a drawing's 'max. 38 kg' describes the part, the class says what the supplier must meet); ranges, ± values and categories keep theirs, 'fill' or NULL only fills. tol and soft_band (default 0.02, 0.05) are passed to value_satisfies; use 0 and 0 for hard limits. query_tree_id is a tree id or a LIST of ids. Trees come from nodes_table/attrs_table (default 'tree_nodes'/'tree_attributes'); candidates from candidate_nodes_table/candidate_attrs_table (default: the same tables). Naming a nodes table without its attributes table is an error (pass NULL for none). Classes resolve class_id -> overrides_table (reviewed vocabulary) -> label_table (classifier). Stage 1 ranks candidates by containment (+ tie_break x jaccard) when every candidate tree is reviewed, else by weighted jaccard (mode 'auto'). candidate_multiset_table: a precomputed index of the candidate class multisets (tree_class_multiset output: entity_id, feature_id, weight[, reviewed]) makes stage 1 skip resolving every candidate tree. NULL [SELECT * FROM tree_coverage('R01', k := 20, candidate_nodes_table := 'programme_nodes', candidate_attrs_table := 'programme_attributes');, SELECT * FROM tree_coverage(['R01', 'R02'], candidates := ['P001', 'P002']);]
tree_coverage_trace table The explanation of tree_coverage: one row per request item and required attribute with the matched candidate item and path, label_sim, req_value, prov_value, gate, name_sim, value_score, distance, rule, attr_score, count_needed, count_available, req_score, is_gap (no counterpart, a count shortfall or a value below 1), name_rule (how the names were compared: key when both attributes carry the same attr_key, vector, exact or tokens), bound_source (where the requirement's bound came from: explicit, text, range, level_type, constraint, template, or template_override when bound_policy 'override' replaced a stated bound) and label_rule (exact, soft, specialized: a subclass was offered, generalized: a superclass was offered, see class_hierarchy). rule is the value rule; gate for a dimension or unit mismatch; missing when the offer states the property without a value; key_mismatch when both attributes carry different attr_keys. Same parameters as tree_coverage. query_tree_id is a tree id or a LIST of ids. Trees come from nodes_table/attrs_table (default 'tree_nodes'/'tree_attributes'); candidates from candidate_nodes_table/candidate_attrs_table (default: the same tables). Naming a nodes table without its attributes table is an error (pass NULL for none). Classes resolve class_id -> overrides_table (reviewed vocabulary) -> label_table (classifier). Stage 1 ranks candidates by containment (+ tie_break x jaccard) when every candidate tree is reviewed, else by weighted jaccard (mode 'auto'). candidate_multiset_table: a precomputed index of the candidate class multisets (tree_class_multiset output: entity_id, feature_id, weight[, reviewed]) makes stage 1 skip resolving every candidate tree. NULL [SELECT * FROM tree_coverage_trace('R01', candidates := ['P001'])
WHERE is_gap AND (value_score IS DISTINCT FROM 1 OR count_available < count_needed);]
tree_from_json scalar Turns a tree from upstream extraction (JSON: {tree_id, source, lang, root: {node_id, kind, edge, label, context, class_id, count, attributes: [{attr_id, name, text, lo, hi, unit, bound, category}], children: […]}}) into a LIST of node STRUCTs with normalised attributes (base units, dimension; text-only values are parsed with parse_quantity in the document's lang, or lang if given; unit_table extends the units seed as in parse_quantity). Attribute STRUCTs carry tree_id and node_id. Unnest it into tree_nodes and tree_attributes. A non-positive count, or a key close to a known one (childs, txt), is an error naming the node; other keys are ignored. Schema: docs/requirements-matching/tree.schema.json. NULL [SELECT unnest(n) FROM (SELECT unnest(tree_from_json(content)) AS n FROM read_text('requests/*.json'));]
tree_multiset scalar The class multiset of one tree given as a LIST of STRUCT(node_id, parent_id, node_kind, edge_type, class_id, count): counts multiply down the tree, add across AND siblings and take the elementwise maximum across OR alternatives. The building block of tree_class_multiset. NULL [SELECT tree_multiset(list(struct_pack(node_id, parent_id, node_kind, edge_type, class_id, count))) FROM tree_nodes GROUP BY tree_id;]
trees_to_aas scalar Writes property trees as an AAS v3 Environment (Part 1 JSON): one shell per tree_id, the level below the root as submodels, collections below. nodes is a LIST of node STRUCTs as aas_to_trees and tree_from_json produce them. Items whose attributes carry a role (required, provided) become IDTA-02020 CapabilityContainers (Required / Offered, class as supplementalSemanticId, properties as PropertyRange / PropertyProperty); other items SubmodelElementCollections with their Property / Range elements. Bounds become ranges (at_least: min only, at_most: max only), equals a levelType nom (a Range with nom for a nominal with a tolerance); variant groups and counts use the DataZoo AAS profile; ComposedOf parts are written next to their composite with CapabilityComposedOf relations. Every attr_key becomes a ConceptDescription (IEC 61360 name and unit); catalogue (LIST of STRUCT(class_id, label, definition)) adds class entries. A tree read from AAS reads back the same: aas_to_trees(trees_to_aas(t)). NULL [SELECT trees_to_aas(aas_to_trees(content)) FROM read_text('offer.aas.json');]
trees_to_aas scalar Writes property trees as an AAS v3 Environment (Part 1 JSON): one shell per tree_id, the level below the root as submodels, collections below. nodes is a LIST of node STRUCTs as aas_to_trees and tree_from_json produce them. Items whose attributes carry a role (required, provided) become IDTA-02020 CapabilityContainers (Required / Offered, class as supplementalSemanticId, properties as PropertyRange / PropertyProperty); other items SubmodelElementCollections with their Property / Range elements. Bounds become ranges (at_least: min only, at_most: max only), equals a levelType nom (a Range with nom for a nominal with a tolerance); variant groups and counts use the DataZoo AAS profile; ComposedOf parts are written next to their composite with CapabilityComposedOf relations. Every attr_key becomes a ConceptDescription (IEC 61360 name and unit); catalogue (LIST of STRUCT(class_id, label, definition)) adds class entries. A tree read from AAS reads back the same: aas_to_trees(trees_to_aas(t)). NULL [SELECT trees_to_aas(aas_to_trees(content), (SELECT list(c) FROM catalogue c)) FROM read_text('offer.aas.json');]
tversky_similarity scalar Asymmetric Tversky similarity of two lists treated as sets: |q∩c| / (|q∩c| + alpha|q\c| + beta|c\q|). alpha = beta = 1 is Jaccard, alpha = 1 and beta = 0 is containment. Pass both alpha and beta, alpha first: DuckDB 1.5.6 binds scalar named arguments by position, so (…, beta := x, alpha := y) silently swaps them there. NULL in gives NULL; two empty lists give 0.0. NULL [SELECT tversky_similarity(['a','b','c'], ['b','c','d']); – 0.5]
tversky_similarity scalar Asymmetric Tversky similarity of two lists treated as sets: |q∩c| / (|q∩c| + alpha|q\c| + beta|c\q|). alpha = beta = 1 is Jaccard, alpha = 1 and beta = 0 is containment. Pass both alpha and beta, alpha first: DuckDB 1.5.6 binds scalar named arguments by position, so (…, beta := x, alpha := y) silently swaps them there. NULL in gives NULL; two empty lists give 0.0. NULL [SELECT tversky_similarity(['a','b'], ['a','b','c','d'], 1.0, 0.25); – 0.8]
uncertain_decisions table The external re-rank hook: the low-margin items of a classify_to_catalogue result (margin < threshold, default 0.2, or the lowest-margin share of the items), overridden items excluded, lowest margin first. All parameters are named. request is JSON text for an LLM or a human: tree_id, node_id, text (texts_table: [tree_id,] node_id, text; tree_id is required when the decisions carry tree ids), margin and the top candidates with p, label and definition (catalogue_table: class_id[, label_en|label, definition]). Write the answers back as an answers_table for classify_to_catalogue, or as vocabulary_overrides per wording. NULL [SELECT request FROM uncertain_decisions(decisions := 'decided', share := 0.15, texts_table := 'texts', catalogue_table := 'catalogue_classes');]
validate_trees table Checks property trees and returns one row per issue (tree_id, node_id, attr_id, issue, severity, detail). Errors: duplicate_node, null_key, bad_node_kind, bad_edge_type, bad_count, orphan, no_root, multiple_roots, cycle, and with an attribute table duplicate_attribute, attribute_on_container, orphan_attribute, bad_interval, bad_bound. Warnings: mixed_edge_types, unknown_unit, category_without_dimension (not for attributes with an attr_key: the key identifies the property), mixed_roles (required and provided attributes in one tree; role is informational), mixed_dimensions (one attribute name with several dimensions within a source), magnitude_outlier (a value about 1000 x or 1/1000 of more than half of the other values of the same attr_key, else name, and dimension; currencies only within one currency: a unit slip). The details name the fix. NULL [SELECT * FROM validate_trees('tree_nodes', 'tree_attributes');]
value_satisfies scalar Direction-aware comparison of a requirement with a provided value (both STRUCTs with lo, hi, dimension; the requirement also bound, either may carry unit). Returns STRUCT(score, distance, rule). at_least uses the high end of a provided range, at_most the low end, within the share of the required range covered, equals the relative difference (with lo < hi, as parsed from a tolerance, how far the offer lies outside the span); an unqualified value is a point widened by ±0.01 decades unless default_bound gives it a direction. score is 1 within tol (decades on log scale, relative on linear scale), falling to 0 across soft_band; distance is relative (absolute in K for temperature, which uses a 1 K tolerance and 2.5 K band). Different dimensions, or different currencies, give rule 'gate' and score 0. scale defaults per dimension (linear for time, currency, percent, sound level). Pass the options in order: scale, tol, soft_band, default_bound. NULL [SELECT value_satisfies(parse_quantity('24 cm'), parse_quantity('26 cm'), NULL, 0.02, 0.05, 'at_least');]
value_satisfies scalar Direction-aware comparison of a requirement with a provided value (both STRUCTs with lo, hi, dimension; the requirement also bound, either may carry unit). Returns STRUCT(score, distance, rule). at_least uses the high end of a provided range, at_most the low end, within the share of the required range covered, equals the relative difference (with lo < hi, as parsed from a tolerance, how far the offer lies outside the span); an unqualified value is a point widened by ±0.01 decades unless default_bound gives it a direction. score is 1 within tol (decades on log scale, relative on linear scale), falling to 0 across soft_band; distance is relative (absolute in K for temperature, which uses a 1 K tolerance and 2.5 K band). Different dimensions, or different currencies, give rule 'gate' and score 0. scale defaults per dimension (linear for time, currency, percent, sound level). Pass the options in order: scale, tol, soft_band, default_bound. NULL [SELECT value_satisfies(parse_quantity('at least 24 cm'), parse_quantity('0.235 m'), 'linear');]
value_satisfies scalar Direction-aware comparison of a requirement with a provided value (both STRUCTs with lo, hi, dimension; the requirement also bound, either may carry unit). Returns STRUCT(score, distance, rule). at_least uses the high end of a provided range, at_most the low end, within the share of the required range covered, equals the relative difference (with lo < hi, as parsed from a tolerance, how far the offer lies outside the span); an unqualified value is a point widened by ±0.01 decades unless default_bound gives it a direction. score is 1 within tol (decades on log scale, relative on linear scale), falling to 0 across soft_band; distance is relative (absolute in K for temperature, which uses a 1 K tolerance and 2.5 K band). Different dimensions, or different currencies, give rule 'gate' and score 0. scale defaults per dimension (linear for time, currency, percent, sound level). Pass the options in order: scale, tol, soft_band, default_bound. NULL [SELECT value_satisfies(parse_quantity('at least 24 cm'), parse_quantity('23 cm'), NULL, 0.05, 0.1);]
value_satisfies scalar Direction-aware comparison of a requirement with a provided value (both STRUCTs with lo, hi, dimension; the requirement also bound, either may carry unit). Returns STRUCT(score, distance, rule). at_least uses the high end of a provided range, at_most the low end, within the share of the required range covered, equals the relative difference (with lo < hi, as parsed from a tolerance, how far the offer lies outside the span); an unqualified value is a point widened by ±0.01 decades unless default_bound gives it a direction. score is 1 within tol (decades on log scale, relative on linear scale), falling to 0 across soft_band; distance is relative (absolute in K for temperature, which uses a 1 K tolerance and 2.5 K band). Different dimensions, or different currencies, give rule 'gate' and score 0. scale defaults per dimension (linear for time, currency, percent, sound level). Pass the options in order: scale, tol, soft_band, default_bound. NULL [SELECT value_satisfies(parse_quantity('max. 38 dB(A)'), parse_quantity('35 dB(A)'));]
vocabulary_review_queue table The vocabulary review queue: one row per distinct wording and source of the item nodes in trees_table (default 'tree_nodes'), with n_occurrences, n_trees_affected, the classifier's top1/p1 and top2/p2, margin and impact = n_trees_affected x (1 - margin), highest impact first. decisions is a classify_to_catalogue result: per wording (tree_id NULL, node_id = wording) or per node (averaged over the wording's occurrences). Wordings in overrides_table are reviewed and leave the queue; sources restricts the document families. NULL [SELECT * FROM vocabulary_review_queue(trees_table := 'programme_nodes', decisions := 'wording_decisions', overrides_table := 'vocabulary_overrides') LIMIT 10;]
vss_join table_macro NULL NULL  
vss_match table_macro NULL NULL  
weighted_containment scalar Share of a MAP(key, weight) query multiset covered by the candidate: Σ min(q_k, c_k) / Σ q_k. Counts matter: 4 requested zones are half covered by 2. Weights must be non-negative; a NULL weight counts as 1. An empty query gives NULL. NULL [SELECT weighted_containment(MAP {'a': 3, 'b': 1}, MAP {'a': 2, 'b': 5}); – 0.75]
weighted_jaccard scalar Weighted Jaccard similarity of two MAP(key, weight) multisets: Σ min(q_k, c_k) / Σ max(q_k, c_k). Weights must be non-negative; a NULL weight counts as 1. Two empty maps give 0.0. NULL [SELECT weighted_jaccard(MAP {'heating': 2, 'massage': 4}, MAP {'heating': 4, 'ventilation': 2}); – 0.2]
weighted_minhash scalar Weighted MinHash signature of a MAP(key, weight) multiset by improved consistent weighted sampling (ICWS, Ioffe 2010): the share of equal positions of two signatures estimates their weighted Jaccard. num_hashes positions (1..4096), seeded (default 7); hashing is our own (FNV-1a, SplitMix64), independent of DuckDB's hash. A NULL weight counts as 1, zero weights are absent, negative weights are an error; NULL or an empty multiset gives NULL. NULL [SELECT weighted_minhash(MAP {'a': 1.0, 'b': 2.0}, 128);]
weighted_minhash scalar Weighted MinHash signature of a MAP(key, weight) multiset by improved consistent weighted sampling (ICWS, Ioffe 2010): the share of equal positions of two signatures estimates their weighted Jaccard. num_hashes positions (1..4096), seeded (default 7); hashing is our own (FNV-1a, SplitMix64), independent of DuckDB's hash. A NULL weight counts as 1, zero weights are absent, negative weights are an error; NULL or an empty multiset gives NULL. NULL [SELECT weighted_minhash(MAP {'a': 1.0, 'b': 2.0}, 128, 7);]
weighted_tversky scalar Weighted Tversky similarity of two MAP(key, weight) multisets: Σmin / (Σmin + alphaΣ(q-c)+ + betaΣ(c-q)+). alpha = beta = 1 (the two-argument default) is weighted Jaccard, alpha = 1 and beta = 0 is weighted containment. Pass both alpha and beta, alpha first: DuckDB 1.5.6 binds scalar named arguments by position, so (…, beta := x, alpha := y) silently swaps them there. NULL [SELECT weighted_tversky(MAP {'a': 3, 'b': 1}, MAP {'a': 2, 'c': 2}); – 0.3333]
weighted_tversky scalar Weighted Tversky similarity of two MAP(key, weight) multisets: Σmin / (Σmin + alphaΣ(q-c)+ + betaΣ(c-q)+). alpha = beta = 1 (the two-argument default) is weighted Jaccard, alpha = 1 and beta = 0 is weighted containment. Pass both alpha and beta, alpha first: DuckDB 1.5.6 binds scalar named arguments by position, so (…, beta := x, alpha := y) silently swaps them there. NULL [SELECT weighted_tversky(MAP {'a': 3, 'b': 1}, MAP {'a': 2, 'c': 2}, 0.5, 0.5); – 0.5]
wl_fingerprint table_macro Depth-expanded component fingerprint of one material, as component -> number of distinct depths at which it is reachable. Written as a non-recursive bounded expansion on purpose: DuckDB cannot decorrelate a recursive CTE inside a correlated scalar subquery, which is exactly how wl_kernel_similarity uses it. Iterations 1-5 are exact; higher values are capped at depth 5. NULL [SELECT * FROM wl_fingerprint('PUMP-A', 3, 'bom_items')]
wl_kernel_similarity macro BOM structure similarity of two materials: weighted Jaccard of their depth fingerprints (wl_fingerprint: component -> number of depths at which it is reachable), a kernel of the Weisfeiler-Lehman family, not WL relabelling. Does not see quantities or which subassembly a part sits in. Returns a score in [0, 1]; 1 means the same components at the same depths. Iterations 1-5 are exact; higher values are capped at depth 5. NULL [SELECT wl_kernel_similarity('PUMP-A', 'PUMP-B')]

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

name description input_type scope aliases typed_value
anofox_telemetry_enabled Enable or disable anonymous usage telemetry BOOLEAN GLOBAL [] true
anofox_telemetry_key PostHog API key for telemetry VARCHAR GLOBAL []  
datazoo_banner Show the DataZoo feedback banner when an extension is loaded in an interactive terminal (at most once a day per extension). BOOLEAN GLOBAL [] true
hnsw_ef_search experimental: override the ef_search parameter when scanning HNSW indexes BIGINT GLOBAL [] NULL
hnsw_enable_experimental_persistence experimental: enable creating HNSW indexes in persistent databases BOOLEAN GLOBAL [] false
hnsw_prefilter experimental: apply static table filters before searching HNSW indexes BOOLEAN GLOBAL [] true
temp_directory Set the directory to which temporary files are written. VARCHAR GLOBAL [] post.db.tmp
© 2026 DuckDB Foundation, Amsterdam NL
DuckDB Home Code of Conduct Trademark Use Blog