-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-17850][Core]Add a flag to ignore corrupt files #15422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
| package org.apache.spark.rdd | ||
|
|
||
| import java.io.IOException | ||
| import java.text.SimpleDateFormat | ||
| import java.util.Date | ||
|
|
||
|
|
@@ -33,6 +34,7 @@ import org.apache.spark._ | |
| import org.apache.spark.annotation.DeveloperApi | ||
| import org.apache.spark.deploy.SparkHadoopUtil | ||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.internal.config.IGNORE_CORRUPT_FILES | ||
| import org.apache.spark.rdd.NewHadoopRDD.NewHadoopMapPartitionsWithSplitRDD | ||
| import org.apache.spark.storage.StorageLevel | ||
| import org.apache.spark.util.{SerializableConfiguration, ShutdownHookManager} | ||
|
|
@@ -85,6 +87,8 @@ class NewHadoopRDD[K, V]( | |
|
|
||
| private val shouldCloneJobConf = sparkContext.conf.getBoolean("spark.hadoop.cloneConf", false) | ||
|
|
||
| private val ignoreCorruptFiles = sparkContext.conf.get(IGNORE_CORRUPT_FILES) | ||
|
|
||
| def getConf: Configuration = { | ||
| val conf: Configuration = confBroadcast.value.value | ||
| if (shouldCloneJobConf) { | ||
|
|
@@ -179,7 +183,11 @@ class NewHadoopRDD[K, V]( | |
|
|
||
| override def hasNext: Boolean = { | ||
| if (!finished && !havePair) { | ||
| finished = !reader.nextKeyValue | ||
| try { | ||
| finished = !reader.nextKeyValue | ||
| } catch { | ||
| case e: IOException if ignoreCorruptFiles => finished = true | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for changing this too ! |
||
| if (finished) { | ||
| // Close and release the reader here; close() will also be called when the task | ||
| // completes, but for tasks that read from many files, it helps to release the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -588,6 +588,12 @@ object SQLConf { | |
| .doubleConf | ||
| .createWithDefault(0.05) | ||
|
|
||
| val IGNORE_CORRUPT_FILES = SQLConfigBuilder("spark.sql.files.ignoreCorruptFiles") | ||
| .doc("Whether to ignore corrupt files. If true, the Spark jobs will continue to run when " + | ||
| "encountering corrupt files and contents that have been read will still be returned.") | ||
| .booleanConf | ||
| .createWithDefault(false) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious why we are duplicating the parameter in sql namespace. Wont spark.files.ignoreCorruptFiles not do ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A sql conf can appear in the following command:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting, thanks for clarifying ! |
||
| object Deprecated { | ||
| val MAPRED_REDUCE_TASKS = "mapred.reduce.tasks" | ||
| } | ||
|
|
@@ -759,6 +765,8 @@ private[sql] class SQLConf extends Serializable with CatalystConf with Logging { | |
|
|
||
| def warehousePath: String = new Path(getConf(WAREHOUSE_PATH)).toString | ||
|
|
||
| def ignoreCorruptFiles: Boolean = getConf(IGNORE_CORRUPT_FILES) | ||
|
|
||
| override def orderByOrdinal: Boolean = getConf(ORDER_BY_ORDINAL) | ||
|
|
||
| override def groupByOrdinal: Boolean = getConf(GROUP_BY_ORDINAL) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So either way we will have a behavioral change - if NewHadoopRDD vs HadoopRDD.
IMO that is fine, given that we are standardizing on the behavior and this is something which was a corner case anyway.
Setting default to false makes sense.