ben
ben

Reputation: 401

U-SQL job to query multiple tables with dynamic names

Our challenge is the following one :

We tried several things :

Is there a way to do that in U-SQL through a custom extractor for instance? Any other ideas?

Upvotes: 2

Views: 263

Answers (1)

Peter Bons
Peter Bons

Reputation: 29780

One solution I can think of is to use Azure Data Factory (v2) to assist in this.

You could create a pipeline with the following activities:

  1. Lookup activity configured to execute the stored procedure
  2. For Each activity that uses the output of the lookup activity as a source
    1. As a child item use a U-Sql Activity that executes your U-Sql script which writes the output of a single table (the item of the For Each activity) to blob or datalake
  3. Add a Copy Activity that merges the blobs from step 2.1 to one final blob.

If you have little or no experience working with ADF v2 do mind that it takes some time to get to know it but once you do, you won't regret it. Having a GUI to create the pipeline is a nice bonus.

Edit: as @wBob mentions another (far easier) solution is to somehow create a single table with all rows since all dynamically generated table have the same schema. You can create a stored procedure for populating this table for example.

Upvotes: 0

Related Questions