Incrementally loading multiple tables from Azure sql to Azure datalakes

Zhu, Yueli YZ [NC] 280 Reputation points
2023-10-11T04:21:46.5766667+00:00

Hi,

The documentation regarding incrementally loading multiple tables https://learn.microsoft.com/en-us/azure/data-factory/tutorial-incremental-copy-multiple-tables-portal

Instead of using stored procedure, I used script activity. But when I lookup the new watermark value from source tables, I always got errors. Please help

User's image

User's image

select MAX(CAST(@item().LastModifytime as datetime2)) as NewWatermarkvalue from @{item().table_name}

Following is the error message: 
The expression 'item().LastModifytime' cannot be evaluated because property 'LastModifytime' doesn't exist, available properties are 'table_name, table_schema'.
Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,562 questions
Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
577 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,637 questions
{count} votes

Accepted answer
  1. Subashri Vasudevan 11,226 Reputation points
    2023-10-11T06:39:48.0833333+00:00

    Hi Zhu, Yueli YZ [NC] in your ListAllLookup, I think you are just bringing table_name, table_schema two columns only instead of doing below -

    select * from watermarktable where TableName  =  '@{item().TABLE_NAME}'
    
    

    That is why in the foreach loop you get the mentioned error.

    Either you modify your base query to bring all the columns from watermark table or, if all the tables have same date column, you can use below expression directly.

    select MAX(CAST(LastModifytime as datetime2)) as NewWatermarkvalue from @{item().table_name}

    Please try this and let us know.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2023-10-16T09:05:43.7366667+00:00

    Hi Zhu, Yueli YZ [NC],

    Thank you for posting query in Microsoft Q&A Platform.

    Why error:

    In ListAllTable(Look up activity) you are getting list of tables as array. You can check same in the output json of look up activity. So basically, you are getting table_name and table_schema columns.
    Above array from lookup activity, you are passing it to ForEach Activity to iterate over that table names. So for every iteration you get one item from array, and in the error you will have only table_name and table_schema columns.

    But, in your below query, you are trying to take LastModifytime property. Technically item() object not contains that property. Hence you are seeing the error.

    select MAX(CAST(@item().LastModifytime as datetime2)) as NewWatermarkvalue from @{item().table_name}
    

    Kindly consider checking below video of mine, where i explained how to pass output of one activity to another activity. That will help you to understand better.

    How to read JSON output of one Activity in to another Activity in Azure Data Factory

    Kindly correct your query according to avoid this error.

    Hope this helps. Please let me know if any further queries.


    Please consdier hitting Accept Answer button. Accepted answers help community as well.

    1 person found this answer helpful.

Your answer

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