0

I have a synapse notebook that makes a var:

  testvar = '6/26/2023'

I can run this from a pipeline in Azure but how do I pass the variable from the notebook to something else, like a copy data task? I know the following sql in the image below doesn't work, I'm just not sure what I need to do to pass this variable

enter image description here

Aswin
  • 4,090
  • 2
  • 4
  • 16
user3486773
  • 1,174
  • 3
  • 25
  • 50
  • https://stackoverflow.com/questions/71163025/how-to-return-integer-value-from-notebook-in-adf-pipeline this, maybe, will help you – AdForte Jun 27 '23 at 08:47

1 Answers1

0

To pass variable from Azure Synapse notebook Add exit value to the notebook using below code:

mssparkutils.notebook.exit(testvar)

enter image description here

Run Notebook activity in Synapse pipeline add set variable activity to the notebook activity. Create variable with below dynamic content.

@activity('Notebook1').output.status.Output.result.exitValue

enter image description here

Above variable will give the variable of notebook as output.

enter image description here

Pass the above variable value into the copy activity with below query.

SELECT * FROM data where date > '@{variables('testvar')}'

enter image description here

It will copy data from source to sink according to the query. Data preview of above query:

enter image description here

Bhavani
  • 1,725
  • 1
  • 3
  • 6