Reputation: 361
I have a table in kusto with 13,000 rows. I would like to know how can I create a new column in this table which fill it with only 2 values (0 and 1) randomly. Is there also a possibility to create a column containing 3 different value of data type: string ?
Upvotes: 3
Views: 3052
Reputation: 25895
you can extend a calculated column using the rand()
function: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/randfunction
for example:
0
or 1
:
| extend y = toint(rand(1) > 0.5)
1 of 3 strings (first
, second
or third
):
| extend r = rand(3)
| extend s = case(r <= 0, "first", r <= 1, "second", "third")
| project-away r
if you need to do this at ingestion time, you can use an update policy: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/management/updatepolicy
or if you want to do this for the existing table, you can use a .set-or-replace
command: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/management/data-ingestion/ingest-from-query
Upvotes: 5