Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7035#discussion_r33772164
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/math.scala
 ---
    @@ -187,6 +188,162 @@ case class Rint(child: Expression) extends 
UnaryMathExpression(math.rint, "ROUND
       override def funcName: String = "rint"
     }
     
    +abstract class BitwiseShiftExpression
    +  extends Expression with trees.BinaryNode[Expression] {
    +  self: Product =>
    +
    +  def symbol: String = sys.error(s"BitwiseShiftExpression must override 
symbol")
    +
    +  override def nullable: Boolean = true
    +
    +  override def checkInputDataTypes(): TypeCheckResult = {
    +    if (!Seq(ByteType, ShortType, IntegerType, LongType, 
NullType).contains(left.dataType)
    +      || !(right.dataType.isInstanceOf[IntegerType] || right.dataType == 
NullType)
    +    ) {
    +      TypeCheckResult.TypeCheckFailure(
    +        s"Incorrect data types for $symbol(${left.dataType}, 
${right.dataType}})")
    +    } else {
    +      TypeCheckResult.TypeCheckSuccess
    +    }
    +  }
    +
    +  override def dataType: DataType = left.dataType match {
    +    case ByteType | ShortType | IntegerType => IntegerType
    +    case LongType => LongType
    +    case NullType => NullType
    +  }
    +
    +  protected def defineCodeGen(ctx: CodeGenContext,
    +                            ev: GeneratedExpressionCode,
    +                            f: (String, String) => String): String = {
    +    val eval1 = left.gen(ctx)
    +    val eval2 = right.gen(ctx)
    +    val resultCode = f(eval1.primitive, eval2.primitive)
    +
    +    s"""
    +      ${eval1.code}
    +      boolean ${ev.isNull} = ${eval1.isNull};
    +      ${ctx.javaType(dataType)} ${ev.primitive} = 
${ctx.defaultValue(dataType)};
    +      if (!${ev.isNull}) {
    +        ${eval2.code}
    +        if (!${eval2.isNull}) {
    +          ${ev.primitive} = $resultCode;
    +        } else {
    +          ${ev.isNull} = true;
    +        }
    +      }
    +    """
    +  }
    +}
    +
    +case class ShiftLeft(valueExpr: Expression, bitsExpr: Expression)
    --- End diff --
    
    Can you also add the doc for the classes?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to