Is it possible to use a dynamic array/list as input for parameterizing a kusto query?

We Are Going To Discuss About Is it possible to use a dynamic array/list as input for parameterizing a kusto query?. So lets Start this Python Article.

Is it possible to use a dynamic array/list as input for parameterizing a kusto query?

  1. How to solve Is it possible to use a dynamic array/list as input for parameterizing a kusto query?

    The value in the parameter list has to be a literal, for dynamic arrays a literal looks like this:
    dynamic([1,2,3])
    for example:
    params = { "scenario": "string", "env": "string2", "duration": "string3", "value_list": "dynamic([1,2,3,4])" }

  2. Is it possible to use a dynamic array/list as input for parameterizing a kusto query?

    The value in the parameter list has to be a literal, for dynamic arrays a literal looks like this:
    dynamic([1,2,3])
    for example:
    params = { "scenario": "string", "env": "string2", "duration": "string3", "value_list": "dynamic([1,2,3,4])" }

Solution 1

The value in the parameter list has to be a literal, for dynamic arrays a literal looks like this:

dynamic([1,2,3])

for example:

params = {
    "scenario": "string",
    "env": "string2",
    "duration": "string3",
    "value_list": "dynamic([1,2,3,4])"
}

Original Author Avnera Of This Content

Solution 2

If you construct your query in Python then you can pass it and execute it like below. I also included a test table with 2 rows to help visualize the results:

let TestTable = datatable (ScenarioCol:string, evnCol:string, durationCol:string, numericalCol:int) 
[
    "scenario 1", "env 1", "duration x", 1,
    "scenario 1", "env 1", "duration x", 9
];
let MyQuery = (scenario:string, env:string, duration:string, value_list:dynamic)
{
    TestTable
    | where ScenarioCol == scenario
    | where evnCol == env
    | where durationCol == duration
    | where numericalCol in(value_list)
};
let scenario = "scenario 1";
let env = "env 1";
let duration = "duration x";
let valueList = dynamic([1,2,3,4]);
MyQuery(scenario, env, duration, valueList)

Output:

output table

As you can see it just took the row that had a matching value from the set.

Original Author SendETHToThisAddress Of This Content

Solution 3

@Avnera has the correct answer, there is just one more thing:
the dynamic type need to be inside the parentheses:

| where value in (value_list)

Original Author Redevil Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment