Create features

Persisting features saves their definitions in the registry so they can be referenced, composed, and shared across queries and teams. You create features with CREATE FEATURES and modify metadata with ALTER FEATURE.

Creating a single feature

CREATE [OR REPLACE] FEATURES [IF NOT EXISTS]
  <feature_name> [IN <namespace> [IF EMPTY]]
  AS <SELECT statement>

CREATE TEMPORARY FEATURES
  <feature_name> AS <SELECT statement>

The simplest form creates one feature with a fully qualified name:

@fql-playground(create_one)

Use SHOW FEATURES to verify what was created — it displays the feature's name, type, and formula:

@fql-playground(create_one_show)

Once persisted, the feature is available in any query:

@fql-playground(create_one_select)

Creating multiple features

A single CREATE statement can define several features at once. Features can reference each other within the same statement — FeatureQL resolves dependencies automatically regardless of definition order.

@fql-playground(create_many)

Using CREATE FEATURES IN

Instead of fully qualifying every name, CREATE FEATURES IN sets a target namespace for all features in the statement:

@fql-playground(create_many_in_location)

Replacing features

CREATE OR REPLACE updates an existing feature's definition. FeatureQL validates that the replacement is compatible with any features that depend on it — see Registry consistency for the full set of rules.

@fql-playground(create_one_replace_succeeds)

Modifying metadata with ALTER

ALTER FEATURE changes metadata (like descriptions) without touching the feature's computation:

@fql-playground(alter)

When to use each variant

SyntaxUse case
CREATE FEATURESFirst-time creation; fails if the feature already exists
CREATE OR REPLACE FEATURESIdempotent creation or update
CREATE FEATURES IF NOT EXISTSCreate only if missing; never overwrites
CREATE TEMPORARY FEATURESSession-scoped features that disappear when the session ends
Last update at: 2026/06/20 10:08:10