You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2022/03/11 12:58:00 UTC

[jira] [Assigned] (SPARK-38523) Failure on referring to the corrupt record from CSV

     [ https://issues.apache.org/jira/browse/SPARK-38523?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Apache Spark reassigned SPARK-38523:
------------------------------------

    Assignee: Apache Spark

> Failure on referring to the corrupt record from CSV
> ---------------------------------------------------
>
>                 Key: SPARK-38523
>                 URL: https://issues.apache.org/jira/browse/SPARK-38523
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 3.3.0
>            Reporter: Max Gekk
>            Assignee: Apache Spark
>            Priority: Major
>
> The file below has a invalid value in a field:
> {code:java}
> 0,2013-111_11 12:13:14
> 1,1983-08-04 {code}
> where the timestamp 2013-111_11 12:13:14 is incorrect.
> The query fails when it refers to the corrupt record column:
> {code:java}
> spark.read.format("csv")
>  .option("header", "true")
>  .schema(schema)
>  .load("csv_corrupt_record.csv")
>  .filter($"_corrupt_record".isNotNull) {code}
> with the exception:
> {code:java}
> org.apache.spark.sql.AnalysisException: 
> Since Spark 2.3, the queries from raw JSON/CSV files are disallowed when the
> referenced columns only include the internal corrupt record column
> (named _corrupt_record by default). For example:
> spark.read.schema(schema).csv(file).filter($"_corrupt_record".isNotNull).count()
> and spark.read.schema(schema).csv(file).select("_corrupt_record").show().
> Instead, you can cache or save the parsed results and then send the same query.
> For example, val df = spark.read.schema(schema).csv(file).cache() and then
> df.filter($"_corrupt_record".isNotNull).count().
>       
>     at org.apache.spark.sql.errors.QueryCompilationErrors$.queryFromRawFilesIncludeCorruptRecordColumnError(QueryCompilationErrors.scala:2047)
>     at org.apache.spark.sql.execution.datasources.csv.CSVFileFormat.buildReader(CSVFileFormat.scala:116) {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org