Azure Data Factory Power Query Date Source not compatible with SQL

D'Anna, Teresa 6 Reputation points
2022-04-06T18:44:51.543+00:00

Hello,

My source file effective date column has a year of 4712 that causes errors when trying to import with a simple copy job in Azure SQL Server. I decided to try to use Power Query in ADF to transform the date, however the column also has nulls which is making things complicated.

Source File Date Column example (string):
12/31/4712 00:00:00
(blank)
2/5/2023 00:00:00

Transformation:

let Source = #"LoadHCMEmp_SourceDS",

"Replaced value" = Table.ReplaceValue(Source, "12/31/4712 00:00:00", "12/31/2050", Replacer.ReplaceText, {"Effective_End_Date"}),

"Replaced value 1" = Table.ReplaceValue(#"Replaced value", "", "12/31/2050", Replacer.ReplaceValue, {"Effective_End_Date"}),

"Replaced value 2" = Table.ReplaceValue(#"Replaced value 1", " 00:00:00", "", Replacer.ReplaceText, {"Effective_End_Date"}) in #"Replaced value 2"

The problem is when I transform the above into a date, I get:
UserQuery: Expression.Error: Unsupported constant null.

I've tried to import into sql using the pipeline both as a string and as a date (after the above adjustments). When I import as a date, it errors out (see above). When I import after the above transformations, the column comes through as blank. A simple copy job doesn't work because of the year issue.

To push the data into sql we're using the Sink in the Power Query:
Settings -> Allow insert (checkbox checked)
Settings -> Truncate table

Source file is csv. Sink is Azure SQL Server.

Essentially I just want to be able to import the dates, whether that means transforming everything thats super far off to 2050 and making the nulls 12/31/2050 or keeping them as null

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.