Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
smpa01
Super User
Super User

Equiavlent js Map

I have a set variable activity that returns a json object and I need to perform JS Array.prototype.map  equiavlent in Data Pipeline.

 

Can you please help. I don't want to manually hardcode by array index inside a concat

 

const obj = {
	"value": {
		"colNames": [
			{
				"tbl_id": 2,
				"tbl_name": "fact_Activity",
				"src_colname": "col1",
				"sample_datetime": "2024-08-02T04:23:18Z",
				"last_run_at": "2024-08-02T00:23:40.071123Z"
			},
			{
				"tbl_id": 2,
				"tbl_name": "fact_Activity",
				"src_colname": "col2",
				"sample_datetime": "2024-08-02T04:23:18Z",
				"last_run_at": "2024-08-02T00:23:40.071123Z"
			},
			{
				"tbl_id": 2,
				"tbl_name": "fact_Activity",
				"src_colname": "col3",				
				"sample_datetime": "2024-08-02T04:23:18Z",
				"last_run_at": "2024-08-02T00:23:40.071123Z"
			}
		]
	}

const result = obj.value.colNames.map(a=>a.src_colname).join(",")
//'col1,col2,col3'
}

 

 

@join(activity('Script1').output.resultSets[0].rows,',')

// this joins all the key-value pairs
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION

Hi @smpa01 ,

 

Yes, the regular js array methods are supported as of now. I'll let you know as soon as possible if subsequent tests reveal unsupported methods.

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-kongfanf-msft
Community Support
Community Support

Hi @smpa01 ,

 

You can try to modify your code like below, this might potentially give you the result 'col1,col2,col3' without hard-coding the array index.

@join(activity('Script1').output.resultSets.rows.map(a => a.src_colname), ',')

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@v-kongfanf-msft  are all js Array methods valid in pipeline expression?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi @smpa01 ,

 

Yes, the regular js array methods are supported as of now. I'll let you know as soon as possible if subsequent tests reveal unsupported methods.

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

November Update

Fabric Monthly Update - November 2024

Check out the November 2024 Fabric update to learn about new features.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.