-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-18352][SQL] Support parsing multiline json files #16386
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 all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
04c8cde
[SPARK-18352][SQL] Support parsing multiline json files
86e3cd2
JacksonParser.parseJsonToken should be explicit about nulls and boxing
f48fc66
Increase type safety of makeRootConverter, remove runtime type tests
361df08
Field converter lookups should be O(1)
06169f7
Support inference of tables with no columns
9b8a265
Improve failedRecord consistency with and without wholeFile mode enabled
42bee5e
Use withTempPath instead of withTempDir
b17809e
Simplify the corrupt document test
422f9b0
Always return a ByteBuffer from getByteBuffer
042d746
Add @Since annotations for all PortableDataStream public methods
e1a620a
Very verbosely test to see if a warning has already been printed
3e67473
Eagerly validate the corrupt column datatype
8ed787f
Avoid broadcasting JsonDataSource references
14d5f93
Remove name binding
5f5214b
Repartition by value instead of luck
7296f7e
Always provide a `T => UTF8String` conversion function
691fa2a
Reorder documentation to match the function parameter order
a629470
Fix build break in Python due to bad rebase
463062a
Fix constructor invocation style
24786d1
Check wholeFile roundtrip against all columns and the source RDD
e323317
Add tests for FAILFAST mode
58118f2
More style fixes
b801ab0
Missed one Javadoc parameter reordering
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
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [ | ||
| { | ||
| "name": "Michael" | ||
| }, | ||
| { | ||
| "name": "Andy", | ||
| "age": 30 | ||
| }, | ||
| { | ||
| "name": "Justin", | ||
| "age": 19 | ||
| } | ||
| ] |
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
46 changes: 46 additions & 0 deletions
46
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/CreateJacksonParser.scala
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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.catalyst.json | ||
|
|
||
| import java.io.InputStream | ||
|
|
||
| import com.fasterxml.jackson.core.{JsonFactory, JsonParser} | ||
| import org.apache.hadoop.io.Text | ||
|
|
||
| import org.apache.spark.unsafe.types.UTF8String | ||
|
|
||
| private[sql] object CreateJacksonParser extends Serializable { | ||
| def string(jsonFactory: JsonFactory, record: String): JsonParser = { | ||
| jsonFactory.createParser(record) | ||
| } | ||
|
|
||
| def utf8String(jsonFactory: JsonFactory, record: UTF8String): JsonParser = { | ||
| val bb = record.getByteBuffer | ||
| assert(bb.hasArray) | ||
|
|
||
| jsonFactory.createParser(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining()) | ||
| } | ||
|
|
||
| def text(jsonFactory: JsonFactory, record: Text): JsonParser = { | ||
| jsonFactory.createParser(record.getBytes, 0, record.getLength) | ||
| } | ||
|
|
||
| def inputStream(jsonFactory: JsonFactory, record: InputStream): JsonParser = { | ||
| jsonFactory.createParser(record) | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
nit: we should rename it to
getConf,getConfigurationis too verbose.