Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
[NSE-955] Support remainder function (#1022)
Browse files Browse the repository at this point in the history
* Initial commit

* Change arrow branch [will revert at last]

* Refine the code

* Ignore a UT

* Revert "Change arrow branch [will revert at last]"

This reverts commit 60a7b34.
  • Loading branch information
PHILO-HE authored Jul 15, 2022
1 parent 0365b7c commit df51fe6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,38 @@ class ColumnarPmod(left: Expression, right: Expression, original: Expression)
}
}

class ColumnarRemainder(left: Expression, right: Expression, original: Expression)
extends Remainder(left, right) with ColumnarExpression with Logging {

buildCheck

def buildCheck(): Unit = {
val supportTypes = List(ByteType, ShortType, IntegerType, LongType, FloatType, DoubleType)
if (supportTypes.indexOf(left.dataType) == -1) {
throw new UnsupportedOperationException(s"The left input type for remainder is" +
s" not supported: ${left.dataType}")
}
if (supportTypes.indexOf(right.dataType) == -1) {
throw new UnsupportedOperationException(s"The right input type for remainder is" +
s" not supported: ${right.dataType}")
}
}

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
false
}

override def doColumnarCodeGen(args: Object): (TreeNode, ArrowType) = {
val (leftNode, leftInputType): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val (rightNode, _): (TreeNode, ArrowType) =
right.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
val outputType = leftInputType
(TreeBuilder.makeFunction("mod",
Lists.newArrayList(leftNode, rightNode), outputType), outputType)
}
}

object ColumnarBinaryArithmetic {

def create(left: Expression, right: Expression, original: Expression): Expression = {
Expand All @@ -458,6 +490,8 @@ object ColumnarBinaryArithmetic {
new ColumnarBitwiseXor(left, right, x)
case pmod: Pmod =>
new ColumnarPmod(left, right, pmod)
case remainder: Remainder =>
new ColumnarRemainder(left, right, remainder)
case other =>
throw new UnsupportedOperationException(s"not currently supported: $other.")
}
Expand Down
3 changes: 2 additions & 1 deletion native-sql-engine/tools/failed_ut_list.log
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@
- SPARK-23786: warning should be printed if CSV header doesn't conform to schema *** FAILED ***
- SPARK-23786: warning should be printed if CSV header doesn't conform to schema *** FAILED ***
- SPARK-30886 Deprecate two-parameter TRIM/LTRIM/RTRIM *** FAILED ***
- test log level *** FAILED ***
- test log level *** FAILED ***
- SPARK-25602: SparkPlan.getByteArrayRdd should not consume the input when not necessary *** FAILED ***

0 comments on commit df51fe6

Please sign in to comment.