Alex
Alex

Reputation: 169

How to use user-defined scalar inside datatable creation in Kusto

Basically I'd like to define a scalar and then use that scalar inside of a datatable. Something like:

let dayOne = "Day One";
let dayTwo = "Day Two";
let dayStringMapping = datatable(Batch: int64, BatchDay: string)
    [   
    01, dayOne,
    02, dayTwo
    ];

How can I do this?

Upvotes: 6

Views: 3431

Answers (1)

Yoni L.
Yoni L.

Reputation: 25905

The datatable operator requires constant scalar values as its input.

An alternative approach could be using the print operator.

If required, you can union several rows generated by multiple usages of the print operator.

For example:

let dayOne = "Day One";
let dayTwo = "Day Two";
let dayStringMapping = 
    union (print Batch = 1, BatchDay = dayOne),
          (print Batch = 2, BatchDay = dayTwo);
... do something with 'dayStringMapping' ...

Upvotes: 9

Related Questions