Create features
Create one feature
Diagram(
Terminal("CREATE"),
Stack(
Choice(1,
Sequence(
Terminal("TEMPORARY FEATURES")
),
Sequence(
Choice(0, Skip(), "OR REPLACE"),
Terminal("FEATURES"),
Choice(0, Skip(), "IF NOT EXISTS")
)
),
Sequence(
NonTerminal("feature_name"),
Choice(0, Skip(),
Sequence(Terminal("IN"), NonTerminal("namespace"), Choice(0, Skip(), Terminal("IF EMPTY")))
),
Terminal("AS"),
NonTerminal("SELECT statement")
)
)
)This creates a persistent feature with the expression 1 + 5 that evaluates to 6.
Inspecting created features
Use SHOW FEATURES to view metadata about created features, including their data type and formula.
Using created features in queries
Once created, features can be referenced directly in SELECT statements and will evaluate using their stored definition.
Create many features
Diagram(
Terminal("CREATE"),
Stack(
Choice(1,
Sequence(
Terminal("TEMPORARY FEATURES")
),
Sequence(
Choice(0, Skip(), "OR REPLACE"),
Terminal("FEATURES"),
Choice(0, Skip(), "IF NOT EXISTS")
)
),
Sequence(
NonTerminal("feature_name"),
Choice(0, Skip(),
Sequence(Terminal("IN"), NonTerminal("namespace"), Choice(0, Skip(), Terminal("IF EMPTY")))
),
Terminal("AS"),
NonTerminal("SELECT statement")
)
)
)This example shows:
- Input features:
INPUT(BIGINT)requires explicit type declaration - Dependencies: Features can reference other features being created in the same statement
- Complex expressions:
CASE WHENlogic for conditional feature values - Automatic dependency resolution: FeatureQL computes features in the correct order
Alternative namespace syntax
You can use CREATE FEATURES IN to specify the target namespace:
This approach creates features directly in the specified namespace without needing fully qualified names.
Feature replacement and consistency
Successful feature replacement
When replacing features, FeatureQL maintains consistency by validating that the new definition is compatible with dependent features.
ALTER operations for metadata
Use ALTER FEATURE to modify feature metadata like descriptions without changing the feature's computational definition.