U.S. Independence Day Deal! Unlock 25% OFF Today – Limited-Time Offer - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Databricks Certified Associate Developer for Apache Spark 3.5 Exam - Topic 1 Question 18 Discussion

24 of 55. Which code should be used to display the schema of the Parquet file stored in the location events.parquet?A.spark.sql("SELECT * FROM events.parquet").show()B.spark.read.format("parquet").load("events.parquet").show()C.spark.read.parquet("events.parquet").printSchema()D.spark.sql("SELECT schema FROM events.parquet").show()
C) Option C
A) Option A
B) Option B
D) Option D

Databricks Certified Associate Developer for Apache Spark 3.5 Exam - Topic 1 Question 18 Discussion

Actual exam question for Databricks's Databricks Certified Associate Developer for Apache Spark 3.5 exam
Question #: 18
Topic #: 1
[All Databricks Certified Associate Developer for Apache Spark 3.5 Questions]

24 of 55. Which code should be used to display the schema of the Parquet file stored in the location events.parquet?

A.

spark.sql("SELECT * FROM events.parquet").show()

B.

spark.read.format("parquet").load("events.parquet").show()

C.

spark.read.parquet("events.parquet").printSchema()

D.

spark.sql("SELECT schema FROM events.parquet").show()

Show Suggested Answer Hide Answer
Suggested Answer: C

To view the schema of a Parquet file, you must use the DataFrameReader to load the Parquet data and call the .printSchema() method.

Correct syntax:

spark.read.parquet('events.parquet').printSchema()

This command loads the file metadata (without triggering a full read) and prints the column names, data types, and nullability information in a tree format.

Why the other options are incorrect:

A/D: SQL queries can't directly introspect file schemas.

B: .show() displays data rows, not schema.


PySpark DataFrameReader API --- read.parquet() and DataFrame.printSchema().

Databricks Exam Guide (June 2025): Section ''Using Spark SQL'' --- describes reading files and examining schemas in Spark SQL and DataFrame APIs.

===========

Contribute your Thoughts:

0/2000 characters

Currently there are no comments in this discussion, be the first to comment!


Save Cancel