Skip to content

Commit

Permalink
fix: testing
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizalo committed Aug 16, 2023
1 parent ac5a787 commit 235709e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
3 changes: 2 additions & 1 deletion core/src/main/scala/doric/syntax/NumericColumns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ protected trait NumericColumns {
*
* @todo decimal type
* @group Numeric Type
* @see [[org.apache.spark.sql.functions.round(e:org\.apache\.spark\.sql\.Column,scale:* org.apache.spark.sql.functions.round]]
* @see org.apache.spark.sql.functions.round
* @todo scaladoc link (issue #135)
*/
def round(scale: IntegerColumn): DoricColumn[T] = (column.elem, scale.elem)
.mapN((c, s) => new Column(Round(c.expr, s.expr)))
Expand Down
10 changes: 0 additions & 10 deletions core/src/test/scala/doric/syntax/NumericOperationsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,6 @@ trait NumericOperationsSpec
)
}

it(s"round function with scale and round mode") {
val scale = 2
val mode = BigDecimal.RoundingMode.FLOOR
testOnlyDoricDecimals[T, T](
List(Some(1.466666f), Some(0.7111111f), Some(1.0f), None),
List(Some(1.46f), Some(0.71f), Some(1.0f), None),
_.round(scale.lit, mode)
)
}

it(s"naNvl function with param") {
testDoricSparkDecimals2[T, T, T](
List(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import doric.Equalities._
import doric.types.NumericType
import doric.types.SparkType.Primitive
import java.sql.Timestamp
import org.scalactic.Equality
import org.scalatest.funspec.AnyFunSpecLike

import org.apache.spark.sql.{DataFrame, SparkSession, functions => f}
Expand All @@ -19,7 +20,7 @@ trait NumericOperations31Spec
def df: DataFrame

import scala.reflect.runtime.universe._
def test[T: NumericType: Primitive: ClassTag: TypeTag]()(implicit
def test[T: NumericType: Primitive: ClassTag: TypeTag: Equality]()(implicit
spark: SparkSession,
fun: FromInt[T]
): Unit = {
Expand Down Expand Up @@ -48,7 +49,7 @@ trait NumericOperations31Spec
}
}

def testDecimals[T: NumWithDecimalsType: Primitive: ClassTag: TypeTag]()(
def testDecimals[T: NumWithDecimalsType: Primitive: ClassTag: TypeTag: Equality]()(
implicit
spark: SparkSession,
fun: FromFloat[T]
Expand All @@ -64,14 +65,22 @@ trait NumericOperations31Spec
f.atanh
)
}

it(s"round function with scale and round mode") {
val scale = 2
val mode = BigDecimal.RoundingMode.FLOOR
testOnlyDoricDecimals[T, T](
List(Some(1.466666f), Some(0.7111111f), Some(1.0f), None),
List(Some(1.46f), Some(0.71f), Some(1.0f), None),
_.round(scale.lit, mode)
)
}
}
}
}

class Numeric31Spec
extends SparkSessionTestWrapper
with AnyFunSpecLike
with TypedColumnTest
with NumericOperations31Spec {

import spark.implicits._
Expand Down

0 comments on commit 235709e

Please sign in to comment.