-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-21677][SQL] json_tuple throws NullPointException when column is null as string type #18930
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
596c280
fix null field name and add corresponding test
jmchung 796041f
add description
jmchung f07a9f7
modify the comment about nullFieldName
jmchung ffa575a
make properly comment on pseudo field name
jmchung 5d71263
discard fake field name, apply Option instead
jmchung 0078445
added unit test that mixes constant field name and non constant one f…
jmchung 5c69df5
use IndexedSeq instead of Array on foldableFieldNames to get better p…
jmchung ab16929
remove redundant comment and move toIndexedSeq after the map
jmchung e0e0c74
move test case from JsonSuite to JsonExpressionsSuite and add new tes…
jmchung 5191ed4
consistent style in SQL and append the corresponding golden file of j…
jmchung ff3b9da
add a newline at the end and alter SQL
jmchung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
use IndexedSeq instead of Array on foldableFieldNames to get better p…
…erformance
- Loading branch information
commit 5c69df524ea4a037095005ad9915cac4ca4aedc5
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -359,15 +359,15 @@ case class JsonTuple(children: Seq[Expression]) | |
| @transient private lazy val jsonExpr: Expression = children.head | ||
|
|
||
| // the fields to query are the remaining children | ||
| @transient private lazy val fieldExpressions: Array[Expression] = children.tail.toArray | ||
| @transient private lazy val fieldExpressions: Seq[Expression] = children.tail | ||
|
|
||
| // eagerly evaluate any foldable the field names | ||
| @transient private lazy val foldableFieldNames: Array[Option[String]] = { | ||
| @transient private lazy val foldableFieldNames: IndexedSeq[Option[String]] = { | ||
| fieldExpressions.map { | ||
| case expr if expr.foldable => Option(expr.eval()).map(_.asInstanceOf[UTF8String].toString) | ||
| case _ => null | ||
| } | ||
| } | ||
| }.toIndexedSeq | ||
|
|
||
| // and count the number of foldable fields, we'll use this later to optimize evaluation | ||
| @transient private lazy val constantFields: Int = foldableFieldNames.count(_ != null) | ||
|
|
@@ -430,6 +430,7 @@ case class JsonTuple(children: Seq[Expression]) | |
| } | ||
| } | ||
|
|
||
| // Array[String] | ||
|
||
| val row = Array.ofDim[Any](fieldNames.length) | ||
|
|
||
| // start reading through the token stream, looking for any requested field names | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we move
toIndexedSeqto inner block, i.e. after the map?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.
@viirya Done: (1) remove redundant comment (2) move
toIndexedSeqafter the map