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-8195] [SPARK-8196] [SQL] udf next_day last_day #6986

Closed
wants to merge 6 commits into from

Conversation

adrian-wang
Copy link
Contributor

next_day, returns next certain dayofweek.
last_day, returns the last day of the month which given date belongs to.

@SparkQA
Copy link

SparkQA commented Jun 24, 2015

Test build #35677 has finished for PR 6986 at commit 5ef6a8c.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class LastDay(startDate: Expression) extends Expression
    • case class NextDay(startDate: Expression, dayOfWeek: Expression) extends Expression

@adrian-wang
Copy link
Contributor Author

Close it because #6782 (comment) for now

@adrian-wang adrian-wang reopened this Jul 23, 2015
@SparkQA
Copy link

SparkQA commented Jul 23, 2015

Test build #38195 has finished for PR 6986 at commit 5ef6a8c.

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

@SparkQA
Copy link

SparkQA commented Jul 23, 2015

Test build #38197 has finished for PR 6986 at commit 1a9de3d.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class NextDay(left: Expression, right: Expression)

@adrian-wang adrian-wang changed the title [SPARK-8195] [SPARK-8196] [WIP] [SQL] udf next_day last_day [SPARK-8195] [SPARK-8196] [SQL] udf next_day last_day Jul 23, 2015
@SparkQA
Copy link

SparkQA commented Jul 23, 2015

Test build #38203 has finished for PR 6986 at commit 2d0629b.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class NextDay(left: Expression, right: Expression)

@adrian-wang
Copy link
Contributor Author

@SparkQA
Copy link

SparkQA commented Jul 24, 2015

Test build #38382 has finished for PR 6986 at commit d09bcce.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class NextDay(left: Expression, right: Expression)

/**
* Returns the last day of the month which the date belongs to.
*/
case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a prettyName last_day

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@SparkQA
Copy link

SparkQA commented Jul 27, 2015

Test build #38533 has finished for PR 6986 at commit 8846086.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class NextDay(startDate: Expression, dayOfWeek: Expression)

@@ -246,4 +247,19 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
}
}

test("last_day") {
checkEvaluation(LastDay(Literal(Date.valueOf("2015-07-23"))), Date.valueOf("2015-07-31"))
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 please add more unit tests?

you should test one for each month, and also test the leap years.

@rxin
Copy link
Contributor

rxin commented Jul 27, 2015

@adrian-wang I think this one is pretty close - we need to add more user facing documentation and internal comments, as well as unit tests.

Thanks.

* @group datetime_funcs
* @since 1.5.0
*/
def next_day(sd: Column, dayOfWeek: Column): Column = NextDay(sd.expr, dayOfWeek.expr)
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 it is ok to not support that in the data frame api, since it is very unlikely somebody will be using a non literal.

@rxin
Copy link
Contributor

rxin commented Jul 28, 2015

Can you address these two issues?

@@ -2392,6 +2399,16 @@ object functions {
def minute(columnName: String): Column = minute(Column(columnName))

/**
* Returns the first date which is later than given date sd and named as dow.
* For example, next_day('2015-07-27', 'Sunday') would return 2015-08-02, which is the
Copy link
Contributor

Choose a reason for hiding this comment

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

quote next_day ... in backticks

@adrian-wang
Copy link
Contributor Author

done

@rxin
Copy link
Contributor

rxin commented Jul 28, 2015

LGTM

@SparkQA
Copy link

SparkQA commented Jul 28, 2015

Test build #38634 has finished for PR 6986 at commit 02b3426.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class NextDay(startDate: Expression, dayOfWeek: Expression)

@SparkQA
Copy link

SparkQA commented Jul 28, 2015

Test build #38645 has finished for PR 6986 at commit ef7e3da.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class NextDay(startDate: Expression, dayOfWeek: Expression)

@SparkQA
Copy link

SparkQA commented Jul 28, 2015

Test build #38627 has finished for PR 6986 at commit dc69630.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class NextDay(startDate: Expression, dayOfWeek: Expression)

@rxin
Copy link
Contributor

rxin commented Jul 28, 2015

Thanks - I've merged this.

@asfgit asfgit closed this in 2e7f99a Jul 28, 2015
Seq(Row(Date.valueOf("2015-07-27")), Row(Date.valueOf("2015-07-27"))))
checkAnswer(
df2.select(next_day(col("t"), "th")),
Seq(Row(Date.valueOf("2015-07-30")), Row(null)))
Copy link
Contributor

Choose a reason for hiding this comment

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

note that this actually fails unit tests. I thought it passed but it was from a previous commit.

Can you please pay a little bit more attention in the future and at least run your own unit tests locally? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for that...

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.

4 participants