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
8 months agoJulieta
8 months agoGregoria
8 months agoDominic
8 months agoTracey
8 months agoCasie
8 months agoCorrie
8 months agoAlida
9 months agoJeannetta
8 months agoPauline
8 months agoMerri
8 months agoLenna
9 months agoGlennis
9 months agoKatina
9 months agoCallie
8 months agoMargart
8 months agoYoko
8 months agoEdmond
9 months agoEdmond
9 months agoLashon
9 months agoTeri
9 months agoMargot
9 months agoCatalina
9 months agoTwana
9 months agoEssie
10 months agoKayleigh
9 months agoJutta
9 months agoDonte
9 months agoHelaine
9 months agoTyra
10 months agoEmiko
9 months agoCarma
10 months ago