Search code examples
kqlazure-data-explorerdata-ingestionaskqlkqlmagic

insert an array in column of the kql table


I have an string array ["AAA", "BBB", "CCC"] tried to ingest this inline into table which contains single dynamic column but its getting ingested only till first comma.

.create table DynamicTable (Data: string) .ingest inline into table DynamicTable <| ["AAA", "BBB", "CCC"]
enter image description here

I tried mapping json, changing the type to csv but nothing worked. this is not the only column in the table, as the other columns might have null values for them


Solution

  • you can achieve that more easily using a ".set-or-append" command:

    .set-or-append DynamicTable <| print Data = dynamic(["AAA","BBB","CCC"])

    EDIT: (as you altered your question in the comment)

    if your table schema is (a:int, b:dynamic, c:string), and you wish to append a record with only b populated, a null and c empty, you can do this:

        .set-or-append MyTable <|
            print a = int(null),
                  b = dynamic(["AAA","BBB","CCC"]),
                  c = ""
    

    Please note that ingesting individual records or very small batches of records is considered very inefficient, and you should refrain from doing this frequently in Production environments, if you care about efficiency and performance. Otherwise, use larger batches (up to 1GB of data size, uncompressed).