-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29444] Add configuration to support JacksonGenrator to keep fields with null values #26098
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 1 commit
0b90344
4f3c83f
143b9e7
f57bea2
eb123bf
f8aea25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
… values
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,18 @@ class JacksonGeneratorSuite extends SparkFunSuite { | |
| assert(writer.toString === """{"a":1}""") | ||
| } | ||
|
|
||
| test("initial with StructType and write out an empty row with allowStructIncludeNull=true") { | ||
|
||
| val dataType = StructType(StructField("a", IntegerType) :: Nil) | ||
| val input = InternalRow(null) | ||
| val writer = new CharArrayWriter() | ||
| val allowNullOption = | ||
| new JSONOptions(Map("structIngoreNull" -> "false"), gmtId) | ||
| val gen = new JacksonGenerator(dataType, writer, allowNullOption) | ||
| gen.write(input) | ||
| gen.flush() | ||
| assert(writer.toString === """{"a":null}""") | ||
|
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. can we also test null inner field? e.g.
Contributor
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. Sure, I have added a test for this |
||
| } | ||
|
|
||
| test("initial with StructType and write out rows") { | ||
| val dataType = StructType(StructField("a", IntegerType) :: Nil) | ||
| val input = new GenericArrayData(InternalRow(1) :: InternalRow(2) :: Nil) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
is it specific to struct type column? if not how about naming it
ignroeNullFields?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.
It works on StructType, including struct field and struct inner data
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.
how about top-level columns?
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.
Yeap, it also works on that
Uh oh!
There was an error while loading. Please reload this page.
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.
then shall we pick a better name for this config?
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.
okey, ignoreNullFields is much better than structIgnoreNull, I'll change it.