question

GouKong-9328 avatar image
0 Votes"
GouKong-9328 asked PRADEEPCHEEKATLA-MSFT commented

Azure Data Factory V2 - Add TriggerTime to Kusto query

Hi, I want to run Kusto query with a time parameter in ADF so I can debug conveniently. I try many times and want to know how to pass parameter to it although I can write 'let timestring = now()' to make code works. Here is part of my Kusto code.

let timestring = todatetime(@convertFromUtc(pipeline().TriggerTime,'GMT Standard Time','yyyy-MM-dd HH:mm:ss.fff'));
let biasDate = startofday(timestring);
let endDate = datetime_add('day', -2, biasDate);
let startDate = datetime_add('day', -3, biasDate);

and adf will tell me "
Failure happened on 'Source' side. ErrorCode=UserErrorKustoReadFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Read from Kusto failed with following error: Syntax error: Query could not be parsed: A recognition error occurred.."

Thanks!




azure-data-factoryazure-monitor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MartinJaffer-MSFT avatar image
1 Vote"
MartinJaffer-MSFT answered PRADEEPCHEEKATLA-MSFT commented

Hello @GouKong-9328 and welcome to Microsoft Q&A.

I have seen something similar happen when trying to mix pipeline expression inside a SQL statment/query.

Could you try:

let timestring = todatetime(@{convertFromUtc(pipeline().TriggerTime,'GMT Standard Time','yyyy-MM-dd HH:mm:ss.fff')});

The difference is adding the curly braces { }. The curly braces serve two purposes.

  1. They help Data Factory tell where to start and stop interpreting the content as an expression, as opposed to text to pass to Kusto

  2. They convert the output of the contained expression to a string

Let us know whether this helps or not. If this solves your issue, please mark as accepted answer. If it does not help you, let us know, and we will look deeper into the issue.

Thank you for your patience.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your help. According to your answer and modify of my kusto query. The final code should be:

let timestring = datetime(@{convertFromUtc(pipeline().TriggerTime,'GMT Standard Time','yyyy-MM-dd HH:mm:ss')});



0 Votes 0 ·

Hello @GouKong-9328,

Glad to know that your issue has resolved.

0 Votes 0 ·