Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Conversation

dai-chen
Copy link
Member

@dai-chen dai-chen commented Dec 12, 2020

Issue #, if available: #928

Description of changes: Previously window function only parses sorting order ASC/DESC. This PR is to support null ordering NULLS FIRST/LAST for window function OVER clause too.

The basic logic is same as ORDER BY clause handling:

  1. SQL frontend just pass sorting and null ordering given in queries.
  2. The final ordering is determined in analyzer which has the knowledge of default ordering option.

Testing: Because both H2 and SQLite has problem with null ordering in OVER clause, a new IT class is added manually.

Documentation: https://github.com/dai-chen/sql/blob/support-null-first-last-for-window-function/docs/user/dql/window.rst#row-number

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dai-chen dai-chen added enhancement New feature or request SQL labels Dec 12, 2020
@dai-chen dai-chen self-assigned this Dec 12, 2020
@codecov
Copy link

codecov bot commented Dec 12, 2020

Codecov Report

Merging #929 (5b2b9a7) into develop (0855c53) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop     #929   +/-   ##
==========================================
  Coverage      99.87%   99.87%           
- Complexity      2341     2347    +6     
==========================================
  Files            232      232           
  Lines           5389     5395    +6     
  Branches         350      350           
==========================================
+ Hits            5382     5388    +6     
  Misses             5        5           
  Partials           2        2           
Impacted Files Coverage Δ Complexity Δ
...csearch/sql/analysis/WindowExpressionAnalyzer.java 100.00% <100.00%> (ø) 12.00 <4.00> (+2.00)
...ticsearch/sql/sql/parser/AstExpressionBuilder.java 100.00% <100.00%> (ø) 48.00 <1.00> (-2.00)
...roforelasticsearch/sql/sql/parser/ParserUtils.java 100.00% <100.00%> (ø) 7.00 <6.00> (+6.00)
...rch/sql/sql/parser/context/QuerySpecification.java 100.00% <100.00%> (ø) 15.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0855c53...5b2b9a7. Read the comment docs.

@dai-chen dai-chen marked this pull request as ready for review December 14, 2020 17:42
Copy link
Contributor

@penghuo penghuo left a comment

Choose a reason for hiding this comment

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

LGTM.

@dai-chen dai-chen merged commit d419e8e into opendistro-for-elasticsearch:develop Jan 5, 2021
@dai-chen dai-chen deleted the support-null-first-last-for-window-function branch January 5, 2021 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request SQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants