QuestionQ123

VerifiedTroubleshooting and Tuning Apache Spark DataFrame API Applications.

A developer has been asked to troubleshoot an issue in a Spark application. The developer determined that data from a CSV file is being loaded incorrectly into a DataFrame.

The CSV file was read with the following Spark SQL statement:

Question Image

The initial lines from SELECT * FROM default.air_ref appear as follows:

Question Image

Which parameter can the developer add to the OPTIONS clause in the CREATE TABLE statement to read the CSV data correctly again?

Explanation

Spark CSV uses a comma as its default field separator and does not treat the first record as a header unless configured to do so. A pipe-delimited file with column names in its first row requires sep = '|' to split fields correctly and header = 'true' to use that row as column names rather than data.

Learn more

Community Discussion

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