Uh oh!
There was an error while loading. Please reload this page.
[SPARK-25600][SQL][MINOR] Make use of TypeCoercion.findTightestCommonType while inferring CSV schema. - #22619
[SPARK-25600][SQL][MINOR] Make use of TypeCoercion.findTightestCommonType while inferring CSV schema.#22619dilipbiswal wants to merge 3 commits into
Conversation
SparkQA
commented
Oct 3, 2018
Test build #96881 has finished for PR 22619 at commit
|
dilipbiswal
commented
Oct 3, 2018
gatorsmile
commented
Oct 3, 2018
Any behavior change? Test cases? |
ueshin
commented
Oct 3, 2018
Maybe this is related to #22448. |
@gatorsmile There should not be any behaviour change. I was thinking that existing test cases should suffice. Basically we used to duplicate the code of TypeCoercion.findTightestCommonType in here. Here i am just reusing the common function. This is tested in CSVInferSchemaSuite |
| } else { | ||
| Some(DecimalType(range + scale, scale)) | ||
| } | ||
| case (_, _) => None |
| Some(DecimalType(range + scale, scale)) | ||
| def compatibleType(t1: DataType, t2: DataType): Option[DataType] = { | ||
| TypeCoercion.findTightestCommonType(t1, t2).orElse { | ||
| (t1, t2) match { |
There was a problem hiding this comment.
Can we leave this out as a private val like the previous and leave a comment that this pattern matching is CSV specific? That will reduce the diff and makes the review easier.
There was a problem hiding this comment.
BTW, let's keep the comments in the original place.
There was a problem hiding this comment.
@HyukjinKwon Did you have any preference or suggestion on the name of the val ? findCommonTypeExtended ?
There was a problem hiding this comment.
not sure. maybe just findCompatibleTypeForCSV
HyukjinKwon
commented
Oct 3, 2018
Looks okay - I checked a case one by one but it needs another look. |
HyukjinKwon
commented
Oct 3, 2018
Let's just file a JIRA @dilipbiswal BTW. |
dilipbiswal
commented
Oct 3, 2018
@HyukjinKwon Okay. |
| findTightestCommonType(t1, DecimalType.forType(t2)) | ||
| // Double support larger range than fixed decimal, DecimalType.Maximum should be enough | ||
| // in most case, also have better precision. |
There was a problem hiding this comment.
Some comments here are ignored in the change. Shall we keep them?
There was a problem hiding this comment.
@viirya Yeah.. we should keep.. sorry.. got dropped inadvertently.
| Some(DoubleType) | ||
| } else { | ||
| Some(DecimalType(range + scale, scale)) | ||
| def compatibleType(t1: DataType, t2: DataType): Option[DataType] = { |
There was a problem hiding this comment.
@viirya i kept the same name used in JsonInferSchema. Change that as well ? Or only change this ?
There was a problem hiding this comment.
compatibleType is also fine if it is consistent with JsonInferSchema.
| case _ => None | ||
| } | ||
There was a problem hiding this comment.
Let's get rid of new lines changes.
| * is compatible with both input data types. | ||
| */ | ||
| private def compatibleType(t1: DataType, t2: DataType): Option[DataType] = { | ||
| TypeCoercion.findTightestCommonType(t1, t2).orElse (findCompatibleTypeForCSV(t1, t2)) |
SparkQA
commented
Oct 3, 2018
Test build #96890 has finished for PR 22619 at commit
|
SparkQA
commented
Oct 3, 2018
Test build #96897 has finished for PR 22619 at commit
|
dilipbiswal
commented
Oct 5, 2018
@HyukjinKwon Does this look okay now ? |
HyukjinKwon
commented
Oct 5, 2018
Yup. Let me leave this open few more days in case. |
dilipbiswal
commented
Oct 5, 2018
@HyukjinKwon Sure :-) |
HyukjinKwon
commented
Oct 6, 2018
Merged to master. |
…Type while inferring CSV schema. ## What changes were proposed in this pull request? Current the CSV's infer schema code inlines `TypeCoercion.findTightestCommonType`. This is a minor refactor to make use of the common type coercion code when applicable. This way we can take advantage of any improvement to the base method. Thanks to MaxGekk for finding this while reviewing another PR. ## How was this patch tested? This is a minor refactor. Existing tests are used to verify the change. Closesapache#22619 from dilipbiswal/csv_minor. Authored-by: Dilip Biswal <dbiswal@us.ibm.com> Signed-off-by: hyukjinkwon <gurwls223@apache.org>
What changes were proposed in this pull request?
Current the CSV's infer schema code inlines
TypeCoercion.findTightestCommonType. This is a minor refactor to make use of the common type coercion code when applicable. This way we can take advantage of any improvement to the base method.Thanks to @MaxGekk for finding this while reviewing another PR.
How was this patch tested?
This is a minor refactor. Existing tests are used to verify the change.