Which of the following code blocks reads in the JSON file stored at filePath as a DataFrame?
spark.read.json(filePath)
Correct. spark.read accesses Spark's DataFrameReader. Then, Spark identifies the file type to be read as JSON type by passing filePath into the DataFrameReader.json() method.
spark.read.path(filePath)
Incorrect. Spark's DataFrameReader does not have a path method. A universal way to read in files is provided by the DataFrameReader.load() method (link below).
spark.read.path(filePath, source='json')
Wrong. A DataFrameReader.path() method does not exist (see above).
spark.read().json(filePath)
Incorrect. spark.read is a way to access Spark's DataFrameReader. However, the DataFrameReader is not callable, so calling it via spark.read() will fail.
spark.read().path(filePath)
No, Spark's DataFrameReader is not callable (see above).
More info: pyspark.sql.DataFrameReader.json --- PySpark 3.1.2 documentation, pyspark.sql.DataFrameReader.load --- PySpark 3.1.2 documentation
Static notebook | Dynamic notebook: See test 3, Question: 34 (Databricks import instructions)
Lenna
4 hours agoGlennis
1 days agoKatina
3 days agoEdmond
7 days agoEdmond
11 days agoLashon
11 days agoTeri
18 days agoCatalina
4 hours agoTwana
4 days agoEssie
21 days agoJutta
4 days agoDonte
8 days agoHelaine
13 days agoTyra
27 days agoEmiko
18 days agoCarma
21 days ago