Ask Your Question
0

How can I execute a user defined function in Kusto which includes toscalar() on every row of my table?

asked 2023-05-31 02:21:41 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-31 02:47:01 +0000

lakamha gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-31 02:21:41 +0000

Seen: 9 times

Last updated: May 31 '23