[GitHub] spark pull request #14786: [SPARK-17212][SQL] TypeCoercion supports widening...
GitHub user HyukjinKwon opened a pull request: https://github.com/apache/spark/pull/14786 [SPARK-17212][SQL] TypeCoercion supports widening conversion between DateType and TimestampType ## What changes were proposed in this pull request? Currently, type-widening does not work between `TimestampType` and `DateType`. This applies to `SetOperation`, `Union`, `In`, `CaseWhen`, `Greatest`, `Leatest`, `CreateArray`, `CreateMap` and `Coalesce`. For a simple example, ``` Seq(Tuple2(new Timestamp(0), new Date(0))).toDF("a", "b").selectExpr("greatest(a, b)").show() ``` shows below: ``` cannot resolve 'greatest(`a`, `b`)' due to data type mismatch: The expressions should all have the same type, got GREATEST(timestamp, date) ``` or union as below: ```scala val a = Seq(Tuple1(new Timestamp(0))).toDF() val b = Seq(Tuple1(new Date(0))).toDF() a.union(b).show() ``` shows below: ``` Union can only be performed on tables with the compatible column types. DateType <> TimestampType at the first column of the second table; ``` This PR adds the support for widening `DateType` to `TimestampType`. ## How was this patch tested? Unit tests in `TypeCoercionSuite`. You can merge this pull request into a Git repository by running: $ git pull https://github.com/HyukjinKwon/spark SPARK-17212 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/14786.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #14786 commit d49fbdbacd6b3ced5801ff62afc7ec12a8831028 Author: hyukjinkwon Date: 2016-08-24T10:52:20Z TypeCoercion supports widening conversion between DateType and TimestampType --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #14786: [SPARK-17212][SQL] TypeCoercion supports widening...
Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/14786#discussion_r76200868 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala --- @@ -134,6 +134,8 @@ object TypeCoercion { Some(DecimalPrecision.widerDecimalType(DecimalType.forType(t), d)) case (_: FractionalType, _: DecimalType) | (_: DecimalType, _: FractionalType) => Some(DoubleType) +case (_: TimestampType, _: DateType) | (_: DateType, _: TimestampType) => --- End diff -- Ah, sure! --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #14786: [SPARK-17212][SQL] TypeCoercion supports widening...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/14786#discussion_r76230207 --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala --- @@ -188,6 +188,7 @@ class TypeCoercionSuite extends PlanTest { // TimestampType widenTest(NullType, TimestampType, Some(TimestampType)) widenTest(TimestampType, TimestampType, Some(TimestampType)) +widenTest(DateType, TimestampType, Some(TimestampType)) --- End diff -- I think we only need this test --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #14786: [SPARK-17212][SQL] TypeCoercion supports widening...
Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/14786#discussion_r76241650 --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala --- @@ -188,6 +188,7 @@ class TypeCoercionSuite extends PlanTest { // TimestampType widenTest(NullType, TimestampType, Some(TimestampType)) widenTest(TimestampType, TimestampType, Some(TimestampType)) +widenTest(DateType, TimestampType, Some(TimestampType)) --- End diff -- Yeap, fixed. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #14786: [SPARK-17212][SQL] TypeCoercion supports widening...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/14786 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org