Uredi

Deli z drugimi prek


Create stored functions

Functions are reusable queries or query parts. Real-Time Intelligence supports two kinds of functions:

  • Built-in functions, which are hard-coded functions that can't be modified by users.

  • User-defined functions, which are divided into two types:

    • Stored functions: are user-defined functions that are stored and managed database schema entities (such as tables). For more information on how to create and manage stored functions, see Stored functions management overview.
    • Query-defined functions: are user-defined functions that are defined and used within the scope of a single query. The definition of such functions is done through a let statement. For more information on how to create query-defined functions, see Create a user defined function.

In this article, you learn how to create or alter an existing stored function using the .create-or-alter function.

For more information on the .create-or-alter function command, see .create-or-alter function

Prerequisites

Functions

This feature allows you to create or alter an existing function using the .create-or-alter function command, which stores it in the database metadata. If the function with the provided functionName doesn't exist in the database metadata, the command creates a new function. Otherwise, the named function is changed.

  1. Browse to your KQL database, and select New > Function. The .create-or-alter command is automatically populated in the Explore your data window.

    Screenshot of a KQL database landing page showing the New option dropdown menu. The option titled Function is highlighted.

  2. Enter the function name and query parameters of your function instead of the placeholder text, and then select Run.

    Screenshot of the Explore your data window showing the newly created function in Real-Time Intelligence.

    Stored functions appear under Functions in the Explorer pane.

    Screenshot of Explorer pane showing the list of stored user-defined functions.

  3. In the Explore your data window, run a query to check that you have successfully created or altered your function.

    Screenshot of the Explore your data window showing query results of a stored function in Real-Time Intelligence.