Stopping a job at a component when certain criteria is met

I have a job that starts with Python code that calls an API for a report. If the report comes back "Data Not Available" I want to stop the job at that Python step and not continue.

What component is best to use for this logic?

Hi @kerri.gathright​,

There are different ways to do conditional branching in a Matillion ETL orchestration job. For what you have described there are two which you could look at first:

  • In your Python Script component, make it raise an Exception if the report comes back "Data Not Available". By default that will make the component fail, which will make the job fail and stop with a failure message. But you can connect another branch onto the red connection ring, finishing in an "end success". That will stop the job gracefully. It's like an except handler in Python.
  • The more generic method is to use an If Component. You can make it check values of variables, and send the logic in different directions accordingly.

Hope that makes sense and is helpful

Ian

I decided to use the Python script, super useful thank you!

 

I also added a start date parameter because I want that date to be the first one so I know I'm on the correct Thursday thereafter. I also added this start date in the job variables, however I think now I need to remove some of the other code or rearrange it because this new job variable is throwing an error. Suggestions?

 

Python:

 

Job variables: