Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Ingest data by using Lakeflow Spark Declarative Pipelines, including Auto Loader

A worked example

Yes or no

A data engineer at an energy company defines two Auto Loader streaming tables in a Python Lakeflow pipeline, as shown in the exhibit. maintenance_schema is a StructType defined earlier in the same file.

No other Auto Loader options are set on either table. In particular, cloudFiles.schemaEvolutionMode and rescuedDataColumn are not set.

The upstream systems sometimes add new columns to the CSV files.

# Excerpt from a pipeline source file
from pyspark import pipelines as dp

@dp.table
def telemetry_bronze():
    return (spark.readStream.format("cloudFiles")
        .option("cloudFiles.format", "csv")
        .option("header", "true")
        .load("/Volumes/energy/raw/landing/telemetry"))

@dp.table
def maintenance_bronze():
    return (spark.readStream.format("cloudFiles")
        .option("cloudFiles.format", "csv")
        .option("header", "true")
        .schema(maintenance_schema)
        .load("/Volumes/energy/raw/landing/maintenance"))

For each of the following statements, select Yes if the statement is true. Otherwise, select No.
StatementYesNo
For telemetry_bronze, the schema evolution mode in effect is addNewColumns.

telemetry_bronze does not provide a schema. When no schema is provided, addNewColumns is the default schema evolution mode.

Correct
When a new column appears in the maintenance files, its values are captured in the _rescued_data column of maintenance_bronze.

maintenance_bronze provides a schema, so the default mode is none. In that mode new columns are ignored, and their data is not rescued unless the rescuedDataColumn option is set, which the scenario says it is not.

Correct
If cloudFiles.schemaEvolutionMode is set to rescue on telemetry_bronze, new columns are added to the table schema while the stream keeps running.

In rescue mode the stream does not fail, but the schema is never evolved. New columns are captured in the _rescued_data column and are not added to the schema.

Correct
Why

The default Auto Loader schema evolution mode depends on whether a schema is supplied. Without a schema, as in telemetry_bronze, the default is addNewColumns. With a schema, as in maintenance_bronze, the default is none: new columns are ignored and not rescued unless rescuedDataColumn is set. Setting the mode to rescue keeps the stream running but never evolves the schema. Instead, new columns go into _rescued_data.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free