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()
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.
===========
Caprice
1 day agoCorrinne
6 days agoWilford
11 days agoWinfred
17 days agoCorrinne
22 days agoRozella
27 days agoJosephine
2 months agoSabine
2 months agoAdria
2 months agoReita
2 months agoDanica
2 months agoLashaunda
2 months agoYun
3 months agoJospeh
3 months agoEmogene
3 months agoMollie
3 months agoAntonio
3 months agoTina
3 months agoNathalie
4 months agoMarkus
4 months agoWinfred
4 months agoCarli
4 months agoCraig
4 months agoEttie
5 months agoChaya
5 months ago