Skip to content

Commit

Permalink
resolve comments: classOf
Browse files Browse the repository at this point in the history
  • Loading branch information
yjshen committed Jul 21, 2015
1 parent 39cefb8 commit 5e90f0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.sql.catalyst.expressions

import scala.collection.mutable

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
import org.apache.spark.sql.catalyst.expressions.codegen.{GeneratedExpressionCode, CodeGenContext}
Expand Down Expand Up @@ -46,7 +48,7 @@ case class CreateArray(children: Seq[Expression]) extends Expression {
}

override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String = {
val arraySeqClass = "scala.collection.mutable.ArraySeq"
val arraySeqClass = classOf[mutable.ArraySeq[Any]].getName
s"""
boolean ${ev.isNull} = false;
$arraySeqClass<Object> ${ev.primitive} = new $arraySeqClass<Object>(${children.size});
Expand Down Expand Up @@ -94,7 +96,7 @@ case class CreateStruct(children: Seq[Expression]) extends Expression {
}

override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String = {
val rowClass = "org.apache.spark.sql.catalyst.expressions.GenericMutableRow"
val rowClass = classOf[GenericMutableRow].getName
s"""
boolean ${ev.isNull} = false;
final $rowClass ${ev.primitive} = new $rowClass(${children.size});
Expand Down Expand Up @@ -158,7 +160,7 @@ case class CreateNamedStruct(children: Seq[Expression]) extends Expression {
}

override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): String = {
val rowClass = "org.apache.spark.sql.catalyst.expressions.GenericMutableRow"
val rowClass = classOf[GenericMutableRow].getName
s"""
boolean ${ev.isNull} = false;
final $rowClass ${ev.primitive} = new $rowClass(${valExprs.size});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ class ComplexTypeSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(CreateArray(intSeq.map(Literal(_))), intSeq, EmptyRow)
checkEvaluation(CreateArray(longSeq.map(Literal(_))), longSeq, EmptyRow)
checkEvaluation(CreateArray(strSeq.map(Literal(_))), strSeq, EmptyRow)

val intWithNull = intSeq.map(Literal(_)).+:(Literal.create(null, IntegerType))
val longWithNull = longSeq.map(Literal(_)).+:(Literal.create(null, LongType))
val strWithNull = strSeq.map(Literal(_)).+:(Literal.create(null, StringType))
checkEvaluation(CreateArray(intWithNull), intSeq.+:(null), EmptyRow)
checkEvaluation(CreateArray(longWithNull), longSeq.+:(null), EmptyRow)
checkEvaluation(CreateArray(strWithNull), strSeq.+:(null), EmptyRow)
}

test("CreateStruct") {
Expand Down

0 comments on commit 5e90f0a

Please sign in to comment.