cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Databricks workflow job

ctiwari7
New Contributor II

Hi team,

I am trying to execute a workflow job which takes in a parameter as unique identifier. I am using this job parameter to push down to tasks. I was hoping if there is any way for me to use python uuid4() function to generate unique id every time the workflow job runs. 

Is there any way to generate uuid on the run time as job parameter.?

2 REPLIES 2

Walter_C
Databricks Employee
Databricks Employee

The intention is that the same job generates this id and once it is generated that this id is passed as a parameter for other tasks?

 

Stefan-Koch
Contributor II

hi ctiwari7

A possible way to do that, you create a python file which generates the uuid and then pass it to jobs.taskValues. This is described here: https://docs.databricks.com/en/jobs/task-values.html 

As test, I created a python file, with the following content:

 

import uuid

uuid = str(uuid.uuid4())

print(uuid)

dbutils.jobs.taskValues.set(key = "uuid", value = uuid)

 

The file will be added as task in a databricks job.

StefanKoch_0-1732638676813.png

For the demo, I have a simple notebook which takes a widget as parameter:

StefanKoch_1-1732638717745.png

In the job, I add a second task, where I refer to the notebook:

StefanKoch_2-1732638761389.png

In the parameter field: put the following information:
name: uuid
value:  {{tasks.create_uuid.values.uuid}}

StefanKoch_3-1732638818391.png

 

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group