Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7805#discussion_r35941994
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
 ---
    @@ -779,4 +779,38 @@ object DateTimeUtils {
         }
         date + (lastDayOfMonthInYear - dayInYear)
       }
    +
    +  private val TRUNC_TO_YEAR = 1
    +  private val TRUNC_TO_MONTH = 2
    +  private val TRUNC_INVALID = -1
    +
    +  /**
    +   * Returns the trunc date from original date and trunc level.
    +   * Trunc level should be generated using `parseTruncLevel()`, should 
only be 1 or 2.
    +   */
    +  def truncDate(d: Int, level: Int): Int = {
    +    if (level == TRUNC_TO_YEAR) {
    +      d - DateTimeUtils.getDayInYear(d) + 1
    +    } else if (level == TRUNC_TO_MONTH) {
    +      d - DateTimeUtils.getDayOfMonth(d) + 1
    +    } else {
    +      throw new Exception(s"Invalid trunc level: $level")
    --- End diff --
    
    sys.error("...")
    
    and add a comment explaining this should never be hit because trunc level 
is internally generated.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to