External Columns

EXTERNAL_COLUMNS() is the simplest way to map FeatureQL features to columns in existing database tables. It provides a declarative, SQL-like syntax for connecting features to external data sources without writing raw SQL queries.

Understanding EXTERNAL_COLUMNS()

The EXTERNAL_COLUMNS() function bridges FeatureQL features with external tables through a column specification:

SELECT
    source := EXTERNAL_COLUMNS(
        column1 ⟨datatype⟩ BOUND TO ⟨input_feature⟩,   -- Key column linked to input
        column2 ⟨datatype⟩,                             -- Regular column
        column3 ⟨datatype⟩,                             -- Additional columns
        FROM ⟨table_name⟩
    ),
    feature1 := source[column2],        -- Map column to feature
    feature2 := source[column3] + 1     -- Use in expressions
;
sql

Parameters explained:

  • column: Column name from the external table
  • datatype: FeatureQL type specification (e.g., BIGINT, VARCHAR, DECIMAL(10,2))
  • BOUND TO: Links a key column to an input feature for join semantics
  • FROM table_name: The source table in your data warehouse

Key principles:

  • Type safety: All columns must be explicitly typed
  • Entity linking: Use entity annotations (BIGINT#ENTITY) to maintain semantic relationships
  • Result cardinality: Must return 0 or 1 row per unique input combination

Example

See the datasets section for more examples.

Last update at: 2025/12/05 16:03:14
Last updated: 2025-12-05 16:07:55