I need to append a row that contains timespan and datetime in kusto command. However,
kusto is throwing error saying
Query schema does not match table schema. QuerySchema=('string,string,string,string,string'), TableSchema=('string,string,datetime,datetime,timespan')
Here's my syntax:
.append async Student <| print StudentID = "12345", StudentName = "John", StartTime = datetime(2021-12-06T08:20:02.011052Z), EndTime = datetime(2022-01-06T11:20:02.011052Z), Duration = time(00:00:00.0000509)
Did I miss anything in the syntax here?
the output schema of the query-part of your command, and the schema of the target table must match in the nubmer of columns, their data types, and their order. column names don't matter.
if, for example, your target table has the following schema:
(a:string, b:int, c:dynamic)and you want to append one record with onlyaandcpopulated, then you need to provide some value forbas well.for example:
.append MyTable <| print "hello", int(null), dynamic([1,2])and not:
.append MyTable <| print "hello", dynamic([1,2])one way you can figure out the differences in the schema in your specific case is by running the following queries, and then aligning the differences:
Student | getschemaprint StudentID = "12345", StudentName = "John", StartTime = datetime(2021-12-06T08:20:02.011052Z), EndTime = datetime(2022-01-06T11:20:02.011052Z), Duration = time(00:00:00.0000509) | getschemaBTW, the error message you included is likely from a different execution you ran, and not the one you quoted - as this part:
QuerySchema=('string,string,string,string,string')doesn't match the fact you havedatetimeandtimespancolumns in the quoted command.