EXTERNAL_COLUMNS()
All functions > SOURCE > EXTERNAL_COLUMNS()
Mapping of source columns to features.
Signatures
Returns: Row of data from table source
EXTERNAL_COLUMNS(source_columns: ARRAY<FEATURE>, aliases: ARRAY<FEATURE>, types: ARRAY<TYPE>, bound_columns: ARRAY<FEATURE>, bound_features: ARRAY<FEATURE>, source_type: VARCHAR, source_content: VARCHAR, [on_condition: VARCHAR]) → ROW sql
| Parameter | Type | Required | Description |
|---|---|---|---|
source_columns | ARRAY<FEATURE> | Yes | Array of source column names dynamic array |
aliases | ARRAY<FEATURE> | Yes | Array of alias names dynamic array |
types | ARRAY<TYPE> | Yes | Array of types dynamic array |
bound_columns | ARRAY<FEATURE> | Yes | Array of bound column names dynamic array |
bound_features | ARRAY<FEATURE> | Yes | Array of bound feature names dynamic array |
source_type | VARCHAR | Yes | Source type: TABLE, SQL, CSV, TSV, JSON |
source_content | VARCHAR | Yes | Source content: table name, SQL query, CSV text, TSV text, JSON text |
on_condition | VARCHAR | No | Optional predicate over declared columns and compile-time constants, stored as formula text |
Examples
CSV mapping with INLINE_COLUMNS (rewrites to EXTERNAL_COLUMNS)
FeatureQL
DEFINE
orders := ENTITY(),
order_id := INPUT(BIGINT#orders),
fct := INLINE_COLUMNS(
order_id BIGINT#orders BIND TO order_id,
amount DOUBLE
FROM CSV(
order_id,amount
10,99.9
11,50.0
)
),
order_fk := fct[order_id]
RETURN
order_id,
order_fk
FOR
order_id := BIND_VALUES(ARRAY(10, 11))
;Result
| ORDER_ID BIGINT#ORDERS | ORDER_FK BIGINT#ORDERS |
|---|---|
| 10 | 10 |
| 11 | 11 |
EXTERNAL_COLUMNS inside VARIANT (FROM SQL subquery)
FeatureQL
DEFINE
id := INPUT(VARCHAR),
expr := INPUT(BIGINT),
power := INPUT(BIGINT),
operation := POW(expr, power)
RETURN
expr2 := 2,
result1 := VARIANT(
operation REPLACING expr, power WITH 2, INLINE_COLUMNS(
id VARCHAR BIND TO id,
val BIGINT
FROM CSV(
id,val
a,1
b,1
)
)[val]
)
FOR
id := BIND_VALUES(ARRAY('a', 'b'))
;Result
| EXPR2 BIGINT | RESULT1 BIGINT |
|---|---|
| 2 | 2 |
| 2 | 2 |