-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18937][SQL] Timezone support in CSV/JSON parsing #16750
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 4 commits
aa052f4
890879e
f08b78c
551cff9
bdad5b7
d5ab37c
9b30a9c
dec84e0
ffc4912
a455f4f
ae6397d
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,7 +17,7 @@ | |
|
|
||
| package org.apache.spark.sql.catalyst.json | ||
|
|
||
| import java.util.Locale | ||
| import java.util.{Locale, TimeZone} | ||
|
|
||
| import com.fasterxml.jackson.core.{JsonFactory, JsonParser} | ||
| import org.apache.commons.lang3.time.FastDateFormat | ||
|
|
@@ -58,13 +58,15 @@ private[sql] class JSONOptions( | |
| private val parseMode = parameters.getOrElse("mode", "PERMISSIVE") | ||
| val columnNameOfCorruptRecord = parameters.get("columnNameOfCorruptRecord") | ||
|
|
||
| val timeZone: TimeZone = TimeZone.getTimeZone(parameters("timeZone")) | ||
|
|
||
| // Uses `FastDateFormat` which can be direct replacement for `SimpleDateFormat` and thread-safe. | ||
| val dateFormat: FastDateFormat = | ||
| FastDateFormat.getInstance(parameters.getOrElse("dateFormat", "yyyy-MM-dd"), Locale.US) | ||
|
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. why we don't need timezone here?
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. That is a combination of the If both timezones of the |
||
|
|
||
| val timestampFormat: FastDateFormat = | ||
| FastDateFormat.getInstance( | ||
| parameters.getOrElse("timestampFormat", "yyyy-MM-dd'T'HH:mm:ss.SSSZZ"), Locale.US) | ||
| parameters.getOrElse("timestampFormat", "yyyy-MM-dd'T'HH:mm:ss.SSSZZ"), timeZone, Locale.US) | ||
|
|
||
| // Parse mode flags | ||
| if (!ParseModes.isValidMode(parseMode)) { | ||
|
|
||
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.
Up to my knowledge, this should be added at the end to prevent breaking the existing codes that use those options by positional arguments.
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.
Ah, I see, I'll move them to the end.