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

    https://github.com/apache/spark/pull/12147#discussion_r58429851
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
 ---
    @@ -262,19 +270,82 @@ object SpecifiedWindowFrame {
        */
       def defaultWindowFrame(
           hasOrderSpecification: Boolean,
    -      acceptWindowFrame: Boolean): SpecifiedWindowFrame = {
    +      acceptWindowFrame: Boolean,
    +      excludeSpec: ExcludeClause = ExcludeClause.defaultExclude): 
SpecifiedWindowFrame = {
         if (hasOrderSpecification && acceptWindowFrame) {
           // If order spec is defined and the window function supports user 
specified window frames,
           // the default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND 
CURRENT ROW.
    -      SpecifiedWindowFrame(RangeFrame, UnboundedPreceding, CurrentRow)
    +      SpecifiedWindowFrame(RangeFrame, UnboundedPreceding, CurrentRow, 
excludeSpec)
         } else {
           // Otherwise, the default frame is
           // ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.
    -      SpecifiedWindowFrame(RowFrame, UnboundedPreceding, 
UnboundedFollowing)
    +      SpecifiedWindowFrame(RowFrame, UnboundedPreceding, 
UnboundedFollowing, excludeSpec)
         }
       }
     }
     
    +/**
    + * The trait used to represent an Exclude type .
    + */
    +sealed trait ExcludeType
    +
    +/**
    + * Represents the type of Excluding Current Row
    + */
    +case object ExcludeCurrentRow extends ExcludeType
    +
    +/**
    + * Specifies excluding the current row and all rows that are tied with it.
    + * Ties occur when there is a match on the order-by column or columns
    + */
    +case object ExcludeGroup extends ExcludeType
    +
    +/**
    + * Specifies excluding all rows that are tied with the current row (peer 
rows),
    + * but retaining the current row.
    + */
    +case object ExcludeTies extends ExcludeType
    +
    +/**
    + * Specifies not excluding any rows. This value is the default if you 
specify no exclusion.
    + */
    +case object ExcludeNoOthers extends ExcludeType
    +
    +/**
    + * Exclude clause within window framing clause.
    + *
    + * 'EXCLUDE CURRENT ROW' means the current row for which the window 
function is calculated
    + * is excluded from the current fame.
    + * 'EXCLUDE GROUP' means that the nearby rows that match the current row 
with respect to
    + * the orderby expression together with the current row will be excluded 
from the calculation
    + * 'EXCLUDE TIES' means that the nearby rows that match the current row 
with respect to
    + * the orderby expression except the current row will be excluded from the 
calculation
    + * 'EXCLUDE NO OTHERS' means not excluding any rows from the calculation. 
This is the
    + * default behavior. Exclude types, GROUP and TIES, requires ORDER BY 
clause in the window
    + * specification clause.
    + * For example, users want to exclude current row from a sliding range 
framing:
    + * RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW
    + * @param excludeType The type of exclusion as defined above
    + * @param valueOrdering The ordering operator that does the value 
comparison between 2 rows
    + * @param toBeCompared The projection of the orderby expression from a row
    + *
    + */
    +case class ExcludeClause (
    --- End diff --
    
    Do we need this class in this location? It seems like this is bound to its 
implementation? Just passing ExcludeTypes should be fine for now.


---
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