CREATE FEATURES

CREATE FEATURES persists the feature definitions produced by a FeatureQL query. The singular form persists one expression.

Create a feature set

CREATE [OR REPLACE] [TEMPORARY] FEATURES
    [IN namespace]
AS query

CREATE [OR REPLACE] [TEMPORARY] FEATURES
    [IN namespace]
AS (query)

The output clause of this statement is PERSIST, not RETURN. PERSIST names the features that outlive the statement. Definitions in DEFINE are stored as internal dependencies and cannot be referenced directly by consumers. WHERE, FOR, ORDER BY, LIMIT, and OFFSET evaluate a query; they are rejected on CREATE FEATURES (UE/CREATE-FEATURES-EVALUATION-CLAUSE). FROM stays, because it names a namespace.

CREATE OR REPLACE FEATURES IN FM.SALES AS
DEFINE
    GROSS_REVENUE := INPUT(DECIMAL(18, 2))
PERSIST
    REFUNDS := INPUT(DECIMAL(18, 2)),
    NET_REVENUE := GROSS_REVENUE - REFUNDS;

Create one feature

CREATE [OR REPLACE] [TEMPORARY] FEATURE
    feature_name
    [IN namespace]
AS expression
[FROM relation [, ...]]

The feature name may be fully qualified or may use IN namespace as its target. The optional FROM clause supplies namespace or relation context to the expression.

CREATE OR REPLACE FEATURE
    FM.SALES.NET_REVENUE
AS GROSS_REVENUE - REFUNDS
FROM FM.SALES;

Modifiers

  • OR REPLACE creates a missing feature or replaces an existing definition after consistency validation.
  • TEMPORARY limits the definition to this request (an overlay). It does not write the registry.
  • IN namespace prefixes unqualified output names with one target namespace.

Choose one existing-name policy: plain CREATE (fails if the name already exists) or OR REPLACE. IF NOT EXISTS is parsed and rejected (UE/CREATE-FEATURES-IF-NOT-EXISTS-NOT-SUPPORTED). TEMPORARY controls lifetime independently.

For deployment guidance and examples, see Create features . Registry mutation guarantees are documented under Registry consistency .