AndrewN
Databricks Employee
Databricks Employee

Ramana,

I checked internally and the suggestion is to structure your code in such a way that it returns from the main function when a certain condition is met. I modified your code to what you see below.

# sys.exit(0) equivalent
def main():
    bucket_name = "prod"
    if bucket_name ==  "prod":
        return
    # Rest of your code

if __name__ == "__main__":
    main()
 
I ran your original code and the job showed as failed in Databricks. Then I ran the modified function that returns from main and the job showed as succeeded. I believe this is the best alternative to achieve your expected sys.exit(0) behavior in Databricks. 
 

View solution in original post