pinot
pinot copied to clipboard
Add IGNORE NULLS option to FIRST_VALUE and LAST_VALUE window functions
- The SQL standard defines a
RESPECT NULLSorIGNORE NULLSoption for the window functionsLEAD,LAG,FIRST_VALUE,LAST_VALUE, andNTH_VALUE(although Pinot currently doesn't support this function). The default behavior isRESPECT NULLS. - This patch adds support for these options on the
FIRST_VALUEandLAST_VALUEwindow functions (LEAD/LAGcan be added in a subsequent patch). As the name suggests, theIGNORE NULLSoption makes it so that theFIRST_VALUEandLAST_VALUEwindow functions compute the first and last non-null values respectively for each window frame. - If
IGNORE NULLSis specified likeLAST_VALUE(col1) IGNORE NULLS OVER (ORDER BY ts), it can effectively be used to gapfill data (see this article for example - https://learn.microsoft.com/en-us/azure/azure-sql-edge/imputing-missing-values). - Calcite has validation to ensure that the
IGNORE NULLS/RESPECT NULLSoperators are only used with window functions that they are applicable to as per standard SQL. This patch also updates the operators being registered in Pinot's operator table forLEAD/LAGsince we don't currently support the null related options for those functions (this way, we fail during query planning rather than at runtime). - There are also some minor changes to the query plan serde here to hold the
IGNORE NULLSoption for a window function call.
Codecov Report
Attention: Patch coverage is 88.94231% with 23 lines in your changes missing coverage. Please review.
Project coverage is 63.82%. Comparing base (
59551e4) to head (4867f2c). Report is 1256 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #14264 +/- ##
============================================
+ Coverage 61.75% 63.82% +2.07%
- Complexity 207 1556 +1349
============================================
Files 2436 2660 +224
Lines 133233 145674 +12441
Branches 20636 22287 +1651
============================================
+ Hits 82274 92981 +10707
- Misses 44911 45822 +911
- Partials 6048 6871 +823
| Flag | Coverage Δ | |
|---|---|---|
| custom-integration1 | 100.00% <ø> (+99.99%) |
:arrow_up: |
| integration | 100.00% <ø> (+99.99%) |
:arrow_up: |
| integration1 | 100.00% <ø> (+99.99%) |
:arrow_up: |
| integration2 | 0.00% <ø> (ø) |
|
| java-11 | 63.80% <88.94%> (+2.09%) |
:arrow_up: |
| java-21 | 63.65% <88.94%> (+2.02%) |
:arrow_up: |
| skip-bytebuffers-false | 63.82% <88.94%> (+2.07%) |
:arrow_up: |
| skip-bytebuffers-true | 63.63% <88.94%> (+35.90%) |
:arrow_up: |
| temurin | 63.82% <88.94%> (+2.07%) |
:arrow_up: |
| unittests | 63.82% <88.94%> (+2.07%) |
:arrow_up: |
| unittests1 | 55.44% <88.94%> (+8.55%) |
:arrow_up: |
| unittests2 | 34.25% <2.88%> (+6.52%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.