你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
.create-or-alter function command
Applies to: ✅ Microsoft Fabric ✅ Azure Data Explorer
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.
Permissions
This command requires Database User permissions for creating a new function, and Function Admin permissions for altering an existing function.
Syntax
.create-or-alter
function
[ with
(
propertyName =
propertyValue [,
...])
] functionName (
parameters)
{
body }
Learn more about syntax conventions.
Parameters
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. |
Note
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. |
view |
bool |
Designates this function as a stored view. Stored views can participate in search and union * scenarios. For more information, see Views. |
skipvalidation |
bool |
Determines whether to run validation logic on the function and fails the process if the function isn't valid. The default is false . |
Example
The following example creates the TestFunction function with a description (docstring
), folder, and defines the MyLimit
parameter.
.create-or-alter function with (docstring = 'Demo function with parameter', folder='MyFolder')
TestFunction(myLimit:int)
{ StormEvents | take myLimit}
Output
Name | Parameters | Body | Folder | DocString |
---|---|---|---|---|
TestFunction | (myLimit:int) | { StormEvents | take myLimit } | MyFolder | Demo function with parameter |