Restrict ADF converting Null data from source date field returning 1900-01-01 in target column

KarthikShanth 26 Reputation points
2021-03-09T23:14:10.59+00:00

Hello All, I am not sure, whether this was already asked, I did a search and didn't find any suitable replies related to this.

ADF copy data is returning '1900-01-01' by default to a NULL DateTime field when moving the data from Source to target table while doing the Polybase copy. Both of my source/target are Azure SQL DW tables

I couldn't find anything to change such settings while creating the copy command pipeline in ADF. Any pointers to restrict ADF from doing the automatic conversion?

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,358 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,521 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Nandan Hegde 29,886 Reputation points MVP
    2021-03-10T03:26:46.167+00:00

    Hey @KarthikShanth ,
    Based on my knowledge, unfortunately there is no alternative for it.
    Whenever you use polybase functionality, ADF provides the default value for NULL values like 0 for int and 1900-01-01 for datetime.
    There are 2 ways:

    1. either keep it a simple copy activity so that null value would be retained
    2. Load into a staging table and then while loading into destination convert the values back to null
      @HimanshuSinha-msft : Any thoughts?
    0 comments No comments

  2. John Aherne 81 Reputation points
    2021-03-10T04:35:18.593+00:00

    A not pretty solution would be to convert them to strings first, then load into a staging table. Convert them back through some sort of merge.

    0 comments No comments

  3. HimanshuSinha-msft 19,376 Reputation points Microsoft Employee
    2021-03-16T22:41:26.45+00:00

    Thanks @Nandan Hegde .
    Hello @KarthikShanth ,

    Great question and I did tried to repro the issue and I was able to do that .

    Took some dummy data .

    --DROP TABLE DATETEST  
    CREATE TABLE DATETEST   
    (  
    ID INT ,  
    SOMEDATE DATETIME NULL  
    )  
    SELECT GETUTCDATE()  
    INSERT INTO DATETEST VALUES (1,'2021-03-16 21:51:35.907')  
    INSERT INTO DATETEST(ID) VALUES (2)  
    --DROP TABLE DATETEST_DESTINATION  
    CREATE TABLE DATETEST_DESTINATION  
    (  
    ID INT ,  
    SOMEDATE DATETIME NULL  
    ).   
    

    Please uncheck "Use Type default" and that should do the trick . I am sharing the snapshot for reference below .

    78501-image.png

    78442-null-issue.png

    let me know how it goes .

    Thanks
    Himanshu
    Please do consider to click on "Accept Answer" and "Up-vote" on the post that helps you, as it can be beneficial to other community members

    0 comments No comments

  4. Darpan Patel 6 Reputation points
    2021-10-15T01:53:25.08+00:00

    Hello @HimanshuSinha-msft ,

    I have same issue with ADF v2. Source is ADF and Sink is Azure SQL DB.

    I already tried to accept data in TABLE TYPE (FieldName01(VARCHAR(max)) and then CAST(FieldName01 as DATE) in Stored Procedure.

    Thanks in advance for anyone who come across this and able to shed some light on this.

    0 comments No comments