This is an automated email from the ASF dual-hosted git repository.
srowen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 102daf9d149 [SPARK-45368][SQL] Remove scala2.12 compatibility logic
for DoubleType, FloatType, Decimal
102daf9d149 is described below
commit 102daf9d1490d12b812be4432c77ce102e82c3bb
Author: tangjiafu <[email protected]>
AuthorDate: Tue Oct 31 08:42:46 2023 -0500
[SPARK-45368][SQL] Remove scala2.12 compatibility logic for DoubleType,
FloatType, Decimal
### What changes were proposed in this pull request?
Remove scala2.12 compatibility logic for DoubleType, FloatType, Decimal
### Why are the changes needed?
Drop Scala 2.12 and make Scala 2.13 by default
https://issues.apache.org/jira/browse/SPARK-45368
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
test by ci
### Was this patch authored or co-authored using generative AI tooling?
no
Closes #43456 from laglangyue/f_SPARK-45368_scala12_dataType.
Lead-authored-by: tangjiafu <[email protected]>
Co-authored-by: laglangyue <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
---
sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala | 4 +---
sql/api/src/main/scala/org/apache/spark/sql/types/DoubleType.scala | 5 +----
sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala | 5 +----
3 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala
b/sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala
index afe73635a68..3ce0508951f 100644
--- a/sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala
+++ b/sql/api/src/main/scala/org/apache/spark/sql/types/Decimal.scala
@@ -681,9 +681,7 @@ 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
+ override def parseString(str: String): Option[Decimal] =
Try(Decimal(str)).toOption
}
/** A [[scala.math.Fractional]] evidence parameter for Decimals. */
diff --git a/sql/api/src/main/scala/org/apache/spark/sql/types/DoubleType.scala
b/sql/api/src/main/scala/org/apache/spark/sql/types/DoubleType.scala
index d18c7b98af2..bc0ed725cf2 100644
--- a/sql/api/src/main/scala/org/apache/spark/sql/types/DoubleType.scala
+++ b/sql/api/src/main/scala/org/apache/spark/sql/types/DoubleType.scala
@@ -42,8 +42,6 @@ class DoubleType private() extends FractionalType {
@Stable
case object DoubleType extends DoubleType {
- // Traits below copied from Scala 2.12; not present in 2.13
- // TODO: SPARK-30011 revisit once Scala 2.12 support is dropped
trait DoubleIsConflicted extends Numeric[Double] {
def plus(x: Double, y: Double): Double = x + y
def minus(x: Double, y: Double): Double = x - y
@@ -56,8 +54,7 @@ case object DoubleType extends DoubleType {
def toDouble(x: Double): Double = x
// logic in Numeric base trait mishandles abs(-0.0)
override def abs(x: Double): Double = math.abs(x)
- // Added from Scala 2.13; don't override to work in 2.12
- def parseString(str: String): Option[Double] =
+ override def parseString(str: String): Option[Double] =
Try(java.lang.Double.parseDouble(str)).toOption
}
diff --git a/sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala
b/sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala
index 978384eebfe..8b54f830d48 100644
--- a/sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala
+++ b/sql/api/src/main/scala/org/apache/spark/sql/types/FloatType.scala
@@ -43,8 +43,6 @@ 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
trait FloatIsConflicted extends Numeric[Float] {
def plus(x: Float, y: Float): Float = x + y
def minus(x: Float, y: Float): Float = x - y
@@ -57,8 +55,7 @@ case object FloatType extends FloatType {
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] =
+ override def parseString(str: String): Option[Float] =
Try(java.lang.Float.parseFloat(str)).toOption
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]