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)
Jerrod
18 days agoJulieta
19 days agoGregoria
22 days agoCasie
4 days agoCorrie
5 days agoAlida
1 months agoJeannetta
2 days agoPauline
11 days agoMerri
13 days agoLenna
1 months agoGlennis
1 months agoKatina
1 months agoCallie
5 days agoMargart
7 days agoYoko
11 days agoEdmond
1 months agoEdmond
1 months agoLashon
1 months agoTeri
2 months agoMargot
1 months agoCatalina
1 months agoTwana
1 months agoEssie
2 months agoKayleigh
1 months agoJutta
1 months agoDonte
1 months agoHelaine
2 months agoTyra
2 months agoEmiko
2 months agoCarma
2 months ago