allisonwang-db commented on code in PR #47456: URL: https://github.com/apache/spark/pull/47456#discussion_r1688661197
########## docs/sql-ref-syntax-qry-select-window.md: ########## @@ -94,107 +94,112 @@ INSERT INTO employees VALUES ("Paul", "Engineering", 29000, 23); INSERT INTO employees VALUES ("Chloe", "Engineering", 23000, 25); SELECT * FROM employees; -+-----+-----------+------+-----+ -| name| dept|salary| age| -+-----+-----------+------+-----+ -|Chloe|Engineering| 23000| 25| -| Fred|Engineering| 21000| 28| -| Paul|Engineering| 29000| 23| -|Helen| Marketing| 29000| 40| -| Tom|Engineering| 23000| 33| -| Jane| Marketing| 29000| 28| -| Jeff| Marketing| 35000| 38| -| Evan| Sales| 32000| 38| -| Lisa| Sales| 10000| 35| -| Alex| Sales| 30000| 33| -+-----+-----------+------+-----+ ++-----+-----------+------+---+ +| name| dept|salary|age| ++-----+-----------+------+---+ +|Chloe|Engineering| 23000| 25| +| Paul|Engineering| 29000| 23| +| Fred|Engineering| 21000| 28| +| Tom|Engineering| 23000| 33| +| Jeff| Marketing| 35000| 38| +| Jane| Marketing| 29000| 28| +| Evan| Sales| 32000| 38| +| Alex| Sales| 30000| 33| +| Lisa| Sales| 10000| 35| ++-----+-----------+------+---+ SELECT name, dept, salary, RANK() OVER (PARTITION BY dept ORDER BY salary) AS rank FROM employees; +-----+-----------+------+----+ | name| dept|salary|rank| +-----+-----------+------+----+ -| Lisa| Sales| 10000| 1| -| Alex| Sales| 30000| 2| -| Evan| Sales| 32000| 3| | Fred|Engineering| 21000| 1| -| Tom|Engineering| 23000| 2| |Chloe|Engineering| 23000| 2| +| Tom|Engineering| 23000| 2| | Paul|Engineering| 29000| 4| -|Helen| Marketing| 29000| 1| | Jane| Marketing| 29000| 1| -| Jeff| Marketing| 35000| 3| +| Jeff| Marketing| 35000| 2| +| Lisa| Sales| 10000| 1| +| Alex| Sales| 30000| 2| +| Evan| Sales| 32000| 3| +-----+-----------+------+----+ SELECT name, dept, salary, DENSE_RANK() OVER (PARTITION BY dept ORDER BY salary ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS dense_rank FROM employees; +-----+-----------+------+----------+ | name| dept|salary|dense_rank| +-----+-----------+------+----------+ -| Lisa| Sales| 10000| 1| -| Alex| Sales| 30000| 2| -| Evan| Sales| 32000| 3| | Fred|Engineering| 21000| 1| -| Tom|Engineering| 23000| 2| |Chloe|Engineering| 23000| 2| +| Tom|Engineering| 23000| 2| | Paul|Engineering| 29000| 3| -|Helen| Marketing| 29000| 1| | Jane| Marketing| 29000| 1| | Jeff| Marketing| 35000| 2| +| Lisa| Sales| 10000| 1| +| Alex| Sales| 30000| 2| +| Evan| Sales| 32000| 3| +-----+-----------+------+----------+ SELECT name, dept, age, CUME_DIST() OVER (PARTITION BY dept ORDER BY age RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cume_dist FROM employees; -+-----+-----------+------+------------------+ -| name| dept|age | cume_dist| -+-----+-----------+------+------------------+ -| Alex| Sales| 33|0.3333333333333333| -| Lisa| Sales| 35|0.6666666666666666| -| Evan| Sales| 38| 1.0| -| Paul|Engineering| 23| 0.25| -|Chloe|Engineering| 25| 0.75| -| Fred|Engineering| 28| 0.25| -| Tom|Engineering| 33| 1.0| -| Jane| Marketing| 28|0.3333333333333333| -| Jeff| Marketing| 38|0.6666666666666666| -|Helen| Marketing| 40| 1.0| -+-----+-----------+------+------------------+ ++-----+-----------+---+------------------+ +| name| dept|age| cume_dist| ++-----+-----------+---+------------------+ +| Paul|Engineering| 23| 0.25| +|Chloe|Engineering| 25| 0.5| +| Fred|Engineering| 28| 0.75| +| Tom|Engineering| 33| 1.0| +| Jane| Marketing| 28| 0.5| +| Jeff| Marketing| 38| 1.0| +| Alex| Sales| 33|0.3333333333333333| +| Lisa| Sales| 35|0.6666666666666666| +| Evan| Sales| 38| 1.0| ++-----+-----------+---+------------------+ SELECT name, dept, salary, MIN(salary) OVER (PARTITION BY dept ORDER BY salary) AS min FROM employees; +-----+-----------+------+-----+ | name| dept|salary| min| +-----+-----------+------+-----+ -| Lisa| Sales| 10000|10000| -| Alex| Sales| 30000|10000| -| Evan| Sales| 32000|10000| -|Helen| Marketing| 29000|29000| -| Jane| Marketing| 29000|29000| -| Jeff| Marketing| 35000|29000| | Fred|Engineering| 21000|21000| -| Tom|Engineering| 23000|21000| |Chloe|Engineering| 23000|21000| +| Tom|Engineering| 23000|21000| | Paul|Engineering| 29000|21000| +| Jane| Marketing| 29000|29000| +| Jeff| Marketing| 35000|29000| +| Lisa| Sales| 10000|10000| +| Alex| Sales| 30000|10000| +| Evan| Sales| 32000|10000| +-----+-----------+------+-----+ -SELECT name, salary, +SELECT name, dept, salary, Review Comment: good catch! ########## docs/sql-ref-syntax-qry-select-window.md: ########## @@ -94,107 +94,112 @@ INSERT INTO employees VALUES ("Paul", "Engineering", 29000, 23); INSERT INTO employees VALUES ("Chloe", "Engineering", 23000, 25); SELECT * FROM employees; -+-----+-----------+------+-----+ -| name| dept|salary| age| -+-----+-----------+------+-----+ -|Chloe|Engineering| 23000| 25| -| Fred|Engineering| 21000| 28| -| Paul|Engineering| 29000| 23| -|Helen| Marketing| 29000| 40| -| Tom|Engineering| 23000| 33| -| Jane| Marketing| 29000| 28| -| Jeff| Marketing| 35000| 38| -| Evan| Sales| 32000| 38| -| Lisa| Sales| 10000| 35| -| Alex| Sales| 30000| 33| -+-----+-----------+------+-----+ ++-----+-----------+------+---+ +| name| dept|salary|age| ++-----+-----------+------+---+ +|Chloe|Engineering| 23000| 25| +| Paul|Engineering| 29000| 23| Review Comment: Why are these changed? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org