Search code examples
azure-data-explorerkqlkusto-explorer

How to ingest using .set-or-append with let statement


I am trying to ingest data into a table by using .set-or-append and let statement as well.

So basically I am trying to ingest data using this query:

let HexCode = "2";
.set-or-append Test <|
    Test
    | where Column startswith "2"

But then I am getting a message error:

The incomplete fragment is unexpected.

If I add the let statement let HexCode = "2"; below the .set-or-append, it works, but not as expected. It ingested less rows than it should.

I didn't find any syntax about that on the documentation. Am I doing right? How can I ingest using multiple let statements if I need?


Solution

  • the let statement is part of the query in the command, and thus should be included after the <|.

    for example:

    .set-or-append T2 <|
        let HexCode = "2";
        T1
        | where Column startswith HexCode