Skip to content

Commit

Permalink
Try to fix compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
tedyu committed Aug 10, 2016
1 parent 6e4fe06 commit edb69ac
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ case class MonotonicallyIncreasingID(offset: Long = 0) extends LeafExpression
this(offset = 0)
}

def this(offset: Expression) = {
this(offset = parseExpression(offset))
def this(offset: Expression) = offset match {
case IntegerLiteral(i) => this(offset = i.toLong)
case NonNullLiteral(l, LongType) => this(offset = l.toString.toLong)
case _ => throw new AnalysisException("The offset must be " +
"an integer or long literal.")
}

/**
Expand All @@ -69,13 +72,6 @@ case class MonotonicallyIncreasingID(offset: Long = 0) extends LeafExpression

override def dataType: DataType = LongType

private def parseExpression(expr: Expression): Long = expr match {
case IntegerLiteral(i) => i.toLong
case NonNullLiteral(l, LongType) => l.toString.toLong
case _ => throw new AnalysisException("The offset must be " +
"an integer or long literal.")
}

override protected def evalInternal(input: InternalRow): Long = {
val currentCount = count
count += 1
Expand Down

0 comments on commit edb69ac

Please sign in to comment.