You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "laglangyue (via GitHub)" <gi...@apache.org> on 2023/10/19 15:52:02 UTC

[PR] [SPARK-45368]Remove scala2.12 compatibility logic for DoubleType, Flo… [spark]

laglangyue opened a new pull request, #43456:
URL: https://github.com/apache/spark/pull/43456

   …atType, Decimal
   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   https://issues.apache.org/jira/browse/SPARK-45368
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Drop Scala 2.12 and make Scala 2.13 by default
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   test by ci
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   no
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1774309585

   cc @srowen 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "srowen (via GitHub)" <gi...@apache.org>.
srowen commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1373180796


##########
sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala:
##########
@@ -41,37 +39,4 @@ class FloatType private() extends FractionalType {
  * @since 1.3.0
  */
 @Stable
-case object FloatType extends FloatType {
-
-  // Traits below copied from Scala 2.12; not present in 2.13
-  // TODO: SPARK-30011 revisit once Scala 2.12 support is dropped
-  trait FloatIsConflicted extends Numeric[Float] {
-    def plus(x: Float, y: Float): Float = x + y
-    def minus(x: Float, y: Float): Float = x - y
-    def times(x: Float, y: Float): Float = x * y
-    def negate(x: Float): Float = -x
-    def fromInt(x: Int): Float = x.toFloat
-    def toInt(x: Float): Int = x.toInt
-    def toLong(x: Float): Long = x.toLong
-    def toFloat(x: Float): Float = x
-    def toDouble(x: Float): Double = x.toDouble
-    // logic in Numeric base trait mishandles abs(-0.0f)
-    override def abs(x: Float): Float = math.abs(x)
-    // Added from Scala 2.13; don't override to work in 2.12
-    def parseString(str: String): Option[Float] =
-      Try(java.lang.Float.parseFloat(str)).toOption
-  }
-
-  trait FloatAsIfIntegral extends FloatIsConflicted with Integral[Float] {
-    def quot(x: Float, y: Float): Float = {
-      (BigDecimal(x.toDouble) quot BigDecimal(y.toDouble)).floatValue
-    }
-    def rem(x: Float, y: Float): Float = {
-      (BigDecimal(x.toDouble) remainder BigDecimal(y.toDouble)).floatValue
-    }
-  }
-
-  object FloatAsIfIntegral extends FloatAsIfIntegral {
-    override def compare(x: Float, y: Float): Int = java.lang.Float.compare(x, y)
-  }
-}
+case object FloatType extends FloatType

Review Comment:
   Do we need to retain this object at all?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1368648303


##########
sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala:
##########
@@ -681,8 +681,6 @@ object Decimal {
     override def toLong(x: Decimal): Long = x.toLong
     override def fromInt(x: Int): Decimal = new Decimal().set(x)
     override def compare(x: Decimal, y: Decimal): Int = x.compare(y)
-    // Added from Scala 2.13; don't override to work in 2.12
-    // TODO revisit once Scala 2.12 support is dropped
     def parseString(str: String): Option[Decimal] = Try(Decimal(str)).toOption

Review Comment:
   in scala2.12, Numberic not has this method, it ok, refer to `scala.math.Numeric.BigDecimalIsConflicted` in scala2.13



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1786451271

   @srowen @amaliujia @HyukjinKwon PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1373118025


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/types/PhysicalDataType.scala:
##########
@@ -92,7 +92,6 @@ object PhysicalNumericType {
 
 sealed abstract class PhysicalFractionalType extends PhysicalNumericType {
   private[sql] val fractional: Fractional[InternalType]
-  private[sql] val asIntegral: Integral[InternalType]

Review Comment:
   same to above



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1374062779


##########
sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala:
##########
@@ -41,37 +39,4 @@ class FloatType private() extends FractionalType {
  * @since 1.3.0
  */
 @Stable
-case object FloatType extends FloatType {
-
-  // Traits below copied from Scala 2.12; not present in 2.13
-  // TODO: SPARK-30011 revisit once Scala 2.12 support is dropped
-  trait FloatIsConflicted extends Numeric[Float] {
-    def plus(x: Float, y: Float): Float = x + y
-    def minus(x: Float, y: Float): Float = x - y
-    def times(x: Float, y: Float): Float = x * y
-    def negate(x: Float): Float = -x
-    def fromInt(x: Int): Float = x.toFloat
-    def toInt(x: Float): Int = x.toInt
-    def toLong(x: Float): Long = x.toLong
-    def toFloat(x: Float): Float = x
-    def toDouble(x: Float): Double = x.toDouble
-    // logic in Numeric base trait mishandles abs(-0.0f)
-    override def abs(x: Float): Float = math.abs(x)
-    // Added from Scala 2.13; don't override to work in 2.12
-    def parseString(str: String): Option[Float] =
-      Try(java.lang.Float.parseFloat(str)).toOption
-  }
-
-  trait FloatAsIfIntegral extends FloatIsConflicted with Integral[Float] {
-    def quot(x: Float, y: Float): Float = {
-      (BigDecimal(x.toDouble) quot BigDecimal(y.toDouble)).floatValue
-    }
-    def rem(x: Float, y: Float): Float = {
-      (BigDecimal(x.toDouble) remainder BigDecimal(y.toDouble)).floatValue
-    }
-  }
-
-  object FloatAsIfIntegral extends FloatAsIfIntegral {
-    override def compare(x: Float, y: Float): Int = java.lang.Float.compare(x, y)
-  }
-}
+case object FloatType extends FloatType

Review Comment:
   sure,same as `org.apache.spark.sql.types.LongType`
   
   



##########
sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala:
##########
@@ -41,37 +39,4 @@ class FloatType private() extends FractionalType {
  * @since 1.3.0
  */
 @Stable
-case object FloatType extends FloatType {
-
-  // Traits below copied from Scala 2.12; not present in 2.13
-  // TODO: SPARK-30011 revisit once Scala 2.12 support is dropped
-  trait FloatIsConflicted extends Numeric[Float] {
-    def plus(x: Float, y: Float): Float = x + y
-    def minus(x: Float, y: Float): Float = x - y
-    def times(x: Float, y: Float): Float = x * y
-    def negate(x: Float): Float = -x
-    def fromInt(x: Int): Float = x.toFloat
-    def toInt(x: Float): Int = x.toInt
-    def toLong(x: Float): Long = x.toLong
-    def toFloat(x: Float): Float = x
-    def toDouble(x: Float): Double = x.toDouble
-    // logic in Numeric base trait mishandles abs(-0.0f)
-    override def abs(x: Float): Float = math.abs(x)
-    // Added from Scala 2.13; don't override to work in 2.12
-    def parseString(str: String): Option[Float] =
-      Try(java.lang.Float.parseFloat(str)).toOption
-  }
-
-  trait FloatAsIfIntegral extends FloatIsConflicted with Integral[Float] {
-    def quot(x: Float, y: Float): Float = {
-      (BigDecimal(x.toDouble) quot BigDecimal(y.toDouble)).floatValue
-    }
-    def rem(x: Float, y: Float): Float = {
-      (BigDecimal(x.toDouble) remainder BigDecimal(y.toDouble)).floatValue
-    }
-  }
-
-  object FloatAsIfIntegral extends FloatAsIfIntegral {
-    override def compare(x: Float, y: Float): Int = java.lang.Float.compare(x, y)
-  }
-}
+case object FloatType extends FloatType

Review Comment:
   sure,same as `org.apache.spark.sql.types.LongType`
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368]Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1366447381


##########
sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala:
##########
@@ -43,26 +43,7 @@ class FloatType private() extends FractionalType {
 @Stable
 case object FloatType extends FloatType {
 
-  // Traits below copied from Scala 2.12; not present in 2.13
-  // TODO: SPARK-30011 revisit once Scala 2.12 support is dropped

Review Comment:
   Can we use this JIRA SPARK-30011?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1368662550


##########
sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala:
##########
@@ -681,8 +681,6 @@ object Decimal {
     override def toLong(x: Decimal): Long = x.toLong
     override def fromInt(x: Int): Decimal = new Decimal().set(x)
     override def compare(x: Decimal, y: Decimal): Int = x.compare(y)
-    // Added from Scala 2.13; don't override to work in 2.12
-    // TODO revisit once Scala 2.12 support is dropped
     def parseString(str: String): Option[Decimal] = Try(Decimal(str)).toOption

Review Comment:
   yes,I will.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "amaliujia (via GitHub)" <gi...@apache.org>.
amaliujia commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1782304036

   > @amaliujia cc. shoudl `asIntegral` be removed for PhysicalFractionalType, float and double , I find the method not be used. if shoudle not removed,should we add this. `implicit object DoubleIsFractional extends DoubleIsFractional with Ordering.DoubleOrdering` because it is in scala2.12. thanks.
   
   We keep the methods for the completeness, even though they may not be used. So for the completeness we should keep those.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1773068036

   I found that `asIntegral` was not used, PhysicalDecimalType.asIntegral was used directly, rather than through trait.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue closed pull request #43456: [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal
URL: https://github.com/apache/spark/pull/43456


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368]Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1366447381


##########
sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala:
##########
@@ -43,26 +43,7 @@ class FloatType private() extends FractionalType {
 @Stable
 case object FloatType extends FloatType {
 
-  // Traits below copied from Scala 2.12; not present in 2.13
-  // TODO: SPARK-30011 revisit once Scala 2.12 support is dropped

Review Comment:
   Can we use this JIRA SPARK-30011?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "srowen (via GitHub)" <gi...@apache.org>.
srowen commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1368591778


##########
sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala:
##########
@@ -681,8 +681,6 @@ object Decimal {
     override def toLong(x: Decimal): Long = x.toLong
     override def fromInt(x: Int): Decimal = new Decimal().set(x)
     override def compare(x: Decimal, y: Decimal): Int = x.compare(y)
-    // Added from Scala 2.13; don't override to work in 2.12
-    // TODO revisit once Scala 2.12 support is dropped
     def parseString(str: String): Option[Decimal] = Try(Decimal(str)).toOption

Review Comment:
   I think this is meant to be `override` in Scala 2.13; does that work?



##########
sql/api/src/main/scala/org/apache/spark/sql/types/DoubleType.scala:
##########
@@ -40,34 +38,4 @@ class DoubleType private() extends FractionalType {
  * @since 1.3.0
  */
 @Stable
-case object DoubleType extends DoubleType {
-
-  // Traits below copied from Scala 2.12; not present in 2.13

Review Comment:
   In the previous PR that added these traits, were just these traits added for Scala 2.12/2.13? I am not sure if the object DoubleAsIfIntegral should be removed too



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/types/PhysicalDataType.scala:
##########
@@ -92,7 +92,6 @@ object PhysicalNumericType {
 
 sealed abstract class PhysicalFractionalType extends PhysicalNumericType {
   private[sql] val fractional: Fractional[InternalType]
-  private[sql] val asIntegral: Integral[InternalType]

Review Comment:
   What's the reason for removing this? I wasn't sure if this is related to Scala 2.12/2.13



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "srowen (via GitHub)" <gi...@apache.org>.
srowen closed pull request #43456: [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal
URL: https://github.com/apache/spark/pull/43456


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1781070727

   @panbingkun @srowen 
   Hi, hope to get your help. 
   If Scala 2.12 is completely removed and only Scala 2.13 is used, is it necessary to remove the `asIntegral` method from the interface and double and float?Because I think this method has not been used, I hope to keep the same design as Scala 2.13.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1788238152

   late LGTM.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1788247942

   It's strange that I haven't received any notification about this PR until today when I received the 'resolved' email on Jira.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1782342252

   > > @amaliujia cc. shoudl `asIntegral` be removed for PhysicalFractionalType, float and double , I find the method not be used. if shoudle not removed,should we add this. `implicit object DoubleIsFractional extends DoubleIsFractional with Ordering.DoubleOrdering` because it is in scala2.12. thanks.
   > 
   > We keep the methods for the completeness, even though they may not be used. So for the completeness we should keep those.
   
   Get it , I have roll back.
   By the way,do we need to redesign the double float based on `scala. path. Numeric. BigDecimalIsConflicted` in scala 2.13?It just seems like a slight difference
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "srowen (via GitHub)" <gi...@apache.org>.
srowen commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1368659888


##########
sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala:
##########
@@ -681,8 +681,6 @@ object Decimal {
     override def toLong(x: Decimal): Long = x.toLong
     override def fromInt(x: Int): Decimal = new Decimal().set(x)
     override def compare(x: Decimal, y: Decimal): Int = x.compare(y)
-    // Added from Scala 2.13; don't override to work in 2.12
-    // TODO revisit once Scala 2.12 support is dropped
     def parseString(str: String): Option[Decimal] = Try(Decimal(str)).toOption

Review Comment:
   Right, so shouldn't it be a `override` now?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1775200284

   @amaliujia cc.
   shoudl `asIntegral`  be removed for PhysicalFractionalType, float and double , I find the method not be used.
   if shoudle not removed,should we add this.
    `implicit object DoubleIsFractional extends DoubleIsFractional with Ordering.DoubleOrdering`
   because it is in scala2.12. 
   thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1774715007

   Let me correct my previous description. 
   Based on SPARK-30011,[SPARK-43110] [SQL] Move asIntegral to PhysicalDataType
   Revised. Removed the implementation of asIntegral in double and float because they were not called.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368]Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1771289209

   As a beginner, I read some of the code here,I am amazed by the type design and submitted a PR.
   Double and Float have removed the traits and directly inherited the traits of scala 2.13.
   The decimal code is quite extensive, and I don't have a deep understanding,It seems to me that just need to remove comment,maybe it's incorrect.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1773760515

   according to PR and `scala.math.Numeric.BigDecimalAsIfIntegral`
   https://github.com/apache/spark/pull/26769/files
   When we drop scala 2.12, all we just need to remove the comments.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "laglangyue (via GitHub)" <gi...@apache.org>.
laglangyue commented on code in PR #43456:
URL: https://github.com/apache/spark/pull/43456#discussion_r1373117603


##########
sql/api/src/main/scala/org/apache/spark/sql/types/DoubleType.scala:
##########
@@ -40,34 +38,4 @@ class DoubleType private() extends FractionalType {
  * @since 1.3.0
  */
 @Stable
-case object DoubleType extends DoubleType {
-
-  // Traits below copied from Scala 2.12; not present in 2.13

Review Comment:
   I have reviewed the previous changes and the code here, and here are my observations.
   method `asIntegral` is used for the DecimalType type to convert to Integral.
   In Scala 2.12, Float, Double, and Decimal belong to Fractional and Integral, which include XXXIsFractional, XXXAsIfIntegral, and XXXIsConflicted.
   
   In Scala 2.13, Decimal remains in its original form, while Float and Double are no longer Integral, all of thess Class were removed. 
   
   To ensure binary compatibility, we copied the code for Float and Double from 2.12, but since we have now removed 2.12, we can discard it completely. We have not used the asIntegral method for Float and Double.
   
   link these pr
   [SPARK-30011][SQL] Inline 2.12 "AsIfIntegral" classes, not present in 2.13
   [SPARK-43110][SQL] Move asIntegral to PhysicalDataType



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal [spark]

Posted by "srowen (via GitHub)" <gi...@apache.org>.
srowen commented on PR #43456:
URL: https://github.com/apache/spark/pull/43456#issuecomment-1787246774

   Merged to master


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org