Forum Discussion
Referencing notebook exit value as a variable in a data pipeline
- 2 years ago
For my own implementation the delimited string just wasnt flexible enough - so here's a version using a JSON object as the notebook return value:
Notebook pyspark:
lResult={"numUpdated":10,"message":"success","fruit":["apple","orange","grapes"]} mssparkutils.notebook.exit(str(lResult))Expression for varMessageStr:
Anonymous(activity('Test Notebook').output.result.exitValue).messageExpression for varNumUpdatedInt:
INT(json(activity('Test Notebook').output.result.exitValue).numUpdated)Expression for varFruitArray:
Anonymous(activity('Test Notebook').output.result.exitValue).fruit
I also struggled, until I tried ignoring the expression builder syntax errors and just ran my pipeline. I was able to get the following to work by using a delimited string as the notebook return value.
Notebook pyspark:
lResult="returnValueOne=25|returnValueTwo=abc|returnValueThree=19"
mssparkutils.notebook.exit(str(lResult))
Expression for varAllReturnValuesArray
@split(activity('Test Notebook').output.result.exitValue,'|')
Expression for varReturnValueOneString
@last(split(first(split(activity('Test Notebook').output.result.exitValue,'|')),'='))
Expression for varReturnValueTwoString
@last(split(split(activity('Test Notebook').output.result.exitValue,'|')[1],'='))
- Nero2 years ago
Advocate II
For my own implementation the delimited string just wasnt flexible enough - so here's a version using a JSON object as the notebook return value:
Notebook pyspark:
lResult={"numUpdated":10,"message":"success","fruit":["apple","orange","grapes"]} mssparkutils.notebook.exit(str(lResult))Expression for varMessageStr:
Anonymous(activity('Test Notebook').output.result.exitValue).messageExpression for varNumUpdatedInt:
INT(json(activity('Test Notebook').output.result.exitValue).numUpdated)Expression for varFruitArray:
Anonymous(activity('Test Notebook').output.result.exitValue).fruit- AdamFry2 years ago
Advocate I
Just want to say that this post was EXTREMELY helpful to me and I want to say thank you for sharing this really nice approach.
- sam_wise2 years agoFrequent Visitor
Bravo! This was extremely helpful!
Many thanks!
- tlanza89_RWL1 year ago
Advocate I
This is exactly what I needed. Thank you!