diff --git a/core/src/main/scala/doric/syntax/NumericColumns.scala b/core/src/main/scala/doric/syntax/NumericColumns.scala index de9950c8a..eb7d1d4ba 100644 --- a/core/src/main/scala/doric/syntax/NumericColumns.scala +++ b/core/src/main/scala/doric/syntax/NumericColumns.scala @@ -28,6 +28,18 @@ private[syntax] trait NumericColumns { def *(other: DoricColumn[T]): DoricColumn[T] = sparkFunction(column, other, _ * _) + /** + * @group Numeric Type + */ + def /(other: DoricColumn[T]): DoricColumn[Double] = + sparkFunction(column, other, _ / _) + + /** + * @group Numeric Type + */ + def %(other: DoricColumn[T]): DoricColumn[T] = + sparkFunction(column, other, _ % _) + /** * @group Comparable Type */ diff --git a/core/src/test/scala/doric/syntax/NumericOperationsSpec.scala b/core/src/test/scala/doric/syntax/NumericOperationsSpec.scala index 37a47eebc..a689ca0e8 100644 --- a/core/src/test/scala/doric/syntax/NumericOperationsSpec.scala +++ b/core/src/test/scala/doric/syntax/NumericOperationsSpec.scala @@ -27,6 +27,12 @@ trait NumericOperationsSpec extends AnyFunSpecLike with TypedColumnTest { it("*") { test[T, T, T]((a, b) => a * b) } + it("/") { + test[T, T, Double]((a, b) => a / b) + } + it("%") { + test[T, T, T]((a, b) => a % b) + } it(">") { test[T, T, Boolean]((a, b) => a > b) } @@ -61,9 +67,15 @@ class NumericSpec extends NumericOperationsSpec with SparkSessionTestWrapper { import spark.implicits._ def df: DataFrame = - List((1, 2f, 3L)).toDF(getName[Int](), getName[Float](), getName[Long]()) + List((1, 2f, 3L, 4.toDouble)).toDF( + getName[Int](), + getName[Float](), + getName[Long](), + getName[Double]() + ) test[Int]() test[Float]() test[Long]() + test[Double]() }