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

Commit

Permalink
add missing codegen check
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Zhou <[email protected]>
  • Loading branch information
zhouyuan committed Aug 5, 2022
1 parent 5de484f commit 976a0a2
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class ColumnarAdd(left: Expression, right: Expression, original: Expression)
extends Add(left: Expression, right: Expression)
with ColumnarExpression
with Logging {
val gName = "add"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

// If casting between DecimalType, unnecessary cast is skipped to avoid data loss,
// because actually res type of "cast" is the res type in "add/subtract",
Expand Down Expand Up @@ -103,6 +110,14 @@ class ColumnarSubtract(left: Expression, right: Expression, original: Expression
with ColumnarExpression
with Logging {

val gName = "subtract"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

val left_val: Any = left match {
case c: ColumnarCast =>
if (c.child.dataType.isInstanceOf[DecimalType] &&
Expand Down Expand Up @@ -163,6 +178,14 @@ class ColumnarMultiply(left: Expression, right: Expression, original: Expression
with ColumnarExpression
with Logging {

val gName = "multiply"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

val left_val: Any = left match {
case c: ColumnarCast =>
if (c.child.dataType.isInstanceOf[DecimalType] &&
Expand Down Expand Up @@ -247,16 +270,20 @@ class ColumnarMultiply(left: Expression, right: Expression, original: Expression
}
}

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
return left_val.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) && right_val.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}
}

class ColumnarDivide(left: Expression, right: Expression,
original: Expression, resType: DecimalType = null)
extends Divide(left: Expression, right: Expression)
with ColumnarExpression
with Logging {
val gName = "divide"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

val left_val: Any = left match {
case c: ColumnarCast =>
Expand Down Expand Up @@ -349,6 +376,15 @@ class ColumnarBitwiseAnd(left: Expression, right: Expression, original: Expressi
extends BitwiseAnd(left: Expression, right: Expression)
with ColumnarExpression
with Logging {

val gName = "bitwise_and"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: Object): (TreeNode, ArrowType) = {
val (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand All @@ -370,6 +406,15 @@ class ColumnarBitwiseOr(left: Expression, right: Expression, original: Expressio
extends BitwiseOr(left: Expression, right: Expression)
with ColumnarExpression
with Logging {

val gName = "bitwise_or"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: Object): (TreeNode, ArrowType) = {
val (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ class ColumnarGetJsonObject(left: Expression, right: Expression, original: GetJs
class ColumnarStringInstr(left: Expression, right: Expression, original: StringInstr)
extends StringInstr(original.str, original.substr) with ColumnarExpression with Logging {

val gName = "locate"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: Object): (TreeNode, ArrowType) = {
val (left_node, _): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ class ColumnarStartsWith(left: Expression, right: Expression, original: Expressi
extends StartsWith(left: Expression, right: Expression)
with ColumnarExpression
with Logging {
val gName = "starts_with"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: java.lang.Object): (TreeNode, ArrowType) = {
val (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand All @@ -121,6 +129,14 @@ class ColumnarLike(left: Expression, right: Expression, original: Expression)
with ColumnarExpression
with Logging {

val gName = "like"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

buildCheck()

def buildCheck(): Unit = {
Expand Down Expand Up @@ -154,7 +170,14 @@ class ColumnarRLike(left: Expression, right: Expression, original: Expression)
extends RLike(left: Expression, right: Expression)
with ColumnarExpression
with Logging {
val gName = "equal"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

buildCheck()

def buildCheck(): Unit = {
Expand All @@ -164,10 +187,6 @@ class ColumnarRLike(left: Expression, right: Expression, original: Expression)
}
}

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

override def doColumnarCodeGen(args: java.lang.Object): (TreeNode, ArrowType) = {
val (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand Down Expand Up @@ -206,6 +225,14 @@ class ColumnarEqualTo(left: Expression, right: Expression, original: Expression)
extends EqualTo(left: Expression, right: Expression)
with ColumnarExpression
with Logging {
val gName = "equal"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: java.lang.Object): (TreeNode, ArrowType) = {
var (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand Down Expand Up @@ -305,8 +332,11 @@ class ColumnarLessThan(left: Expression, right: Expression, original: Expression
with ColumnarExpression
with Logging {

val gName = "less_than"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
true && left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

Expand Down Expand Up @@ -352,6 +382,14 @@ class ColumnarLessThanOrEqual(left: Expression, right: Expression, original: Exp
extends LessThanOrEqual(left: Expression, right: Expression)
with ColumnarExpression
with Logging {
val gName = "less_than_or_equal_to"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: java.lang.Object): (TreeNode, ArrowType) = {
var (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand Down Expand Up @@ -396,6 +434,15 @@ class ColumnarGreaterThan(left: Expression, right: Expression, original: Express
extends GreaterThan(left: Expression, right: Expression)
with ColumnarExpression
with Logging {

val gName = "greater_than"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: java.lang.Object): (TreeNode, ArrowType) = {
var (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand Down Expand Up @@ -440,6 +487,14 @@ class ColumnarGreaterThanOrEqual(left: Expression, right: Expression, original:
extends GreaterThanOrEqual(left: Expression, right: Expression)
with ColumnarExpression
with Logging {
val gName = "greater_than_or_equal_to"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: java.lang.Object): (TreeNode, ArrowType) = {
var (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand Down Expand Up @@ -484,6 +539,15 @@ class ColumnarShiftLeft(left: Expression, right: Expression, original: Expressio
extends ShiftLeft(left: Expression, right: Expression)
with ColumnarExpression
with Logging {

val gName = "shift_left"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: Object): (TreeNode, ArrowType) = {
var (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand All @@ -506,6 +570,15 @@ class ColumnarShiftRight(left: Expression, right: Expression, original: Expressi
extends ShiftRight(left: Expression, right: Expression)
with ColumnarExpression
with Logging {

val gName = "shift_right"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
left.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
right.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

override def doColumnarCodeGen(args: Object): (TreeNode, ArrowType) = {
val (left_node, left_type): (TreeNode, ArrowType) =
left.asInstanceOf[ColumnarExpression].doColumnarCodeGen(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ object ColumnarDateTimeExpressions {

class ColumnarYear(child: Expression) extends Year(child) with
ColumnarExpression {
val gName = "extractYear"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
child.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

buildCheck()

Expand Down Expand Up @@ -420,6 +426,12 @@ object ColumnarDateTimeExpressions {

class ColumnarMicrosToTimestamp(child: Expression) extends MicrosToTimestamp(child) with
ColumnarExpression {
val gName = "micros_to_timestamp"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
child.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

buildCheck()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import scala.collection.mutable.ListBuffer
trait ColumnarExpression {

val codegenFuncList: List[String] = List(
"less_than",
"less_than",
"less_than_with_nan",
"greater_than",
"greater_than_with_nan",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class ColumnarRound(child: Expression, scale: Expression, original: Expression)
extends Round(child: Expression, scale: Expression)
with ColumnarExpression
with Logging {
val gName = "round"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
child.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
scale.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

buildCheck()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class ColumnarStringTrim(srcStr: Expression, trimStr: Option[Expression], origin
extends StringTrim(srcStr: Expression, trimStr: Option[Expression])
with ColumnarExpression
with Logging {
val gName = "btrim"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
srcStr.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
trimStr.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}

buildCheck()

Expand Down Expand Up @@ -63,7 +70,13 @@ class ColumnarStringTrimLeft(srcStr: Expression, trimStr: Option[Expression], or
extends StringTrimLeft(srcStr: Expression, trimStr: Option[Expression])
with ColumnarExpression
with Logging {
val gName = "ltrim"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
srcStr.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
trimStr.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}
buildCheck()

def buildCheck(): Unit = {
Expand Down Expand Up @@ -93,7 +106,13 @@ class ColumnarStringTrimRight(child: Expression, trimStr: Option[Expression], or
extends StringTrimRight(child: Expression, trimStr: Option[Expression])
with ColumnarExpression
with Logging {
val gName = "rtrim"

override def supportColumnarCodegen(args: java.lang.Object): Boolean = {
codegenFuncList.contains(gName) &&
srcStr.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args) &&
trimStr.asInstanceOf[ColumnarExpression].supportColumnarCodegen(args)
}
buildCheck()

def buildCheck(): Unit = {
Expand Down
Loading

0 comments on commit 976a0a2

Please sign in to comment.