-
Notifications
You must be signed in to change notification settings - Fork 29k
[Spark-16791] [SQL] cast struct with timestamp field fails #14400
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
[Spark-16791] [SQL] cast struct with timestamp field fails #14400
Conversation
|
@ueshin , you seem to be the original committer of this code. can you please have a look? |
|
|
||
| private[this] def cast(from: DataType, to: DataType): Any => Any = to match { | ||
| case dt if dt == child.dataType => identity[Any] | ||
| case dt if dt == from => identity[Any] |
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: remove extra whitespace before from.
|
Good catch! |
|
Good catch! LGTM except the style comment given by @ueshin . And please also use full word for variable name, e.g. |
…s from reviewers.
| } | ||
|
|
||
| test("cast struct with a timestamp field") { | ||
| val originalSchema = StructType( |
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.
we usually use new StructType().add("name", TimestampType, nullable = false)
| } | ||
|
|
||
| test("cast struct with a timestamp field") { | ||
| val originalSchema = new StructType().add( "tsField", TimestampType, nullable = false ) |
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.
please remove the space in add( xxx )
|
ok to test |
|
|
||
| val inp = Literal.create(InternalRow(0L), originalSchema) | ||
| val expected = InternalRow(0L) | ||
| checkEvaluation(cast(inp, targetSchema), expected ) |
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.
and remove the extra space here too
|
Test build #63052 has finished for PR 14400 at commit
|
|
@cloud-fan, any update on this? |
|
@cloud-fan, just for notice for the next patches: is there a way to run mvn in a mode that fails on style issues? it could save a lot of round-trips if it existed. (can be sbt just as well) |
|
we have an individual style check script: |
|
Test build #63076 has finished for PR 14400 at commit
|
## What changes were proposed in this pull request? a failing test case + fix to SPARK-16791 (https://issues.apache.org/jira/browse/SPARK-16791) ## How was this patch tested? added a failing test case to CastSuit, then fixed the Cast code and rerun the entire CastSuit Author: eyal farago <eyal farago> Author: Eyal Farago <[email protected]> Closes #14400 from eyalfa/SPARK-16791_cast_struct_with_timestamp_field_fails. (cherry picked from commit 338a98d) Signed-off-by: Wenchen Fan <[email protected]>
|
thanks, merging to master and 2.0! |
What changes were proposed in this pull request?
a failing test case + fix to SPARK-16791 (https://issues.apache.org/jira/browse/SPARK-16791)
How was this patch tested?
added a failing test case to CastSuit, then fixed the Cast code and rerun the entire CastSuit