DAZL Documentation | Data Analytics A-to-Z Processing Language


Contents

exit

Flow Control

slug: step-exit

Exit Step

Purpose

Immediately terminates pipeline execution with an optional message. Provides a controlled way to stop processing based on conditions or at specific points in the workflow.

When to Use

  • Stop execution when a critical condition is met
  • End processing early when required data is missing
  • Terminate after completing a specific operation
  • Provide early exit points in conditional workflows
  • Debug pipelines by stopping at specific stages
  • Prevent unnecessary processing when objectives are met

How It Works

  1. Takes an optional message parameter
  2. Sets an internal exit flag to halt pipeline execution
  3. Returns the exit signal with the provided (or default) message
  4. Prevents any subsequent steps from executing
  5. Allows the pipeline to terminate gracefully with context

Parameters

Optional

  • message (string) - Custom message to display when exiting
    • Default: "script ended."
    • Prefixed with "EXIT: " in the output
    • Useful for logging or debugging why execution stopped

Input Requirements

  • None - can be called at any point in the pipeline
  • Does not require specific data structure
  • Can be used with any upstream data

Output Structure

Returns a special control structure:

  • _ypl_exit - Boolean flag (true) signaling termination
  • message - The exit message (prefixed with "EXIT: ")

Note: This output does not follow the standard data contract format as it's a control flow directive.

Example Usage

Basic Exit

exit:
  message: "Processing complete - no further steps needed"

Conditional Exit (with executeIf)

executeIf:
  condition: "freq == 0"
  then:
    - exit:
        message: "No records found matching criteria"

Exit After Validation

- load:
    file: "input.csv"

- filter:
    keep_if: "revenue > 0"

- executeIf:
    condition: "freq == 0"
    then:
      - exit:
          message: "All records filtered out - invalid data"

- cube:
    dimensions: [region]
    measures: [revenue]

Debug Exit Point

- load:
    file: "data.csv"

- calculate:
    new_column: "total_sales * 1.1"

- exit:
    message: "DEBUG: Stopping after calculations to inspect data"

- chart:  # This step will not execute
    type: "bar"

Exit Message Output

When the exit step executes, the message appears as:

EXIT: [your message here]

For example, with message: "No data to process", the output would be:

EXIT: No data to process

Best Practices

  • Use descriptive messages that explain why execution stopped
  • Combine with executeIf for conditional exits based on data conditions
  • Place strategically to avoid unnecessary processing
  • Use for validation checkpoints in data pipelines
  • Include context in messages for debugging and logging

Common Patterns

Data Validation Pattern

- load:
    file: "transactions.csv"

- executeIf:
    condition: "freq < 100"
    then:
      - exit:
          message: "Insufficient records - need at least 100 transactions"

Multi-Condition Exit Pattern

- freq:
    column: "status"

- executeIf:
    condition: "status == 'error' AND freq > 0"
    then:
      - exit:
          message: "Error records detected - halting pipeline"

Optional Processing Pattern

- load:
    file: "config.yaml"

- executeIf:
    condition: "process_mode == 'validate_only'"
    then:
      - print:
          title: "Validation Complete"
      - exit:
          message: "Validation mode - no processing performed"

Related Documentation

  • [[step-executeIf]] - Conditional execution for exit logic
  • [[step-forEach]] - Loop control that can include exits