Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the mv-apply operator to apply your user-defined function to every row of your table, and then use the toscalar() function to convert the resulting array back to a scalar value. Here's an example:

Suppose you have a table called MyTable with columns Col1 and Col2, and you want to apply a user-defined function myFunction() to every row of this table. Here's how you can do it:

MyTable
| mv-apply myFunction() on (Col1, Col2)
| extend Result = toscalar(Result)

The mv-apply operator applies myFunction() to every row of the table, using the values in columns Col1 and Col2 as arguments. This will create a new column called Result which contains an array with the results of the function for each row.

The extend operator is then used to create a new column called Result which contains the scalar value in the Result array. The toscalar() function is used here to convert the array to a scalar value.

Note that you'll need to modify the mv-apply expression to match your specific user-defined function and table columns.