Skip to content

Data Engineer Professional · Domain 1: Developing Code for Data Processing using Python and SQL · 23% of the exam

Task 1.9: Create Lakeflow Jobs that use control-flow operators such as If/Else conditions and For Each loops.

If/else condition tasks and their operands, For each inputs and concurrency, Run if dependencies, task values, and repairing iterations.

Study it

  • If/else conditions, For each loops and Run if

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the Databricks documentation page that proves it.

Question 1 · choose 1

A task named list_tables queries a control table and produces about 300 table configurations as a JSON array of objects, roughly 30 KB in total. A For each task must run a notebook once per object, at most 10 at a time, and the list changes daily. How should the For each task get its inputs?

  1. Alist_tables sets a task value, and Inputs holds {{tasks.list_tables.values.tables}}, with Concurrency 10
  2. BThe array is pasted into the Inputs box each morning, with Concurrency 10
  3. Clist_tables writes the array to a job parameter that Inputs references, with Concurrency 10
  4. DThe nested notebook reads the control table and loops over the rows itself, with Concurrency 10
Show the answer and why
  • Alist_tables sets a task value, and Inputs holds {{tasks.list_tables.values.tables}}, with Concurrency 10

    Correct

    A task value reference can stand for a value of up to 48 KB, and Concurrency sets how many iterations run in parallel.

  • BThe array is pasted into the Inputs box each morning, with Concurrency 10

    Incorrect

    The Inputs box is limited to 5,000 characters, and a daily manual paste is not automation.

  • Clist_tables writes the array to a job parameter that Inputs references, with Concurrency 10

    Incorrect

    Job parameter values are limited to 10,000 characters, and a task cannot change a job parameter of its own run.

  • DThe nested notebook reads the control table and loops over the rows itself, with Concurrency 10

    Incorrect

    That replaces the For each task with one long run of one notebook, losing per-iteration runs and parallel execution.

For each inputs can come from a JSON array, a job parameter or a task value reference. The Inputs box holds 5,000 characters and job parameter values 10,000, while a task value reference can represent up to 48 KB. For larger lists, pass a lookup to a config file instead.

Question 2 · choose 1

A job's If/else condition task tests a task value set by the task check. An engineer disables check for a week. What happens in the next run?

  1. AThe condition evaluates to false and the false branch runs instead
  2. BThe condition evaluates to true and the true branch runs
  3. CThe condition task is skipped and both branches run
  4. DThe If/else task fails because its value source is disabled
Show the answer and why
  • AThe condition evaluates to false and the false branch runs instead

    Incorrect

    The task does not default to false; it fails.

  • BThe condition evaluates to true and the true branch runs

    Incorrect

    A missing value does not evaluate to true.

  • CThe condition task is skipped and both branches run

    Incorrect

    The condition task fails instead of being skipped.

  • DThe If/else task fails because its value source is disabled

    Correct

    An If/else task fails if the upstream task that provides its condition value is disabled.

An If/else condition task fails if the upstream task that provides its condition value is disabled. The same applies to a For each task whose inputs come from a disabled task.

Question 3 · choose 1

A For each task iterates over [{"table": "sales"}, {"table": "orders"}]. How does the nested notebook task pass the table name as a parameter?

  1. A{{input.table}}
  2. B{{tasks.input.values.table}}
  3. C{{job.parameters.table}}
  4. D{{input[0].table}}
Show the answer and why
  • A{{input.table}}

    Correct

    {{input.<key>}} references a field of the object for each iteration.

  • B{{tasks.input.values.table}}

    Incorrect

    That is the task value syntax for a task named input.

  • C{{job.parameters.table}}

    Incorrect

    That reads a job parameter, not the iteration input.

  • D{{input[0].table}}

    Incorrect

    Each iteration receives one element; there is no index syntax.

In the nested task's parameters, {{input}} is the array value of the iteration and {{input.<key>}} references a field when iterating over objects.

Question 4 · choose 1

A task named list_regions produces the input array of a For each task, which runs a nested notebook once per region with Concurrency 4. A summary task must start only after every iteration has finished. How is the summary task's dependency set?

  1. AIt depends directly on the nested task inside the For each task
  2. BIt runs as a second nested task inside the same For each task
  3. CIt depends on the For each task, the top-level task of the loop
  4. DIt depends on list_regions, the task that supplies the input array
Show the answer and why
  • AIt depends directly on the nested task inside the For each task

    Incorrect

    A downstream task cannot set the nested task as a dependency.

  • BIt runs as a second nested task inside the same For each task

    Incorrect

    A For each task has one nested task, which runs once per iteration.

  • CIt depends on the For each task, the top-level task of the loop

    Correct

    The For each task is the top-level task that downstream tasks can name as a dependency, and it completes after its iterations.

  • DIt depends on list_regions, the task that supplies the input array

    Incorrect

    That dependency is met as soon as list_regions finishes, so the summary would run alongside the iterations.

A For each task and its nested task appear as one node in the job. The For each task is the top-level task, and downstream tasks set it as their dependency; they cannot depend on the nested task directly.

Question 5 · choose 1

A task sets the task value has_errors with the Python boolean True. An If/else condition compares {{tasks.validate.values.has_errors}} with ==. Which right-hand operand makes the condition true for this value?

  1. Aon
  2. Btrue
  3. C1
  4. Dyes
Show the answer and why
  • Aon

    Incorrect

    Booleans are not serialized as on or off.

  • Btrue

    Correct

    Boolean task values are serialized to the strings "true" or "false", and == compares strings.

  • C1

    Incorrect

    The value is the string "true", not a number.

  • Dyes

    Incorrect

    Booleans are not serialized as yes or no.

In an If/else operand, non-numeric task values are serialized to strings, so a boolean becomes "true" or "false", and == and != compare strings.

Practice domain 1 →Practice all domains →