Spark SQL and DataFrames Flashcards
6 cards from real Apache Spark practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Spark SQL and DataFrames flashcards as text
What is the entry point for Spark SQL functionality in Spark 2.x and later?
Answer: SparkSession
SparkSession is the unified entry point for Spark SQL, DataFrame, and Dataset APIs introduced in Spark 2.0.
Which method is used to run a SQL query on a registered temporary view in Spark SQL?
Answer: spark.sql()
spark.sql() executes a SQL query and returns the results as a DataFrame.
What is a DataFrame in Apache Spark?
Answer: An RDD of Row objects with a named column schema
A DataFrame is a distributed collection of data organized into named columns, conceptually equivalent to a database table.
How do you register a DataFrame as a temporary SQL view in Spark?
Answer: df.createOrReplaceTempView("name")
createOrReplaceTempView() registers a DataFrame as a temporary view scoped to the current SparkSession.
Which DataFrame function is used to select specific columns?
Answer: select()
select() returns a new DataFrame with only the specified columns.
What does the printSchema() method do in Spark DataFrames?
Answer: Prints the schema of the DataFrame in a tree format
printSchema() prints the schema of the DataFrame as a tree showing column names, types, and nullability.