QuestionQ99

VerifiedUsing Spark SQL

A data scientist is working with a large Apache Spark dataset and wants to enable SQL queries on a DataFrame. The dataset includes sensitive information that must be accessible only within the current Spark session.

Which method can the data scientist use to create a SQL-queryable DataFrame view without conflicting with earlier instances of that view?

Explanation

createOrReplaceTempView creates a local temporary view whose lifetime is tied to the current SparkSession, and it replaces any existing local temporary view with the same name. This keeps the sensitive data session-scoped while preventing duplicate-view-name conflicts.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!