-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-51296][SQL] Support collecting corrupt data in singleVariantColumn mode. #50517
[SPARK-51296][SQL] Support collecting corrupt data in singleVariantColumn mode. #50517
Conversation
@gene-db @sandip-db Please take a look. Thanks! |
schema.length match { | ||
case 1 => | ||
case 2 => | ||
val corruptRecordName = options.getOrElse( |
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.
nit:
val corruptRecordName = options.getOrElse( | |
val corruptRecordColumnName = options.getOrElse( |
@@ -4007,6 +4007,7 @@ abstract class JsonSuite | |||
"true", | |||
"""{"a": [], "b": null}""", | |||
"""{"a": 1}""", | |||
"bad json", |
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.
Add from_json test
@@ -396,7 +396,7 @@ object CSVOptions extends DataSourceOptions { | |||
val EMPTY_VALUE = newOption("emptyValue") | |||
val LINE_SEP = newOption("lineSep") | |||
val INPUT_BUFFER_SIZE = newOption("inputBufferSize") | |||
val COLUMN_NAME_OF_CORRUPT_RECORD = newOption("columnNameOfCorruptRecord") | |||
val COLUMN_NAME_OF_CORRUPT_RECORD = newOption(DataSourceOptions.COLUMN_NAME_OF_CORRUPT_RECORD) |
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.
Add from_csv and csv file reader test with corrupt column and variant
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.
Thanks for this feature! I left a few comments.
@@ -3330,7 +3330,7 @@ | |||
}, | |||
"INVALID_SINGLE_VARIANT_COLUMN" : { | |||
"message" : [ | |||
"The `singleVariantColumn` option cannot be used if there is also a user specified schema." | |||
"User specified schema <schema> is invalid when the `singleVariantColumn` option is enabled." |
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.
Are we allowed to change existing error codes/messages?
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.
I guess it is okay but I'm not sure.
options: CaseInsensitiveMap[String], | ||
userSpecifiedSchema: Option[StructType]): Unit = { | ||
(options.get(SINGLE_VARIANT_COLUMN), userSpecifiedSchema) match { | ||
case (Some(col), Some(schema)) => |
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.
NIT: col
-> variantColName
@@ -3330,7 +3330,7 @@ | |||
}, | |||
"INVALID_SINGLE_VARIANT_COLUMN" : { | |||
"message" : [ | |||
"The `singleVariantColumn` option cannot be used if there is also a user specified schema." | |||
"User specified schema <schema> is invalid when the `singleVariantColumn` option is enabled." |
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.
Indicate what is allowed and how can user fix it.
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.
Thanks for supporting this!
LGTM
@HyukjinKwon could you help merge it? Thanks! |
Merged to master. |
What changes were proposed in this pull request?
Currently, if the
singleVariantColumn
is specified, the schema will be a single variant column. It is then impossible to collect corrupt data, which requires the schema to contain a column for corrupt data. This PR enables collecting corrupt data insingleVariantColumn
mode by relaxing the requirement thatsingleVariantColumn
must not exist together with the user-specified schema. The new requirement is that, if the user-specified schema exists, it must either be a variant field, or a variant field plus a corrupt column field. Corrupt data can be collected in the latter case.Why are the changes needed?
It allows collecting corrupt data in
singleVariantColumn
mode.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Unit test.
Was this patch authored or co-authored using generative AI tooling?
No.