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