How to use expression builder to iterate through an array?

Wei Yang 0 Reputation points
2023-12-07T08:55:49.3233333+00:00

Hi, I am trying to use a lookup activity to build a SQL query to retrieve some data UNIONing multiple tables.

Input: [{"Table":"Accounts"},{"Table":"Users"}]

Output in expression builder:

SELECT * FROM [Accounts]

UNION

SELECT * FROM [Users]

P.S: I understand there is an iterate activity to use, and it helps iterate through multiple tables and fire single query per tables within array and essentially combined the output from each activity to create a combined output, but that is very costly.

Edit: The expression should stay the same as it would handle different length of array and it is able to union all the tables based on the how many input is given

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

1 answer

Sort by: Most helpful
  1. KranthiPakala-MSFT 46,737 Reputation points Microsoft Employee Moderator
    2024-01-09T23:06:40.95+00:00

    @Wei Yang Thanks for posting your query.

    As you are looking for a dynamic solution, it would be difficult to achieve this using ADF. Rather I would rather prefer to try with Azure Databricks or Azure Synapse spark for writing your custom code logic to achieve the same.

    0 comments No comments

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.