Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-9165][SQL] codegen for CreateArray, CreateStruct and CreateNamedStruct #7537

Closed
wants to merge 3 commits into from

Conversation

yjshen
Copy link
Member

@yjshen yjshen commented Jul 20, 2015

@yjshen
Copy link
Member Author

yjshen commented Jul 20, 2015

/cc @rxin

@SparkQA
Copy link

SparkQA commented Jul 21, 2015

Test build #1133 has finished for PR 7537 at commit 39cefb8.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

val strSeq = intSeq.map(_.toString)
checkEvaluation(CreateArray(intSeq.map(Literal(_))), intSeq, EmptyRow)
checkEvaluation(CreateArray(longSeq.map(Literal(_))), longSeq, EmptyRow)
checkEvaluation(CreateArray(strSeq.map(Literal(_))), strSeq, EmptyRow)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a test that includes null values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added below.

@yjshen
Copy link
Member Author

yjshen commented Jul 21, 2015

Thanks @marmbrus , I would update my code soon.

@SparkQA
Copy link

SparkQA commented Jul 21, 2015

Test build #1142 has finished for PR 7537 at commit 39cefb8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class CreateArray(children: Seq[Expression]) extends Expression
    • case class CreateStruct(children: Seq[Expression]) extends Expression
    • case class CreateNamedStruct(children: Seq[Expression]) extends Expression

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to nit-pick, but what is happening here is kind of confusing:

scala> List(1,2).+:(null)
res0: List[Any] = List(null, 1, 2)

Perhaps just use infix notation for operators:

scala> List(1,2) :+ null
res1: List[Any] = List(1, 2, null)

@asfgit asfgit closed this in 86f80e2 Jul 22, 2015
@marmbrus
Copy link
Contributor

Thanks! Merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants