Skip to content

Commit

Permalink
Remove some half finished functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
marmbrus committed Jul 9, 2014
1 parent 92e74a4 commit efad14f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ abstract class CodeGenerator extends Logging {
case EqualTo(e1, e2) =>
(e1, e2).evaluateAs (BooleanType) { case (eval1, eval2) => q"$eval1 == $eval2" }

/* TODO: Fix null semantics.
case In(e1, list) if !list.exists(!_.isInstanceOf[expressions.Literal]) =>
val eval = expressionEvaluator(e1)
Expand All @@ -238,6 +239,7 @@ abstract class CodeGenerator extends Logging {
val $nullTerm = false
val $primitiveTerm = $funcName
""".children
*/

case GreaterThan(e1 @ NumericType(), e2 @ NumericType()) =>
(e1, e2).evaluateAs (BooleanType) { case (eval1, eval2) => q"$eval1 > $eval2" }
Expand Down Expand Up @@ -352,27 +354,6 @@ abstract class CodeGenerator extends Logging {
$primitiveTerm = ${falseEval.primitiveTerm}
}
""".children

case SubString(str, start, end) =>
val stringEval = expressionEvaluator(str)
val startEval = expressionEvaluator(start)
val endEval = expressionEvaluator(end)

stringEval.code ++ startEval.code ++ endEval.code ++
q"""
var $nullTerm = ${stringEval.nullTerm}
var $primitiveTerm: String =
if($nullTerm) {
null
} else {
val len =
if(${endEval.primitiveTerm} <= ${stringEval.primitiveTerm}.length)
${endEval.primitiveTerm}
else
${stringEval.primitiveTerm}.length
${stringEval.primitiveTerm}.substring(${startEval.primitiveTerm}, len)
}
""".children
}

// If there was no match in the partial function above, we fall back on calling the interpreted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ import org.apache.spark.sql.catalyst.types.DataType
import org.apache.spark.sql.catalyst.types.StringType
import org.apache.spark.sql.catalyst.types.BooleanType

case class SubString(string: Expression, start: Expression, end: Expression) extends Expression {
def children = string :: start :: end :: Nil
def references = children.flatMap(_.references).toSet
def dataType = StringType
def nullable = string.nullable

override def eval(input: Row) = ???

override def toString = s"substr($string, $start, $end"
}

trait StringRegexExpression {
self: BinaryExpression =>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,6 @@ private[hive] object HiveQl {
IsNull(nodeToExpr(child))
case Token("TOK_FUNCTION", Token(IN(), Nil) :: value :: list) =>
In(nodeToExpr(value), list.map(nodeToExpr))
case Token("TOK_FUNCTION", Token(SUBSTR(), Nil) :: str :: start :: end :: Nil) =>
SubString(nodeToExpr(str), nodeToExpr(start), nodeToExpr(end))
case Token("TOK_FUNCTION",
Token(BETWEEN(), Nil) ::
Token("KW_FALSE", Nil) ::
Expand Down

0 comments on commit efad14f

Please sign in to comment.