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-8203] [SPARK-8204] [SQL] conditional function: least/greatest #6851

Closed
wants to merge 6 commits into from

Conversation

adrian-wang
Copy link
Contributor

@@ -134,4 +134,21 @@ class ConditionalExpressionSuite extends SparkFunSuite with ExpressionEvalHelper
checkEvaluation(CaseKeyWhen(literalNull, Seq(c2, c5, c1, c6)), "c", row)
}

test("greatest/least") {
val row = create_row(1, 2, "a", "b", "c")
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to test this for all data types.

@chenghao-intel
Copy link
Contributor

Don't forget to implement the def foldable.

@SparkQA
Copy link

SparkQA commented Jun 17, 2015

Test build #35027 has finished for PR 6851 at commit 3e25c6c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class Least(children: Expression*)
    • case class Greatest(children: Expression*)

@SparkQA
Copy link

SparkQA commented Jul 9, 2015

Test build #36926 has finished for PR 6851 at commit e478369.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class Least(children: Expression*) extends Expression
    • case class Greatest(children: Expression*) extends Expression

greatest((columnName +: columnNames).map(Column.apply): _*)

/**
* Computes hex value of the given column
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:
/**

  • Computes hex value for the given column.
    *

@chenghao-intel
Copy link
Contributor

Can you rebase the code?

@SparkQA
Copy link

SparkQA commented Jul 10, 2015

Test build #36999 has finished for PR 6851 at commit c1f6824.

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

@adrian-wang adrian-wang changed the title [SPARK-8203] [SPARK-8204] [WIP] [SQL] conditional function: least/greatest [SPARK-8203] [SPARK-8204] [SQL] conditional function: least/greatest Jul 10, 2015
@SparkQA
Copy link

SparkQA commented Jul 10, 2015

Test build #37001 has finished for PR 6851 at commit 7a6bdbb.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class Least(children: Expression*) extends Expression
    • case class Greatest(children: Expression*) extends Expression

@adrian-wang
Copy link
Contributor Author

retest this please.

@SparkQA
Copy link

SparkQA commented Jul 10, 2015

Test build #37011 has finished for PR 6851 at commit 7a6bdbb.

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

@adrian-wang
Copy link
Contributor Author

retest this please.

@SparkQA
Copy link

SparkQA commented Jul 10, 2015

Test build #37012 has finished for PR 6851 at commit 7a6bdbb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class Least(children: Expression*) extends Expression
    • case class Greatest(children: Expression*) extends Expression

@adrian-wang
Copy link
Contributor Author

@rxin @davies

* @since 1.5.0
*/
@scala.annotation.varargs
def greatest(exprs: Column*): Column = Greatest(exprs.map(_.expr): _*)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check that exprs have at least two columns? Also for others, it's good to fail fast.

@SparkQA
Copy link

SparkQA commented Jul 13, 2015

Test build #37117 has finished for PR 6851 at commit 0f1bff2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class Least(children: Expression*) extends Expression
    • case class Greatest(children: Expression*) extends Expression

@adrian-wang
Copy link
Contributor Author

cc @davies

@davies
Copy link
Contributor

davies commented Jul 13, 2015

LGTM, merging this into master, thanks!

@@ -312,3 +313,103 @@ case class CaseKeyWhen(key: Expression, branches: Seq[Expression]) extends CaseW
}.mkString
}
}

case class Least(children: Expression*) extends Expression {
Copy link
Contributor

Choose a reason for hiding this comment

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

note: this should be Seq[Expression], not vararg

dbtsai pushed a commit to dbtsai/spark that referenced this pull request Jul 13, 2015
chenghao-intel zhichao-li qiansl127

Author: Daoyuan Wang <daoyuan.wang@intel.com>

Closes apache#6851 from adrian-wang/udflg and squashes the following commits:

0f1bff2 [Daoyuan Wang] address comments from davis
7a6bdbb [Daoyuan Wang] add '.' for hex()
c1f6824 [Daoyuan Wang] add codegen, test for all types
ec625b0 [Daoyuan Wang] conditional function: least/greatest
@adrian-wang
Copy link
Contributor Author

oh, it seems this pr has been merged but stay unclosed...
@davies @rxin

@srowen
Copy link
Member

srowen commented Jul 13, 2015

@adrian-wang probably a sync problem. It was evidently merged into master. You can just close it too.

@SparkQA
Copy link

SparkQA commented Jul 13, 2015

Test build #37132 has finished for PR 6851 at commit 22e8f3d.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class Least(children: Seq[Expression]) extends Expression
    • case class Greatest(children: Seq[Expression]) extends Expression

@@ -312,3 +313,103 @@ case class CaseKeyWhen(key: Expression, branches: Seq[Expression]) extends CaseW
}.mkString
}
}

case class Least(children: Seq[Expression]) extends Expression {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add scaladoc explaining the semantics of this expression? also do it for greatest.

@rxin
Copy link
Contributor

rxin commented Jul 13, 2015

@adrian-wang I found that happening quite a bit lately. Can you close the pr and just submit followup patches to address my comments? thanks.

adrian-wang added a commit that referenced this pull request Jul 14, 2015
This is a follow up of remaining comments from #6851

Author: Daoyuan Wang <daoyuan.wang@intel.com>

Closes #7387 from adrian-wang/udflgfollow and squashes the following commits:

6163e62 [Daoyuan Wang] add skipping null values
e8c2e09 [Daoyuan Wang] use seq
8362966 [Daoyuan Wang] pr6851 follow up
private lazy val ordering = TypeUtils.getOrdering(dataType)

override def checkInputDataTypes(): TypeCheckResult = {
if (children.map(_.dataType).distinct.count(_ != NullType) > 1) {
Copy link
Member

Choose a reason for hiding this comment

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

Why count against not NullType? any reason here?

Copy link
Contributor

Choose a reason for hiding this comment

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

i think the problem is that null literals are not converted into any non-null type when it happens in greatest.

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

Successfully merging this pull request may close these issues.

7 participants