Skip to content

Data Engineer Associate · Domain 2: Data Ingestion and Loading · 21% of the exam

Task 2.5: Use JDBC/ODBC or REST clients in notebooks to land data into cloud storage or directly into Unity Catalog–governed tables, usually orchestrated and scheduled with Lakeflow Jobs.

Reading a database over JDBC with partitioned reads and secrets, calling a REST API from a notebook, writing the result to a volume or table, and scheduling the notebook as a job task.

Study it

  • JDBC reads and REST calls from a notebook, scheduled as a job

    Partly covered by: Designing a REST API

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 notebook reads a PostgreSQL table into a DataFrame and then writes it to a Unity Catalog table: df = (spark.read.format("jdbc") .option("url", jdbc_url) .option("dbtable", "public.orders") .option("partitionColumn", "order_id") .option("lowerBound", "1") .option("upperBound", "1000000") .option("numPartitions", "8") .load()) The table has order_id values from 1 to 3,000,000. Which rows does df contain?

  1. ARows with order_id 1 to 3,000,000, split into 8 partitions by stride
  2. BRows with order_id from 1 to 1,000,000, since the bounds act as a filter
  3. CThe first 8 rows, one row from each partition
  4. DNo rows; the read fails because values exceed upperBound
Show the answer and why
  • ARows with order_id 1 to 3,000,000, split into 8 partitions by stride

    Correct

    lowerBound and upperBound decide the partition stride and do not filter, so every row in the table is partitioned and returned.

  • BRows with order_id from 1 to 1,000,000, since the bounds act as a filter

    Incorrect

    The bounds only set the stride of each partition; they do not filter the rows of the table.

  • CThe first 8 rows, one row from each partition

    Incorrect

    numPartitions sets how many partitions the read is split into; it is not a row limit.

  • DNo rows; the read fails because values exceed upperBound

    Incorrect

    Rows outside the bounds still land in a partition; the read does not fail.

For a parallel JDBC read you set partitionColumn, lowerBound, upperBound and numPartitions together. The bounds shape the partitions, numPartitions sets how many there are, and all rows are still read.

Question 2 · choose 1

A notebook reads a PostgreSQL table over JDBC each night. The database password must not appear in the notebook's code, its parameters or its output. How should the notebook obtain it?

  1. AFrom a notebook widget whose default value is the password
  2. Bdbutils.secrets.get on a secret scope that holds the password
  3. CFrom the compute's Spark configuration, typed in as plain text
  4. DFrom a CSV file stored in a Unity Catalog volume
Show the answer and why
  • AFrom a notebook widget whose default value is the password

    Incorrect

    Widget values are visible in the notebook and in job parameters, so the password would be exposed.

  • Bdbutils.secrets.get on a secret scope that holds the password

    Correct

    Databricks secrets store credentials outside the code, and the documentation shows reading JDBC credentials with dbutils.secrets.get.

  • CFrom the compute's Spark configuration, typed in as plain text

    Incorrect

    A plain-text value in the compute configuration is visible to anyone who can view that configuration.

  • DFrom a CSV file stored in a Unity Catalog volume

    Incorrect

    A file in a volume is readable by anyone with access to the volume and is not a secret store.

Store database credentials in a secret scope and read them at run time. Databricks redacts secret values in notebook output, although users with access to the scope can still read them.

Question 3 · choose 1

A JDBC read from an Oracle table is slow. The table has no numeric, date or timestamp column suitable for partitioning, and profiling shows the time goes to network round trips, because the driver returns 10 rows per trip. Which option addresses this?

  1. ApartitionColumn with lowerBound, upperBound and numPartitions
  2. Bbatchsize
  3. CqueryTimeout
  4. Dfetchsize
Show the answer and why
  • ApartitionColumn with lowerBound, upperBound and numPartitions

    Incorrect

    Partitioned reads need a numeric, date or timestamp column, which this table lacks.

  • Bbatchsize

    Incorrect

    batchsize sets how many rows are inserted per round trip and applies only to writes.

  • CqueryTimeout

    Incorrect

    queryTimeout limits how long a statement may run; it does not change rows per round trip.

  • Dfetchsize

    Correct

    fetchsize sets how many rows are fetched per round trip, which helps drivers with a low default such as Oracle's 10 rows.

The JDBC source has read and write tuning options. fetchsize raises rows per round trip on reads; batchsize does the same for writes.

Question 4 · choose 1

A notebook must read only the last seven days of a large orders table over JDBC, and the filtering should run in the database. The read does not need to be split into partitions. Which option setup is valid?

  1. AThe query option set to a SELECT with the date filter, and no dbtable option
  2. BBoth dbtable set to orders and query set to the filtered SELECT
  3. Cdbtable set to orders with pushDownPredicate set to false, then a Spark filter
  4. DThe query option with the filtered SELECT plus partitionColumn set to order_id
Show the answer and why
  • AThe query option set to a SELECT with the date filter, and no dbtable option

    Correct

    The query option sends a parenthesized subquery to the database; it cannot be combined with dbtable.

  • BBoth dbtable set to orders and query set to the filtered SELECT

    Incorrect

    dbtable and query cannot be specified together.

  • Cdbtable set to orders with pushDownPredicate set to false, then a Spark filter

    Incorrect

    Turning off predicate pushdown makes Spark read every row and filter on its side, the opposite of the goal.

  • DThe query option with the filtered SELECT plus partitionColumn set to order_id

    Incorrect

    partitionColumn cannot be used with query; partitioned reads need dbtable with a subquery instead.

Use query for a filtered read run by the database, or dbtable with a subquery alias when you also need partitionColumn.

Question 5 · choose 1

A notebook calls a partner's REST API, which returns pages of JSON. The raw responses must be kept as files governed by Unity Catalog and then loaded incrementally into a bronze table by a later step of the same job. Where should the notebook write the responses?

  1. ATo /tmp on the driver's local disk
  2. BTo the DBFS root of the workspace
  3. CTo a directory in a Unity Catalog volume
  4. DInto task values for the next task to read
Show the answer and why
  • ATo /tmp on the driver's local disk

    Incorrect

    Compute-local paths do not persist beyond the compute's lifecycle, and Unity Catalog does not govern them.

  • BTo the DBFS root of the workspace

    Incorrect

    Storing data in the DBFS root is a deprecated pattern; Databricks recommends Unity Catalog volumes.

  • CTo a directory in a Unity Catalog volume

    Correct

    Volumes are governed storage for files, and Auto Loader or COPY INTO can then load the files incrementally.

  • DInto task values for the next task to read

    Incorrect

    Task values carry small JSON values between tasks, up to 48 KiB, not raw data files.

Land API output as files in a volume, then ingest them with Auto Loader or COPY INTO, with both steps orchestrated as tasks in Lakeflow Jobs.

Practise domain 2 →Practise all domains →