.create-or-alter function command

Creates a stored function or alters an existing function and stores it inside the database metadata.

Rules for parameter types and CSL statements are the same as for let statements.


This command requires Database User permissions for creating a new function, and Function Admin permissions for altering an existing function.


.create-or-alter function [ with (propertyName = propertyValue [, ...])] functionName (parameters) { body }

Learn more about syntax conventions.


Name Type Required Description
functionName string ✔️ The name of the function to create or alter.
propertyName, propertyValue string A comma-separated list of key-value property pairs. See supported properties.
parameters string A comma-separated list of parameters required by the function. The format for each parameter must be ParameterName:ParameterDataType.
body string ✔️ Zero or more let statements followed by a valid CSL expression that is evaluated upon function invocation.


If the function with the provided functionName doesn't exist in the database metadata, the command creates a new function. Else, that function will be changed.

Supported properties

Name Type Description
docstring string A description of the function for UI purposes.
folder string The name of a folder used for UI functions categorization.


.create-or-alter function with (docstring = 'Demo function with parameter', folder='MyFolder') TestFunction(myLimit:int)
    StormEvents | take myLimit 


Name Parameters Body Folder DocString
TestFunction (myLimit:int) { StormEvents | take myLimit } MyFolder Demo function with parameter