QuestionQ249

VerifiedUsing Spark SQL

An engineer has a large ORC file at /file/test_data. orc and wants to read only particular columns to reduce memory usage.

Which code fragment will select the columns—namely, co11 and co12—during the read process?

Choose two
Explanation

Both spark.read.orc(path) and spark.read.format("orc").load(path) return a DataFrame, and DataFrame.select("col1", "col2") projects the specified columns. Spark can use that projection for column pruning when scanning ORC data. select cannot be called on a DataFrameReader before load returns a DataFrame.

Learn more

Community Discussion

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