Issue with Date Calculation Logic in ADF Pipeline
Hello ADF Community,
I am currently facing an issue with a piece of code in my ADF pipeline that has been functioning correctly for like 2 years until recently. The code is designed to handle date calculations for incremental loads based on historical depth parameters. The parameters are always negative and stored in string type. Below is the original code that was working before:
@IF(
greater(activity(‘Get table properties’).output.count,0),
IF(
not(equals(activity(‘Get table properties’).output.value[0].Start_Time,’null’)),
activity(‘Get table properties’).output.value[0].Start_Time,
IF(
not(equals(activity(‘Get table properties’).output.value[0].Start_Time,’null’)),
activity(‘Get table properties’).output.value[0].Start_Time,
IF(
greater(activity(‘Get table properties’).output.value[0].Depth_History_In_Days_start_time,’0′),
formatDateTime(adddays(utcnow(),int(pipeline().parameters.Depth_History_In_Days_start)),’yyyy-MM-dd’),
formatDateTime(utcnow(),’yyyy-MM-dd’)
)
)
),
formatDateTime(adddays(utcnow(),0),’yyyy-MM-dd’)
)
Issue Description
Until recently, this logic correctly loaded data based on the historical depth parameters. However, it now seems to be malfunctioning, leading to incorrect date calculations and always selecting today dates. (utcnow)
My Investigation and Changes
To address this issue, I simplified the logic, assuming the problem might be due to redundant checks and over-complication. Here’s the updated version of the code:
@IF(
greater(activity(‘Get table properties’).output.count, 0),
IF(
not(equals(activity(‘Get table properties’).output.value[0].Start_Time, ‘null’)),
activity(‘Get table properties’).output.value[0].Start_Time,
formatDateTime(adddays(utcnow(), int(pipeline().parameters.Depth_History_In_Days_start)), ‘yyyy-MM-dd’)
),
formatDateTime(adddays(utcnow(), int(pipeline().parameters.Depth_History_In_Days_start)), ‘yyyy-MM-dd’)
)
Despite these changes, I am still unclear on why the original logic stopped working. The Depth_History_In_Days_start_time and Depth_History_In_Days_end_time variables are strings, and we have been using greater than 0 for comparisons, which worked previously since in string comparison, -2 is considered greater than 0.
Could anyone provide insights into why the original code might have stopped functioning correctly? Have there been any updates or changes in ADF that might affect string comparison logic? Any guidance or suggestions to ensure reliable date calculations would be greatly appreciated.
Thank you in advance for your assistance!
Hello ADF Community,I am currently facing an issue with a piece of code in my ADF pipeline that has been functioning correctly for like 2 years until recently. The code is designed to handle date calculations for incremental loads based on historical depth parameters. The parameters are always negative and stored in string type. Below is the original code that was working before: @IF(
greater(activity(‘Get table properties’).output.count,0),
IF(
not(equals(activity(‘Get table properties’).output.value[0].Start_Time,’null’)),
activity(‘Get table properties’).output.value[0].Start_Time,
IF(
not(equals(activity(‘Get table properties’).output.value[0].Start_Time,’null’)),
activity(‘Get table properties’).output.value[0].Start_Time,
IF(
greater(activity(‘Get table properties’).output.value[0].Depth_History_In_Days_start_time,’0′),
formatDateTime(adddays(utcnow(),int(pipeline().parameters.Depth_History_In_Days_start)),’yyyy-MM-dd’),
formatDateTime(utcnow(),’yyyy-MM-dd’)
)
)
),
formatDateTime(adddays(utcnow(),0),’yyyy-MM-dd’)
) Issue DescriptionUntil recently, this logic correctly loaded data based on the historical depth parameters. However, it now seems to be malfunctioning, leading to incorrect date calculations and always selecting today dates. (utcnow)My Investigation and ChangesTo address this issue, I simplified the logic, assuming the problem might be due to redundant checks and over-complication. Here’s the updated version of the code: @IF(
greater(activity(‘Get table properties’).output.count, 0),
IF(
not(equals(activity(‘Get table properties’).output.value[0].Start_Time, ‘null’)),
activity(‘Get table properties’).output.value[0].Start_Time,
formatDateTime(adddays(utcnow(), int(pipeline().parameters.Depth_History_In_Days_start)), ‘yyyy-MM-dd’)
),
formatDateTime(adddays(utcnow(), int(pipeline().parameters.Depth_History_In_Days_start)), ‘yyyy-MM-dd’)
) Despite these changes, I am still unclear on why the original logic stopped working. The Depth_History_In_Days_start_time and Depth_History_In_Days_end_time variables are strings, and we have been using greater than 0 for comparisons, which worked previously since in string comparison, -2 is considered greater than 0. Could anyone provide insights into why the original code might have stopped functioning correctly? Have there been any updates or changes in ADF that might affect string comparison logic? Any guidance or suggestions to ensure reliable date calculations would be greatly appreciated.Thank you in advance for your assistance! Read More