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.
===========
Renea
1 month agoCaprice
2 months agoCorrinne
2 months agoWilford
2 months agoWinfred
2 months agoCorrinne
2 months agoRozella
2 months agoJosephine
3 months agoSabine
3 months agoAdria
3 months agoReita
4 months agoDanica
4 months agoLashaunda
4 months agoYun
4 months agoJospeh
4 months agoEmogene
4 months agoMollie
5 months agoAntonio
5 months agoTina
5 months agoNathalie
5 months agoMarkus
5 months agoWinfred
5 months agoCarli
6 months agoCraig
6 months agoEttie
6 months agoChaya
6 months agoMila
15 days agoMi
20 days agoRochell
26 days agoFausto
1 month agoDusti
1 month ago